Merge branches 'clk-of', 'clk-samsung', 'clk-rockchip' and 'clk-qcom' into clk-next
authorStephen Boyd <sboyd@kernel.org>
Tue, 25 Apr 2023 18:52:25 +0000 (11:52 -0700)
committerStephen Boyd <sboyd@kernel.org>
Tue, 25 Apr 2023 18:52:25 +0000 (11:52 -0700)
* clk-of:
  clk: add missing of_node_put() in "assigned-clocks" property parsing

* clk-samsung:
  clk: samsung: exynos850: Make PMU_ALIVE_PCLK critical
  clk: samsung: Convert to platform remove callback returning void
  clk: samsung: exynos5433: Extract PM support to common ARM64 layer
  clk: samsung: Extract parent clock enabling to common function
  clk: samsung: Extract clocks registration to common function
  clk: samsung: exynos850: Add AUD and HSI main gate clocks
  clk: samsung: exynos850: Implement CMU_G3D domain
  clk: samsung: clk-pll: Implement pll0818x PLL type
  clk: samsung: Set dev in samsung_clk_init()
  clk: samsung: Don't pass reg_base to samsung_clk_register_pll()
  clk: samsung: Remove np argument from samsung_clk_init()
  dt-bindings: clock: exynos850: Add AUD and HSI main gate clocks
  dt-bindings: clock: exynos850: Add Exynos850 CMU_G3D

* clk-rockchip:
  clk: rockchip: rk3588: make gate linked clocks critical
  clk: rockchip: rk3399: allow clk_cifout to force clk_cifout_src to reparent

* clk-qcom: (57 commits)
  clk: qcom: gcc-sc8280xp: Add EMAC GDSCs
  clk: qcom: dispcc-qcm2290: Remove inexistent DSI1PHY clk
  clk: qcom: add the GPUCC driver for sa8775p
  dt-bindings: clock: qcom: describe the GPUCC clock for SA8775P
  clk: qcom: gcc-sm8350: fix PCIe PIPE clocks handling
  clk: qcom: lpassaudiocc-sc7280: Add required gdsc power domain clks in lpass_cc_sc7280_desc
  clk: qcom: lpasscc-sc7280: Skip qdsp6ss clock registration
  dt-bindings: clock: qcom,sc7280-lpasscc: Add qcom,adsp-pil-mode property
  clk: qcom: rpm: Use managed `of_clk_add_hw_provider()`
  clk: qcom: Add Global Clock Controller driver for IPQ9574
  dt-bindings: clock: Add ipq9574 clock and reset definitions
  clk: qcom: gpucc-sm6375: Configure CX_GDSC disable wait value
  clk: qcom: gcc-sm6115: Mark RCGs shared where applicable
  clk: qcom: dispcc-qcm2290: Add MDSS_CORE reset
  dt-bindings: clock: dispcc-qcm2290: Add MDSS_CORE reset
  clk: qcom: apss-ipq-pll: add support for IPQ5332
  dt-bindings: clock: qcom,a53pll: add IPQ5332 compatible
  clk: qcom: apss-ipq-pll: refactor the driver to accommodate different PLL types
  dt-bindings: mailbox: qcom,apcs-kpss-global: fix SDX55 'if' match
  dt-bindings: mailbox: qcom,apcs-kpss-global: correct SDX55 clocks
  ...

705 files changed:
.mailmap
Documentation/ABI/stable/sysfs-block
Documentation/bpf/bpf_devel_QA.rst
Documentation/devicetree/bindings/clock/brcm,bcm63268-timer-clocks.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/clock/loongson,ls1x-clk.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/clock/mediatek,mt8186-fhctl.yaml
Documentation/devicetree/bindings/clock/mediatek,mt8188-clock.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/clock/mediatek,mt8188-sys-clock.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/clock/renesas,9series.yaml
Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml
Documentation/devicetree/bindings/clock/skyworks,si521xx.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/clock/starfive,jh7110-aoncrg.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/clock/starfive,jh7110-syscrg.yaml [new file with mode: 0644]
Documentation/filesystems/ext4/blockgroup.rst
Documentation/netlink/genetlink-c.yaml
Documentation/netlink/genetlink-legacy.yaml
Documentation/netlink/genetlink.yaml
Documentation/netlink/specs/ethtool.yaml
Documentation/netlink/specs/fou.yaml
Documentation/netlink/specs/netdev.yaml
Documentation/userspace-api/netlink/specs.rst
MAINTAINERS
Makefile
arch/alpha/lib/fpreg.c
arch/m68k/kernel/setup_mm.c
arch/m68k/kernel/traps.c
arch/m68k/mm/motorola.c
arch/mips/configs/mtx1_defconfig
arch/mips/include/asm/mach-loongson32/platform.h
arch/mips/loongson32/common/time.c
arch/powerpc/boot/dts/fsl/t1040rdb-rev-a.dts
arch/powerpc/boot/dts/fsl/t1040rdb.dts
arch/powerpc/boot/dts/fsl/t1040si-post.dtsi
arch/powerpc/configs/ppc6xx_defconfig
arch/powerpc/xmon/xmon.c
arch/riscv/Makefile
arch/riscv/errata/sifive/errata.c
arch/riscv/include/asm/ftrace.h
arch/riscv/include/asm/patch.h
arch/riscv/kernel/compat_vdso/Makefile
arch/riscv/kernel/ftrace.c
arch/riscv/kernel/patch.c
arch/riscv/kernel/stacktrace.c
arch/riscv/net/bpf_jit_comp64.c
arch/sh/include/asm/processor_32.h
arch/sh/kernel/signal_32.c
arch/x86/include/asm/resctrl.h
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/cpu/resctrl/rdtgroup.c
arch/x86/kernel/process_32.c
arch/x86/kernel/process_64.c
block/bfq-iosched.c
block/genhd.c
drivers/char/random.c
drivers/char/tpm/eventlog/acpi.c
drivers/char/tpm/tpm-chip.c
drivers/char/tpm/tpm.h
drivers/clk/Kconfig
drivers/clk/Makefile
drivers/clk/at91/clk-sam9x60-pll.c
drivers/clk/axs10x/i2s_pll_clock.c
drivers/clk/axs10x/pll_clock.c
drivers/clk/bcm/Kconfig
drivers/clk/bcm/Makefile
drivers/clk/bcm/clk-bcm2711-dvp.c
drivers/clk/bcm/clk-bcm63268-timer.c [new file with mode: 0644]
drivers/clk/bcm/clk-bcm63xx-gate.c
drivers/clk/bcm/clk-raspberrypi.c
drivers/clk/clk-ast2600.c
drivers/clk/clk-axi-clkgen.c
drivers/clk/clk-axm5516.c
drivers/clk/clk-cdce706.c
drivers/clk/clk-conf.c
drivers/clk/clk-fixed-factor.c
drivers/clk/clk-fixed-mmio.c
drivers/clk/clk-fixed-rate.c
drivers/clk/clk-fractional-divider.c
drivers/clk/clk-hsdk-pll.c
drivers/clk/clk-lmk04832.c
drivers/clk/clk-loongson1.c [new file with mode: 0644]
drivers/clk/clk-loongson2.c [new file with mode: 0644]
drivers/clk/clk-milbeaut.c
drivers/clk/clk-palmas.c
drivers/clk/clk-pwm.c
drivers/clk/clk-renesas-pcie.c
drivers/clk/clk-s2mps11.c
drivers/clk/clk-scpi.c
drivers/clk/clk-si514.c
drivers/clk/clk-si521xx.c [new file with mode: 0644]
drivers/clk/clk-si5351.c
drivers/clk/clk-si570.c
drivers/clk/clk-sp7021.c [new file with mode: 0644]
drivers/clk/clk-stm32h7.c
drivers/clk/clk-stm32mp1.c
drivers/clk/clk.c
drivers/clk/hisilicon/clk-hi3519.c
drivers/clk/hisilicon/clk-hi3559a.c
drivers/clk/hisilicon/crg-hi3516cv300.c
drivers/clk/hisilicon/crg-hi3798cv200.c
drivers/clk/imx/clk-composite-7ulp.c
drivers/clk/keystone/sci-clk.c
drivers/clk/loongson1/Makefile [deleted file]
drivers/clk/loongson1/clk-loongson1b.c [deleted file]
drivers/clk/loongson1/clk-loongson1c.c [deleted file]
drivers/clk/loongson1/clk.c [deleted file]
drivers/clk/loongson1/clk.h [deleted file]
drivers/clk/mediatek/Kconfig
drivers/clk/mediatek/Makefile
drivers/clk/mediatek/clk-fhctl.c
drivers/clk/mediatek/clk-fhctl.h
drivers/clk/mediatek/clk-mt2701-aud.c
drivers/clk/mediatek/clk-mt2701-bdp.c
drivers/clk/mediatek/clk-mt2701-eth.c
drivers/clk/mediatek/clk-mt2701-g3d.c
drivers/clk/mediatek/clk-mt2701-hif.c
drivers/clk/mediatek/clk-mt2701-img.c
drivers/clk/mediatek/clk-mt2701-mm.c
drivers/clk/mediatek/clk-mt2701-vdec.c
drivers/clk/mediatek/clk-mt2701.c
drivers/clk/mediatek/clk-mt2712-apmixedsys.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt2712-bdp.c
drivers/clk/mediatek/clk-mt2712-img.c
drivers/clk/mediatek/clk-mt2712-jpgdec.c
drivers/clk/mediatek/clk-mt2712-mfg.c
drivers/clk/mediatek/clk-mt2712-mm.c
drivers/clk/mediatek/clk-mt2712-vdec.c
drivers/clk/mediatek/clk-mt2712-venc.c
drivers/clk/mediatek/clk-mt2712.c
drivers/clk/mediatek/clk-mt6765-audio.c
drivers/clk/mediatek/clk-mt6765-cam.c
drivers/clk/mediatek/clk-mt6765-img.c
drivers/clk/mediatek/clk-mt6765-mipi0a.c
drivers/clk/mediatek/clk-mt6765-mm.c
drivers/clk/mediatek/clk-mt6765-vcodec.c
drivers/clk/mediatek/clk-mt6765.c
drivers/clk/mediatek/clk-mt6779-aud.c
drivers/clk/mediatek/clk-mt6779-cam.c
drivers/clk/mediatek/clk-mt6779-img.c
drivers/clk/mediatek/clk-mt6779-ipe.c
drivers/clk/mediatek/clk-mt6779-mfg.c
drivers/clk/mediatek/clk-mt6779-mm.c
drivers/clk/mediatek/clk-mt6779-vdec.c
drivers/clk/mediatek/clk-mt6779-venc.c
drivers/clk/mediatek/clk-mt6779.c
drivers/clk/mediatek/clk-mt6795-apmixedsys.c
drivers/clk/mediatek/clk-mt6795-infracfg.c
drivers/clk/mediatek/clk-mt6795-mfg.c
drivers/clk/mediatek/clk-mt6795-mm.c
drivers/clk/mediatek/clk-mt6795-pericfg.c
drivers/clk/mediatek/clk-mt6795-topckgen.c
drivers/clk/mediatek/clk-mt6795-vdecsys.c
drivers/clk/mediatek/clk-mt6795-vencsys.c
drivers/clk/mediatek/clk-mt6797-img.c
drivers/clk/mediatek/clk-mt6797-mm.c
drivers/clk/mediatek/clk-mt6797-vdec.c
drivers/clk/mediatek/clk-mt6797-venc.c
drivers/clk/mediatek/clk-mt6797.c
drivers/clk/mediatek/clk-mt7622-apmixedsys.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt7622-aud.c
drivers/clk/mediatek/clk-mt7622-eth.c
drivers/clk/mediatek/clk-mt7622-hif.c
drivers/clk/mediatek/clk-mt7622-infracfg.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt7622.c
drivers/clk/mediatek/clk-mt7629-eth.c
drivers/clk/mediatek/clk-mt7629-hif.c
drivers/clk/mediatek/clk-mt7629.c
drivers/clk/mediatek/clk-mt7981-apmixed.c
drivers/clk/mediatek/clk-mt7981-eth.c
drivers/clk/mediatek/clk-mt7981-infracfg.c
drivers/clk/mediatek/clk-mt7981-topckgen.c
drivers/clk/mediatek/clk-mt7986-apmixed.c
drivers/clk/mediatek/clk-mt7986-eth.c
drivers/clk/mediatek/clk-mt7986-infracfg.c
drivers/clk/mediatek/clk-mt7986-topckgen.c
drivers/clk/mediatek/clk-mt8135-apmixedsys.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8135.c
drivers/clk/mediatek/clk-mt8167-apmixedsys.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8167-aud.c
drivers/clk/mediatek/clk-mt8167-img.c
drivers/clk/mediatek/clk-mt8167-mfgcfg.c
drivers/clk/mediatek/clk-mt8167-mm.c
drivers/clk/mediatek/clk-mt8167-vdec.c
drivers/clk/mediatek/clk-mt8167.c
drivers/clk/mediatek/clk-mt8173-apmixedsys.c
drivers/clk/mediatek/clk-mt8173-img.c
drivers/clk/mediatek/clk-mt8173-infracfg.c
drivers/clk/mediatek/clk-mt8173-mm.c
drivers/clk/mediatek/clk-mt8173-pericfg.c
drivers/clk/mediatek/clk-mt8173-topckgen.c
drivers/clk/mediatek/clk-mt8173-vdecsys.c
drivers/clk/mediatek/clk-mt8173-vencsys.c
drivers/clk/mediatek/clk-mt8183-apmixedsys.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8183-audio.c
drivers/clk/mediatek/clk-mt8183-cam.c
drivers/clk/mediatek/clk-mt8183-img.c
drivers/clk/mediatek/clk-mt8183-ipu0.c
drivers/clk/mediatek/clk-mt8183-ipu1.c
drivers/clk/mediatek/clk-mt8183-ipu_adl.c
drivers/clk/mediatek/clk-mt8183-ipu_conn.c
drivers/clk/mediatek/clk-mt8183-mfgcfg.c
drivers/clk/mediatek/clk-mt8183-mm.c
drivers/clk/mediatek/clk-mt8183-vdec.c
drivers/clk/mediatek/clk-mt8183-venc.c
drivers/clk/mediatek/clk-mt8183.c
drivers/clk/mediatek/clk-mt8186-apmixedsys.c
drivers/clk/mediatek/clk-mt8186-cam.c
drivers/clk/mediatek/clk-mt8186-img.c
drivers/clk/mediatek/clk-mt8186-imp_iic_wrap.c
drivers/clk/mediatek/clk-mt8186-infra_ao.c
drivers/clk/mediatek/clk-mt8186-ipe.c
drivers/clk/mediatek/clk-mt8186-mcu.c
drivers/clk/mediatek/clk-mt8186-mdp.c
drivers/clk/mediatek/clk-mt8186-mfg.c
drivers/clk/mediatek/clk-mt8186-mm.c
drivers/clk/mediatek/clk-mt8186-topckgen.c
drivers/clk/mediatek/clk-mt8186-vdec.c
drivers/clk/mediatek/clk-mt8186-venc.c
drivers/clk/mediatek/clk-mt8186-wpe.c
drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-apmixedsys.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-cam.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-ccu.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-img.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-imp_iic_wrap.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-infra_ao.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-ipe.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-mfg.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-peri_ao.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-topckgen.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-vdec.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-vdo0.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-vdo1.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-venc.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-vpp0.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-vpp1.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8188-wpe.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8192-apmixedsys.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8192-aud.c
drivers/clk/mediatek/clk-mt8192-cam.c
drivers/clk/mediatek/clk-mt8192-img.c
drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c
drivers/clk/mediatek/clk-mt8192-ipe.c
drivers/clk/mediatek/clk-mt8192-mdp.c
drivers/clk/mediatek/clk-mt8192-mfg.c
drivers/clk/mediatek/clk-mt8192-mm.c
drivers/clk/mediatek/clk-mt8192-msdc.c
drivers/clk/mediatek/clk-mt8192-scp_adsp.c
drivers/clk/mediatek/clk-mt8192-vdec.c
drivers/clk/mediatek/clk-mt8192-venc.c
drivers/clk/mediatek/clk-mt8192.c
drivers/clk/mediatek/clk-mt8195-apmixedsys.c
drivers/clk/mediatek/clk-mt8195-apusys_pll.c
drivers/clk/mediatek/clk-mt8195-cam.c
drivers/clk/mediatek/clk-mt8195-ccu.c
drivers/clk/mediatek/clk-mt8195-img.c
drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c
drivers/clk/mediatek/clk-mt8195-infra_ao.c
drivers/clk/mediatek/clk-mt8195-ipe.c
drivers/clk/mediatek/clk-mt8195-mfg.c
drivers/clk/mediatek/clk-mt8195-peri_ao.c
drivers/clk/mediatek/clk-mt8195-scp_adsp.c
drivers/clk/mediatek/clk-mt8195-topckgen.c
drivers/clk/mediatek/clk-mt8195-vdec.c
drivers/clk/mediatek/clk-mt8195-vdo0.c
drivers/clk/mediatek/clk-mt8195-vdo1.c
drivers/clk/mediatek/clk-mt8195-venc.c
drivers/clk/mediatek/clk-mt8195-vpp0.c
drivers/clk/mediatek/clk-mt8195-vpp1.c
drivers/clk/mediatek/clk-mt8195-wpe.c
drivers/clk/mediatek/clk-mt8365-apmixedsys.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8365-apu.c
drivers/clk/mediatek/clk-mt8365-cam.c
drivers/clk/mediatek/clk-mt8365-mfg.c
drivers/clk/mediatek/clk-mt8365-mm.c
drivers/clk/mediatek/clk-mt8365-vdec.c
drivers/clk/mediatek/clk-mt8365-venc.c
drivers/clk/mediatek/clk-mt8365.c
drivers/clk/mediatek/clk-mt8516-apmixedsys.c [new file with mode: 0644]
drivers/clk/mediatek/clk-mt8516-aud.c
drivers/clk/mediatek/clk-mt8516.c
drivers/clk/mediatek/clk-mtk.c
drivers/clk/mediatek/clk-mtk.h
drivers/clk/mediatek/clk-pllfh.c
drivers/clk/mediatek/clk-pllfh.h
drivers/clk/microchip/clk-mpfs.c
drivers/clk/mmp/clk-audio.c
drivers/clk/mvebu/armada-37xx-periph.c
drivers/clk/mvebu/armada-37xx-tbg.c
drivers/clk/mvebu/armada-37xx-xtal.c
drivers/clk/renesas/r8a77970-cpg-mssr.c
drivers/clk/renesas/r8a77980-cpg-mssr.c
drivers/clk/renesas/r8a77995-cpg-mssr.c
drivers/clk/renesas/r8a779g0-cpg-mssr.c
drivers/clk/renesas/r9a06g032-clocks.c
drivers/clk/renesas/rcar-usb2-clock-sel.c
drivers/clk/renesas/renesas-cpg-mssr.c
drivers/clk/rockchip/clk-rk3399.c
drivers/clk/rockchip/clk-rk3588.c
drivers/clk/rockchip/clk.c
drivers/clk/samsung/clk-exynos-arm64.c
drivers/clk/samsung/clk-exynos-arm64.h
drivers/clk/samsung/clk-exynos-audss.c
drivers/clk/samsung/clk-exynos-clkout.c
drivers/clk/samsung/clk-exynos4.c
drivers/clk/samsung/clk-exynos4412-isp.c
drivers/clk/samsung/clk-exynos5250.c
drivers/clk/samsung/clk-exynos5420.c
drivers/clk/samsung/clk-exynos5433.c
drivers/clk/samsung/clk-exynos850.c
drivers/clk/samsung/clk-pll.c
drivers/clk/samsung/clk-pll.h
drivers/clk/samsung/clk-s3c64xx.c
drivers/clk/samsung/clk-s5pv210.c
drivers/clk/samsung/clk.c
drivers/clk/samsung/clk.h
drivers/clk/sifive/Kconfig
drivers/clk/socfpga/clk-gate-a10.c
drivers/clk/socfpga/clk-gate.c
drivers/clk/socfpga/clk-periph-a10.c
drivers/clk/socfpga/clk-periph.c
drivers/clk/socfpga/clk-pll-a10.c
drivers/clk/socfpga/clk-pll.c
drivers/clk/sprd/common.c
drivers/clk/starfive/Kconfig
drivers/clk/starfive/Makefile
drivers/clk/starfive/clk-starfive-jh7100-audio.c
drivers/clk/starfive/clk-starfive-jh7100.c
drivers/clk/starfive/clk-starfive-jh7100.h [deleted file]
drivers/clk/starfive/clk-starfive-jh7110-aon.c [new file with mode: 0644]
drivers/clk/starfive/clk-starfive-jh7110-sys.c [new file with mode: 0644]
drivers/clk/starfive/clk-starfive-jh7110.h [new file with mode: 0644]
drivers/clk/starfive/clk-starfive-jh71x0.c [new file with mode: 0644]
drivers/clk/starfive/clk-starfive-jh71x0.h [new file with mode: 0644]
drivers/clk/stm32/clk-stm32mp13.c
drivers/clk/tegra/clk-dfll.c
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c
drivers/clk/tegra/clk-tegra20.c
drivers/clk/ti/adpll.c
drivers/clk/ti/clkctrl.c
drivers/clk/uniphier/clk-uniphier-core.c
drivers/clk/visconti/pll.h
drivers/clk/x86/clk-fch.c
drivers/clk/x86/clk-pmc-atom.c
drivers/clk/xilinx/clk-xlnx-clock-wizard.c
drivers/clk/xilinx/xlnx_vcu.c
drivers/clk/zynqmp/pll.c
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c
drivers/gpu/drm/amd/amdgpu/nv.c
drivers/gpu/drm/amd/amdgpu/soc15.c
drivers/gpu/drm/amd/amdgpu/soc21.c
drivers/gpu/drm/amd/amdgpu/umc_v8_10.h
drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
drivers/gpu/drm/display/drm_hdmi_helper.c
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/msm/Kconfig
drivers/gpu/drm/msm/adreno/a5xx_gpu.c
drivers/gpu/drm/msm/adreno/a5xx_preempt.c
drivers/gpu/drm/msm/adreno/a6xx_gmu.c
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
drivers/gpu/drm/msm/adreno/adreno_device.c
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
drivers/gpu/drm/msm/msm_gem_submit.c
drivers/gpu/drm/nouveau/dispnv50/wndw.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/fb.h
drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ga100.c
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ga102.c
drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp102.c
drivers/gpu/drm/nouveau/nvkm/subdev/fb/gv100.c
drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h
drivers/gpu/drm/nouveau/nvkm/subdev/fb/tu102.c
drivers/gpu/drm/tiny/cirrus.c
drivers/hid/hid-core.c
drivers/hid/hid-cp2112.c
drivers/hid/hid-logitech-hidpp.c
drivers/hid/intel-ish-hid/ipc/ipc.c
drivers/hid/uhid.c
drivers/i2c/i2c-core-base.c
drivers/i2c/i2c-dev.c
drivers/i2c/i2c-slave-eeprom.c
drivers/i2c/i2c-slave-testunit.c
drivers/i2c/i2c-smbus.c
drivers/i2c/muxes/i2c-mux-ltc4306.c
drivers/i2c/muxes/i2c-mux-pca9541.c
drivers/i2c/muxes/i2c-mux-pca954x.c
drivers/media/i2c/ov2685.c
drivers/media/i2c/ov5695.c
drivers/misc/ad525x_dpot-i2c.c
drivers/mtd/maps/pismo.c
drivers/mtd/ubi/block.c
drivers/net/dsa/mt7530.c
drivers/net/ethernet/Kconfig
drivers/net/ethernet/Makefile
drivers/net/ethernet/broadcom/bgmac.c
drivers/net/ethernet/broadcom/bgmac.h
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
drivers/net/ethernet/fealnx.c [new file with mode: 0644]
drivers/net/ethernet/intel/ice/ice_dcb.c
drivers/net/ethernet/intel/ice/ice_ethtool.c
drivers/net/ethernet/intel/ice/ice_lib.c
drivers/net/ethernet/intel/ice/ice_tc_lib.c
drivers/net/ethernet/marvell/octeontx2/af/rvu.h
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h
drivers/net/ethernet/mediatek/mtk_eth_soc.c
drivers/net/ethernet/mediatek/mtk_eth_soc.h
drivers/net/ethernet/microchip/lan966x/lan966x_police.c
drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
drivers/net/ethernet/netronome/nfp/nfd3/dp.c
drivers/net/ethernet/netronome/nfp/nfd3/ipsec.c
drivers/net/ethernet/netronome/nfp/nfdk/dp.c
drivers/net/ethernet/netronome/nfp/nfdk/ipsec.c
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ieee802154/ca8210.c
drivers/net/phy/microchip.c
drivers/net/phy/phy_device.c
drivers/net/phy/smsc.c
drivers/net/usb/cdc_mbim.c
drivers/net/usb/lan78xx.c
drivers/net/usb/qmi_wwan.c
drivers/net/wireguard/queueing.h
drivers/nfc/fdp/i2c.c
drivers/platform/mellanox/Kconfig
drivers/platform/x86/Kconfig
drivers/platform/x86/amd/pmc.c
drivers/platform/x86/dell/dell-wmi-ddv.c
drivers/platform/x86/intel/int3472/tps68470_board_data.c
drivers/platform/x86/intel/speed_select_if/isst_if_common.c
drivers/platform/x86/intel/speed_select_if/isst_if_common.h
drivers/platform/x86/intel/tpmi.c
drivers/platform/x86/mlx-platform.c
drivers/reset/Kconfig
drivers/reset/Makefile
drivers/reset/reset-starfive-jh7100.c [deleted file]
drivers/reset/starfive/Kconfig [new file with mode: 0644]
drivers/reset/starfive/Makefile [new file with mode: 0644]
drivers/reset/starfive/reset-starfive-jh7100.c [new file with mode: 0644]
drivers/reset/starfive/reset-starfive-jh7110.c [new file with mode: 0644]
drivers/reset/starfive/reset-starfive-jh71x0.c [new file with mode: 0644]
drivers/reset/starfive/reset-starfive-jh71x0.h [new file with mode: 0644]
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_sli.c
drivers/scsi/megaraid/megaraid_sas.h
drivers/scsi/megaraid/megaraid_sas_fp.c
drivers/scsi/megaraid/megaraid_sas_fusion.c
drivers/scsi/mpi3mr/mpi3mr.h
drivers/scsi/mpi3mr/mpi3mr_app.c
drivers/scsi/mpi3mr/mpi3mr_fw.c
drivers/scsi/mpi3mr/mpi3mr_os.c
drivers/scsi/mpi3mr/mpi3mr_transport.c
drivers/scsi/qla2xxx/qla_gbl.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/sd.c
drivers/scsi/sd_zbc.c
drivers/scsi/storvsc_drv.c
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/r8188eu/Kconfig [deleted file]
drivers/staging/r8188eu/Makefile [deleted file]
drivers/staging/r8188eu/TODO [deleted file]
drivers/staging/r8188eu/core/rtw_ap.c [deleted file]
drivers/staging/r8188eu/core/rtw_br_ext.c [deleted file]
drivers/staging/r8188eu/core/rtw_cmd.c [deleted file]
drivers/staging/r8188eu/core/rtw_efuse.c [deleted file]
drivers/staging/r8188eu/core/rtw_fw.c [deleted file]
drivers/staging/r8188eu/core/rtw_ieee80211.c [deleted file]
drivers/staging/r8188eu/core/rtw_ioctl_set.c [deleted file]
drivers/staging/r8188eu/core/rtw_iol.c [deleted file]
drivers/staging/r8188eu/core/rtw_led.c [deleted file]
drivers/staging/r8188eu/core/rtw_mlme.c [deleted file]
drivers/staging/r8188eu/core/rtw_mlme_ext.c [deleted file]
drivers/staging/r8188eu/core/rtw_p2p.c [deleted file]
drivers/staging/r8188eu/core/rtw_pwrctrl.c [deleted file]
drivers/staging/r8188eu/core/rtw_recv.c [deleted file]
drivers/staging/r8188eu/core/rtw_rf.c [deleted file]
drivers/staging/r8188eu/core/rtw_security.c [deleted file]
drivers/staging/r8188eu/core/rtw_sta_mgt.c [deleted file]
drivers/staging/r8188eu/core/rtw_wlan_util.c [deleted file]
drivers/staging/r8188eu/core/rtw_xmit.c [deleted file]
drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c [deleted file]
drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c [deleted file]
drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c [deleted file]
drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c [deleted file]
drivers/staging/r8188eu/hal/HalPhyRf_8188e.c [deleted file]
drivers/staging/r8188eu/hal/HalPwrSeqCmd.c [deleted file]
drivers/staging/r8188eu/hal/hal_com.c [deleted file]
drivers/staging/r8188eu/hal/hal_intf.c [deleted file]
drivers/staging/r8188eu/hal/odm.c [deleted file]
drivers/staging/r8188eu/hal/odm_HWConfig.c [deleted file]
drivers/staging/r8188eu/hal/odm_RTL8188E.c [deleted file]
drivers/staging/r8188eu/hal/rtl8188e_cmd.c [deleted file]
drivers/staging/r8188eu/hal/rtl8188e_dm.c [deleted file]
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c [deleted file]
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c [deleted file]
drivers/staging/r8188eu/hal/rtl8188e_rf6052.c [deleted file]
drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c [deleted file]
drivers/staging/r8188eu/hal/rtl8188eu_xmit.c [deleted file]
drivers/staging/r8188eu/hal/usb_halinit.c [deleted file]
drivers/staging/r8188eu/hal/usb_ops_linux.c [deleted file]
drivers/staging/r8188eu/include/Hal8188EPhyCfg.h [deleted file]
drivers/staging/r8188eu/include/Hal8188EPhyReg.h [deleted file]
drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h [deleted file]
drivers/staging/r8188eu/include/HalHWImg8188E_BB.h [deleted file]
drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h [deleted file]
drivers/staging/r8188eu/include/HalHWImg8188E_RF.h [deleted file]
drivers/staging/r8188eu/include/HalPhyRf_8188e.h [deleted file]
drivers/staging/r8188eu/include/HalPwrSeqCmd.h [deleted file]
drivers/staging/r8188eu/include/HalVerDef.h [deleted file]
drivers/staging/r8188eu/include/drv_types.h [deleted file]
drivers/staging/r8188eu/include/hal_com.h [deleted file]
drivers/staging/r8188eu/include/hal_intf.h [deleted file]
drivers/staging/r8188eu/include/ieee80211.h [deleted file]
drivers/staging/r8188eu/include/odm.h [deleted file]
drivers/staging/r8188eu/include/odm_HWConfig.h [deleted file]
drivers/staging/r8188eu/include/odm_RTL8188E.h [deleted file]
drivers/staging/r8188eu/include/odm_RegDefine11N.h [deleted file]
drivers/staging/r8188eu/include/osdep_intf.h [deleted file]
drivers/staging/r8188eu/include/osdep_service.h [deleted file]
drivers/staging/r8188eu/include/rtl8188e_cmd.h [deleted file]
drivers/staging/r8188eu/include/rtl8188e_dm.h [deleted file]
drivers/staging/r8188eu/include/rtl8188e_hal.h [deleted file]
drivers/staging/r8188eu/include/rtl8188e_recv.h [deleted file]
drivers/staging/r8188eu/include/rtl8188e_rf.h [deleted file]
drivers/staging/r8188eu/include/rtl8188e_spec.h [deleted file]
drivers/staging/r8188eu/include/rtl8188e_xmit.h [deleted file]
drivers/staging/r8188eu/include/rtw_ap.h [deleted file]
drivers/staging/r8188eu/include/rtw_br_ext.h [deleted file]
drivers/staging/r8188eu/include/rtw_cmd.h [deleted file]
drivers/staging/r8188eu/include/rtw_eeprom.h [deleted file]
drivers/staging/r8188eu/include/rtw_efuse.h [deleted file]
drivers/staging/r8188eu/include/rtw_event.h [deleted file]
drivers/staging/r8188eu/include/rtw_fw.h [deleted file]
drivers/staging/r8188eu/include/rtw_ht.h [deleted file]
drivers/staging/r8188eu/include/rtw_io.h [deleted file]
drivers/staging/r8188eu/include/rtw_ioctl.h [deleted file]
drivers/staging/r8188eu/include/rtw_ioctl_set.h [deleted file]
drivers/staging/r8188eu/include/rtw_iol.h [deleted file]
drivers/staging/r8188eu/include/rtw_led.h [deleted file]
drivers/staging/r8188eu/include/rtw_mlme.h [deleted file]
drivers/staging/r8188eu/include/rtw_mlme_ext.h [deleted file]
drivers/staging/r8188eu/include/rtw_p2p.h [deleted file]
drivers/staging/r8188eu/include/rtw_pwrctrl.h [deleted file]
drivers/staging/r8188eu/include/rtw_recv.h [deleted file]
drivers/staging/r8188eu/include/rtw_rf.h [deleted file]
drivers/staging/r8188eu/include/rtw_security.h [deleted file]
drivers/staging/r8188eu/include/rtw_xmit.h [deleted file]
drivers/staging/r8188eu/include/sta_info.h [deleted file]
drivers/staging/r8188eu/include/usb_ops.h [deleted file]
drivers/staging/r8188eu/include/usb_osintf.h [deleted file]
drivers/staging/r8188eu/include/wifi.h [deleted file]
drivers/staging/r8188eu/include/wlan_bssdef.h [deleted file]
drivers/staging/r8188eu/os_dep/ioctl_linux.c [deleted file]
drivers/staging/r8188eu/os_dep/os_intfs.c [deleted file]
drivers/staging/r8188eu/os_dep/osdep_service.c [deleted file]
drivers/staging/r8188eu/os_dep/usb_intf.c [deleted file]
drivers/staging/r8188eu/os_dep/usb_ops_linux.c [deleted file]
drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
drivers/staging/rtl8723bs/include/rtw_security.h
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
drivers/target/iscsi/iscsi_target_parameters.c
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
drivers/tty/serial/sc16is7xx.c
drivers/ufs/core/ufshcd.c
drivers/ufs/host/ufs-qcom.c
drivers/w1/masters/ds2482.c
fs/btrfs/bio.c
fs/btrfs/block-group.c
fs/btrfs/delayed-inode.c
fs/btrfs/extent_map.c
fs/btrfs/ioctl.c
fs/btrfs/sysfs.c
fs/erofs/data.c
fs/erofs/decompressor_lzma.c
fs/erofs/internal.h
fs/erofs/pcpubuf.c
fs/erofs/zdata.c
fs/erofs/zmap.c
fs/ext4/ext4.h
fs/ext4/fsmap.c
fs/ext4/inline.c
fs/ext4/inode.c
fs/ext4/ioctl.c
fs/ext4/namei.c
fs/ext4/page-io.c
fs/ext4/super.c
fs/ext4/sysfs.c
fs/ext4/xattr.c
fs/file.c
fs/jbd2/journal.c
fs/locks.c
fs/nfsd/vfs.c
fs/splice.c
fs/udf/inode.c
fs/xfs/xfs_aops.c
fs/xfs/xfs_qm.c
include/dt-bindings/clock/ast2600-clock.h
include/dt-bindings/clock/bcm63268-clock.h
include/dt-bindings/clock/exynos850.h
include/dt-bindings/clock/loongson,ls1x-clk.h [new file with mode: 0644]
include/dt-bindings/clock/loongson,ls2k-clk.h
include/dt-bindings/clock/mediatek,mt8188-clk.h [new file with mode: 0644]
include/dt-bindings/clock/starfive,jh7110-crg.h [new file with mode: 0644]
include/dt-bindings/reset/bcm63268-reset.h
include/dt-bindings/reset/starfive,jh7110-crg.h [new file with mode: 0644]
include/linux/clk-provider.h
include/linux/cpumask.h
include/linux/hid.h
include/linux/highmem.h
include/linux/i2c.h
include/linux/jbd2.h
include/net/netfilter/nf_tproxy.h
include/soc/starfive/reset-starfive-jh71x0.h [new file with mode: 0644]
include/uapi/linux/btrfs.h
include/uapi/linux/fou.h
include/uapi/linux/netdev.h
io_uring/io-wq.c
io_uring/io_uring.c
io_uring/slist.h
io_uring/uring_cmd.c
kernel/bpf/btf.c
kernel/fork.c
kernel/watch_queue.c
net/bpf/test_run.c
net/caif/caif_usb.c
net/core/netdev-genl-gen.c
net/core/netdev-genl-gen.h
net/core/skbuff.c
net/core/sock.c
net/ieee802154/nl802154.c
net/ipv4/fou_nl.c
net/ipv4/fou_nl.h
net/ipv4/netfilter/nf_tproxy_ipv4.c
net/ipv4/tcp_bpf.c
net/ipv4/udp_bpf.c
net/ipv6/ila/ila_xlat.c
net/ipv6/netfilter/nf_tproxy_ipv6.c
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nft_last.c
net/netfilter/nft_quota.c
net/nfc/netlink.c
net/sched/act_connmark.c
net/sched/cls_flower.c
net/smc/af_smc.c
net/socket.c
net/sunrpc/svc.c
net/tls/tls_device.c
net/tls/tls_main.c
net/tls/tls_sw.c
net/unix/af_unix.c
net/unix/unix_bpf.c
net/wireless/sme.c
tools/arch/arm64/include/uapi/asm/kvm.h
tools/arch/x86/include/asm/cpufeatures.h
tools/arch/x86/include/asm/disabled-features.h
tools/arch/x86/include/asm/msr-index.h
tools/arch/x86/include/asm/required-features.h
tools/arch/x86/include/uapi/asm/kvm.h
tools/arch/x86/include/uapi/asm/svm.h
tools/arch/x86/lib/memcpy_64.S
tools/arch/x86/lib/memset_64.S
tools/include/linux/bits.h
tools/include/uapi/linux/fcntl.h
tools/include/uapi/linux/kvm.h
tools/include/uapi/linux/netdev.h
tools/include/uapi/linux/perf_event.h
tools/include/uapi/linux/prctl.h
tools/include/uapi/linux/vhost.h
tools/include/vdso/bits.h
tools/net/ynl/cli.py
tools/net/ynl/lib/__init__.py
tools/net/ynl/lib/nlspec.py
tools/net/ynl/lib/ynl.py
tools/net/ynl/ynl-gen-c.py
tools/net/ynl/ynl-regen.sh
tools/perf/builtin-inject.c
tools/perf/builtin-stat.c
tools/perf/tests/shell/lib/perf_json_output_lint.py
tools/perf/tests/shell/stat+csv_output.sh
tools/perf/util/bpf_skel/off_cpu.bpf.c
tools/perf/util/stat.c
tools/perf/util/stat.h
tools/perf/util/target.h
tools/testing/selftests/bpf/prog_tests/btf.c
tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
tools/testing/selftests/clone3/clone3.c
tools/testing/selftests/hid/config
tools/testing/selftests/netfilter/nft_nat.sh

index 5367faaf7831242fa334b1e55d8189fbd9ade7ab..424564f40733ade9bbf057a3840b45e4418e3ae5 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -136,6 +136,9 @@ Erik Kaneda <erik.kaneda@intel.com> <erik.schmauss@intel.com>
 Eugen Hristev <eugen.hristev@collabora.com> <eugen.hristev@microchip.com>
 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> <ezequiel@collabora.com>
+Faith Ekstrand <faith.ekstrand@collabora.com> <jason@jlekstrand.net>
+Faith Ekstrand <faith.ekstrand@collabora.com> <jason.ekstrand@intel.com>
+Faith Ekstrand <faith.ekstrand@collabora.com> <jason.ekstrand@collabora.com>
 Felipe W Damasio <felipewd@terra.com.br>
 Felix Kuhling <fxkuehl@gmx.de>
 Felix Moeller <felix@derklecks.de>
@@ -306,6 +309,8 @@ Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@osg.samsung.com>
 Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@redhat.com>
 Mauro Carvalho Chehab <mchehab@kernel.org> <m.chehab@samsung.com>
 Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@s-opensource.com>
+Maxim Mikityanskiy <maxtram95@gmail.com> <maximmi@mellanox.com>
+Maxim Mikityanskiy <maxtram95@gmail.com> <maximmi@nvidia.com>
 Maxime Ripard <mripard@kernel.org> <maxime.ripard@bootlin.com>
 Maxime Ripard <mripard@kernel.org> <maxime.ripard@free-electrons.com>
 Mayuresh Janorkar <mayur@ti.com>
@@ -411,7 +416,10 @@ Shuah Khan <shuah@kernel.org> <shuah.kh@samsung.com>
 Simon Arlott <simon@octiron.net> <simon@fire.lp0.eu>
 Simon Kelley <simon@thekelleys.org.uk>
 Stéphane Witzmann <stephane.witzmann@ubpmes.univ-bpclermont.fr>
-Stephen Hemminger <shemminger@osdl.org>
+Stephen Hemminger <stephen@networkplumber.org> <shemminger@linux-foundation.org>
+Stephen Hemminger <stephen@networkplumber.org> <shemminger@osdl.org>
+Stephen Hemminger <stephen@networkplumber.org> <sthemmin@microsoft.com>
+Stephen Hemminger <stephen@networkplumber.org> <sthemmin@vyatta.com>
 Steve Wise <larrystevenwise@gmail.com> <swise@chelsio.com>
 Steve Wise <larrystevenwise@gmail.com> <swise@opengridcomputing.com>
 Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
index ac1e519272aa2bb40a72eed5c50c49e51429a8e4..282de3680367d4a3b3c86b1bdb54352d18c0fedd 100644 (file)
@@ -705,6 +705,15 @@ Description:
                zoned will report "none".
 
 
+What:          /sys/block/<disk>/hidden
+Date:          March 2023
+Contact:       linux-block@vger.kernel.org
+Description:
+               [RO] the block device is hidden. it doesn’t produce events, and
+               can’t be opened from userspace or using blkdev_get*.
+               Used for the underlying components of multipath devices.
+
+
 What:          /sys/block/<disk>/stat
 Date:          February 2008
 Contact:       Jerome Marchand <jmarchan@redhat.com>
index 03d4993eda6f055732478b6067d44cf7399ec5d0..b421d94dc9f216ab44e44f8eed0035c6e796df3f 100644 (file)
@@ -7,8 +7,8 @@ workflows related to reporting bugs, submitting patches, and queueing
 patches for stable kernels.
 
 For general information about submitting patches, please refer to
-`Documentation/process/`_. This document only describes additional specifics
-related to BPF.
+Documentation/process/submitting-patches.rst. This document only describes
+additional specifics related to BPF.
 
 .. contents::
     :local:
@@ -461,15 +461,15 @@ needed::
 
   $ sudo make run_tests
 
-See the kernels selftest `Documentation/dev-tools/kselftest.rst`_
-document for further documentation.
+See :doc:`kernel selftest documentation </dev-tools/kselftest>`
+for details.
 
 To maximize the number of tests passing, the .config of the kernel
 under test should match the config file fragment in
 tools/testing/selftests/bpf as closely as possible.
 
 Finally to ensure support for latest BPF Type Format features -
-discussed in `Documentation/bpf/btf.rst`_ - pahole version 1.16
+discussed in Documentation/bpf/btf.rst - pahole version 1.16
 is required for kernels built with CONFIG_DEBUG_INFO_BTF=y.
 pahole is delivered in the dwarves package or can be built
 from source at
@@ -684,12 +684,8 @@ when:
 
 
 .. Links
-.. _Documentation/process/: https://www.kernel.org/doc/html/latest/process/
 .. _netdev-FAQ: Documentation/process/maintainer-netdev.rst
 .. _selftests:
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/
-.. _Documentation/dev-tools/kselftest.rst:
-   https://www.kernel.org/doc/html/latest/dev-tools/kselftest.html
-.. _Documentation/bpf/btf.rst: btf.rst
 
 Happy BPF hacking!
diff --git a/Documentation/devicetree/bindings/clock/brcm,bcm63268-timer-clocks.yaml b/Documentation/devicetree/bindings/clock/brcm,bcm63268-timer-clocks.yaml
new file mode 100644 (file)
index 0000000..199818b
--- /dev/null
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/brcm,bcm63268-timer-clocks.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM63268 Timer Clock and Reset Device Tree Bindings
+
+maintainers:
+  - Álvaro Fernández Rojas <noltari@gmail.com>
+
+properties:
+  compatible:
+    const: brcm,bcm63268-timer-clocks
+
+  reg:
+    maxItems: 1
+
+  "#clock-cells":
+    const: 1
+
+  "#reset-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - "#clock-cells"
+  - "#reset-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    timer_clk: clock-controller@100000ac {
+      compatible = "brcm,bcm63268-timer-clocks";
+      reg = <0x100000ac 0x4>;
+      #clock-cells = <1>;
+      #reset-cells = <1>;
+    };
diff --git a/Documentation/devicetree/bindings/clock/loongson,ls1x-clk.yaml b/Documentation/devicetree/bindings/clock/loongson,ls1x-clk.yaml
new file mode 100644 (file)
index 0000000..01561a0
--- /dev/null
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/loongson,ls1x-clk.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 Clock Controller
+
+maintainers:
+  - Keguang Zhang <keguang.zhang@gmail.com>
+
+properties:
+  compatible:
+    enum:
+      - loongson,ls1b-clk
+      - loongson,ls1c-clk
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  "#clock-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - "#clock-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    clkc: clock-controller@1fe78030 {
+        compatible = "loongson,ls1b-clk";
+        reg = <0x1fe78030 0x8>;
+
+        clocks = <&xtal>;
+        #clock-cells = <1>;
+    };
+
+...
index cfd042ac1e141123c1c16762ce469aa9037c2472..d00327d12e1e5e78115f9fada9987b870784844b 100644 (file)
@@ -16,7 +16,12 @@ description: |
 
 properties:
   compatible:
-    const: mediatek,mt8186-fhctl
+    enum:
+      - mediatek,mt6795-fhctl
+      - mediatek,mt8173-fhctl
+      - mediatek,mt8186-fhctl
+      - mediatek,mt8192-fhctl
+      - mediatek,mt8195-fhctl
 
   reg:
     maxItems: 1
diff --git a/Documentation/devicetree/bindings/clock/mediatek,mt8188-clock.yaml b/Documentation/devicetree/bindings/clock/mediatek,mt8188-clock.yaml
new file mode 100644 (file)
index 0000000..d7214d9
--- /dev/null
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/mediatek,mt8188-clock.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek Functional Clock Controller for MT8188
+
+maintainers:
+  - Garmin Chang <garmin.chang@mediatek.com>
+
+description: |
+  The clock architecture in MediaTek like below
+  PLLs -->
+          dividers -->
+                      muxes
+                           -->
+                              clock gate
+
+  The devices provide clock gate control in different IP blocks.
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt8188-adsp-audio26m
+      - mediatek,mt8188-camsys
+      - mediatek,mt8188-camsys-rawa
+      - mediatek,mt8188-camsys-rawb
+      - mediatek,mt8188-camsys-yuva
+      - mediatek,mt8188-camsys-yuvb
+      - mediatek,mt8188-ccusys
+      - mediatek,mt8188-imgsys
+      - mediatek,mt8188-imgsys-wpe1
+      - mediatek,mt8188-imgsys-wpe2
+      - mediatek,mt8188-imgsys-wpe3
+      - mediatek,mt8188-imgsys1-dip-nr
+      - mediatek,mt8188-imgsys1-dip-top
+      - mediatek,mt8188-imp-iic-wrap-c
+      - mediatek,mt8188-imp-iic-wrap-en
+      - mediatek,mt8188-imp-iic-wrap-w
+      - mediatek,mt8188-ipesys
+      - mediatek,mt8188-mfgcfg
+      - mediatek,mt8188-vdecsys
+      - mediatek,mt8188-vdecsys-soc
+      - mediatek,mt8188-vencsys
+      - mediatek,mt8188-vppsys0
+      - mediatek,mt8188-vppsys1
+      - mediatek,mt8188-wpesys
+      - mediatek,mt8188-wpesys-vpp0
+
+  reg:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - '#clock-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@11283000 {
+        compatible = "mediatek,mt8188-imp-iic-wrap-c";
+        reg = <0x11283000 0x1000>;
+        #clock-cells = <1>;
+    };
+
diff --git a/Documentation/devicetree/bindings/clock/mediatek,mt8188-sys-clock.yaml b/Documentation/devicetree/bindings/clock/mediatek,mt8188-sys-clock.yaml
new file mode 100644 (file)
index 0000000..4cf8d3a
--- /dev/null
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/mediatek,mt8188-sys-clock.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek System Clock Controller for MT8188
+
+maintainers:
+  - Garmin Chang <garmin.chang@mediatek.com>
+
+description: |
+  The clock architecture in MediaTek like below
+  PLLs -->
+          dividers -->
+                      muxes
+                           -->
+                              clock gate
+
+  The apmixedsys provides most of PLLs which generated from SoC 26m.
+  The topckgen provides dividers and muxes which provide the clock source to other IP blocks.
+  The infracfg_ao provides clock gate in peripheral and infrastructure IP blocks.
+  The mcusys provides mux control to select the clock source in AP MCU.
+  The device nodes also provide the system control capacity for configuration.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - mediatek,mt8188-apmixedsys
+          - mediatek,mt8188-infracfg-ao
+          - mediatek,mt8188-pericfg-ao
+          - mediatek,mt8188-topckgen
+      - const: syscon
+
+  reg:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - '#clock-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@10000000 {
+        compatible = "mediatek,mt8188-topckgen", "syscon";
+        reg = <0x10000000 0x1000>;
+        #clock-cells = <1>;
+    };
index 6b6cec3fba528f943c069722488ca40e7e3bbd68..3afdebdb52ad4bf7508673301efd26b79e6f3a0f 100644 (file)
@@ -16,6 +16,11 @@ description: |
   - 9FGV0241:
     0 -- DIF0
     1 -- DIF1
+  - 9FGV0441:
+    0 -- DIF0
+    1 -- DIF1
+    2 -- DIF2
+    3 -- DIF3
 
 maintainers:
   - Marek Vasut <marex@denx.de>
@@ -24,6 +29,7 @@ properties:
   compatible:
     enum:
       - renesas,9fgv0241
+      - renesas,9fgv0441
 
   reg:
     description: I2C device address
index 141cf173f87d48f4ee9bcc7d42ef468ce14402f2..8aa87b8c1b33018f3f2b9d228688852fb4b2b3ec 100644 (file)
@@ -37,6 +37,7 @@ properties:
       - samsung,exynos850-cmu-cmgp
       - samsung,exynos850-cmu-core
       - samsung,exynos850-cmu-dpu
+      - samsung,exynos850-cmu-g3d
       - samsung,exynos850-cmu-hsi
       - samsung,exynos850-cmu-is
       - samsung,exynos850-cmu-mfcmscl
@@ -169,6 +170,24 @@ allOf:
             - const: oscclk
             - const: dout_dpu
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: samsung,exynos850-cmu-g3d
+
+    then:
+      properties:
+        clocks:
+          items:
+            - description: External reference clock (26 MHz)
+            - description: G3D clock (from CMU_TOP)
+
+        clock-names:
+          items:
+            - const: oscclk
+            - const: dout_g3d_switch
+
   - if:
       properties:
         compatible:
diff --git a/Documentation/devicetree/bindings/clock/skyworks,si521xx.yaml b/Documentation/devicetree/bindings/clock/skyworks,si521xx.yaml
new file mode 100644 (file)
index 0000000..9e35e0e
--- /dev/null
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/skyworks,si521xx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Skyworks Si521xx I2C PCIe clock generators
+
+description: |
+  The Skyworks Si521xx are I2C PCIe clock generators providing
+  from 4 to 9 output clocks.
+
+maintainers:
+  - Marek Vasut <marex@denx.de>
+
+properties:
+  compatible:
+    enum:
+      - skyworks,si52144
+      - skyworks,si52146
+      - skyworks,si52147
+
+  reg:
+    const: 0x6b
+
+  '#clock-cells':
+    const: 1
+
+  clocks:
+    items:
+      - description: XTal input clock
+
+  skyworks,out-amplitude-microvolt:
+    enum: [ 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000 ]
+    description: Output clock signal amplitude
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - '#clock-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        clock-generator@6b {
+            compatible = "skyworks,si52144";
+            reg = <0x6b>;
+            #clock-cells = <1>;
+            clocks = <&ref25m>;
+        };
+    };
+
+...
diff --git a/Documentation/devicetree/bindings/clock/starfive,jh7110-aoncrg.yaml b/Documentation/devicetree/bindings/clock/starfive,jh7110-aoncrg.yaml
new file mode 100644 (file)
index 0000000..923680a
--- /dev/null
@@ -0,0 +1,107 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/starfive,jh7110-aoncrg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: StarFive JH7110 Always-On Clock and Reset Generator
+
+maintainers:
+  - Emil Renner Berthing <kernel@esmil.dk>
+
+properties:
+  compatible:
+    const: starfive,jh7110-aoncrg
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    oneOf:
+      - items:
+          - description: Main Oscillator (24 MHz)
+          - description: GMAC0 RMII reference or GMAC0 RGMII RX
+          - description: STG AXI/AHB
+          - description: APB Bus
+          - description: GMAC0 GTX
+
+      - items:
+          - description: Main Oscillator (24 MHz)
+          - description: GMAC0 RMII reference or GMAC0 RGMII RX
+          - description: STG AXI/AHB or GMAC0 RGMII RX
+          - description: APB Bus or STG AXI/AHB
+          - description: GMAC0 GTX or APB Bus
+          - description: RTC Oscillator (32.768 kHz) or GMAC0 GTX
+
+      - items:
+          - description: Main Oscillator (24 MHz)
+          - description: GMAC0 RMII reference
+          - description: GMAC0 RGMII RX
+          - description: STG AXI/AHB
+          - description: APB Bus
+          - description: GMAC0 GTX
+          - description: RTC Oscillator (32.768 kHz)
+
+  clock-names:
+    oneOf:
+      - minItems: 5
+        items:
+          - const: osc
+          - enum:
+              - gmac0_rmii_refin
+              - gmac0_rgmii_rxin
+          - const: stg_axiahb
+          - const: apb_bus
+          - const: gmac0_gtxclk
+          - const: rtc_osc
+
+      - minItems: 6
+        items:
+          - const: osc
+          - const: gmac0_rmii_refin
+          - const: gmac0_rgmii_rxin
+          - const: stg_axiahb
+          - const: apb_bus
+          - const: gmac0_gtxclk
+          - const: rtc_osc
+
+  '#clock-cells':
+    const: 1
+    description:
+      See <dt-bindings/clock/starfive,jh7110-crg.h> for valid indices.
+
+  '#reset-cells':
+    const: 1
+    description:
+      See <dt-bindings/reset/starfive,jh7110-crg.h> for valid indices.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+  - '#reset-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/starfive,jh7110-crg.h>
+
+    clock-controller@17000000 {
+        compatible = "starfive,jh7110-aoncrg";
+        reg = <0x17000000 0x10000>;
+        clocks = <&osc>, <&gmac0_rmii_refin>,
+                 <&gmac0_rgmii_rxin>,
+                 <&syscrg JH7110_SYSCLK_STG_AXIAHB>,
+                 <&syscrg JH7110_SYSCLK_APB_BUS>,
+                 <&syscrg JH7110_SYSCLK_GMAC0_GTXCLK>,
+                 <&rtc_osc>;
+        clock-names = "osc", "gmac0_rmii_refin",
+                      "gmac0_rgmii_rxin", "stg_axiahb",
+                      "apb_bus", "gmac0_gtxclk",
+                      "rtc_osc";
+        #clock-cells = <1>;
+        #reset-cells = <1>;
+    };
diff --git a/Documentation/devicetree/bindings/clock/starfive,jh7110-syscrg.yaml b/Documentation/devicetree/bindings/clock/starfive,jh7110-syscrg.yaml
new file mode 100644 (file)
index 0000000..84373ae
--- /dev/null
@@ -0,0 +1,104 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/starfive,jh7110-syscrg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: StarFive JH7110 System Clock and Reset Generator
+
+maintainers:
+  - Emil Renner Berthing <kernel@esmil.dk>
+
+properties:
+  compatible:
+    const: starfive,jh7110-syscrg
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    oneOf:
+      - items:
+          - description: Main Oscillator (24 MHz)
+          - description: GMAC1 RMII reference or GMAC1 RGMII RX
+          - description: External I2S TX bit clock
+          - description: External I2S TX left/right channel clock
+          - description: External I2S RX bit clock
+          - description: External I2S RX left/right channel clock
+          - description: External TDM clock
+          - description: External audio master clock
+
+      - items:
+          - description: Main Oscillator (24 MHz)
+          - description: GMAC1 RMII reference
+          - description: GMAC1 RGMII RX
+          - description: External I2S TX bit clock
+          - description: External I2S TX left/right channel clock
+          - description: External I2S RX bit clock
+          - description: External I2S RX left/right channel clock
+          - description: External TDM clock
+          - description: External audio master clock
+
+  clock-names:
+    oneOf:
+      - items:
+          - const: osc
+          - enum:
+              - gmac1_rmii_refin
+              - gmac1_rgmii_rxin
+          - const: i2stx_bclk_ext
+          - const: i2stx_lrck_ext
+          - const: i2srx_bclk_ext
+          - const: i2srx_lrck_ext
+          - const: tdm_ext
+          - const: mclk_ext
+
+      - items:
+          - const: osc
+          - const: gmac1_rmii_refin
+          - const: gmac1_rgmii_rxin
+          - const: i2stx_bclk_ext
+          - const: i2stx_lrck_ext
+          - const: i2srx_bclk_ext
+          - const: i2srx_lrck_ext
+          - const: tdm_ext
+          - const: mclk_ext
+
+  '#clock-cells':
+    const: 1
+    description:
+      See <dt-bindings/clock/starfive,jh7110-crg.h> for valid indices.
+
+  '#reset-cells':
+    const: 1
+    description:
+      See <dt-bindings/reset/starfive,jh7110-crg.h> for valid indices.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+  - '#reset-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@13020000 {
+        compatible = "starfive,jh7110-syscrg";
+        reg = <0x13020000 0x10000>;
+        clocks = <&osc>, <&gmac1_rmii_refin>,
+                 <&gmac1_rgmii_rxin>,
+                 <&i2stx_bclk_ext>, <&i2stx_lrck_ext>,
+                 <&i2srx_bclk_ext>, <&i2srx_lrck_ext>,
+                 <&tdm_ext>, <&mclk_ext>;
+        clock-names = "osc", "gmac1_rmii_refin",
+                      "gmac1_rgmii_rxin",
+                      "i2stx_bclk_ext", "i2stx_lrck_ext",
+                      "i2srx_bclk_ext", "i2srx_lrck_ext",
+                      "tdm_ext", "mclk_ext";
+        #clock-cells = <1>;
+        #reset-cells = <1>;
+    };
index 46d78f860623f146915d518456d7a99991172a42..ed5a5cac6d40e15c9a6745189d0e4314913feda1 100644 (file)
@@ -105,9 +105,9 @@ descriptors. Instead, the superblock and a single block group descriptor
 block is placed at the beginning of the first, second, and last block
 groups in a meta-block group. A meta-block group is a collection of
 block groups which can be described by a single block group descriptor
-block. Since the size of the block group descriptor structure is 32
-bytes, a meta-block group contains 32 block groups for filesystems with
-a 1KB block size, and 128 block groups for filesystems with a 4KB
+block. Since the size of the block group descriptor structure is 64
+bytes, a meta-block group contains 16 block groups for filesystems with
+a 1KB block size, and 64 block groups for filesystems with a 4KB
 blocksize. Filesystems can either be created using this new block group
 descriptor layout, or existing filesystems can be resized on-line, and
 the field s_first_meta_bg in the superblock will indicate the first
index bbcfa2472b047662af0ff2a7a9b415f1b90fd17e..f082a5ad7cf1d47d127086111de8f6b1a8ac5acc 100644 (file)
@@ -1,4 +1,4 @@
-# SPDX-License-Identifier: GPL-2.0
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 %YAML 1.2
 ---
 $id: http://kernel.org/schemas/netlink/genetlink-c.yaml#
index 5642925c4ceb1afc64c675292bbf362c58b9ac72..c6b8c77f7d12e82f1ccd4f106a9ee2df34e5f5ff 100644 (file)
@@ -1,4 +1,4 @@
-# SPDX-License-Identifier: GPL-2.0
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 %YAML 1.2
 ---
 $id: http://kernel.org/schemas/netlink/genetlink-legacy.yaml#
index 62a922755ce2d518e53a0ce92fcf719a427ca3ff..b2d56ab9e615d3262c1a2b757c465f1d5b41b007 100644 (file)
@@ -1,4 +1,4 @@
-# SPDX-License-Identifier: GPL-2.0
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 %YAML 1.2
 ---
 $id: http://kernel.org/schemas/netlink/genetlink-legacy.yaml#
index 08b776908d152131699eaa338fe964c63d3001be..18ecb7d90cbe5f3baf464987be6eb09d3f8ae948 100644 (file)
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+
 name: ethtool
 
 protocol: genetlink-legacy
@@ -11,7 +13,6 @@ attribute-sets:
       -
         name: dev-index
         type: u32
-        value: 1
       -
         name: dev-name
         type: string
@@ -25,7 +26,6 @@ attribute-sets:
       -
         name: index
         type: u32
-        value: 1
       -
         name: name
         type: string
@@ -39,14 +39,12 @@ attribute-sets:
         name: bit
         type: nest
         nested-attributes: bitset-bit
-        value: 1
   -
     name: bitset
     attributes:
       -
         name: nomask
         type: flag
-        value: 1
       -
         name: size
         type: u32
@@ -61,7 +59,6 @@ attribute-sets:
       -
         name: index
         type: u32
-        value: 1
       -
         name: value
         type: string
@@ -71,7 +68,6 @@ attribute-sets:
       -
         name: string
         type: nest
-        value: 1
         multi-attr: true
         nested-attributes: string
   -
@@ -80,7 +76,6 @@ attribute-sets:
       -
         name: id
         type: u32
-        value: 1
       -
         name: count
         type: u32
@@ -96,14 +91,12 @@ attribute-sets:
         name: stringset
         type: nest
         multi-attr: true
-        value: 1
         nested-attributes: stringset
   -
     name: strset
     attributes:
       -
         name: header
-        value: 1
         type: nest
         nested-attributes: header
       -
@@ -119,7 +112,6 @@ attribute-sets:
     attributes:
       -
         name: header
-        value: 1
         type: nest
         nested-attributes: header
       -
@@ -132,7 +124,6 @@ attribute-sets:
     attributes:
       -
         name: header
-        value: 1
         type: nest
         nested-attributes: header
       -
@@ -180,7 +171,6 @@ attribute-sets:
     attributes:
       -
         name: pad
-        value: 1
         type: pad
       -
         name: reassembly-errors
@@ -205,7 +195,6 @@ attribute-sets:
     attributes:
       -
         name: header
-        value: 1
         type: nest
         nested-attributes: header
       -
@@ -251,13 +240,11 @@ operations:
 
       do: &strset-get-op
         request:
-          value: 1
           attributes:
             - header
             - stringsets
             - counts-only
         reply:
-          value: 1
           attributes:
             - header
             - stringsets
index 266c386eedf3a08949b503a855e76db5ff333ff3..cff104288723bb9dfb723c0a47a038b10b9db6d6 100644 (file)
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+
 name: fou
 
 protocol: genetlink-legacy
@@ -26,6 +28,7 @@ attribute-sets:
       -
         name: unspec
         type: unused
+        value: 0
       -
         name: port
         type: u16
@@ -71,6 +74,7 @@ operations:
     -
       name: unspec
       doc: unused
+      value: 0
 
     -
       name: add
index cffef09729f1562e870cfcd557bc1bff1b83c2d9..24de747b53443158fc8adab3816219dcd3e82ec7 100644 (file)
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+
 name: netdev
 
 doc:
@@ -48,7 +50,6 @@ attribute-sets:
         name: ifindex
         doc: netdev ifindex
         type: u32
-        value: 1
         checks:
           min: 1
       -
@@ -66,7 +67,6 @@ operations:
     -
       name: dev-get
       doc: Get / dump information about a netdev.
-      value: 1
       attribute-set: dev
       do:
         request:
index 6ffe8137cd9021605bb83f7a05f60f6e4311c537..2122e0c4a39987c4fdf86a1d4fbbcb954d1813ce 100644 (file)
@@ -24,6 +24,9 @@ YAML specifications can be found under ``Documentation/netlink/specs/``
 This document describes details of the schema.
 See :doc:`intro-specs` for a practical starting guide.
 
+All specs must be licensed under ``GPL-2.0-only OR BSD-3-Clause``
+to allow for easy adoption in user space code.
+
 Compatibility levels
 ====================
 
@@ -197,9 +200,15 @@ value
 Numerical attribute ID, used in serialized Netlink messages.
 The ``value`` property can be skipped, in which case the attribute ID
 will be the value of the previous attribute plus one (recursively)
-and ``0`` for the first attribute in the attribute set.
+and ``1`` for the first attribute in the attribute set.
+
+Attributes (and operations) use ``1`` as the default value for the first
+entry (unlike enums in definitions which start from ``0``) because
+entry ``0`` is almost always reserved as undefined. Spec can explicitly
+set value to ``0`` if needed.
 
-Note that the ``value`` of an attribute is defined only in its main set.
+Note that the ``value`` of an attribute is defined only in its main set
+(not in subsets).
 
 enum
 ~~~~
index 8d5bc223f3053bf83c8a5aeaa6900ceafe111179..bd89746b29abf22ab6b1a33eb8015bab7c9801bd 100644 (file)
@@ -2849,6 +2849,7 @@ F:        Documentation/devicetree/bindings/reset/sunplus,reset.yaml
 F:     arch/arm/boot/dts/sunplus-sp7021*.dts*
 F:     arch/arm/configs/sp7021_*defconfig
 F:     arch/arm/mach-sunplus/
+F:     drivers/clk/clk-sp7021.c
 F:     drivers/irqchip/irq-sp7021-intc.c
 F:     drivers/reset/reset-sunplus.c
 F:     include/dt-bindings/clock/sunplus,sp7021-clkc.h
@@ -9871,10 +9872,10 @@ M:      Christian Brauner <brauner@kernel.org>
 M:     Seth Forshee <sforshee@kernel.org>
 L:     linux-fsdevel@vger.kernel.org
 S:     Maintained
-T:     git://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping.git
+T:     git git://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping.git
 F:     Documentation/filesystems/idmappings.rst
-F:     tools/testing/selftests/mount_setattr/
 F:     include/linux/mnt_idmapping.*
+F:     tools/testing/selftests/mount_setattr/
 
 IDT VersaClock 5 CLOCK DRIVER
 M:     Luca Ceresoli <luca@lucaceresoli.net>
@@ -12121,6 +12122,7 @@ M:      Yinbo Zhu <zhuyinbo@loongson.cn>
 L:     linux-clk@vger.kernel.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/clock/loongson,ls2k-clk.yaml
+F:     drivers/clk/clk-loongson2.c
 F:     include/dt-bindings/clock/loongson,ls2k-clk.h
 
 LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)
@@ -14000,7 +14002,6 @@ L:      linux-mips@vger.kernel.org
 S:     Maintained
 F:     arch/mips/include/asm/mach-loongson32/
 F:     arch/mips/loongson32/
-F:     drivers/*/*/*loongson1*
 F:     drivers/*/*loongson1*
 
 MIPS/LOONGSON2EF ARCHITECTURE
@@ -16391,6 +16392,7 @@ R:      Alexander Shishkin <alexander.shishkin@linux.intel.com>
 R:     Jiri Olsa <jolsa@kernel.org>
 R:     Namhyung Kim <namhyung@kernel.org>
 R:     Ian Rogers <irogers@google.com>
+R:     Adrian Hunter <adrian.hunter@intel.com>
 L:     linux-perf-users@vger.kernel.org
 L:     linux-kernel@vger.kernel.org
 S:     Supported
@@ -19863,13 +19865,6 @@ S:     Maintained
 W:     http://wiki.laptop.org/go/DCON
 F:     drivers/staging/olpc_dcon/
 
-STAGING - REALTEK RTL8188EU DRIVERS
-M:     Larry Finger <Larry.Finger@lwfinger.net>
-M:     Phillip Potter <phil@philpotter.co.uk>
-R:     Pavel Skripkin <paskripkin@gmail.com>
-S:     Supported
-F:     drivers/staging/r8188eu/
-
 STAGING - REALTEK RTL8712U DRIVERS
 M:     Larry Finger <Larry.Finger@lwfinger.net>
 M:     Florian Schilhabel <florian.c.schilhabel@googlemail.com>.
@@ -19913,19 +19908,20 @@ M:    Emil Renner Berthing <kernel@esmil.dk>
 S:     Maintained
 F:     arch/riscv/boot/dts/starfive/
 
-STARFIVE JH7100 CLOCK DRIVERS
-M:     Emil Renner Berthing <kernel@esmil.dk>
-S:     Maintained
-F:     Documentation/devicetree/bindings/clock/starfive,jh7100-*.yaml
-F:     drivers/clk/starfive/clk-starfive-jh7100*
-F:     include/dt-bindings/clock/starfive-jh7100*.h
-
 STARFIVE JH7110 MMC/SD/SDIO DRIVER
 M:     William Qiu <william.qiu@starfivetech.com>
 S:     Supported
 F:     Documentation/devicetree/bindings/mmc/starfive*
 F:     drivers/mmc/host/dw_mmc-starfive.c
 
+STARFIVE JH71X0 CLOCK DRIVERS
+M:     Emil Renner Berthing <kernel@esmil.dk>
+M:     Hal Feng <hal.feng@starfivetech.com>
+S:     Maintained
+F:     Documentation/devicetree/bindings/clock/starfive,jh71*.yaml
+F:     drivers/clk/starfive/clk-starfive-jh71*
+F:     include/dt-bindings/clock/starfive?jh71*.h
+
 STARFIVE JH71X0 PINCTRL DRIVERS
 M:     Emil Renner Berthing <kernel@esmil.dk>
 M:     Jianlong Huang <jianlong.huang@starfivetech.com>
@@ -19936,12 +19932,13 @@ F:    drivers/pinctrl/starfive/pinctrl-starfive-jh71*
 F:     include/dt-bindings/pinctrl/pinctrl-starfive-jh7100.h
 F:     include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h
 
-STARFIVE JH7100 RESET CONTROLLER DRIVER
+STARFIVE JH71X0 RESET CONTROLLER DRIVERS
 M:     Emil Renner Berthing <kernel@esmil.dk>
+M:     Hal Feng <hal.feng@starfivetech.com>
 S:     Maintained
 F:     Documentation/devicetree/bindings/reset/starfive,jh7100-reset.yaml
-F:     drivers/reset/reset-starfive-jh7100.c
-F:     include/dt-bindings/reset/starfive-jh7100.h
+F:     drivers/reset/starfive/reset-starfive-jh71*
+F:     include/dt-bindings/reset/starfive?jh71*.h
 
 STARFIVE JH71XX PMU CONTROLLER DRIVER
 M:     Walker Chen <walker.chen@starfivetech.com>
index d7bd0eb9b34633f22d70649e245575f49dfd1e41..c933ceb4f21db15d9789f8e9fd12a931174c121f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 VERSION = 6
 PATCHLEVEL = 3
 SUBLEVEL = 0
-EXTRAVERSION = -rc1
+EXTRAVERSION = -rc2
 NAME = Hurr durr I'ma ninja sloth
 
 # *DOCUMENTATION*
index 612c5eca71bc0fea03dcf1c888076c065fc65f57..7c08b225261c4add9b50b62a907239d30ecd4cf1 100644 (file)
@@ -23,7 +23,7 @@ alpha_read_fp_reg (unsigned long reg)
 
        if (unlikely(reg >= 32))
                return 0;
-       preempt_enable();
+       preempt_disable();
        if (current_thread_info()->status & TS_SAVED_FP)
                val = current_thread_info()->fp[reg];
        else switch (reg) {
@@ -133,7 +133,7 @@ alpha_read_fp_reg_s (unsigned long reg)
        if (unlikely(reg >= 32))
                return 0;
 
-       preempt_enable();
+       preempt_disable();
        if (current_thread_info()->status & TS_SAVED_FP) {
                LDT(0, current_thread_info()->fp[reg]);
                STS(0, val);
index 3a2bb2e8fdad47b44f3ff442325d3d7582eaea4b..fbff1cea62caac23c0463270f320394fabb235b2 100644 (file)
@@ -326,16 +326,16 @@ void __init setup_arch(char **cmdline_p)
                panic("No configuration setup");
        }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (m68k_ramdisk.size) {
+       if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && m68k_ramdisk.size)
                memblock_reserve(m68k_ramdisk.addr, m68k_ramdisk.size);
+
+       paging_init();
+
+       if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && m68k_ramdisk.size) {
                initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
                initrd_end = initrd_start + m68k_ramdisk.size;
                pr_info("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
        }
-#endif
-
-       paging_init();
 
 #ifdef CONFIG_NATFEAT
        nf_init();
index 5c8cba0efc63e580d924d6ad667220d927dbb637..a700807c9b6d9999f188c215edb872ba1724c3d8 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/ptrace.h>
 #include <linux/kallsyms.h>
+#include <linux/extable.h>
 
 #include <asm/setup.h>
 #include <asm/fpu.h>
@@ -545,7 +546,8 @@ static inline void bus_error030 (struct frame *fp)
                        errorcode |= 2;
 
                if (mmusr & (MMU_I | MMU_WP)) {
-                       if (ssw & 4) {
+                       /* We might have an exception table for this PC */
+                       if (ssw & 4 && !search_exception_tables(fp->ptregs.pc)) {
                                pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n",
                                       ssw & RW ? "read" : "write",
                                       fp->un.fmtb.daddr,
index 2a375637e0077852ed86abf7b9310bc872f345b4..9113012240789469e20f7360583e861d4d3c3c65 100644 (file)
@@ -437,7 +437,7 @@ void __init paging_init(void)
        }
 
        min_addr = m68k_memory[0].addr;
-       max_addr = min_addr + m68k_memory[0].size;
+       max_addr = min_addr + m68k_memory[0].size - 1;
        memblock_add_node(m68k_memory[0].addr, m68k_memory[0].size, 0,
                          MEMBLOCK_NONE);
        for (i = 1; i < m68k_num_memory;) {
@@ -452,21 +452,21 @@ void __init paging_init(void)
                }
                memblock_add_node(m68k_memory[i].addr, m68k_memory[i].size, i,
                                  MEMBLOCK_NONE);
-               addr = m68k_memory[i].addr + m68k_memory[i].size;
+               addr = m68k_memory[i].addr + m68k_memory[i].size - 1;
                if (addr > max_addr)
                        max_addr = addr;
                i++;
        }
        m68k_memoffset = min_addr - PAGE_OFFSET;
-       m68k_virt_to_node_shift = fls(max_addr - min_addr - 1) - 6;
+       m68k_virt_to_node_shift = fls(max_addr - min_addr) - 6;
 
        module_fixup(NULL, __start_fixup, __stop_fixup);
        flush_icache();
 
-       high_memory = phys_to_virt(max_addr);
+       high_memory = phys_to_virt(max_addr) + 1;
 
        min_low_pfn = availmem >> PAGE_SHIFT;
-       max_pfn = max_low_pfn = max_addr >> PAGE_SHIFT;
+       max_pfn = max_low_pfn = (max_addr >> PAGE_SHIFT) + 1;
 
        /* Reserve kernel text/data/bss and the memory allocated in head.S */
        memblock_reserve(m68k_memory[0].addr, availmem - m68k_memory[0].addr);
index 89a1511d2ee47126ca5121b1cfccd6d749ab4afb..edf9634aa8ee1d1b904252c66895ef5dbce7ec2c 100644 (file)
@@ -284,6 +284,7 @@ CONFIG_IXGB=m
 CONFIG_SKGE=m
 CONFIG_SKY2=m
 CONFIG_MYRI10GE=m
+CONFIG_FEALNX=m
 CONFIG_NATSEMI=m
 CONFIG_NS83820=m
 CONFIG_S2IO=m
index 86e1a6aab4e5f61ffc8d0da48c55f384f2e16241..2cdcfb5f6012d467b0f4daa2cae056562e11d953 100644 (file)
@@ -20,7 +20,6 @@ extern struct platform_device ls1x_gpio1_pdev;
 extern struct platform_device ls1x_rtc_pdev;
 extern struct platform_device ls1x_wdt_pdev;
 
-void __init ls1x_clk_init(void);
 void __init ls1x_rtc_set_extclk(struct platform_device *pdev);
 void __init ls1x_serial_set_uartclk(struct platform_device *pdev);
 
index 459b15c96d3b250cd02e6e78ca2d665a4d3c0e97..965c04aa56fd6f8b7cf974fab15fd08a4922d768 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/of_clk.h>
 #include <linux/interrupt.h>
 #include <linux/sizes.h>
 #include <asm/time.h>
@@ -211,7 +212,7 @@ void __init plat_time_init(void)
        struct clk *clk = NULL;
 
        /* initialize LS1X clocks */
-       ls1x_clk_init();
+       of_clk_init(NULL);
 
 #ifdef CONFIG_CEVT_CSRC_LS1X
        /* setup LS1X PWM timer */
index 73f8c998c64dfefa6859cd5bcda8ddafcdc51f38..d4f5f159d6f236b02c010013e61cdc1e1e915080 100644 (file)
@@ -10,7 +10,6 @@
 
 / {
        model = "fsl,T1040RDB-REV-A";
-       compatible = "fsl,T1040RDB-REV-A";
 };
 
 &seville_port0 {
index b6733e7e65805e47fc52d345040dd190ca0ea2e7..dd3aab81e9dea4c43c6982b323daee702461f1f9 100644 (file)
 };
 
 &seville_port8 {
-       ethernet = <&enet0>;
+       status = "okay";
+};
+
+&seville_port9 {
        status = "okay";
 };
index f58eb820eb5ec748eee5bf482ec5a9c6661a72c4..ad0ab33336b88c0e49d27e5d0a76ece3d5d73f12 100644 (file)
                        seville_port8: port@8 {
                                reg = <8>;
                                phy-mode = "internal";
+                               ethernet = <&enet0>;
                                status = "disabled";
 
                                fixed-link {
                        seville_port9: port@9 {
                                reg = <9>;
                                phy-mode = "internal";
+                               ethernet = <&enet1>;
                                status = "disabled";
 
                                fixed-link {
index 1102582779599bf11e224a3d95f58f8a4ffc978a..f73c98be56c8fa4b2c2cbe202b45f60692779d1e 100644 (file)
@@ -461,6 +461,7 @@ CONFIG_MV643XX_ETH=m
 CONFIG_SKGE=m
 CONFIG_SKY2=m
 CONFIG_MYRI10GE=m
+CONFIG_FEALNX=m
 CONFIG_NATSEMI=m
 CONFIG_NS83820=m
 CONFIG_PCMCIA_AXNET=m
index 73c620c2a3a166b2b5c6b4d460847b01edf27541..e753a6bd48881026339abd56fe92c3944a0eb124 100644 (file)
@@ -1275,7 +1275,7 @@ static int xmon_batch_next_cpu(void)
        while (!cpumask_empty(&xmon_batch_cpus)) {
                cpu = cpumask_next_wrap(smp_processor_id(), &xmon_batch_cpus,
                                        xmon_batch_start_cpu, true);
-               if (cpu == nr_cpumask_bits)
+               if (cpu >= nr_cpu_ids)
                        break;
                if (xmon_batch_start_cpu == -1)
                        xmon_batch_start_cpu = cpu;
index 6203c3378922821b580ea50a953af2dd0cb141bb..4de83b9b1772d14d766d6b3a14102709b9c96caa 100644 (file)
@@ -84,6 +84,13 @@ endif
 # Avoid generating .eh_frame sections.
 KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
 
+# The RISC-V attributes frequently cause compatibility issues and provide no
+# information, so just turn them off.
+KBUILD_CFLAGS += $(call cc-option,-mno-riscv-attribute)
+KBUILD_AFLAGS += $(call cc-option,-mno-riscv-attribute)
+KBUILD_CFLAGS += $(call as-option,-Wa$(comma)-mno-arch-attr)
+KBUILD_AFLAGS += $(call as-option,-Wa$(comma)-mno-arch-attr)
+
 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
 KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
 
index da55cb247e89499a875ea3b8089576e324b45494..31d2ebea4286ecef4dd539645c52f70c4883ceaa 100644 (file)
@@ -111,7 +111,7 @@ void __init_or_module sifive_errata_patch_func(struct alt_entry *begin,
                        mutex_lock(&text_mutex);
                        patch_text_nosync(ALT_OLD_PTR(alt), ALT_ALT_PTR(alt),
                                          alt->alt_len);
-                       mutex_lock(&text_mutex);
+                       mutex_unlock(&text_mutex);
                        cpu_apply_errata |= tmp;
                }
        }
index 9e73922e1e2e5bf8bd35ee8197d46a35690428e5..d47d87c2d7e3d0f1393688527f3c72d589fdb907 100644 (file)
@@ -109,6 +109,6 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
 #define ftrace_init_nop ftrace_init_nop
 #endif
 
-#endif
+#endif /* CONFIG_DYNAMIC_FTRACE */
 
 #endif /* _ASM_RISCV_FTRACE_H */
index f433121774c0190628b0a2f071059c92d782deb7..63c98833d5105d325db88ab3a232462fc0bdae85 100644 (file)
@@ -9,4 +9,6 @@
 int patch_text_nosync(void *addr, const void *insns, size_t len);
 int patch_text(void *addr, u32 *insns, int ninsns);
 
+extern int riscv_patch_in_stop_machine;
+
 #endif /* _ASM_RISCV_PATCH_H */
index 260daf3236d3a8dd08ac046410170c59f5d09b29..7f34f3c7c8827aeb32662f95dd1312d5ea047256 100644 (file)
@@ -14,6 +14,10 @@ COMPAT_LD := $(LD)
 COMPAT_CC_FLAGS := -march=rv32g -mabi=ilp32
 COMPAT_LD_FLAGS := -melf32lriscv
 
+# Disable attributes, as they're useless and break the build.
+COMPAT_CC_FLAGS += $(call cc-option,-mno-riscv-attribute)
+COMPAT_CC_FLAGS += $(call as-option,-Wa$(comma)-mno-arch-attr)
+
 # Files to link into the compat_vdso
 obj-compat_vdso = $(patsubst %, %.o, $(compat_vdso-syms)) note.o
 
index 5bff37af4770b5976332b880916a73807f786534..03a6434a8cdd0035bbc59629b1751c00df24b918 100644 (file)
 void ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)
 {
        mutex_lock(&text_mutex);
+
+       /*
+        * The code sequences we use for ftrace can't be patched while the
+        * kernel is running, so we need to use stop_machine() to modify them
+        * for now.  This doesn't play nice with text_mutex, we use this flag
+        * to elide the check.
+        */
+       riscv_patch_in_stop_machine = true;
 }
 
 void ftrace_arch_code_modify_post_process(void) __releases(&text_mutex)
 {
+       riscv_patch_in_stop_machine = false;
        mutex_unlock(&text_mutex);
 }
 
@@ -107,9 +116,9 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
 {
        int out;
 
-       ftrace_arch_code_modify_prepare();
+       mutex_lock(&text_mutex);
        out = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
-       ftrace_arch_code_modify_post_process();
+       mutex_unlock(&text_mutex);
 
        return out;
 }
index 8086d1a281cd32c52fb126beb5a514732618a6e2..575e71d6c8ae2d0b4e9b0935f117299884272a80 100644 (file)
@@ -11,6 +11,7 @@
 #include <asm/kprobes.h>
 #include <asm/cacheflush.h>
 #include <asm/fixmap.h>
+#include <asm/ftrace.h>
 #include <asm/patch.h>
 
 struct patch_insn {
@@ -20,6 +21,8 @@ struct patch_insn {
        atomic_t cpu_count;
 };
 
+int riscv_patch_in_stop_machine = false;
+
 #ifdef CONFIG_MMU
 /*
  * The fix_to_virt(, idx) needs a const value (not a dynamic variable of
@@ -60,8 +63,15 @@ static int patch_insn_write(void *addr, const void *insn, size_t len)
         * Before reaching here, it was expected to lock the text_mutex
         * already, so we don't need to give another lock here and could
         * ensure that it was safe between each cores.
+        *
+        * We're currently using stop_machine() for ftrace & kprobes, and while
+        * that ensures text_mutex is held before installing the mappings it
+        * does not ensure text_mutex is held by the calling thread.  That's
+        * safe but triggers a lockdep failure, so just elide it for that
+        * specific case.
         */
-       lockdep_assert_held(&text_mutex);
+       if (!riscv_patch_in_stop_machine)
+               lockdep_assert_held(&text_mutex);
 
        if (across_pages)
                patch_map(addr + len, FIX_TEXT_POKE1);
@@ -125,6 +135,7 @@ NOKPROBE_SYMBOL(patch_text_cb);
 
 int patch_text(void *addr, u32 *insns, int ninsns)
 {
+       int ret;
        struct patch_insn patch = {
                .addr = addr,
                .insns = insns,
@@ -132,7 +143,18 @@ int patch_text(void *addr, u32 *insns, int ninsns)
                .cpu_count = ATOMIC_INIT(0),
        };
 
-       return stop_machine_cpuslocked(patch_text_cb,
-                                      &patch, cpu_online_mask);
+       /*
+        * kprobes takes text_mutex, before calling patch_text(), but as we call
+        * calls stop_machine(), the lockdep assertion in patch_insn_write()
+        * gets confused by the context in which the lock is taken.
+        * Instead, ensure the lock is held before calling stop_machine(), and
+        * set riscv_patch_in_stop_machine to skip the check in
+        * patch_insn_write().
+        */
+       lockdep_assert_held(&text_mutex);
+       riscv_patch_in_stop_machine = true;
+       ret = stop_machine_cpuslocked(patch_text_cb, &patch, cpu_online_mask);
+       riscv_patch_in_stop_machine = false;
+       return ret;
 }
 NOKPROBE_SYMBOL(patch_text);
index f9a5a7c90ff0939b7d303de2454fcb94fc0dee85..64a9c093aef93a1b9ec4a99bab001a1f9932e776 100644 (file)
@@ -101,7 +101,7 @@ void notrace walk_stackframe(struct task_struct *task,
        while (!kstack_end(ksp)) {
                if (__kernel_text_address(pc) && unlikely(!fn(arg, pc)))
                        break;
-               pc = (*ksp++) - 0x4;
+               pc = READ_ONCE_NOCHECK(*ksp++) - 0x4;
        }
 }
 
index f5a668736c79b1113b81f57b9243f9a05975619f..acdc3f040195e011634805de7027de18da05a180 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/filter.h>
 #include <linux/memory.h>
 #include <linux/stop_machine.h>
+#include <asm/patch.h>
 #include "bpf_jit.h"
 
 #define RV_REG_TCC RV_REG_A6
index 27aebf1e75a2003003cffaf82c43d46b3e206357..3ef7adf739c836d8f742e131daae0c511d3060db 100644 (file)
@@ -50,6 +50,7 @@
 #define SR_FD          0x00008000
 #define SR_MD          0x40000000
 
+#define SR_USER_MASK   0x00000303      // M, Q, S, T bits
 /*
  * DSP structure and data
  */
index 90f495d35db29a7e7b139d4541eb20fe053f02ed..a6bfc6f374911d5ac639030c196bd72ebd19d614 100644 (file)
@@ -115,6 +115,7 @@ static int
 restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p)
 {
        unsigned int err = 0;
+       unsigned int sr = regs->sr & ~SR_USER_MASK;
 
 #define COPY(x)                err |= __get_user(regs->x, &sc->sc_##x)
                        COPY(regs[1]);
@@ -130,6 +131,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p
        COPY(sr);       COPY(pc);
 #undef COPY
 
+       regs->sr = (regs->sr & SR_USER_MASK) | sr;
+
 #ifdef CONFIG_SH_FPU
        if (boot_cpu_data.flags & CPU_HAS_FPU) {
                int owned_fp;
index 52788f79786fad74f2c373e5ce7895e79af26942..255a78d9d90672afb053875184d89b05bab52a0b 100644 (file)
@@ -49,7 +49,7 @@ DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
  *   simple as possible.
  * Must be called with preemption disabled.
  */
-static void __resctrl_sched_in(void)
+static inline void __resctrl_sched_in(struct task_struct *tsk)
 {
        struct resctrl_pqr_state *state = this_cpu_ptr(&pqr_state);
        u32 closid = state->default_closid;
@@ -61,13 +61,13 @@ static void __resctrl_sched_in(void)
         * Else use the closid/rmid assigned to this cpu.
         */
        if (static_branch_likely(&rdt_alloc_enable_key)) {
-               tmp = READ_ONCE(current->closid);
+               tmp = READ_ONCE(tsk->closid);
                if (tmp)
                        closid = tmp;
        }
 
        if (static_branch_likely(&rdt_mon_enable_key)) {
-               tmp = READ_ONCE(current->rmid);
+               tmp = READ_ONCE(tsk->rmid);
                if (tmp)
                        rmid = tmp;
        }
@@ -88,17 +88,17 @@ static inline unsigned int resctrl_arch_round_mon_val(unsigned int val)
        return val * scale;
 }
 
-static inline void resctrl_sched_in(void)
+static inline void resctrl_sched_in(struct task_struct *tsk)
 {
        if (static_branch_likely(&rdt_enable_key))
-               __resctrl_sched_in();
+               __resctrl_sched_in(tsk);
 }
 
 void resctrl_cpu_detect(struct cpuinfo_x86 *c);
 
 #else
 
-static inline void resctrl_sched_in(void) {}
+static inline void resctrl_sched_in(struct task_struct *tsk) {}
 static inline void resctrl_cpu_detect(struct cpuinfo_x86 *c) {}
 
 #endif /* CONFIG_X86_CPU_RESCTRL */
index 380753b14cab0751310c8bd1e9f1a2970ee39478..95cdd08c4cbb91ffa88fb14960ca532132c363ff 100644 (file)
@@ -880,6 +880,15 @@ void init_spectral_chicken(struct cpuinfo_x86 *c)
                }
        }
 #endif
+       /*
+        * Work around Erratum 1386.  The XSAVES instruction malfunctions in
+        * certain circumstances on Zen1/2 uarch, and not all parts have had
+        * updated microcode at the time of writing (March 2023).
+        *
+        * Affected parts all have no supervisor XSAVE states, meaning that
+        * the XSAVEC instruction (which works fine) is equivalent.
+        */
+       clear_cpu_cap(c, X86_FEATURE_XSAVES);
 }
 
 static void init_amd_zn(struct cpuinfo_x86 *c)
index e2c1599d1b373d8ff9fb4d0af5e1e6d4787bfded..884b6e9a7e31c36281afe21b2f507f9b223781b2 100644 (file)
@@ -314,7 +314,7 @@ static void update_cpu_closid_rmid(void *info)
         * executing task might have its own closid selected. Just reuse
         * the context switch code.
         */
-       resctrl_sched_in();
+       resctrl_sched_in(current);
 }
 
 /*
@@ -530,7 +530,7 @@ static void _update_task_closid_rmid(void *task)
         * Otherwise, the MSR is updated when the task is scheduled in.
         */
        if (task == current)
-               resctrl_sched_in();
+               resctrl_sched_in(task);
 }
 
 static void update_task_closid_rmid(struct task_struct *t)
index 470c128759eab3c82b05539f13e204354452cdc1..708c87b88cc150ee64145de90de938e0482afa3f 100644 (file)
@@ -212,7 +212,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
        switch_fpu_finish();
 
        /* Load the Intel cache allocation PQR MSR. */
-       resctrl_sched_in();
+       resctrl_sched_in(next_p);
 
        return prev_p;
 }
index 4e34b3b68ebdc96a76c9bf265415ecac3a5314a8..bb65a68b4b49968c6d33ea9324b37c3a242e1458 100644 (file)
@@ -656,7 +656,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
        }
 
        /* Load the Intel cache allocation PQR MSR. */
-       resctrl_sched_in();
+       resctrl_sched_in(next_p);
 
        return prev_p;
 }
index 8a8d4441519ce7bcbf28e3c5a21d236c994cf115..d9ed3108c17af60d0b0a8cc53629bbfba104bf4f 100644 (file)
@@ -2854,11 +2854,11 @@ bfq_setup_stable_merge(struct bfq_data *bfqd, struct bfq_queue *bfqq,
 {
        int proc_ref = min(bfqq_process_refs(bfqq),
                           bfqq_process_refs(stable_merge_bfqq));
-       struct bfq_queue *new_bfqq;
+       struct bfq_queue *new_bfqq = NULL;
 
-       if (idling_boosts_thr_without_issues(bfqd, bfqq) ||
-           proc_ref == 0)
-               return NULL;
+       bfqq_data->stable_merge_bfqq = NULL;
+       if (idling_boosts_thr_without_issues(bfqd, bfqq) || proc_ref == 0)
+               goto out;
 
        /* next function will take at least one ref */
        new_bfqq = bfq_setup_merge(bfqq, stable_merge_bfqq);
@@ -2873,6 +2873,11 @@ bfq_setup_stable_merge(struct bfq_data *bfqd, struct bfq_queue *bfqq,
                        new_bfqq_data->stably_merged = true;
                }
        }
+
+out:
+       /* deschedule stable merge, because done or aborted here */
+       bfq_put_stable_ref(stable_merge_bfqq);
+
        return new_bfqq;
 }
 
@@ -2933,11 +2938,6 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
                        struct bfq_queue *stable_merge_bfqq =
                                bfqq_data->stable_merge_bfqq;
 
-                       /* deschedule stable merge, because done or aborted here */
-                       bfq_put_stable_ref(stable_merge_bfqq);
-
-                       bfqq_data->stable_merge_bfqq = NULL;
-
                        return bfq_setup_stable_merge(bfqd, bfqq,
                                                      stable_merge_bfqq,
                                                      bfqq_data);
index 3ee5577e15860ceb1221c609160cc6b5f56158f1..02d9cfb9e077aaa5877aad060036191324d2e7a0 100644 (file)
@@ -385,7 +385,7 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode)
        if (IS_ERR(bdev))
                ret =  PTR_ERR(bdev);
        else
-               blkdev_put(bdev, mode);
+               blkdev_put(bdev, mode & ~FMODE_EXCL);
 
        if (!(mode & FMODE_EXCL))
                bd_abort_claiming(disk->part0, disk_scan_partitions);
index ce3ccd172cc868d9f89ea2c5489a600ea08e2a0d..253f2ddb891308591db05ada2de72aa8703043da 100644 (file)
@@ -1311,7 +1311,7 @@ static void __cold try_to_generate_entropy(void)
                        /* Basic CPU round-robin, which avoids the current CPU. */
                        do {
                                cpu = cpumask_next(cpu, &timer_cpus);
-                               if (cpu == nr_cpumask_bits)
+                               if (cpu >= nr_cpu_ids)
                                        cpu = cpumask_first(&timer_cpus);
                        } while (cpu == smp_processor_id() && num_cpus > 1);
 
index 40360e599bc36083fd3fa10e11d48473915e8e80..bd757d836c5cf9ba53b6355da877d5907e32a8e7 100644 (file)
@@ -144,8 +144,12 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
 
        ret = -EIO;
        virt = acpi_os_map_iomem(start, len);
-       if (!virt)
+       if (!virt) {
+               dev_warn(&chip->dev, "%s: Failed to map ACPI memory\n", __func__);
+               /* try EFI log next */
+               ret = -ENODEV;
                goto err;
+       }
 
        memcpy_fromio(log->bios_event_log, virt, len);
 
index b99f55f2d4fd25dd1669489d81f07ac8c7513100..0601e6e5e326312696c0313038394f23fba87737 100644 (file)
@@ -511,6 +511,63 @@ static int tpm_add_legacy_sysfs(struct tpm_chip *chip)
        return 0;
 }
 
+/*
+ * Some AMD fTPM versions may cause stutter
+ * https://www.amd.com/en/support/kb/faq/pa-410
+ *
+ * Fixes are available in two series of fTPM firmware:
+ * 6.x.y.z series: 6.0.18.6 +
+ * 3.x.y.z series: 3.57.y.5 +
+ */
+static bool tpm_amd_is_rng_defective(struct tpm_chip *chip)
+{
+       u32 val1, val2;
+       u64 version;
+       int ret;
+
+       if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
+               return false;
+
+       ret = tpm_request_locality(chip);
+       if (ret)
+               return false;
+
+       ret = tpm2_get_tpm_pt(chip, TPM2_PT_MANUFACTURER, &val1, NULL);
+       if (ret)
+               goto release;
+       if (val1 != 0x414D4400U /* AMD */) {
+               ret = -ENODEV;
+               goto release;
+       }
+       ret = tpm2_get_tpm_pt(chip, TPM2_PT_FIRMWARE_VERSION_1, &val1, NULL);
+       if (ret)
+               goto release;
+       ret = tpm2_get_tpm_pt(chip, TPM2_PT_FIRMWARE_VERSION_2, &val2, NULL);
+
+release:
+       tpm_relinquish_locality(chip);
+
+       if (ret)
+               return false;
+
+       version = ((u64)val1 << 32) | val2;
+       if ((version >> 48) == 6) {
+               if (version >= 0x0006000000180006ULL)
+                       return false;
+       } else if ((version >> 48) == 3) {
+               if (version >= 0x0003005700000005ULL)
+                       return false;
+       } else {
+               return false;
+       }
+
+       dev_warn(&chip->dev,
+                "AMD fTPM version 0x%llx causes system stutter; hwrng disabled\n",
+                version);
+
+       return true;
+}
+
 static int tpm_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
 {
        struct tpm_chip *chip = container_of(rng, struct tpm_chip, hwrng);
@@ -520,7 +577,8 @@ static int tpm_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
 
 static int tpm_add_hwrng(struct tpm_chip *chip)
 {
-       if (!IS_ENABLED(CONFIG_HW_RANDOM_TPM) || tpm_is_firmware_upgrade(chip))
+       if (!IS_ENABLED(CONFIG_HW_RANDOM_TPM) || tpm_is_firmware_upgrade(chip) ||
+           tpm_amd_is_rng_defective(chip))
                return 0;
 
        snprintf(chip->hwrng_name, sizeof(chip->hwrng_name),
index 24ee4e1cc452a006945ffbe9c257275332a46d6d..830014a266090868a6123ed2b3b8043e0ddcc548 100644 (file)
@@ -150,6 +150,79 @@ enum tpm_sub_capabilities {
        TPM_CAP_PROP_TIS_DURATION = 0x120,
 };
 
+enum tpm2_pt_props {
+       TPM2_PT_NONE = 0x00000000,
+       TPM2_PT_GROUP = 0x00000100,
+       TPM2_PT_FIXED = TPM2_PT_GROUP * 1,
+       TPM2_PT_FAMILY_INDICATOR = TPM2_PT_FIXED + 0,
+       TPM2_PT_LEVEL = TPM2_PT_FIXED + 1,
+       TPM2_PT_REVISION = TPM2_PT_FIXED + 2,
+       TPM2_PT_DAY_OF_YEAR = TPM2_PT_FIXED + 3,
+       TPM2_PT_YEAR = TPM2_PT_FIXED + 4,
+       TPM2_PT_MANUFACTURER = TPM2_PT_FIXED + 5,
+       TPM2_PT_VENDOR_STRING_1 = TPM2_PT_FIXED + 6,
+       TPM2_PT_VENDOR_STRING_2 = TPM2_PT_FIXED + 7,
+       TPM2_PT_VENDOR_STRING_3 = TPM2_PT_FIXED + 8,
+       TPM2_PT_VENDOR_STRING_4 = TPM2_PT_FIXED + 9,
+       TPM2_PT_VENDOR_TPM_TYPE = TPM2_PT_FIXED + 10,
+       TPM2_PT_FIRMWARE_VERSION_1 = TPM2_PT_FIXED + 11,
+       TPM2_PT_FIRMWARE_VERSION_2 = TPM2_PT_FIXED + 12,
+       TPM2_PT_INPUT_BUFFER = TPM2_PT_FIXED + 13,
+       TPM2_PT_HR_TRANSIENT_MIN = TPM2_PT_FIXED + 14,
+       TPM2_PT_HR_PERSISTENT_MIN = TPM2_PT_FIXED + 15,
+       TPM2_PT_HR_LOADED_MIN = TPM2_PT_FIXED + 16,
+       TPM2_PT_ACTIVE_SESSIONS_MAX = TPM2_PT_FIXED + 17,
+       TPM2_PT_PCR_COUNT = TPM2_PT_FIXED + 18,
+       TPM2_PT_PCR_SELECT_MIN = TPM2_PT_FIXED + 19,
+       TPM2_PT_CONTEXT_GAP_MAX = TPM2_PT_FIXED + 20,
+       TPM2_PT_NV_COUNTERS_MAX = TPM2_PT_FIXED + 22,
+       TPM2_PT_NV_INDEX_MAX = TPM2_PT_FIXED + 23,
+       TPM2_PT_MEMORY = TPM2_PT_FIXED + 24,
+       TPM2_PT_CLOCK_UPDATE = TPM2_PT_FIXED + 25,
+       TPM2_PT_CONTEXT_HASH = TPM2_PT_FIXED + 26,
+       TPM2_PT_CONTEXT_SYM = TPM2_PT_FIXED + 27,
+       TPM2_PT_CONTEXT_SYM_SIZE = TPM2_PT_FIXED + 28,
+       TPM2_PT_ORDERLY_COUNT = TPM2_PT_FIXED + 29,
+       TPM2_PT_MAX_COMMAND_SIZE = TPM2_PT_FIXED + 30,
+       TPM2_PT_MAX_RESPONSE_SIZE = TPM2_PT_FIXED + 31,
+       TPM2_PT_MAX_DIGEST = TPM2_PT_FIXED + 32,
+       TPM2_PT_MAX_OBJECT_CONTEXT = TPM2_PT_FIXED + 33,
+       TPM2_PT_MAX_SESSION_CONTEXT = TPM2_PT_FIXED + 34,
+       TPM2_PT_PS_FAMILY_INDICATOR = TPM2_PT_FIXED + 35,
+       TPM2_PT_PS_LEVEL = TPM2_PT_FIXED + 36,
+       TPM2_PT_PS_REVISION = TPM2_PT_FIXED + 37,
+       TPM2_PT_PS_DAY_OF_YEAR = TPM2_PT_FIXED + 38,
+       TPM2_PT_PS_YEAR = TPM2_PT_FIXED + 39,
+       TPM2_PT_SPLIT_MAX = TPM2_PT_FIXED + 40,
+       TPM2_PT_TOTAL_COMMANDS = TPM2_PT_FIXED + 41,
+       TPM2_PT_LIBRARY_COMMANDS = TPM2_PT_FIXED + 42,
+       TPM2_PT_VENDOR_COMMANDS = TPM2_PT_FIXED + 43,
+       TPM2_PT_NV_BUFFER_MAX = TPM2_PT_FIXED + 44,
+       TPM2_PT_MODES = TPM2_PT_FIXED + 45,
+       TPM2_PT_MAX_CAP_BUFFER = TPM2_PT_FIXED + 46,
+       TPM2_PT_VAR = TPM2_PT_GROUP * 2,
+       TPM2_PT_PERMANENT = TPM2_PT_VAR + 0,
+       TPM2_PT_STARTUP_CLEAR = TPM2_PT_VAR + 1,
+       TPM2_PT_HR_NV_INDEX = TPM2_PT_VAR + 2,
+       TPM2_PT_HR_LOADED = TPM2_PT_VAR + 3,
+       TPM2_PT_HR_LOADED_AVAIL = TPM2_PT_VAR + 4,
+       TPM2_PT_HR_ACTIVE = TPM2_PT_VAR + 5,
+       TPM2_PT_HR_ACTIVE_AVAIL = TPM2_PT_VAR + 6,
+       TPM2_PT_HR_TRANSIENT_AVAIL = TPM2_PT_VAR + 7,
+       TPM2_PT_HR_PERSISTENT = TPM2_PT_VAR + 8,
+       TPM2_PT_HR_PERSISTENT_AVAIL = TPM2_PT_VAR + 9,
+       TPM2_PT_NV_COUNTERS = TPM2_PT_VAR + 10,
+       TPM2_PT_NV_COUNTERS_AVAIL = TPM2_PT_VAR + 11,
+       TPM2_PT_ALGORITHM_SET = TPM2_PT_VAR + 12,
+       TPM2_PT_LOADED_CURVES = TPM2_PT_VAR + 13,
+       TPM2_PT_LOCKOUT_COUNTER = TPM2_PT_VAR + 14,
+       TPM2_PT_MAX_AUTH_FAIL = TPM2_PT_VAR + 15,
+       TPM2_PT_LOCKOUT_INTERVAL = TPM2_PT_VAR + 16,
+       TPM2_PT_LOCKOUT_RECOVERY = TPM2_PT_VAR + 17,
+       TPM2_PT_NV_WRITE_RECOVERY = TPM2_PT_VAR + 18,
+       TPM2_PT_AUDIT_COUNTER_0 = TPM2_PT_VAR + 19,
+       TPM2_PT_AUDIT_COUNTER_1 = TPM2_PT_VAR + 20,
+};
 
 /* 128 bytes is an arbitrary cap. This could be as large as TPM_BUFSIZE - 18
  * bytes, but 128 is still a relatively large number of random bytes and
index b6c5bf69a2b2c65aa24c2dfcfb6050c1412708d8..8f0fa6fdaa44e5bdd86611a633647835dcc78e8d 100644 (file)
@@ -325,6 +325,15 @@ config COMMON_CLK_LOCHNAGAR
          This driver supports the clocking features of the Cirrus Logic
          Lochnagar audio development board.
 
+config COMMON_CLK_LOONGSON2
+       bool "Clock driver for Loongson-2 SoC"
+       depends on LOONGARCH || COMPILE_TEST
+       help
+          This driver provides support for clock controller on Loongson-2 SoC.
+          The clock controller can generates and supplies clock to various
+          peripherals within the SoC.
+          Say Y here to support Loongson-2 SoC clock driver.
+
 config COMMON_CLK_NXP
        def_bool COMMON_CLK && (ARCH_LPC18XX || ARCH_LPC32XX)
        select REGMAP_MMIO if ARCH_LPC32XX
@@ -367,6 +376,15 @@ config COMMON_CLK_RS9_PCIE
          This driver supports the Renesas 9-series PCIe clock generator
          models 9FGV/9DBV/9DMV/9FGL/9DML/9QXL/9SQ.
 
+config COMMON_CLK_SI521XX
+       tristate "Clock driver for SkyWorks Si521xx PCIe clock generators"
+       depends on I2C
+       depends on OF
+       select REGMAP_I2C
+       help
+         This driver supports the SkyWorks Si521xx PCIe clock generator
+         models Si52144/Si52146/Si52147.
+
 config COMMON_CLK_VC5
        tristate "Clock driver for IDT VersaClock 5,6 devices"
        depends on I2C
@@ -436,6 +454,16 @@ config COMMON_CLK_K210
        help
          Support for the Canaan Kendryte K210 RISC-V SoC clocks.
 
+config COMMON_CLK_SP7021
+       tristate "Clock driver for Sunplus SP7021 SoC"
+       depends on SOC_SP7021 || COMPILE_TEST
+       default SOC_SP7021
+       help
+         This driver supports the Sunplus SP7021 SoC clocks.
+         It implements SP7021 PLLs/gate.
+         Not all features of the PLL are currently supported
+         by the driver.
+
 source "drivers/clk/actions/Kconfig"
 source "drivers/clk/analogbits/Kconfig"
 source "drivers/clk/baikal-t1/Kconfig"
index e3ca0d058a25671f2c391a1a42748358e136256b..0aebef17edc66cfde2403112db0ee99f135bf5eb 100644 (file)
@@ -43,6 +43,8 @@ obj-$(CONFIG_COMMON_CLK_K210)         += clk-k210.o
 obj-$(CONFIG_LMK04832)                 += clk-lmk04832.o
 obj-$(CONFIG_COMMON_CLK_LAN966X)       += clk-lan966x.o
 obj-$(CONFIG_COMMON_CLK_LOCHNAGAR)     += clk-lochnagar.o
+obj-$(CONFIG_MACH_LOONGSON32)          += clk-loongson1.o
+obj-$(CONFIG_COMMON_CLK_LOONGSON2)     += clk-loongson2.o
 obj-$(CONFIG_COMMON_CLK_MAX77686)      += clk-max77686.o
 obj-$(CONFIG_COMMON_CLK_MAX9485)       += clk-max9485.o
 obj-$(CONFIG_ARCH_MILBEAUT_M10V)       += clk-milbeaut.o
@@ -65,6 +67,7 @@ obj-$(CONFIG_COMMON_CLK_SI5351)               += clk-si5351.o
 obj-$(CONFIG_COMMON_CLK_SI514)         += clk-si514.o
 obj-$(CONFIG_COMMON_CLK_SI544)         += clk-si544.o
 obj-$(CONFIG_COMMON_CLK_SI570)         += clk-si570.o
+obj-$(CONFIG_COMMON_CLK_SP7021)                += clk-sp7021.o
 obj-$(CONFIG_COMMON_CLK_STM32F)                += clk-stm32f4.o
 obj-$(CONFIG_COMMON_CLK_STM32H7)       += clk-stm32h7.o
 obj-$(CONFIG_COMMON_CLK_STM32MP157)    += clk-stm32mp1.o
@@ -72,6 +75,7 @@ obj-$(CONFIG_COMMON_CLK_TPS68470)      += clk-tps68470.o
 obj-$(CONFIG_CLK_TWL6040)              += clk-twl6040.o
 obj-$(CONFIG_ARCH_VT8500)              += clk-vt8500.o
 obj-$(CONFIG_COMMON_CLK_RS9_PCIE)      += clk-renesas-pcie.o
+obj-$(CONFIG_COMMON_CLK_SI521XX)       += clk-si521xx.o
 obj-$(CONFIG_COMMON_CLK_VC5)           += clk-versaclock5.o
 obj-$(CONFIG_COMMON_CLK_VC7)           += clk-versaclock7.o
 obj-$(CONFIG_COMMON_CLK_WM831X)                += clk-wm831x.o
@@ -93,7 +97,6 @@ obj-y                                 += imx/
 obj-y                                  += ingenic/
 obj-$(CONFIG_ARCH_K3)                  += keystone/
 obj-$(CONFIG_ARCH_KEYSTONE)            += keystone/
-obj-$(CONFIG_MACH_LOONGSON32)          += loongson1/
 obj-y                                  += mediatek/
 obj-$(CONFIG_ARCH_MESON)               += meson/
 obj-y                                  += microchip/
@@ -117,7 +120,7 @@ obj-$(CONFIG_PLAT_SPEAR)            += spear/
 obj-y                                  += sprd/
 obj-$(CONFIG_ARCH_STI)                 += st/
 obj-$(CONFIG_ARCH_STM32)               += stm32/
-obj-$(CONFIG_SOC_STARFIVE)             += starfive/
+obj-y                                  += starfive/
 obj-$(CONFIG_ARCH_SUNXI)               += sunxi/
 obj-y                                  += sunxi-ng/
 obj-$(CONFIG_ARCH_TEGRA)               += tegra/
index d757003004cbb22e474e58283f037f6b0ba31c41..0882ed01d5c27fd1a693ff5a197584fc5009736e 100644 (file)
@@ -668,7 +668,7 @@ sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock,
 
                ret = sam9x60_frac_pll_compute_mul_frac(&frac->core, FCORE_MIN,
                                                        parent_rate, true);
-               if (ret <= 0) {
+               if (ret < 0) {
                        hw = ERR_PTR(ret);
                        goto free;
                }
index e1fda6ad5cd559a1603fb4551dadf77c293c77ec..2334e6c334cf854774b4a81570885976166d65c8 100644 (file)
@@ -198,10 +198,9 @@ static int i2s_pll_clk_probe(struct platform_device *pdev)
        return of_clk_add_provider(node, of_clk_src_simple_get, clk);
 }
 
-static int i2s_pll_clk_remove(struct platform_device *pdev)
+static void i2s_pll_clk_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-       return 0;
 }
 
 static const struct of_device_id i2s_pll_clk_id[] = {
@@ -216,7 +215,7 @@ static struct platform_driver i2s_pll_clk_driver = {
                .of_match_table = i2s_pll_clk_id,
        },
        .probe = i2s_pll_clk_probe,
-       .remove = i2s_pll_clk_remove,
+       .remove_new = i2s_pll_clk_remove,
 };
 module_platform_driver(i2s_pll_clk_driver);
 
index 90fb0e6ff573602cbc40f91fd1f547c67c81ad60..242bf5d75babd048dea5877438aa80b9be89f411 100644 (file)
@@ -253,14 +253,8 @@ static int axs10x_pll_clk_probe(struct platform_device *pdev)
                return ret;
        }
 
-       return of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get,
-                       &pll_clk->hw);
-}
-
-static int axs10x_pll_clk_remove(struct platform_device *pdev)
-{
-       of_clk_del_provider(pdev->dev.of_node);
-       return 0;
+       return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
+                                          &pll_clk->hw);
 }
 
 static void __init of_axs10x_pll_clk_setup(struct device_node *node)
@@ -332,7 +326,6 @@ static struct platform_driver axs10x_pll_clk_driver = {
                .of_match_table = axs10x_pll_clk_id,
        },
        .probe = axs10x_pll_clk_probe,
-       .remove = axs10x_pll_clk_remove,
 };
 builtin_platform_driver(axs10x_pll_clk_driver);
 
index 77266afb1c79a9a2b2cec3c12d89051c6fb71bde..a972d763eb77d9686c1c1493dc715eb368c5ec16 100644 (file)
@@ -37,6 +37,15 @@ config CLK_BCM_63XX_GATE
          Enable common clock framework support for Broadcom BCM63xx DSL SoCs
          based on the MIPS architecture
 
+config CLK_BCM63268_TIMER
+       bool "Broadcom BCM63268 timer clock and reset support"
+       depends on BMIPS_GENERIC || COMPILE_TEST
+       default BMIPS_GENERIC
+       select RESET_CONTROLLER
+       help
+         Enable timer clock and reset support for Broadcom BCM63268 DSL SoCs
+         based on the MIPS architecture.
+
 config CLK_BCM_KONA
        bool "Broadcom Kona CCU clock support"
        depends on ARCH_BCM_MOBILE || COMPILE_TEST
index edb66b44cb273492d669a3c8af783e5277799955..d0b6f4b1fb089bd38ce4080521823a775b211222 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_CLK_BCM_63XX)     += clk-bcm63xx.o
 obj-$(CONFIG_CLK_BCM_63XX_GATE)        += clk-bcm63xx-gate.o
+obj-$(CONFIG_CLK_BCM63268_TIMER) += clk-bcm63268-timer.o
 obj-$(CONFIG_CLK_BCM_KONA)     += clk-kona.o
 obj-$(CONFIG_CLK_BCM_KONA)     += clk-kona-setup.o
 obj-$(CONFIG_CLK_BCM_KONA)     += clk-bcm281xx.o
index e63a42618ac2cd7e3657ce84770f91b7e5e1b036..e4fbbf3c40fe2b1a3175a089f2f08642340824a3 100644 (file)
@@ -92,15 +92,13 @@ unregister_clk0:
        return ret;
 };
 
-static int clk_dvp_remove(struct platform_device *pdev)
+static void clk_dvp_remove(struct platform_device *pdev)
 {
        struct clk_dvp *dvp = platform_get_drvdata(pdev);
        struct clk_hw_onecell_data *data = dvp->data;
 
        clk_hw_unregister_gate(data->hws[1]);
        clk_hw_unregister_gate(data->hws[0]);
-
-       return 0;
 }
 
 static const struct of_device_id clk_dvp_dt_ids[] = {
@@ -111,7 +109,7 @@ MODULE_DEVICE_TABLE(of, clk_dvp_dt_ids);
 
 static struct platform_driver clk_dvp_driver = {
        .probe  = clk_dvp_probe,
-       .remove = clk_dvp_remove,
+       .remove_new = clk_dvp_remove,
        .driver = {
                .name           = "brcm2711-dvp",
                .of_match_table = clk_dvp_dt_ids,
diff --git a/drivers/clk/bcm/clk-bcm63268-timer.c b/drivers/clk/bcm/clk-bcm63268-timer.c
new file mode 100644 (file)
index 0000000..463710d
--- /dev/null
@@ -0,0 +1,216 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * BCM63268 Timer Clock and Reset Controller Driver
+ *
+ * Copyright (C) 2023 Álvaro Fernández Rojas <noltari@gmail.com>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/container_of.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/reset-controller.h>
+#include <linux/spinlock.h>
+
+#include <dt-bindings/clock/bcm63268-clock.h>
+
+#define BCM63268_TIMER_RESET_SLEEP_MIN_US      10000
+#define BCM63268_TIMER_RESET_SLEEP_MAX_US      20000
+
+struct bcm63268_tclkrst_hw {
+       void __iomem *regs;
+       spinlock_t lock;
+
+       struct reset_controller_dev rcdev;
+       struct clk_hw_onecell_data data;
+};
+
+struct bcm63268_tclk_table_entry {
+       const char * const name;
+       u8 bit;
+};
+
+static const struct bcm63268_tclk_table_entry bcm63268_timer_clocks[] = {
+       {
+               .name = "ephy1",
+               .bit = BCM63268_TCLK_EPHY1,
+       }, {
+               .name = "ephy2",
+               .bit = BCM63268_TCLK_EPHY2,
+       }, {
+               .name = "ephy3",
+               .bit = BCM63268_TCLK_EPHY3,
+       }, {
+               .name = "gphy1",
+               .bit = BCM63268_TCLK_GPHY1,
+       }, {
+               .name = "dsl",
+               .bit = BCM63268_TCLK_DSL,
+       }, {
+               .name = "wakeon_ephy",
+               .bit = BCM63268_TCLK_WAKEON_EPHY,
+       }, {
+               .name = "wakeon_dsl",
+               .bit = BCM63268_TCLK_WAKEON_DSL,
+       }, {
+               .name = "fap1_pll",
+               .bit = BCM63268_TCLK_FAP1,
+       }, {
+               .name = "fap2_pll",
+               .bit = BCM63268_TCLK_FAP2,
+       }, {
+               .name = "uto_50",
+               .bit = BCM63268_TCLK_UTO_50,
+       }, {
+               .name = "uto_extin",
+               .bit = BCM63268_TCLK_UTO_EXTIN,
+       }, {
+               .name = "usb_ref",
+               .bit = BCM63268_TCLK_USB_REF,
+       }, {
+               /* sentinel */
+       }
+};
+
+static inline struct bcm63268_tclkrst_hw *
+to_bcm63268_timer_reset(struct reset_controller_dev *rcdev)
+{
+       return container_of(rcdev, struct bcm63268_tclkrst_hw, rcdev);
+}
+
+static int bcm63268_timer_reset_update(struct reset_controller_dev *rcdev,
+                               unsigned long id, bool assert)
+{
+       struct bcm63268_tclkrst_hw *reset = to_bcm63268_timer_reset(rcdev);
+       unsigned long flags;
+       uint32_t val;
+
+       spin_lock_irqsave(&reset->lock, flags);
+       val = __raw_readl(reset->regs);
+       if (assert)
+               val &= ~BIT(id);
+       else
+               val |= BIT(id);
+       __raw_writel(val, reset->regs);
+       spin_unlock_irqrestore(&reset->lock, flags);
+
+       return 0;
+}
+
+static int bcm63268_timer_reset_assert(struct reset_controller_dev *rcdev,
+                               unsigned long id)
+{
+       return bcm63268_timer_reset_update(rcdev, id, true);
+}
+
+static int bcm63268_timer_reset_deassert(struct reset_controller_dev *rcdev,
+                                 unsigned long id)
+{
+       return bcm63268_timer_reset_update(rcdev, id, false);
+}
+
+static int bcm63268_timer_reset_reset(struct reset_controller_dev *rcdev,
+                              unsigned long id)
+{
+       bcm63268_timer_reset_update(rcdev, id, true);
+       usleep_range(BCM63268_TIMER_RESET_SLEEP_MIN_US,
+                    BCM63268_TIMER_RESET_SLEEP_MAX_US);
+
+       bcm63268_timer_reset_update(rcdev, id, false);
+       /*
+        * Ensure component is taken out reset state by sleeping also after
+        * deasserting the reset. Otherwise, the component may not be ready
+        * for operation.
+        */
+       usleep_range(BCM63268_TIMER_RESET_SLEEP_MIN_US,
+                    BCM63268_TIMER_RESET_SLEEP_MAX_US);
+
+       return 0;
+}
+
+static int bcm63268_timer_reset_status(struct reset_controller_dev *rcdev,
+                               unsigned long id)
+{
+       struct bcm63268_tclkrst_hw *reset = to_bcm63268_timer_reset(rcdev);
+
+       return !(__raw_readl(reset->regs) & BIT(id));
+}
+
+static const struct reset_control_ops bcm63268_timer_reset_ops = {
+       .assert = bcm63268_timer_reset_assert,
+       .deassert = bcm63268_timer_reset_deassert,
+       .reset = bcm63268_timer_reset_reset,
+       .status = bcm63268_timer_reset_status,
+};
+
+static int bcm63268_tclk_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       const struct bcm63268_tclk_table_entry *entry;
+       struct bcm63268_tclkrst_hw *hw;
+       struct clk_hw *clk;
+       u8 maxbit = 0;
+       int i, ret;
+
+       for (entry = bcm63268_timer_clocks; entry->name; entry++)
+               maxbit = max(maxbit, entry->bit);
+       maxbit++;
+
+       hw = devm_kzalloc(&pdev->dev, struct_size(hw, data.hws, maxbit),
+                         GFP_KERNEL);
+       if (!hw)
+               return -ENOMEM;
+
+       platform_set_drvdata(pdev, hw);
+
+       spin_lock_init(&hw->lock);
+
+       hw->data.num = maxbit;
+       for (i = 0; i < maxbit; i++)
+               hw->data.hws[i] = ERR_PTR(-ENODEV);
+
+       hw->regs = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(hw->regs))
+               return PTR_ERR(hw->regs);
+
+       for (entry = bcm63268_timer_clocks; entry->name; entry++) {
+               clk = devm_clk_hw_register_gate(dev, entry->name, NULL, 0,
+                                               hw->regs, entry->bit,
+                                               CLK_GATE_BIG_ENDIAN,
+                                               &hw->lock);
+               if (IS_ERR(clk))
+                       return PTR_ERR(clk);
+
+               hw->data.hws[entry->bit] = clk;
+       }
+
+       ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+                                         &hw->data);
+       if (ret)
+               return ret;
+
+       hw->rcdev.of_node = dev->of_node;
+       hw->rcdev.ops = &bcm63268_timer_reset_ops;
+
+       ret = devm_reset_controller_register(dev, &hw->rcdev);
+       if (ret)
+               dev_err(dev, "Failed to register reset controller\n");
+
+       return 0;
+}
+
+static const struct of_device_id bcm63268_tclk_dt_ids[] = {
+       { .compatible = "brcm,bcm63268-timer-clocks" },
+       { /* sentinel */ }
+};
+
+static struct platform_driver bcm63268_tclk = {
+       .probe = bcm63268_tclk_probe,
+       .driver = {
+               .name = "bcm63268-timer-clock",
+               .of_match_table = bcm63268_tclk_dt_ids,
+       },
+};
+builtin_platform_driver(bcm63268_tclk);
index 89297c57881e224c4e40273d894cfa7e8b2b43ec..0769f98767da6a1c33d7494d0a9b1d7f775f77d1 100644 (file)
@@ -541,7 +541,7 @@ out_err:
        return ret;
 }
 
-static int clk_bcm63xx_remove(struct platform_device *pdev)
+static void clk_bcm63xx_remove(struct platform_device *pdev)
 {
        struct clk_bcm63xx_hw *hw = platform_get_drvdata(pdev);
        int i;
@@ -552,8 +552,6 @@ static int clk_bcm63xx_remove(struct platform_device *pdev)
                if (!IS_ERR(hw->data.hws[i]))
                        clk_hw_unregister_gate(hw->data.hws[i]);
        }
-
-       return 0;
 }
 
 static const struct of_device_id clk_bcm63xx_dt_ids[] = {
@@ -570,7 +568,7 @@ static const struct of_device_id clk_bcm63xx_dt_ids[] = {
 
 static struct platform_driver clk_bcm63xx = {
        .probe = clk_bcm63xx_probe,
-       .remove = clk_bcm63xx_remove,
+       .remove_new = clk_bcm63xx_remove,
        .driver = {
                .name = "bcm63xx-clock",
                .of_match_table = clk_bcm63xx_dt_ids,
index ce2f9347973697eaaa7a672633e987f4f3fc4cfa..eb399a4d141ba24b5656064b3799765666acad7c 100644 (file)
@@ -439,13 +439,11 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int raspberrypi_clk_remove(struct platform_device *pdev)
+static void raspberrypi_clk_remove(struct platform_device *pdev)
 {
        struct raspberrypi_clk *rpi = platform_get_drvdata(pdev);
 
        platform_device_unregister(rpi->cpufreq);
-
-       return 0;
 }
 
 static const struct of_device_id raspberrypi_clk_match[] = {
@@ -460,7 +458,7 @@ static struct platform_driver raspberrypi_clk_driver = {
                .of_match_table = raspberrypi_clk_match,
        },
        .probe          = raspberrypi_clk_probe,
-       .remove         = raspberrypi_clk_remove,
+       .remove_new     = raspberrypi_clk_remove,
 };
 module_platform_driver(raspberrypi_clk_driver);
 
index 9c3305bcb27ae0810a677ac9bb693bd04e53e6c4..a094a2601a373026be9ae4adb57d6ffafa09a522 100644 (file)
 
 #include "clk-aspeed.h"
 
-#define ASPEED_G6_NUM_CLKS             71
+/*
+ * This includes the gates (configured from aspeed_g6_gates), plus the
+ * explicitly-configured clocks (ASPEED_CLK_HPLL and up).
+ */
+#define ASPEED_G6_NUM_CLKS             72
 
 #define ASPEED_G6_SILICON_REV          0x014
 #define CHIP_REVISION_ID                       GENMASK(23, 16)
 #define ASPEED_G6_CLK_SELECTION1       0x300
 #define ASPEED_G6_CLK_SELECTION2       0x304
 #define ASPEED_G6_CLK_SELECTION4       0x310
+#define ASPEED_G6_CLK_SELECTION5       0x314
+#define   I3C_CLK_SELECTION_SHIFT      31
+#define   I3C_CLK_SELECTION            BIT(31)
+#define     I3C_CLK_SELECT_HCLK                (0 << I3C_CLK_SELECTION_SHIFT)
+#define     I3C_CLK_SELECT_APLL_DIV    (1 << I3C_CLK_SELECTION_SHIFT)
+#define   APLL_DIV_SELECTION_SHIFT     28
+#define   APLL_DIV_SELECTION           GENMASK(30, 28)
+#define     APLL_DIV_2                 (0b001 << APLL_DIV_SELECTION_SHIFT)
+#define     APLL_DIV_3                 (0b010 << APLL_DIV_SELECTION_SHIFT)
+#define     APLL_DIV_4                 (0b011 << APLL_DIV_SELECTION_SHIFT)
+#define     APLL_DIV_5                 (0b100 << APLL_DIV_SELECTION_SHIFT)
+#define     APLL_DIV_6                 (0b101 << APLL_DIV_SELECTION_SHIFT)
+#define     APLL_DIV_7                 (0b110 << APLL_DIV_SELECTION_SHIFT)
+#define     APLL_DIV_8                 (0b111 << APLL_DIV_SELECTION_SHIFT)
 
 #define ASPEED_HPLL_PARAM              0x200
 #define ASPEED_APLL_PARAM              0x210
@@ -55,6 +73,27 @@ static void __iomem *scu_g6_base;
 static u8 soc_rev;
 
 /*
+ * The majority of the clocks in the system are gates paired with a reset
+ * controller that holds the IP in reset; this is represented by the @reset_idx
+ * member of entries here.
+ *
+ * This borrows from clk_hw_register_gate, but registers two 'gates', one
+ * to control the clock enable register and the other to control the reset
+ * IP. This allows us to enforce the ordering:
+ *
+ * 1. Place IP in reset
+ * 2. Enable clock
+ * 3. Delay
+ * 4. Release reset
+ *
+ * Consequently, if reset_idx is set, reset control is implicit: the clock
+ * consumer does not need its own reset handling, as enabling the clock will
+ * also deassert reset.
+ *
+ * There are some gates that do not have an associated reset; these are
+ * handled by using -1 as the index for the reset, and the consumer must
+ * explictly assert/deassert reset lines as required.
+ *
  * Clocks marked with CLK_IS_CRITICAL:
  *
  *  ref0 and ref1 are essential for the SoC to operate
@@ -97,14 +136,13 @@ static const struct aspeed_gate_data aspeed_g6_gates[] = {
        [ASPEED_CLK_GATE_LHCCLK]        = { 37, -1, "lhclk-gate",       "lhclk", 0 },   /* LPC master/LPC+ */
        /* Reserved 38 RSA: no longer used */
        /* Reserved 39 */
-       [ASPEED_CLK_GATE_I3C0CLK]       = { 40,  40, "i3c0clk-gate",    NULL,    0 },   /* I3C0 */
-       [ASPEED_CLK_GATE_I3C1CLK]       = { 41,  41, "i3c1clk-gate",    NULL,    0 },   /* I3C1 */
-       [ASPEED_CLK_GATE_I3C2CLK]       = { 42,  42, "i3c2clk-gate",    NULL,    0 },   /* I3C2 */
-       [ASPEED_CLK_GATE_I3C3CLK]       = { 43,  43, "i3c3clk-gate",    NULL,    0 },   /* I3C3 */
-       [ASPEED_CLK_GATE_I3C4CLK]       = { 44,  44, "i3c4clk-gate",    NULL,    0 },   /* I3C4 */
-       [ASPEED_CLK_GATE_I3C5CLK]       = { 45,  45, "i3c5clk-gate",    NULL,    0 },   /* I3C5 */
-       [ASPEED_CLK_GATE_I3C6CLK]       = { 46,  46, "i3c6clk-gate",    NULL,    0 },   /* I3C6 */
-       [ASPEED_CLK_GATE_I3C7CLK]       = { 47,  47, "i3c7clk-gate",    NULL,    0 },   /* I3C7 */
+       [ASPEED_CLK_GATE_I3C0CLK]       = { 40,  40, "i3c0clk-gate",    "i3cclk", 0 }, /* I3C0 */
+       [ASPEED_CLK_GATE_I3C1CLK]       = { 41,  41, "i3c1clk-gate",    "i3cclk", 0 }, /* I3C1 */
+       [ASPEED_CLK_GATE_I3C2CLK]       = { 42,  42, "i3c2clk-gate",    "i3cclk", 0 }, /* I3C2 */
+       [ASPEED_CLK_GATE_I3C3CLK]       = { 43,  43, "i3c3clk-gate",    "i3cclk", 0 }, /* I3C3 */
+       [ASPEED_CLK_GATE_I3C4CLK]       = { 44,  44, "i3c4clk-gate",    "i3cclk", 0 }, /* I3C4 */
+       [ASPEED_CLK_GATE_I3C5CLK]       = { 45,  45, "i3c5clk-gate",    "i3cclk", 0 }, /* I3C5 */
+       /* Reserved: 46 & 47 */
        [ASPEED_CLK_GATE_UART1CLK]      = { 48,  -1, "uart1clk-gate",   "uart",  0 },   /* UART1 */
        [ASPEED_CLK_GATE_UART2CLK]      = { 49,  -1, "uart2clk-gate",   "uart",  0 },   /* UART2 */
        [ASPEED_CLK_GATE_UART3CLK]      = { 50,  -1, "uart3clk-gate",   "uart",  0 },   /* UART3 */
@@ -652,6 +690,9 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)
                const struct aspeed_gate_data *gd = &aspeed_g6_gates[i];
                u32 gate_flags;
 
+               if (!gd->name)
+                       continue;
+
                /*
                 * Special case: the USB port 1 clock (bit 14) is always
                 * working the opposite way from the other ones.
@@ -772,6 +813,14 @@ static void __init aspeed_g6_cc(struct regmap *map)
        /* USB 2.0 port1 phy 40MHz clock */
        hw = clk_hw_register_fixed_rate(NULL, "usb-phy-40m", NULL, 0, 40000000);
        aspeed_g6_clk_data->hws[ASPEED_CLK_USBPHY_40M] = hw;
+
+       /* i3c clock: source from apll, divide by 8 */
+       regmap_update_bits(map, ASPEED_G6_CLK_SELECTION5,
+                          I3C_CLK_SELECTION | APLL_DIV_SELECTION,
+                          I3C_CLK_SELECT_APLL_DIV | APLL_DIV_8);
+
+       hw = clk_hw_register_fixed_factor(NULL, "i3cclk", "apll", 0, 1, 8);
+       aspeed_g6_clk_data->hws[ASPEED_CLK_I3C] = hw;
 };
 
 static void __init aspeed_g6_cc_init(struct device_node *np)
index ac6ff736ac8f6cd598d33554d4c1c3943bdbd2d5..a04a3d38c76eac478cdede0173767512e07d7461 100644 (file)
@@ -553,15 +553,8 @@ static int axi_clkgen_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       return of_clk_add_hw_provider(pdev->dev.of_node, of_clk_hw_simple_get,
-                                     &axi_clkgen->clk_hw);
-}
-
-static int axi_clkgen_remove(struct platform_device *pdev)
-{
-       of_clk_del_provider(pdev->dev.of_node);
-
-       return 0;
+       return devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_simple_get,
+                                          &axi_clkgen->clk_hw);
 }
 
 static const struct of_device_id axi_clkgen_ids[] = {
@@ -583,7 +576,6 @@ static struct platform_driver axi_clkgen_driver = {
                .of_match_table = axi_clkgen_ids,
        },
        .probe = axi_clkgen_probe,
-       .remove = axi_clkgen_remove,
 };
 module_platform_driver(axi_clkgen_driver);
 
index 07e80fe8c310c9e75b18515e50240e06ff51867f..1afcfdf2e6f99cd5dbf8fade10011f8606df66c5 100644 (file)
@@ -569,18 +569,11 @@ static int axmclk_probe(struct platform_device *pdev)
                        return ret;
        }
 
-       return of_clk_add_hw_provider(dev->of_node, of_clk_axmclk_get, NULL);
-}
-
-static int axmclk_remove(struct platform_device *pdev)
-{
-       of_clk_del_provider(pdev->dev.of_node);
-       return 0;
+       return devm_of_clk_add_hw_provider(dev, of_clk_axmclk_get, NULL);
 }
 
 static struct platform_driver axmclk_driver = {
        .probe          = axmclk_probe,
-       .remove         = axmclk_remove,
        .driver         = {
                .name   = "clk-axm5516",
                .of_match_table = axmclk_match_table,
index 1449d0537674eba490687ceb497b9d81c7bf28e0..d8bee8180a6b37946f47aea6fdae986779b8a62c 100644 (file)
@@ -661,16 +661,10 @@ static int cdce706_probe(struct i2c_client *client)
        ret = cdce706_register_clkouts(cdce);
        if (ret < 0)
                return ret;
-       return of_clk_add_hw_provider(client->dev.of_node, of_clk_cdce_get,
-                                     cdce);
+       return devm_of_clk_add_hw_provider(&client->dev, of_clk_cdce_get,
+                                          cdce);
 }
 
-static void cdce706_remove(struct i2c_client *client)
-{
-       of_clk_del_provider(client->dev.of_node);
-}
-
-
 #ifdef CONFIG_OF
 static const struct of_device_id cdce706_dt_match[] = {
        { .compatible = "ti,cdce706" },
@@ -691,7 +685,6 @@ static struct i2c_driver cdce706_i2c_driver = {
                .of_match_table = of_match_ptr(cdce706_dt_match),
        },
        .probe_new      = cdce706_probe,
-       .remove         = cdce706_remove,
        .id_table       = cdce706_id,
 };
 module_i2c_driver(cdce706_i2c_driver);
index 2ef819606c4170caed8fd8d059ad97e3719599bd..1a4e6340f95ce4c276bc7df61c7c2590e0ad1d99 100644 (file)
@@ -33,9 +33,12 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)
                        else
                                return rc;
                }
-               if (clkspec.np == node && !clk_supplier)
+               if (clkspec.np == node && !clk_supplier) {
+                       of_node_put(clkspec.np);
                        return 0;
+               }
                pclk = of_clk_get_from_provider(&clkspec);
+               of_node_put(clkspec.np);
                if (IS_ERR(pclk)) {
                        if (PTR_ERR(pclk) != -EPROBE_DEFER)
                                pr_warn("clk: couldn't get parent clock %d for %pOF\n",
@@ -48,10 +51,12 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)
                if (rc < 0)
                        goto err;
                if (clkspec.np == node && !clk_supplier) {
+                       of_node_put(clkspec.np);
                        rc = 0;
                        goto err;
                }
                clk = of_clk_get_from_provider(&clkspec);
+               of_node_put(clkspec.np);
                if (IS_ERR(clk)) {
                        if (PTR_ERR(clk) != -EPROBE_DEFER)
                                pr_warn("clk: couldn't get assigned clock %d for %pOF\n",
@@ -93,10 +98,13 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)
                                else
                                        return rc;
                        }
-                       if (clkspec.np == node && !clk_supplier)
+                       if (clkspec.np == node && !clk_supplier) {
+                               of_node_put(clkspec.np);
                                return 0;
+                       }
 
                        clk = of_clk_get_from_provider(&clkspec);
+                       of_node_put(clkspec.np);
                        if (IS_ERR(clk)) {
                                if (PTR_ERR(clk) != -EPROBE_DEFER)
                                        pr_warn("clk: couldn't get clock %d for %pOF\n",
index f734e34735a99b188cd6b3bf79a63e938cb24467..b3e66202b942422293711ded295e2124ecf00c27 100644 (file)
@@ -297,14 +297,12 @@ void __init of_fixed_factor_clk_setup(struct device_node *node)
 CLK_OF_DECLARE(fixed_factor_clk, "fixed-factor-clock",
                of_fixed_factor_clk_setup);
 
-static int of_fixed_factor_clk_remove(struct platform_device *pdev)
+static void of_fixed_factor_clk_remove(struct platform_device *pdev)
 {
        struct clk_hw *clk = platform_get_drvdata(pdev);
 
        of_clk_del_provider(pdev->dev.of_node);
        clk_hw_unregister_fixed_factor(clk);
-
-       return 0;
 }
 
 static int of_fixed_factor_clk_probe(struct platform_device *pdev)
@@ -336,7 +334,7 @@ static struct platform_driver of_fixed_factor_clk_driver = {
                .of_match_table = of_fixed_factor_clk_ids,
        },
        .probe = of_fixed_factor_clk_probe,
-       .remove = of_fixed_factor_clk_remove,
+       .remove_new = of_fixed_factor_clk_remove,
 };
 builtin_platform_driver(of_fixed_factor_clk_driver);
 #endif
index 5225d17d6b3f39210dc19de7ffb861f4544e124a..7435055670d202ff11e438db52aacc1a986c465f 100644 (file)
@@ -71,14 +71,12 @@ static int of_fixed_mmio_clk_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int of_fixed_mmio_clk_remove(struct platform_device *pdev)
+static void of_fixed_mmio_clk_remove(struct platform_device *pdev)
 {
        struct clk_hw *clk = platform_get_drvdata(pdev);
 
        of_clk_del_provider(pdev->dev.of_node);
        clk_hw_unregister_fixed_rate(clk);
-
-       return 0;
 }
 
 static const struct of_device_id of_fixed_mmio_clk_ids[] = {
@@ -93,7 +91,7 @@ static struct platform_driver of_fixed_mmio_clk_driver = {
                .of_match_table = of_fixed_mmio_clk_ids,
        },
        .probe = of_fixed_mmio_clk_probe,
-       .remove = of_fixed_mmio_clk_remove,
+       .remove_new = of_fixed_mmio_clk_remove,
 };
 module_platform_driver(of_fixed_mmio_clk_driver);
 
index 7d775954e26da0e53c66c27376eb978cb8710a85..3481eb8cdeb3b994d22f1e73ea8985684c5dcb91 100644 (file)
@@ -196,14 +196,12 @@ void __init of_fixed_clk_setup(struct device_node *node)
 }
 CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup);
 
-static int of_fixed_clk_remove(struct platform_device *pdev)
+static void of_fixed_clk_remove(struct platform_device *pdev)
 {
        struct clk_hw *hw = platform_get_drvdata(pdev);
 
        of_clk_del_provider(pdev->dev.of_node);
        clk_hw_unregister_fixed_rate(hw);
-
-       return 0;
 }
 
 static int of_fixed_clk_probe(struct platform_device *pdev)
@@ -234,7 +232,7 @@ static struct platform_driver of_fixed_clk_driver = {
                .of_match_table = of_fixed_clk_ids,
        },
        .probe = of_fixed_clk_probe,
-       .remove = of_fixed_clk_remove,
+       .remove_new = of_fixed_clk_remove,
 };
 builtin_platform_driver(of_fixed_clk_driver);
 #endif
index 6affe3565025832d9a492ad3bcfa681fd8c391e3..479297763e7042d6ec00eeef41a6a29ffc6a8f3a 100644 (file)
@@ -71,6 +71,7 @@ static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract)
        struct clk_fractional_divider *fd = to_clk_fd(hw);
        unsigned long flags = 0;
        unsigned long m, n;
+       u32 mmask, nmask;
        u32 val;
 
        if (fd->lock)
@@ -85,8 +86,11 @@ static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract)
        else
                __release(fd->lock);
 
-       m = (val & fd->mmask) >> fd->mshift;
-       n = (val & fd->nmask) >> fd->nshift;
+       mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift;
+       nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift;
+
+       m = (val & mmask) >> fd->mshift;
+       n = (val & nmask) >> fd->nshift;
 
        if (fd->flags & CLK_FRAC_DIVIDER_ZERO_BASED) {
                m++;
@@ -166,6 +170,7 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
        struct clk_fractional_divider *fd = to_clk_fd(hw);
        unsigned long flags = 0;
        unsigned long m, n;
+       u32 mmask, nmask;
        u32 val;
 
        rational_best_approximation(rate, parent_rate,
@@ -182,8 +187,11 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
        else
                __acquire(fd->lock);
 
+       mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift;
+       nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift;
+
        val = clk_fd_readl(fd);
-       val &= ~(fd->mmask | fd->nmask);
+       val &= ~(mmask | nmask);
        val |= (m << fd->mshift) | (n << fd->nshift);
        clk_fd_writel(fd, val);
 
@@ -260,10 +268,8 @@ struct clk_hw *clk_hw_register_fractional_divider(struct device *dev,
        fd->reg = reg;
        fd->mshift = mshift;
        fd->mwidth = mwidth;
-       fd->mmask = GENMASK(mwidth - 1, 0) << mshift;
        fd->nshift = nshift;
        fd->nwidth = nwidth;
-       fd->nmask = GENMASK(nwidth - 1, 0) << nshift;
        fd->flags = clk_divider_flags;
        fd->lock = lock;
        fd->hw.init = &init;
index 60007b508590414eaa50f95b9bf96ac9c0a3f0c3..33b48ea5ea3d6b15ddf5d381e430e41a50406bd8 100644 (file)
@@ -346,14 +346,8 @@ static int hsdk_pll_clk_probe(struct platform_device *pdev)
                return ret;
        }
 
-       return of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get,
-                       &pll_clk->hw);
-}
-
-static int hsdk_pll_clk_remove(struct platform_device *pdev)
-{
-       of_clk_del_provider(pdev->dev.of_node);
-       return 0;
+       return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
+                                          &pll_clk->hw);
 }
 
 static void __init of_hsdk_pll_clk_setup(struct device_node *node)
@@ -432,6 +426,5 @@ static struct platform_driver hsdk_pll_clk_driver = {
                .of_match_table = hsdk_pll_clk_id,
        },
        .probe = hsdk_pll_clk_probe,
-       .remove = hsdk_pll_clk_remove,
 };
 builtin_platform_driver(hsdk_pll_clk_driver);
index 57485356de4ca6f5efc3c986c1773496df587976..afdfee3b365f35f7d7766a879460a91b1a3c592d 100644 (file)
@@ -1522,8 +1522,8 @@ static int lmk04832_probe(struct spi_device *spi)
        }
 
        lmk->clk_data->num = info->num_channels;
-       ret = of_clk_add_hw_provider(lmk->dev->of_node, of_clk_hw_onecell_get,
-                                    lmk->clk_data);
+       ret = devm_of_clk_add_hw_provider(lmk->dev, of_clk_hw_onecell_get,
+                                         lmk->clk_data);
        if (ret) {
                dev_err(lmk->dev, "failed to add provider (%d)\n", ret);
                goto err_disable_vco;
@@ -1547,7 +1547,6 @@ static void lmk04832_remove(struct spi_device *spi)
        struct lmk04832 *lmk = spi_get_drvdata(spi);
 
        clk_disable_unprepare(lmk->oscin);
-       of_clk_del_provider(spi->dev.of_node);
 }
 
 static const struct spi_device_id lmk04832_id[] = {
diff --git a/drivers/clk/clk-loongson1.c b/drivers/clk/clk-loongson1.c
new file mode 100644 (file)
index 0000000..a3467aa
--- /dev/null
@@ -0,0 +1,303 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Clock driver for Loongson-1 SoC
+ *
+ * Copyright (C) 2012-2023 Keguang Zhang <keguang.zhang@gmail.com>
+ */
+
+#include <linux/bits.h>
+#include <linux/clk-provider.h>
+#include <linux/container_of.h>
+#include <linux/io.h>
+#include <linux/of_address.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/printk.h>
+
+#include <dt-bindings/clock/loongson,ls1x-clk.h>
+
+/* Loongson 1 Clock Register Definitions */
+#define CLK_PLL_FREQ           0x0
+#define CLK_PLL_DIV            0x4
+
+static DEFINE_SPINLOCK(ls1x_clk_div_lock);
+
+struct ls1x_clk_pll_data {
+       u32 fixed;
+       u8 shift;
+       u8 int_shift;
+       u8 int_width;
+       u8 frac_shift;
+       u8 frac_width;
+};
+
+struct ls1x_clk_div_data {
+       u8 shift;
+       u8 width;
+       unsigned long flags;
+       const struct clk_div_table *table;
+       u8 bypass_shift;
+       u8 bypass_inv;
+       spinlock_t *lock;       /* protect access to DIV registers */
+};
+
+struct ls1x_clk {
+       void __iomem *reg;
+       unsigned int offset;
+       struct clk_hw hw;
+       const void *data;
+};
+
+#define to_ls1x_clk(_hw) container_of(_hw, struct ls1x_clk, hw)
+
+static inline unsigned long ls1x_pll_rate_part(unsigned int val,
+                                              unsigned int shift,
+                                              unsigned int width)
+{
+       return (val & GENMASK(shift + width, shift)) >> shift;
+}
+
+static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       struct ls1x_clk *ls1x_clk = to_ls1x_clk(hw);
+       const struct ls1x_clk_pll_data *d = ls1x_clk->data;
+       u32 val, rate;
+
+       val = readl(ls1x_clk->reg);
+       rate = d->fixed;
+       rate += ls1x_pll_rate_part(val, d->int_shift, d->int_width);
+       if (d->frac_width)
+               rate += ls1x_pll_rate_part(val, d->frac_shift, d->frac_width);
+       rate *= parent_rate;
+       rate >>= d->shift;
+
+       return rate;
+}
+
+static const struct clk_ops ls1x_pll_clk_ops = {
+       .recalc_rate = ls1x_pll_recalc_rate,
+};
+
+static unsigned long ls1x_divider_recalc_rate(struct clk_hw *hw,
+                                             unsigned long parent_rate)
+{
+       struct ls1x_clk *ls1x_clk = to_ls1x_clk(hw);
+       const struct ls1x_clk_div_data *d = ls1x_clk->data;
+       unsigned int val;
+
+       val = readl(ls1x_clk->reg) >> d->shift;
+       val &= clk_div_mask(d->width);
+
+       return divider_recalc_rate(hw, parent_rate, val, d->table,
+                                  d->flags, d->width);
+}
+
+static long ls1x_divider_round_rate(struct clk_hw *hw, unsigned long rate,
+                                   unsigned long *prate)
+{
+       struct ls1x_clk *ls1x_clk = to_ls1x_clk(hw);
+       const struct ls1x_clk_div_data *d = ls1x_clk->data;
+
+       return divider_round_rate(hw, rate, prate, d->table,
+                                 d->width, d->flags);
+}
+
+static int ls1x_divider_set_rate(struct clk_hw *hw, unsigned long rate,
+                                unsigned long parent_rate)
+{
+       struct ls1x_clk *ls1x_clk = to_ls1x_clk(hw);
+       const struct ls1x_clk_div_data *d = ls1x_clk->data;
+       int val, div_val;
+       unsigned long flags = 0;
+
+       div_val = divider_get_val(rate, parent_rate, d->table,
+                                 d->width, d->flags);
+       if (div_val < 0)
+               return div_val;
+
+       spin_lock_irqsave(d->lock, flags);
+
+       /* Bypass the clock */
+       val = readl(ls1x_clk->reg);
+       if (d->bypass_inv)
+               val &= ~BIT(d->bypass_shift);
+       else
+               val |= BIT(d->bypass_shift);
+       writel(val, ls1x_clk->reg);
+
+       val = readl(ls1x_clk->reg);
+       val &= ~(clk_div_mask(d->width) << d->shift);
+       val |= (u32)div_val << d->shift;
+       writel(val, ls1x_clk->reg);
+
+       /* Restore the clock */
+       val = readl(ls1x_clk->reg);
+       if (d->bypass_inv)
+               val |= BIT(d->bypass_shift);
+       else
+               val &= ~BIT(d->bypass_shift);
+       writel(val, ls1x_clk->reg);
+
+       spin_unlock_irqrestore(d->lock, flags);
+
+       return 0;
+}
+
+static const struct clk_ops ls1x_clk_divider_ops = {
+       .recalc_rate = ls1x_divider_recalc_rate,
+       .round_rate = ls1x_divider_round_rate,
+       .set_rate = ls1x_divider_set_rate,
+};
+
+#define LS1X_CLK_PLL(_name, _offset, _fixed, _shift,                   \
+                    f_shift, f_width, i_shift, i_width)                \
+struct ls1x_clk _name = {                                              \
+       .offset = (_offset),                                            \
+       .data = &(const struct ls1x_clk_pll_data) {                     \
+               .fixed = (_fixed),                                      \
+               .shift = (_shift),                                      \
+               .int_shift = (i_shift),                                 \
+               .int_width = (i_width),                                 \
+               .frac_shift = (f_shift),                                \
+               .frac_width = (f_width),                                \
+       },                                                              \
+       .hw.init = &(const struct clk_init_data) {                      \
+               .name = #_name,                                         \
+               .ops = &ls1x_pll_clk_ops,                               \
+               .parent_data = &(const struct clk_parent_data) {        \
+                       .fw_name = "xtal",                              \
+                       .name = "xtal",                                 \
+                       .index = -1,                                    \
+               },                                                      \
+               .num_parents = 1,                                       \
+       },                                                              \
+}
+
+#define LS1X_CLK_DIV(_name, _pname, _offset, _shift, _width,           \
+                    _table, _bypass_shift, _bypass_inv, _flags)        \
+struct ls1x_clk _name = {                                              \
+       .offset = (_offset),                                            \
+       .data = &(const struct ls1x_clk_div_data){                      \
+               .shift = (_shift),                                      \
+               .width = (_width),                                      \
+               .table = (_table),                                      \
+               .flags = (_flags),                                      \
+               .bypass_shift = (_bypass_shift),                        \
+               .bypass_inv = (_bypass_inv),                            \
+               .lock = &ls1x_clk_div_lock,                             \
+       },                                                              \
+       .hw.init = &(const struct clk_init_data) {                      \
+               .name = #_name,                                         \
+               .ops = &ls1x_clk_divider_ops,                           \
+               .parent_hws = (const struct clk_hw *[]) { _pname },     \
+               .num_parents = 1,                                       \
+               .flags = CLK_GET_RATE_NOCACHE,                          \
+       },                                                              \
+}
+
+static LS1X_CLK_PLL(ls1b_clk_pll, CLK_PLL_FREQ, 12, 1, 0, 5, 0, 0);
+static LS1X_CLK_DIV(ls1b_clk_cpu, &ls1b_clk_pll.hw, CLK_PLL_DIV,
+                   20, 4, NULL, 8, 0,
+                   CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ROUND_CLOSEST);
+static LS1X_CLK_DIV(ls1b_clk_dc, &ls1b_clk_pll.hw, CLK_PLL_DIV,
+                   26, 4, NULL, 12, 0, CLK_DIVIDER_ONE_BASED);
+static LS1X_CLK_DIV(ls1b_clk_ahb, &ls1b_clk_pll.hw, CLK_PLL_DIV,
+                   14, 4, NULL, 10, 0, CLK_DIVIDER_ONE_BASED);
+static CLK_FIXED_FACTOR(ls1b_clk_apb, "ls1b_clk_apb", "ls1b_clk_ahb", 2, 1,
+                       CLK_SET_RATE_PARENT);
+
+static struct clk_hw_onecell_data ls1b_clk_hw_data = {
+       .hws = {
+               [LS1X_CLKID_PLL] = &ls1b_clk_pll.hw,
+               [LS1X_CLKID_CPU] = &ls1b_clk_cpu.hw,
+               [LS1X_CLKID_DC] = &ls1b_clk_dc.hw,
+               [LS1X_CLKID_AHB] = &ls1b_clk_ahb.hw,
+               [LS1X_CLKID_APB] = &ls1b_clk_apb.hw,
+       },
+       .num = CLK_NR_CLKS,
+};
+
+static const struct clk_div_table ls1c_ahb_div_table[] = {
+       [0] = { .val = 0, .div = 2 },
+       [1] = { .val = 1, .div = 4 },
+       [2] = { .val = 2, .div = 3 },
+       [3] = { .val = 3, .div = 3 },
+       [4] = { /* sentinel */ }
+};
+
+static LS1X_CLK_PLL(ls1c_clk_pll, CLK_PLL_FREQ, 0, 2, 8, 8, 16, 8);
+static LS1X_CLK_DIV(ls1c_clk_cpu, &ls1c_clk_pll.hw, CLK_PLL_DIV,
+                   8, 7, NULL, 0, 1,
+                   CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ROUND_CLOSEST);
+static LS1X_CLK_DIV(ls1c_clk_dc, &ls1c_clk_pll.hw, CLK_PLL_DIV,
+                   24, 7, NULL, 4, 1, CLK_DIVIDER_ONE_BASED);
+static LS1X_CLK_DIV(ls1c_clk_ahb, &ls1c_clk_cpu.hw, CLK_PLL_FREQ,
+                   0, 2, ls1c_ahb_div_table, 0, 0, CLK_DIVIDER_ALLOW_ZERO);
+static CLK_FIXED_FACTOR(ls1c_clk_apb, "ls1c_clk_apb", "ls1c_clk_ahb", 1, 1,
+                       CLK_SET_RATE_PARENT);
+
+static struct clk_hw_onecell_data ls1c_clk_hw_data = {
+       .hws = {
+               [LS1X_CLKID_PLL] = &ls1c_clk_pll.hw,
+               [LS1X_CLKID_CPU] = &ls1c_clk_cpu.hw,
+               [LS1X_CLKID_DC] = &ls1c_clk_dc.hw,
+               [LS1X_CLKID_AHB] = &ls1c_clk_ahb.hw,
+               [LS1X_CLKID_APB] = &ls1c_clk_apb.hw,
+       },
+       .num = CLK_NR_CLKS,
+};
+
+static void __init ls1x_clk_init(struct device_node *np,
+                                struct clk_hw_onecell_data *hw_data)
+{
+       struct ls1x_clk *ls1x_clk;
+       void __iomem *reg;
+       int i, ret;
+
+       reg = of_iomap(np, 0);
+       if (!reg) {
+               pr_err("Unable to map base for %pOF\n", np);
+               return;
+       }
+
+       for (i = 0; i < hw_data->num; i++) {
+               /* array might be sparse */
+               if (!hw_data->hws[i])
+                       continue;
+
+               if (i != LS1X_CLKID_APB) {
+                       ls1x_clk = to_ls1x_clk(hw_data->hws[i]);
+                       ls1x_clk->reg = reg + ls1x_clk->offset;
+               }
+
+               ret = of_clk_hw_register(np, hw_data->hws[i]);
+               if (ret)
+                       goto err;
+       }
+
+       ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, hw_data);
+       if (!ret)
+               return;
+
+err:
+       pr_err("Failed to register %pOF\n", np);
+
+       while (--i >= 0)
+               clk_hw_unregister(hw_data->hws[i]);
+
+       iounmap(reg);
+}
+
+static void __init ls1b_clk_init(struct device_node *np)
+{
+       return ls1x_clk_init(np, &ls1b_clk_hw_data);
+}
+
+static void __init ls1c_clk_init(struct device_node *np)
+{
+       return ls1x_clk_init(np, &ls1c_clk_hw_data);
+}
+
+CLK_OF_DECLARE(ls1b_clk, "loongson,ls1b-clk", ls1b_clk_init);
+CLK_OF_DECLARE(ls1c_clk, "loongson,ls1c-clk", ls1c_clk_init);
diff --git a/drivers/clk/clk-loongson2.c b/drivers/clk/clk-loongson2.c
new file mode 100644 (file)
index 0000000..70ae1dd
--- /dev/null
@@ -0,0 +1,341 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Author: Yinbo Zhu <zhuyinbo@loongson.cn>
+ * Copyright (C) 2022-2023 Loongson Technology Corporation Limited
+ */
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/clk-provider.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/io-64-nonatomic-lo-hi.h>
+#include <dt-bindings/clock/loongson,ls2k-clk.h>
+
+#define LOONGSON2_PLL_MULT_SHIFT               32
+#define LOONGSON2_PLL_MULT_WIDTH               10
+#define LOONGSON2_PLL_DIV_SHIFT                        26
+#define LOONGSON2_PLL_DIV_WIDTH                        6
+#define LOONGSON2_APB_FREQSCALE_SHIFT          20
+#define LOONGSON2_APB_FREQSCALE_WIDTH          3
+#define LOONGSON2_USB_FREQSCALE_SHIFT          16
+#define LOONGSON2_USB_FREQSCALE_WIDTH          3
+#define LOONGSON2_SATA_FREQSCALE_SHIFT         12
+#define LOONGSON2_SATA_FREQSCALE_WIDTH         3
+#define LOONGSON2_BOOT_FREQSCALE_SHIFT         8
+#define LOONGSON2_BOOT_FREQSCALE_WIDTH         3
+
+static void __iomem *loongson2_pll_base;
+
+static const struct clk_parent_data pdata[] = {
+       { .fw_name = "ref_100m",},
+};
+
+static struct clk_hw *loongson2_clk_register(struct device *dev,
+                                         const char *name,
+                                         const char *parent_name,
+                                         const struct clk_ops *ops,
+                                         unsigned long flags)
+{
+       int ret;
+       struct clk_hw *hw;
+       struct clk_init_data init;
+
+       hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL);
+       if (!hw)
+               return ERR_PTR(-ENOMEM);
+
+       init.name = name;
+       init.ops = ops;
+       init.flags = flags;
+       init.num_parents = 1;
+
+       if (!parent_name)
+               init.parent_data = pdata;
+       else
+               init.parent_names = &parent_name;
+
+       hw->init = &init;
+
+       ret = devm_clk_hw_register(dev, hw);
+       if (ret)
+               hw = ERR_PTR(ret);
+
+       return hw;
+}
+
+static unsigned long loongson2_calc_pll_rate(int offset, unsigned long rate)
+{
+       u64 val;
+       u32 mult, div;
+
+       val = readq(loongson2_pll_base + offset);
+
+       mult = (val >> LOONGSON2_PLL_MULT_SHIFT) &
+                       clk_div_mask(LOONGSON2_PLL_MULT_WIDTH);
+       div = (val >> LOONGSON2_PLL_DIV_SHIFT) &
+                       clk_div_mask(LOONGSON2_PLL_DIV_WIDTH);
+
+       return div_u64((u64)rate * mult, div);
+}
+
+static unsigned long loongson2_node_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       return loongson2_calc_pll_rate(0x0, parent_rate);
+}
+
+static const struct clk_ops loongson2_node_clk_ops = {
+       .recalc_rate = loongson2_node_recalc_rate,
+};
+
+static unsigned long loongson2_ddr_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       return loongson2_calc_pll_rate(0x10, parent_rate);
+}
+
+static const struct clk_ops loongson2_ddr_clk_ops = {
+       .recalc_rate = loongson2_ddr_recalc_rate,
+};
+
+static unsigned long loongson2_dc_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       return loongson2_calc_pll_rate(0x20, parent_rate);
+}
+
+static const struct clk_ops loongson2_dc_clk_ops = {
+       .recalc_rate = loongson2_dc_recalc_rate,
+};
+
+static unsigned long loongson2_pix0_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       return loongson2_calc_pll_rate(0x30, parent_rate);
+}
+
+static const struct clk_ops loongson2_pix0_clk_ops = {
+       .recalc_rate = loongson2_pix0_recalc_rate,
+};
+
+static unsigned long loongson2_pix1_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       return loongson2_calc_pll_rate(0x40, parent_rate);
+}
+
+static const struct clk_ops loongson2_pix1_clk_ops = {
+       .recalc_rate = loongson2_pix1_recalc_rate,
+};
+
+static unsigned long loongson2_calc_rate(unsigned long rate,
+                                        int shift, int width)
+{
+       u64 val;
+       u32 mult;
+
+       val = readq(loongson2_pll_base + 0x50);
+
+       mult = (val >> shift) & clk_div_mask(width);
+
+       return div_u64((u64)rate * (mult + 1), 8);
+}
+
+static unsigned long loongson2_boot_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       return loongson2_calc_rate(parent_rate,
+                                  LOONGSON2_BOOT_FREQSCALE_SHIFT,
+                                  LOONGSON2_BOOT_FREQSCALE_WIDTH);
+}
+
+static const struct clk_ops loongson2_boot_clk_ops = {
+       .recalc_rate = loongson2_boot_recalc_rate,
+};
+
+static unsigned long loongson2_apb_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       return loongson2_calc_rate(parent_rate,
+                                  LOONGSON2_APB_FREQSCALE_SHIFT,
+                                  LOONGSON2_APB_FREQSCALE_WIDTH);
+}
+
+static const struct clk_ops loongson2_apb_clk_ops = {
+       .recalc_rate = loongson2_apb_recalc_rate,
+};
+
+static unsigned long loongson2_usb_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       return loongson2_calc_rate(parent_rate,
+                                  LOONGSON2_USB_FREQSCALE_SHIFT,
+                                  LOONGSON2_USB_FREQSCALE_WIDTH);
+}
+
+static const struct clk_ops loongson2_usb_clk_ops = {
+       .recalc_rate = loongson2_usb_recalc_rate,
+};
+
+static unsigned long loongson2_sata_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       return loongson2_calc_rate(parent_rate,
+                                  LOONGSON2_SATA_FREQSCALE_SHIFT,
+                                  LOONGSON2_SATA_FREQSCALE_WIDTH);
+}
+
+static const struct clk_ops loongson2_sata_clk_ops = {
+       .recalc_rate = loongson2_sata_recalc_rate,
+};
+
+static inline int loongson2_check_clk_hws(struct clk_hw *clks[], unsigned int count)
+{
+       unsigned int i;
+
+       for (i = 0; i < count; i++)
+               if (IS_ERR(clks[i])) {
+                       pr_err("Loongson2 clk %u: register failed with %ld\n",
+                               i, PTR_ERR(clks[i]));
+                       return PTR_ERR(clks[i]);
+               }
+
+       return 0;
+}
+
+static int loongson2_clk_probe(struct platform_device *pdev)
+{
+       int ret;
+       struct clk_hw **hws;
+       struct clk_hw_onecell_data *clk_hw_data;
+       spinlock_t loongson2_clk_lock;
+       struct device *dev = &pdev->dev;
+
+       loongson2_pll_base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(loongson2_pll_base))
+               return PTR_ERR(loongson2_pll_base);
+
+       clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws, LOONGSON2_CLK_END),
+                                       GFP_KERNEL);
+       if (WARN_ON(!clk_hw_data))
+               return -ENOMEM;
+
+       clk_hw_data->num = LOONGSON2_CLK_END;
+       hws = clk_hw_data->hws;
+
+       hws[LOONGSON2_NODE_PLL] = loongson2_clk_register(dev, "node_pll",
+                                               NULL,
+                                               &loongson2_node_clk_ops, 0);
+
+       hws[LOONGSON2_DDR_PLL] = loongson2_clk_register(dev, "ddr_pll",
+                                               NULL,
+                                               &loongson2_ddr_clk_ops, 0);
+
+       hws[LOONGSON2_DC_PLL] = loongson2_clk_register(dev, "dc_pll",
+                                               NULL,
+                                               &loongson2_dc_clk_ops, 0);
+
+       hws[LOONGSON2_PIX0_PLL] = loongson2_clk_register(dev, "pix0_pll",
+                                               NULL,
+                                               &loongson2_pix0_clk_ops, 0);
+
+       hws[LOONGSON2_PIX1_PLL] = loongson2_clk_register(dev, "pix1_pll",
+                                               NULL,
+                                               &loongson2_pix1_clk_ops, 0);
+
+       hws[LOONGSON2_BOOT_CLK] = loongson2_clk_register(dev, "boot",
+                                               NULL,
+                                               &loongson2_boot_clk_ops, 0);
+
+       hws[LOONGSON2_NODE_CLK] = devm_clk_hw_register_divider(dev, "node",
+                                               "node_pll", 0,
+                                               loongson2_pll_base + 0x8, 0,
+                                               6, CLK_DIVIDER_ONE_BASED,
+                                               &loongson2_clk_lock);
+
+       /*
+        * The hda clk divisor in the upper 32bits and the clk-prodiver
+        * layer code doesn't support 64bit io operation thus a conversion
+        * is required that subtract shift by 32 and add 4byte to the hda
+        * address
+        */
+       hws[LOONGSON2_HDA_CLK] = devm_clk_hw_register_divider(dev, "hda",
+                                               "ddr_pll", 0,
+                                               loongson2_pll_base + 0x22, 12,
+                                               7, CLK_DIVIDER_ONE_BASED,
+                                               &loongson2_clk_lock);
+
+       hws[LOONGSON2_GPU_CLK] = devm_clk_hw_register_divider(dev, "gpu",
+                                               "ddr_pll", 0,
+                                               loongson2_pll_base + 0x18, 22,
+                                               6, CLK_DIVIDER_ONE_BASED,
+                                               &loongson2_clk_lock);
+
+       hws[LOONGSON2_DDR_CLK] = devm_clk_hw_register_divider(dev, "ddr",
+                                               "ddr_pll", 0,
+                                               loongson2_pll_base + 0x18, 0,
+                                               6, CLK_DIVIDER_ONE_BASED,
+                                               &loongson2_clk_lock);
+
+       hws[LOONGSON2_GMAC_CLK] = devm_clk_hw_register_divider(dev, "gmac",
+                                               "dc_pll", 0,
+                                               loongson2_pll_base + 0x28, 22,
+                                               6, CLK_DIVIDER_ONE_BASED,
+                                               &loongson2_clk_lock);
+
+       hws[LOONGSON2_DC_CLK] = devm_clk_hw_register_divider(dev, "dc",
+                                               "dc_pll", 0,
+                                               loongson2_pll_base + 0x28, 0,
+                                               6, CLK_DIVIDER_ONE_BASED,
+                                               &loongson2_clk_lock);
+
+       hws[LOONGSON2_APB_CLK] = loongson2_clk_register(dev, "apb",
+                                               "gmac",
+                                               &loongson2_apb_clk_ops, 0);
+
+       hws[LOONGSON2_USB_CLK] = loongson2_clk_register(dev, "usb",
+                                               "gmac",
+                                               &loongson2_usb_clk_ops, 0);
+
+       hws[LOONGSON2_SATA_CLK] = loongson2_clk_register(dev, "sata",
+                                               "gmac",
+                                               &loongson2_sata_clk_ops, 0);
+
+       hws[LOONGSON2_PIX0_CLK] = clk_hw_register_divider(NULL, "pix0",
+                                               "pix0_pll", 0,
+                                               loongson2_pll_base + 0x38, 0, 6,
+                                               CLK_DIVIDER_ONE_BASED,
+                                               &loongson2_clk_lock);
+
+       hws[LOONGSON2_PIX1_CLK] = clk_hw_register_divider(NULL, "pix1",
+                                               "pix1_pll", 0,
+                                               loongson2_pll_base + 0x48, 0, 6,
+                                               CLK_DIVIDER_ONE_BASED,
+                                               &loongson2_clk_lock);
+
+       ret = loongson2_check_clk_hws(hws, LOONGSON2_CLK_END);
+       if (ret)
+               return ret;
+
+       return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_hw_data);
+}
+
+static const struct of_device_id loongson2_clk_match_table[] = {
+       { .compatible = "loongson,ls2k-clk" },
+       { }
+};
+MODULE_DEVICE_TABLE(of, loongson2_clk_match_table);
+
+static struct platform_driver loongson2_clk_driver = {
+       .probe  = loongson2_clk_probe,
+       .driver = {
+               .name   = "loongson2-clk",
+               .of_match_table = loongson2_clk_match_table,
+       },
+};
+module_platform_driver(loongson2_clk_driver);
+
+MODULE_DESCRIPTION("Loongson2 clock driver");
+MODULE_LICENSE("GPL");
index 80b9d78493bcd40546fb448f075271ab6df34c8f..050fd4fb588f8c3812cb424a333fa31112977d6c 100644 (file)
@@ -560,14 +560,12 @@ static void m10v_reg_mux_pre(const struct m10v_clk_mux_factors *factors,
 static int m10v_clk_probe(struct platform_device *pdev)
 {
        int id;
-       struct resource *res;
        struct device *dev = &pdev->dev;
        struct device_node *np = dev->of_node;
        void __iomem *base;
        const char *parent_name;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       base = devm_ioremap_resource(dev, res);
+       base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
        if (IS_ERR(base))
                return PTR_ERR(base);
 
index b8c3d0da1918b719c2f3ba2c642d87ea51fd44f3..74a241b1e1f49aa46937a3f541579fc118eddf7e 100644 (file)
@@ -271,10 +271,9 @@ static int palmas_clks_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int palmas_clks_remove(struct platform_device *pdev)
+static void palmas_clks_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-       return 0;
 }
 
 static struct platform_driver palmas_clks_driver = {
@@ -283,7 +282,7 @@ static struct platform_driver palmas_clks_driver = {
                .of_match_table = palmas_clks_of_match,
        },
        .probe = palmas_clks_probe,
-       .remove = palmas_clks_remove,
+       .remove_new = palmas_clks_remove,
 };
 
 module_platform_driver(palmas_clks_driver);
index da2c8eddfd9ff6a0114f4ca7ec6f8d60ec65e058..3dd2b83d0404a93e237d5efa3b868ed28db98964 100644 (file)
@@ -129,11 +129,9 @@ static int clk_pwm_probe(struct platform_device *pdev)
        return of_clk_add_hw_provider(node, of_clk_hw_simple_get, &clk_pwm->hw);
 }
 
-static int clk_pwm_remove(struct platform_device *pdev)
+static void clk_pwm_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-
-       return 0;
 }
 
 static const struct of_device_id clk_pwm_dt_ids[] = {
@@ -144,7 +142,7 @@ MODULE_DEVICE_TABLE(of, clk_pwm_dt_ids);
 
 static struct platform_driver clk_pwm_driver = {
        .probe = clk_pwm_probe,
-       .remove = clk_pwm_remove,
+       .remove_new = clk_pwm_remove,
        .driver = {
                .name = "pwm-clock",
                .of_match_table = clk_pwm_dt_ids,
index f91f30560820d529e035c2e62efee3b659acbe6c..6799fb0fa2d3c5e5c9c428de046b3a2e50e5ff76 100644 (file)
@@ -6,6 +6,7 @@
  *   - 9FGV/9DBV/9DMV/9FGL/9DML/9QXL/9SQ
  * Currently supported:
  *   - 9FGV0241
+ *   - 9FGV0441
  *
  * Copyright (C) 2022 Marek Vasut <marex@denx.de>
  */
@@ -18,7 +19,6 @@
 #include <linux/regmap.h>
 
 #define RS9_REG_OE                             0x0
-#define RS9_REG_OE_DIF_OE(n)                   BIT((n) + 1)
 #define RS9_REG_SS                             0x1
 #define RS9_REG_SS_AMP_0V6                     0x0
 #define RS9_REG_SS_AMP_0V7                     0x1
@@ -31,9 +31,6 @@
 #define RS9_REG_SS_SSC_MASK                    (3 << 3)
 #define RS9_REG_SS_SSC_LOCK                    BIT(5)
 #define RS9_REG_SR                             0x2
-#define RS9_REG_SR_2V0_DIF(n)                  0
-#define RS9_REG_SR_3V0_DIF(n)                  BIT((n) + 1)
-#define RS9_REG_SR_DIF_MASK(n)         BIT((n) + 1)
 #define RS9_REG_REF                            0x3
 #define RS9_REG_REF_OE                         BIT(4)
 #define RS9_REG_REF_OD                         BIT(5)
 #define RS9_REG_DID                            0x6
 #define RS9_REG_BCP                            0x7
 
+#define RS9_REG_VID_IDT                                0x01
+
+#define RS9_REG_DID_TYPE_FGV                   (0x0 << RS9_REG_DID_TYPE_SHIFT)
+#define RS9_REG_DID_TYPE_DBV                   (0x1 << RS9_REG_DID_TYPE_SHIFT)
+#define RS9_REG_DID_TYPE_DMV                   (0x2 << RS9_REG_DID_TYPE_SHIFT)
+#define RS9_REG_DID_TYPE_SHIFT                 0x6
+
 /* Supported Renesas 9-series models. */
 enum rs9_model {
        RENESAS_9FGV0241,
+       RENESAS_9FGV0441,
 };
 
 /* Structure to describe features of a particular 9-series model */
 struct rs9_chip_info {
        const enum rs9_model    model;
        unsigned int            num_clks;
+       u8                      did;
 };
 
 struct rs9_driver_data {
        struct i2c_client       *client;
        struct regmap           *regmap;
        const struct rs9_chip_info *chip_info;
-       struct clk_hw           *clk_dif[2];
+       struct clk_hw           *clk_dif[4];
        u8                      pll_amplitude;
        u8                      pll_ssc;
        u8                      clk_dif_sr;
@@ -151,17 +157,29 @@ static const struct regmap_config rs9_regmap_config = {
        .reg_read = rs9_regmap_i2c_read,
 };
 
+static u8 rs9_calc_dif(const struct rs9_driver_data *rs9, int idx)
+{
+       enum rs9_model model = rs9->chip_info->model;
+
+       if (model == RENESAS_9FGV0241)
+               return BIT(idx) + 1;
+       else if (model == RENESAS_9FGV0441)
+               return BIT(idx);
+
+       return 0;
+}
+
 static int rs9_get_output_config(struct rs9_driver_data *rs9, int idx)
 {
        struct i2c_client *client = rs9->client;
+       u8 dif = rs9_calc_dif(rs9, idx);
        unsigned char name[5] = "DIF0";
        struct device_node *np;
        int ret;
        u32 sr;
 
        /* Set defaults */
-       rs9->clk_dif_sr &= ~RS9_REG_SR_DIF_MASK(idx);
-       rs9->clk_dif_sr |= RS9_REG_SR_3V0_DIF(idx);
+       rs9->clk_dif_sr |= dif;
 
        snprintf(name, 5, "DIF%d", idx);
        np = of_get_child_by_name(client->dev.of_node, name);
@@ -173,11 +191,9 @@ static int rs9_get_output_config(struct rs9_driver_data *rs9, int idx)
        of_node_put(np);
        if (!ret) {
                if (sr == 2000000) {            /* 2V/ns */
-                       rs9->clk_dif_sr &= ~RS9_REG_SR_DIF_MASK(idx);
-                       rs9->clk_dif_sr |= RS9_REG_SR_2V0_DIF(idx);
+                       rs9->clk_dif_sr &= ~dif;
                } else if (sr == 3000000) {     /* 3V/ns (default) */
-                       rs9->clk_dif_sr &= ~RS9_REG_SR_DIF_MASK(idx);
-                       rs9->clk_dif_sr |= RS9_REG_SR_3V0_DIF(idx);
+                       rs9->clk_dif_sr |= dif;
                } else
                        ret = dev_err_probe(&client->dev, -EINVAL,
                                            "Invalid renesas,slew-rate value\n");
@@ -248,11 +264,13 @@ static void rs9_update_config(struct rs9_driver_data *rs9)
        }
 
        for (i = 0; i < rs9->chip_info->num_clks; i++) {
-               if (rs9->clk_dif_sr & RS9_REG_SR_3V0_DIF(i))
+               u8 dif = rs9_calc_dif(rs9, i);
+
+               if (rs9->clk_dif_sr & dif)
                        continue;
 
-               regmap_update_bits(rs9->regmap, RS9_REG_SR, RS9_REG_SR_3V0_DIF(i),
-                                  rs9->clk_dif_sr & RS9_REG_SR_3V0_DIF(i));
+               regmap_update_bits(rs9->regmap, RS9_REG_SR, dif,
+                                  rs9->clk_dif_sr & dif);
        }
 }
 
@@ -269,6 +287,7 @@ static int rs9_probe(struct i2c_client *client)
 {
        unsigned char name[5] = "DIF0";
        struct rs9_driver_data *rs9;
+       unsigned int vid, did;
        struct clk_hw *hw;
        int i, ret;
 
@@ -305,6 +324,20 @@ static int rs9_probe(struct i2c_client *client)
        if (ret < 0)
                return ret;
 
+       ret = regmap_read(rs9->regmap, RS9_REG_VID, &vid);
+       if (ret < 0)
+               return ret;
+
+       ret = regmap_read(rs9->regmap, RS9_REG_DID, &did);
+       if (ret < 0)
+               return ret;
+
+       if (vid != RS9_REG_VID_IDT || did != rs9->chip_info->did)
+               return dev_err_probe(&client->dev, -ENODEV,
+                                    "Incorrect VID/DID: %#02x, %#02x. Expected %#02x, %#02x\n",
+                                    vid, did, RS9_REG_VID_IDT,
+                                    rs9->chip_info->did);
+
        /* Register clock */
        for (i = 0; i < rs9->chip_info->num_clks; i++) {
                snprintf(name, 5, "DIF%d", i);
@@ -348,16 +381,25 @@ static int __maybe_unused rs9_resume(struct device *dev)
 static const struct rs9_chip_info renesas_9fgv0241_info = {
        .model          = RENESAS_9FGV0241,
        .num_clks       = 2,
+       .did            = RS9_REG_DID_TYPE_FGV | 0x02,
+};
+
+static const struct rs9_chip_info renesas_9fgv0441_info = {
+       .model          = RENESAS_9FGV0441,
+       .num_clks       = 4,
+       .did            = RS9_REG_DID_TYPE_FGV | 0x04,
 };
 
 static const struct i2c_device_id rs9_id[] = {
        { "9fgv0241", .driver_data = RENESAS_9FGV0241 },
+       { "9fgv0441", .driver_data = RENESAS_9FGV0441 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, rs9_id);
 
 static const struct of_device_id clk_rs9_of_match[] = {
        { .compatible = "renesas,9fgv0241", .data = &renesas_9fgv0241_info },
+       { .compatible = "renesas,9fgv0441", .data = &renesas_9fgv0441_info },
        { }
 };
 MODULE_DEVICE_TABLE(of, clk_rs9_of_match);
index a3e883a9f4067191f0f97071516fdb0b6a3bbf81..38c456540d1b98cca0fc0370c185b03b497fd3ca 100644 (file)
@@ -202,7 +202,7 @@ err_reg:
        return ret;
 }
 
-static int s2mps11_clk_remove(struct platform_device *pdev)
+static void s2mps11_clk_remove(struct platform_device *pdev)
 {
        struct s2mps11_clk *s2mps11_clks = platform_get_drvdata(pdev);
        int i;
@@ -217,8 +217,6 @@ static int s2mps11_clk_remove(struct platform_device *pdev)
                        continue;
                clkdev_drop(s2mps11_clks[i].lookup);
        }
-
-       return 0;
 }
 
 static const struct platform_device_id s2mps11_clk_id[] = {
@@ -265,7 +263,7 @@ static struct platform_driver s2mps11_clk_driver = {
                .name  = "s2mps11-clk",
        },
        .probe = s2mps11_clk_probe,
-       .remove = s2mps11_clk_remove,
+       .remove_new = s2mps11_clk_remove,
        .id_table = s2mps11_clk_id,
 };
 module_platform_driver(s2mps11_clk_driver);
index a39af7616b13c5fc3b0adf56e3adeaca1ae77bd0..3fb4003453eebac59503398101b0e4530ba4eb13 100644 (file)
@@ -246,7 +246,7 @@ static int scpi_clk_add(struct device *dev, struct device_node *np,
        return of_clk_add_hw_provider(np, scpi_of_clk_src_get, clk_data);
 }
 
-static int scpi_clocks_remove(struct platform_device *pdev)
+static void scpi_clocks_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct device_node *child, *np = dev->of_node;
@@ -258,7 +258,6 @@ static int scpi_clocks_remove(struct platform_device *pdev)
 
        for_each_available_child_of_node(np, child)
                of_clk_del_provider(np);
-       return 0;
 }
 
 static int scpi_clocks_probe(struct platform_device *pdev)
@@ -305,7 +304,7 @@ static struct platform_driver scpi_clocks_driver = {
                .of_match_table = scpi_clocks_ids,
        },
        .probe = scpi_clocks_probe,
-       .remove = scpi_clocks_remove,
+       .remove_new = scpi_clocks_remove,
 };
 module_platform_driver(scpi_clocks_driver);
 
index c028fa103bedabdd47891d6e5ab8eb11375ebf38..cabdd8e8f4dbd2855418668c56c00a9d4e486d18 100644 (file)
@@ -360,8 +360,8 @@ static int si514_probe(struct i2c_client *client)
                dev_err(&client->dev, "clock registration failed\n");
                return err;
        }
-       err = of_clk_add_hw_provider(client->dev.of_node, of_clk_hw_simple_get,
-                                    &data->hw);
+       err = devm_of_clk_add_hw_provider(&client->dev, of_clk_hw_simple_get,
+                                         &data->hw);
        if (err) {
                dev_err(&client->dev, "unable to add clk provider\n");
                return err;
@@ -370,11 +370,6 @@ static int si514_probe(struct i2c_client *client)
        return 0;
 }
 
-static void si514_remove(struct i2c_client *client)
-{
-       of_clk_del_provider(client->dev.of_node);
-}
-
 static const struct i2c_device_id si514_id[] = {
        { "si514", 0 },
        { }
@@ -393,7 +388,6 @@ static struct i2c_driver si514_driver = {
                .of_match_table = clk_si514_of_match,
        },
        .probe_new      = si514_probe,
-       .remove         = si514_remove,
        .id_table       = si514_id,
 };
 module_i2c_driver(si514_driver);
diff --git a/drivers/clk/clk-si521xx.c b/drivers/clk/clk-si521xx.c
new file mode 100644 (file)
index 0000000..ac8d4c5
--- /dev/null
@@ -0,0 +1,395 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Driver for Skyworks Si521xx PCIe clock generator driver
+ *
+ * The following series can be supported:
+ *   - Si52144 - 4x DIFF
+ *   - Si52146 - 6x DIFF
+ *   - Si52147 - 9x DIFF
+ * Currently tested:
+ *   - Si52144
+ *
+ * Copyright (C) 2022 Marek Vasut <marex@denx.de>
+ */
+
+#include <linux/bitfield.h>
+#include <linux/bitrev.h>
+#include <linux/clk-provider.h>
+#include <linux/i2c.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+
+/* OE1 and OE2 register */
+#define SI521XX_REG_OE(n)                      (((n) & 0x1) + 1)
+#define SI521XX_REG_ID                         0x3
+#define SI521XX_REG_ID_PROG                    GENMASK(7, 4)
+#define SI521XX_REG_ID_VENDOR                  GENMASK(3, 0)
+#define SI521XX_REG_BC                         0x4
+#define SI521XX_REG_DA                         0x5
+#define SI521XX_REG_DA_AMP_SEL                 BIT(7)
+#define SI521XX_REG_DA_AMP_MASK                        GENMASK(6, 4)
+#define SI521XX_REG_DA_AMP_MIN                 300000
+#define SI521XX_REG_DA_AMP_DEFAULT             800000
+#define SI521XX_REG_DA_AMP_MAX                 1000000
+#define SI521XX_REG_DA_AMP_STEP                        100000
+#define SI521XX_REG_DA_AMP(UV)                 \
+       FIELD_PREP(SI521XX_REG_DA_AMP_MASK,     \
+                  ((UV) - SI521XX_REG_DA_AMP_MIN) / SI521XX_REG_DA_AMP_STEP)
+#define SI521XX_REG_DA_UNKNOWN                 BIT(3)  /* Always set */
+
+/* Count of populated OE bits in control register ref, 1 and 2 */
+#define SI521XX_OE_MAP(cr1, cr2)       (((cr2) << 8) | (cr1))
+#define SI521XX_OE_MAP_GET_OE(oe, map) (((map) >> (((oe) - 1) * 8)) & 0xff)
+
+#define SI521XX_DIFF_MULT      4
+#define SI521XX_DIFF_DIV       1
+
+/* Supported Skyworks Si521xx models. */
+enum si521xx_model {
+       SI52144 = 0x44,
+       SI52146 = 0x46,
+       SI52147 = 0x47,
+};
+
+struct si521xx;
+
+struct si_clk {
+       struct clk_hw           hw;
+       struct si521xx          *si;
+       u8                      reg;
+       u8                      bit;
+};
+
+struct si521xx {
+       struct i2c_client       *client;
+       struct regmap           *regmap;
+       struct si_clk           clk_dif[9];
+       u16                     chip_info;
+       u8                      pll_amplitude;
+};
+
+/*
+ * Si521xx i2c regmap
+ */
+static const struct regmap_range si521xx_readable_ranges[] = {
+       regmap_reg_range(SI521XX_REG_OE(0), SI521XX_REG_DA),
+};
+
+static const struct regmap_access_table si521xx_readable_table = {
+       .yes_ranges = si521xx_readable_ranges,
+       .n_yes_ranges = ARRAY_SIZE(si521xx_readable_ranges),
+};
+
+static const struct regmap_range si521xx_writeable_ranges[] = {
+       regmap_reg_range(SI521XX_REG_OE(0), SI521XX_REG_OE(1)),
+       regmap_reg_range(SI521XX_REG_BC, SI521XX_REG_DA),
+};
+
+static const struct regmap_access_table si521xx_writeable_table = {
+       .yes_ranges = si521xx_writeable_ranges,
+       .n_yes_ranges = ARRAY_SIZE(si521xx_writeable_ranges),
+};
+
+static int si521xx_regmap_i2c_write(void *context, unsigned int reg,
+                                   unsigned int val)
+{
+       struct i2c_client *i2c = context;
+       const u8 data[3] = { reg, 1, val };
+       const int count = ARRAY_SIZE(data);
+       int ret;
+
+       ret = i2c_master_send(i2c, data, count);
+       if (ret == count)
+               return 0;
+       else if (ret < 0)
+               return ret;
+       else
+               return -EIO;
+}
+
+static int si521xx_regmap_i2c_read(void *context, unsigned int reg,
+                                  unsigned int *val)
+{
+       struct i2c_client *i2c = context;
+       struct i2c_msg xfer[2];
+       u8 txdata = reg;
+       u8 rxdata[2];
+       int ret;
+
+       xfer[0].addr = i2c->addr;
+       xfer[0].flags = 0;
+       xfer[0].len = 1;
+       xfer[0].buf = (void *)&txdata;
+
+       xfer[1].addr = i2c->addr;
+       xfer[1].flags = I2C_M_RD;
+       xfer[1].len = 2;
+       xfer[1].buf = (void *)rxdata;
+
+       ret = i2c_transfer(i2c->adapter, xfer, 2);
+       if (ret < 0)
+               return ret;
+       if (ret != 2)
+               return -EIO;
+
+       /*
+        * Byte 0 is transfer length, which is always 1 due
+        * to BCP register programming to 1 in si521xx_probe(),
+        * ignore it and use data from Byte 1.
+        */
+       *val = rxdata[1];
+       return 0;
+}
+
+static const struct regmap_config si521xx_regmap_config = {
+       .reg_bits = 8,
+       .val_bits = 8,
+       .cache_type = REGCACHE_NONE,
+       .max_register = SI521XX_REG_DA,
+       .rd_table = &si521xx_readable_table,
+       .wr_table = &si521xx_writeable_table,
+       .reg_write = si521xx_regmap_i2c_write,
+       .reg_read = si521xx_regmap_i2c_read,
+};
+
+static unsigned long si521xx_diff_recalc_rate(struct clk_hw *hw,
+                                             unsigned long parent_rate)
+{
+       unsigned long long rate;
+
+       rate = (unsigned long long)parent_rate * SI521XX_DIFF_MULT;
+       do_div(rate, SI521XX_DIFF_DIV);
+       return (unsigned long)rate;
+}
+
+static long si521xx_diff_round_rate(struct clk_hw *hw, unsigned long rate,
+                                   unsigned long *prate)
+{
+       unsigned long best_parent;
+
+       best_parent = (rate / SI521XX_DIFF_MULT) * SI521XX_DIFF_DIV;
+       *prate = clk_hw_round_rate(clk_hw_get_parent(hw), best_parent);
+
+       return (*prate / SI521XX_DIFF_DIV) * SI521XX_DIFF_MULT;
+}
+
+static int si521xx_diff_set_rate(struct clk_hw *hw, unsigned long rate,
+                                unsigned long parent_rate)
+{
+       /*
+        * We must report success but we can do so unconditionally because
+        * si521xx_diff_round_rate returns values that ensure this call is a
+        * nop.
+        */
+
+       return 0;
+}
+
+#define to_si521xx_clk(_hw) container_of(_hw, struct si_clk, hw)
+
+static int si521xx_diff_prepare(struct clk_hw *hw)
+{
+       struct si_clk *si_clk = to_si521xx_clk(hw);
+       struct si521xx *si = si_clk->si;
+
+       regmap_set_bits(si->regmap, SI521XX_REG_OE(si_clk->reg), si_clk->bit);
+
+       return 0;
+}
+
+static void si521xx_diff_unprepare(struct clk_hw *hw)
+{
+       struct si_clk *si_clk = to_si521xx_clk(hw);
+       struct si521xx *si = si_clk->si;
+
+       regmap_clear_bits(si->regmap, SI521XX_REG_OE(si_clk->reg), si_clk->bit);
+}
+
+static const struct clk_ops si521xx_diff_clk_ops = {
+       .round_rate     = si521xx_diff_round_rate,
+       .set_rate       = si521xx_diff_set_rate,
+       .recalc_rate    = si521xx_diff_recalc_rate,
+       .prepare        = si521xx_diff_prepare,
+       .unprepare      = si521xx_diff_unprepare,
+};
+
+static int si521xx_get_common_config(struct si521xx *si)
+{
+       struct i2c_client *client = si->client;
+       struct device_node *np = client->dev.of_node;
+       unsigned int amp;
+       int ret;
+
+       /* Set defaults */
+       si->pll_amplitude = SI521XX_REG_DA_AMP(SI521XX_REG_DA_AMP_DEFAULT);
+
+       /* Output clock amplitude */
+       ret = of_property_read_u32(np, "skyworks,out-amplitude-microvolt",
+                                  &amp);
+       if (!ret) {
+               if (amp < SI521XX_REG_DA_AMP_MIN || amp > SI521XX_REG_DA_AMP_MAX ||
+                   amp % SI521XX_REG_DA_AMP_STEP) {
+                       return dev_err_probe(&client->dev, -EINVAL,
+                                            "Invalid skyworks,out-amplitude-microvolt value\n");
+               }
+               si->pll_amplitude = SI521XX_REG_DA_AMP(amp);
+       }
+
+       return 0;
+}
+
+static void si521xx_update_config(struct si521xx *si)
+{
+       /* If amplitude is non-default, update it. */
+       if (si->pll_amplitude == SI521XX_REG_DA_AMP(SI521XX_REG_DA_AMP_DEFAULT))
+               return;
+
+       regmap_update_bits(si->regmap, SI521XX_REG_DA,
+                          SI521XX_REG_DA_AMP_MASK, si->pll_amplitude);
+}
+
+static void si521xx_diff_idx_to_reg_bit(const u16 chip_info, const int idx,
+                                       struct si_clk *clk)
+{
+       unsigned long mask;
+       int oe, b, ctr = 0;
+
+       for (oe = 1; oe <= 2; oe++) {
+               mask = bitrev8(SI521XX_OE_MAP_GET_OE(oe, chip_info));
+               for_each_set_bit(b, &mask, 8) {
+                       if (ctr++ != idx)
+                               continue;
+                       clk->reg = SI521XX_REG_OE(oe);
+                       clk->bit = 7 - b;
+                       return;
+               }
+       }
+}
+
+static struct clk_hw *
+si521xx_of_clk_get(struct of_phandle_args *clkspec, void *data)
+{
+       struct si521xx *si = data;
+       unsigned int idx = clkspec->args[0];
+
+       return &si->clk_dif[idx].hw;
+}
+
+static int si521xx_probe(struct i2c_client *client)
+{
+       const u16 chip_info = (u16)(uintptr_t)device_get_match_data(&client->dev);
+       const struct clk_parent_data clk_parent_data = { .index = 0 };
+       struct si521xx *si;
+       unsigned char name[6] = "DIFF0";
+       struct clk_init_data init = {};
+       int i, ret;
+
+       if (!chip_info)
+               return -EINVAL;
+
+       si = devm_kzalloc(&client->dev, sizeof(*si), GFP_KERNEL);
+       if (!si)
+               return -ENOMEM;
+
+       i2c_set_clientdata(client, si);
+       si->client = client;
+
+       /* Fetch common configuration from DT (if specified) */
+       ret = si521xx_get_common_config(si);
+       if (ret)
+               return ret;
+
+       si->regmap = devm_regmap_init(&client->dev, NULL, client,
+                                     &si521xx_regmap_config);
+       if (IS_ERR(si->regmap))
+               return dev_err_probe(&client->dev, PTR_ERR(si->regmap),
+                                    "Failed to allocate register map\n");
+
+       /* Always read back 1 Byte via I2C */
+       ret = regmap_write(si->regmap, SI521XX_REG_BC, 1);
+       if (ret < 0)
+               return ret;
+
+       /* Register clock */
+       for (i = 0; i < hweight16(chip_info); i++) {
+               memset(&init, 0, sizeof(init));
+               snprintf(name, 6, "DIFF%d", i);
+               init.name = name;
+               init.ops = &si521xx_diff_clk_ops;
+               init.parent_data = &clk_parent_data;
+               init.num_parents = 1;
+               init.flags = CLK_SET_RATE_PARENT;
+
+               si->clk_dif[i].hw.init = &init;
+               si->clk_dif[i].si = si;
+
+               si521xx_diff_idx_to_reg_bit(chip_info, i, &si->clk_dif[i]);
+
+               ret = devm_clk_hw_register(&client->dev, &si->clk_dif[i].hw);
+               if (ret)
+                       return ret;
+       }
+
+       ret = devm_of_clk_add_hw_provider(&client->dev, si521xx_of_clk_get, si);
+       if (!ret)
+               si521xx_update_config(si);
+
+       return ret;
+}
+
+static int __maybe_unused si521xx_suspend(struct device *dev)
+{
+       struct si521xx *si = dev_get_drvdata(dev);
+
+       regcache_cache_only(si->regmap, true);
+       regcache_mark_dirty(si->regmap);
+
+       return 0;
+}
+
+static int __maybe_unused si521xx_resume(struct device *dev)
+{
+       struct si521xx *si = dev_get_drvdata(dev);
+       int ret;
+
+       regcache_cache_only(si->regmap, false);
+       ret = regcache_sync(si->regmap);
+       if (ret)
+               dev_err(dev, "Failed to restore register map: %d\n", ret);
+       return ret;
+}
+
+static const struct i2c_device_id si521xx_id[] = {
+       { "si52144", .driver_data = SI521XX_OE_MAP(0x5, 0xc0) },
+       { "si52146", .driver_data = SI521XX_OE_MAP(0x15, 0xe0) },
+       { "si52147", .driver_data = SI521XX_OE_MAP(0x17, 0xf8) },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, si521xx_id);
+
+static const struct of_device_id clk_si521xx_of_match[] = {
+       { .compatible = "skyworks,si52144", .data = (void *)SI521XX_OE_MAP(0x5, 0xc0) },
+       { .compatible = "skyworks,si52146", .data = (void *)SI521XX_OE_MAP(0x15, 0xe0) },
+       { .compatible = "skyworks,si52147", .data = (void *)SI521XX_OE_MAP(0x15, 0xf8) },
+       { }
+};
+MODULE_DEVICE_TABLE(of, clk_si521xx_of_match);
+
+static SIMPLE_DEV_PM_OPS(si521xx_pm_ops, si521xx_suspend, si521xx_resume);
+
+static struct i2c_driver si521xx_driver = {
+       .driver = {
+               .name = "clk-si521xx",
+               .pm     = &si521xx_pm_ops,
+               .of_match_table = clk_si521xx_of_match,
+       },
+       .probe_new      = si521xx_probe,
+       .id_table       = si521xx_id,
+};
+module_i2c_driver(si521xx_driver);
+
+MODULE_AUTHOR("Marek Vasut <marex@denx.de>");
+MODULE_DESCRIPTION("Skyworks Si521xx PCIe clock generator driver");
+MODULE_LICENSE("GPL");
index 9e939c98a4558535ee52a508c725e985516411bc..4fcf7056717e9a98fc7f6fab40222a88429e7f94 100644 (file)
@@ -1641,8 +1641,8 @@ static int si5351_i2c_probe(struct i2c_client *client)
                }
        }
 
-       ret = of_clk_add_hw_provider(client->dev.of_node, si53351_of_clk_get,
-                                    drvdata);
+       ret = devm_of_clk_add_hw_provider(&client->dev, si53351_of_clk_get,
+                                         drvdata);
        if (ret) {
                dev_err(&client->dev, "unable to add clk provider\n");
                return ret;
@@ -1651,18 +1651,12 @@ static int si5351_i2c_probe(struct i2c_client *client)
        return 0;
 }
 
-static void si5351_i2c_remove(struct i2c_client *client)
-{
-       of_clk_del_provider(client->dev.of_node);
-}
-
 static struct i2c_driver si5351_driver = {
        .driver = {
                .name = "si5351",
                .of_match_table = of_match_ptr(si5351_dt_ids),
        },
        .probe_new = si5351_i2c_probe,
-       .remove = si5351_i2c_remove,
        .id_table = si5351_i2c_ids,
 };
 module_i2c_driver(si5351_driver);
index 0a6d70c497267872ee843d7bc3e399d5491acb86..0b834e9efb4bc2d1473451655c27870ddb782e61 100644 (file)
@@ -474,8 +474,8 @@ static int si570_probe(struct i2c_client *client)
                dev_err(&client->dev, "clock registration failed\n");
                return err;
        }
-       err = of_clk_add_hw_provider(client->dev.of_node, of_clk_hw_simple_get,
-                                    &data->hw);
+       err = devm_of_clk_add_hw_provider(&client->dev, of_clk_hw_simple_get,
+                                         &data->hw);
        if (err) {
                dev_err(&client->dev, "unable to add clk provider\n");
                return err;
@@ -485,10 +485,8 @@ static int si570_probe(struct i2c_client *client)
        if (!of_property_read_u32(client->dev.of_node, "clock-frequency",
                                &initial_fout)) {
                err = clk_set_rate(data->hw.clk, initial_fout);
-               if (err) {
-                       of_clk_del_provider(client->dev.of_node);
+               if (err)
                        return err;
-               }
        }
 
        /* Display a message indicating that we've successfully registered */
@@ -498,11 +496,6 @@ static int si570_probe(struct i2c_client *client)
        return 0;
 }
 
-static void si570_remove(struct i2c_client *client)
-{
-       of_clk_del_provider(client->dev.of_node);
-}
-
 static const struct of_device_id clk_si570_of_match[] = {
        { .compatible = "silabs,si570" },
        { .compatible = "silabs,si571" },
@@ -518,7 +511,6 @@ static struct i2c_driver si570_driver = {
                .of_match_table = clk_si570_of_match,
        },
        .probe_new      = si570_probe,
-       .remove         = si570_remove,
        .id_table       = si570_id,
 };
 module_i2c_driver(si570_driver);
diff --git a/drivers/clk/clk-sp7021.c b/drivers/clk/clk-sp7021.c
new file mode 100644 (file)
index 0000000..8fec141
--- /dev/null
@@ -0,0 +1,713 @@
+// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+/*
+ * Copyright (C) Sunplus Technology Co., Ltd.
+ *       All rights reserved.
+ */
+#include <linux/module.h>
+#include <linux/clk-provider.h>
+#include <linux/of.h>
+#include <linux/bitfield.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+
+#include <dt-bindings/clock/sunplus,sp7021-clkc.h>
+
+/* speical div_width values for PLLTV/PLLA */
+#define DIV_TV         33
+#define DIV_A          34
+
+/* PLLTV parameters */
+enum {
+       SEL_FRA,
+       SDM_MOD,
+       PH_SEL,
+       NFRA,
+       DIVR,
+       DIVN,
+       DIVM,
+       P_MAX
+};
+
+#define MASK_SEL_FRA   GENMASK(1, 1)
+#define MASK_SDM_MOD   GENMASK(2, 2)
+#define MASK_PH_SEL    GENMASK(4, 4)
+#define MASK_NFRA      GENMASK(12, 6)
+#define MASK_DIVR      GENMASK(8, 7)
+#define MASK_DIVN      GENMASK(7, 0)
+#define MASK_DIVM      GENMASK(14, 8)
+
+/* HIWORD_MASK FIELD_PREP */
+#define HWM_FIELD_PREP(mask, value)            \
+({                                             \
+       u32 _m = mask;                          \
+       (_m << 16) | FIELD_PREP(_m, value);     \
+})
+
+struct sp_pll {
+       struct clk_hw hw;
+       void __iomem *reg;
+       spinlock_t lock;        /* lock for reg */
+       int div_shift;
+       int div_width;
+       int pd_bit;             /* power down bit idx */
+       int bp_bit;             /* bypass bit idx */
+       unsigned long brate;    /* base rate, TODO: replace brate with muldiv */
+       u32 p[P_MAX];           /* for hold PLLTV/PLLA parameters */
+};
+
+#define to_sp_pll(_hw) container_of(_hw, struct sp_pll, hw)
+
+struct sp_clk_gate_info {
+       u16     reg;            /* reg_index_shift */
+       u16     ext_parent;     /* parent is extclk */
+};
+
+static const struct sp_clk_gate_info sp_clk_gates[] = {
+       { 0x02 },
+       { 0x05 },
+       { 0x06 },
+       { 0x07 },
+       { 0x09 },
+       { 0x0b, 1 },
+       { 0x0f, 1 },
+       { 0x14 },
+       { 0x15 },
+       { 0x16 },
+       { 0x17 },
+       { 0x18, 1 },
+       { 0x19, 1 },
+       { 0x1a, 1 },
+       { 0x1b, 1 },
+       { 0x1c, 1 },
+       { 0x1d, 1 },
+       { 0x1e },
+       { 0x1f, 1 },
+       { 0x20 },
+       { 0x21 },
+       { 0x22 },
+       { 0x23 },
+       { 0x24 },
+       { 0x25 },
+       { 0x26 },
+       { 0x2a },
+       { 0x2b },
+       { 0x2d },
+       { 0x2e },
+       { 0x30 },
+       { 0x31 },
+       { 0x32 },
+       { 0x33 },
+       { 0x3d },
+       { 0x3e },
+       { 0x3f },
+       { 0x42 },
+       { 0x44 },
+       { 0x4b },
+       { 0x4c },
+       { 0x4d },
+       { 0x4e },
+       { 0x4f },
+       { 0x50 },
+       { 0x55 },
+       { 0x60 },
+       { 0x61 },
+       { 0x6a },
+       { 0x73 },
+       { 0x86 },
+       { 0x8a },
+       { 0x8b },
+       { 0x8d },
+       { 0x8e },
+       { 0x8f },
+       { 0x90 },
+       { 0x92 },
+       { 0x93 },
+       { 0x95 },
+       { 0x96 },
+       { 0x97 },
+       { 0x98 },
+       { 0x99 },
+};
+
+#define _M             1000000UL
+#define F_27M          (27 * _M)
+
+/*********************************** PLL_TV **********************************/
+
+/* TODO: set proper FVCO range */
+#define FVCO_MIN       (100 * _M)
+#define FVCO_MAX       (200 * _M)
+
+#define F_MIN          (FVCO_MIN / 8)
+#define F_MAX          (FVCO_MAX)
+
+static long plltv_integer_div(struct sp_pll *clk, unsigned long freq)
+{
+       /* valid m values: 27M must be divisible by m */
+       static const u32 m_table[] = {
+               1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32
+       };
+       u32 m, n, r;
+       unsigned long fvco, nf;
+       long ret;
+
+       freq = clamp(freq, F_MIN, F_MAX);
+
+       /* DIVR 0~3 */
+       for (r = 0; r <= 3; r++) {
+               fvco = freq << r;
+               if (fvco <= FVCO_MAX)
+                       break;
+       }
+
+       /* DIVM */
+       for (m = 0; m < ARRAY_SIZE(m_table); m++) {
+               nf = fvco * m_table[m];
+               n = nf / F_27M;
+               if ((n * F_27M) == nf)
+                       break;
+       }
+       if (m >= ARRAY_SIZE(m_table)) {
+               ret = -EINVAL;
+               goto err_not_found;
+       }
+
+       /* save parameters */
+       clk->p[SEL_FRA] = 0;
+       clk->p[DIVR]    = r;
+       clk->p[DIVN]    = n;
+       clk->p[DIVM]    = m_table[m];
+
+       return freq;
+
+err_not_found:
+       pr_err("%s: %s freq:%lu not found a valid setting\n",
+              __func__, clk_hw_get_name(&clk->hw), freq);
+
+       return ret;
+}
+
+/* parameters for PLLTV fractional divider */
+static const u32 pt[][5] = {
+       /* conventional fractional */
+       {
+               1,                      /* factor */
+               5,                      /* 5 * p0 (nint) */
+               1,                      /* 1 * p0 */
+               F_27M,                  /* F_27M / p0 */
+               1,                      /* p0 / p2 */
+       },
+       /* phase rotation */
+       {
+               10,                     /* factor */
+               54,                     /* 5.4 * p0 (nint) */
+               2,                      /* 0.2 * p0 */
+               F_27M / 10,             /* F_27M / p0 */
+               5,                      /* p0 / p2 */
+       },
+};
+
+static const u32 sdm_mod_vals[] = { 91, 55 };
+
+static long plltv_fractional_div(struct sp_pll *clk, unsigned long freq)
+{
+       u32 m, r;
+       u32 nint, nfra;
+       u32 df_quotient_min = 210000000;
+       u32 df_remainder_min = 0;
+       unsigned long fvco, nf, f, fout = 0;
+       int sdm, ph;
+
+       freq = clamp(freq, F_MIN, F_MAX);
+
+       /* DIVR 0~3 */
+       for (r = 0; r <= 3; r++) {
+               fvco = freq << r;
+               if (fvco <= FVCO_MAX)
+                       break;
+       }
+       f = F_27M >> r;
+
+       /* PH_SEL */
+       for (ph = ARRAY_SIZE(pt) - 1; ph >= 0; ph--) {
+               const u32 *pp = pt[ph];
+
+               /* SDM_MOD */
+               for (sdm = 0; sdm < ARRAY_SIZE(sdm_mod_vals); sdm++) {
+                       u32 mod = sdm_mod_vals[sdm];
+
+                       /* DIVM 1~32 */
+                       for (m = 1; m <= 32; m++) {
+                               u32 df; /* diff freq */
+                               u32 df_quotient, df_remainder;
+
+                               nf = fvco * m;
+                               nint = nf / pp[3];
+
+                               if (nint < pp[1])
+                                       continue;
+                               if (nint > pp[1])
+                                       break;
+
+                               nfra = (((nf % pp[3]) * mod * pp[4]) + (F_27M / 2)) / F_27M;
+                               if (nfra) {
+                                       u32 df0 = f * (nint + pp[2]) / pp[0];
+                                       u32 df1 = f * (mod - nfra) / mod / pp[4];
+
+                                       df = df0 - df1;
+                               } else {
+                                       df = f * (nint) / pp[0];
+                               }
+
+                               df_quotient  = df / m;
+                               df_remainder = ((df % m) * 1000) / m;
+
+                               if (freq > df_quotient) {
+                                       df_quotient  = freq - df_quotient - 1;
+                                       df_remainder = 1000 - df_remainder;
+                               } else {
+                                       df_quotient = df_quotient - freq;
+                               }
+
+                               if (df_quotient_min > df_quotient ||
+                                   (df_quotient_min == df_quotient &&
+                                   df_remainder_min > df_remainder)) {
+                                       /* found a closer freq, save parameters */
+                                       clk->p[SEL_FRA] = 1;
+                                       clk->p[SDM_MOD] = sdm;
+                                       clk->p[PH_SEL]  = ph;
+                                       clk->p[NFRA]    = nfra;
+                                       clk->p[DIVR]    = r;
+                                       clk->p[DIVM]    = m;
+
+                                       fout = df / m;
+                                       df_quotient_min = df_quotient;
+                                       df_remainder_min = df_remainder;
+                               }
+                       }
+               }
+       }
+
+       if (!fout) {
+               pr_err("%s: %s freq:%lu not found a valid setting\n",
+                      __func__, clk_hw_get_name(&clk->hw), freq);
+               return -EINVAL;
+       }
+
+       return fout;
+}
+
+static long plltv_div(struct sp_pll *clk, unsigned long freq)
+{
+       if (freq % 100)
+               return plltv_fractional_div(clk, freq);
+
+       return plltv_integer_div(clk, freq);
+}
+
+static int plltv_set_rate(struct sp_pll *clk)
+{
+       unsigned long flags;
+       u32 r0, r1, r2;
+
+       r0  = BIT(clk->bp_bit + 16);
+       r0 |= HWM_FIELD_PREP(MASK_SEL_FRA, clk->p[SEL_FRA]);
+       r0 |= HWM_FIELD_PREP(MASK_SDM_MOD, clk->p[SDM_MOD]);
+       r0 |= HWM_FIELD_PREP(MASK_PH_SEL, clk->p[PH_SEL]);
+       r0 |= HWM_FIELD_PREP(MASK_NFRA, clk->p[NFRA]);
+
+       r1  = HWM_FIELD_PREP(MASK_DIVR, clk->p[DIVR]);
+
+       r2  = HWM_FIELD_PREP(MASK_DIVN, clk->p[DIVN] - 1);
+       r2 |= HWM_FIELD_PREP(MASK_DIVM, clk->p[DIVM] - 1);
+
+       spin_lock_irqsave(&clk->lock, flags);
+       writel(r0, clk->reg);
+       writel(r1, clk->reg + 4);
+       writel(r2, clk->reg + 8);
+       spin_unlock_irqrestore(&clk->lock, flags);
+
+       return 0;
+}
+
+/*********************************** PLL_A ***********************************/
+
+/* from Q628_PLLs_REG_setting.xlsx */
+static const struct {
+       u32 rate;
+       u32 regs[5];
+} pa[] = {
+       {
+               .rate = 135475200,
+               .regs = {
+                       0x4801,
+                       0x02df,
+                       0x248f,
+                       0x0211,
+                       0x33e9
+               }
+       },
+       {
+               .rate = 147456000,
+               .regs = {
+                       0x4801,
+                       0x1adf,
+                       0x2490,
+                       0x0349,
+                       0x33e9
+               }
+       },
+       {
+               .rate = 196608000,
+               .regs = {
+                       0x4801,
+                       0x42ef,
+                       0x2495,
+                       0x01c6,
+                       0x33e9
+               }
+       },
+};
+
+static int plla_set_rate(struct sp_pll *clk)
+{
+       const u32 *pp = pa[clk->p[0]].regs;
+       unsigned long flags;
+       int i;
+
+       spin_lock_irqsave(&clk->lock, flags);
+       for (i = 0; i < ARRAY_SIZE(pa->regs); i++)
+               writel(0xffff0000 | pp[i], clk->reg + (i * 4));
+       spin_unlock_irqrestore(&clk->lock, flags);
+
+       return 0;
+}
+
+static long plla_round_rate(struct sp_pll *clk, unsigned long rate)
+{
+       int i = ARRAY_SIZE(pa);
+
+       while (--i) {
+               if (rate >= pa[i].rate)
+                       break;
+       }
+       clk->p[0] = i;
+
+       return pa[i].rate;
+}
+
+/********************************** SP_PLL ***********************************/
+
+static long sp_pll_calc_div(struct sp_pll *clk, unsigned long rate)
+{
+       u32 fbdiv;
+       u32 max = 1 << clk->div_width;
+
+       fbdiv = DIV_ROUND_CLOSEST(rate, clk->brate);
+       if (fbdiv > max)
+               fbdiv = max;
+
+       return fbdiv;
+}
+
+static long sp_pll_round_rate(struct clk_hw *hw, unsigned long rate,
+                             unsigned long *prate)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+       long ret;
+
+       if (rate == *prate) {
+               ret = *prate; /* bypass */
+       } else if (clk->div_width == DIV_A) {
+               ret = plla_round_rate(clk, rate);
+       } else if (clk->div_width == DIV_TV) {
+               ret = plltv_div(clk, rate);
+               if (ret < 0)
+                       ret = *prate;
+       } else {
+               ret = sp_pll_calc_div(clk, rate) * clk->brate;
+       }
+
+       return ret;
+}
+
+static unsigned long sp_pll_recalc_rate(struct clk_hw *hw,
+                                       unsigned long prate)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+       u32 reg = readl(clk->reg);
+       unsigned long ret;
+
+       if (reg & BIT(clk->bp_bit)) {
+               ret = prate; /* bypass */
+       } else if (clk->div_width == DIV_A) {
+               ret = pa[clk->p[0]].rate;
+       } else if (clk->div_width == DIV_TV) {
+               u32 m, r, reg2;
+
+               r = FIELD_GET(MASK_DIVR, readl(clk->reg + 4));
+               reg2 = readl(clk->reg + 8);
+               m = FIELD_GET(MASK_DIVM, reg2) + 1;
+
+               if (reg & MASK_SEL_FRA) {
+                       /* fractional divider */
+                       u32 sdm  = FIELD_GET(MASK_SDM_MOD, reg);
+                       u32 ph   = FIELD_GET(MASK_PH_SEL, reg);
+                       u32 nfra = FIELD_GET(MASK_NFRA, reg);
+                       const u32 *pp = pt[ph];
+                       unsigned long r0, r1;
+
+                       ret = prate >> r;
+                       r0  = ret * (pp[1] + pp[2]) / pp[0];
+                       r1  = ret * (sdm_mod_vals[sdm] - nfra) / sdm_mod_vals[sdm] / pp[4];
+                       ret = (r0 - r1) / m;
+               } else {
+                       /* integer divider */
+                       u32 n = FIELD_GET(MASK_DIVN, reg2) + 1;
+
+                       ret = (prate / m * n) >> r;
+               }
+       } else {
+               u32 fbdiv = ((reg >> clk->div_shift) & ((1 << clk->div_width) - 1)) + 1;
+
+               ret = clk->brate * fbdiv;
+       }
+
+       return ret;
+}
+
+static int sp_pll_set_rate(struct clk_hw *hw, unsigned long rate,
+                          unsigned long prate)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+       unsigned long flags;
+       u32 reg;
+
+       reg = BIT(clk->bp_bit + 16); /* HIWORD_MASK */
+
+       if (rate == prate) {
+               reg |= BIT(clk->bp_bit); /* bypass */
+       } else if (clk->div_width == DIV_A) {
+               return plla_set_rate(clk);
+       } else if (clk->div_width == DIV_TV) {
+               return plltv_set_rate(clk);
+       } else if (clk->div_width) {
+               u32 fbdiv = sp_pll_calc_div(clk, rate);
+               u32 mask = GENMASK(clk->div_shift + clk->div_width - 1, clk->div_shift);
+
+               reg |= mask << 16;
+               reg |= ((fbdiv - 1) << clk->div_shift) & mask;
+       }
+
+       spin_lock_irqsave(&clk->lock, flags);
+       writel(reg, clk->reg);
+       spin_unlock_irqrestore(&clk->lock, flags);
+
+       return 0;
+}
+
+static int sp_pll_enable(struct clk_hw *hw)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+
+       writel(BIT(clk->pd_bit + 16) | BIT(clk->pd_bit), clk->reg);
+
+       return 0;
+}
+
+static void sp_pll_disable(struct clk_hw *hw)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+
+       writel(BIT(clk->pd_bit + 16), clk->reg);
+}
+
+static int sp_pll_is_enabled(struct clk_hw *hw)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+
+       return readl(clk->reg) & BIT(clk->pd_bit);
+}
+
+static const struct clk_ops sp_pll_ops = {
+       .enable = sp_pll_enable,
+       .disable = sp_pll_disable,
+       .is_enabled = sp_pll_is_enabled,
+       .round_rate = sp_pll_round_rate,
+       .recalc_rate = sp_pll_recalc_rate,
+       .set_rate = sp_pll_set_rate
+};
+
+static const struct clk_ops sp_pll_sub_ops = {
+       .enable = sp_pll_enable,
+       .disable = sp_pll_disable,
+       .is_enabled = sp_pll_is_enabled,
+       .recalc_rate = sp_pll_recalc_rate,
+};
+
+static struct clk_hw *sp_pll_register(struct device *dev, const char *name,
+                                     const struct clk_parent_data *parent_data,
+                                     void __iomem *reg, int pd_bit, int bp_bit,
+                                     unsigned long brate, int shift, int width,
+                                     unsigned long flags)
+{
+       struct sp_pll *pll;
+       struct clk_hw *hw;
+       struct clk_init_data initd = {
+               .name = name,
+               .parent_data = parent_data,
+               .ops = (bp_bit >= 0) ? &sp_pll_ops : &sp_pll_sub_ops,
+               .num_parents = 1,
+               .flags = flags,
+       };
+       int ret;
+
+       pll = devm_kzalloc(dev, sizeof(*pll), GFP_KERNEL);
+       if (!pll)
+               return ERR_PTR(-ENOMEM);
+
+       pll->hw.init = &initd;
+       pll->reg = reg;
+       pll->pd_bit = pd_bit;
+       pll->bp_bit = bp_bit;
+       pll->brate = brate;
+       pll->div_shift = shift;
+       pll->div_width = width;
+       spin_lock_init(&pll->lock);
+
+       hw = &pll->hw;
+       ret = devm_clk_hw_register(dev, hw);
+       if (ret)
+               return ERR_PTR(ret);
+
+       return hw;
+}
+
+#define PLLA_CTL       (pll_base + 0x1c)
+#define PLLE_CTL       (pll_base + 0x30)
+#define PLLF_CTL       (pll_base + 0x34)
+#define PLLTV_CTL      (pll_base + 0x38)
+
+static int sp7021_clk_probe(struct platform_device *pdev)
+{
+       static const u32 sp_clken[] = {
+               0x67ef, 0x03ff, 0xff03, 0xfff0, 0x0004, /* G0.1~5  */
+               0x0000, 0x8000, 0xffff, 0x0040, 0x0000, /* G0.6~10 */
+       };
+       static struct clk_parent_data pd_ext, pd_sys, pd_e;
+       struct device *dev = &pdev->dev;
+       void __iomem *clk_base, *pll_base, *sys_base;
+       struct clk_hw_onecell_data *clk_data;
+       struct clk_hw **hws;
+       int i;
+
+       clk_base = devm_platform_ioremap_resource(pdev, 0);
+       if (!clk_base)
+               return -ENXIO;
+       pll_base = devm_platform_ioremap_resource(pdev, 1);
+       if (!pll_base)
+               return -ENXIO;
+       sys_base = devm_platform_ioremap_resource(pdev, 2);
+       if (!sys_base)
+               return -ENXIO;
+
+       /* enable default clks */
+       for (i = 0; i < ARRAY_SIZE(sp_clken); i++)
+               writel((sp_clken[i] << 16) | sp_clken[i], clk_base + i * 4);
+
+       clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, CLK_MAX),
+                               GFP_KERNEL);
+       if (!clk_data)
+               return -ENOMEM;
+
+       hws = clk_data->hws;
+       pd_ext.index = 0;
+
+       /* PLLs */
+       hws[PLL_A] = sp_pll_register(dev, "plla", &pd_ext, PLLA_CTL,
+                                    11, 12, 27000000, 0, DIV_A, 0);
+       if (IS_ERR(hws[PLL_A]))
+               return PTR_ERR(hws[PLL_A]);
+
+       hws[PLL_E] = sp_pll_register(dev, "plle", &pd_ext, PLLE_CTL,
+                                    6, 2, 50000000, 0, 0, 0);
+       if (IS_ERR(hws[PLL_E]))
+               return PTR_ERR(hws[PLL_E]);
+       pd_e.hw = hws[PLL_E];
+       hws[PLL_E_2P5] = sp_pll_register(dev, "plle_2p5", &pd_e, PLLE_CTL,
+                                        13, -1, 2500000, 0, 0, 0);
+       if (IS_ERR(hws[PLL_E_2P5]))
+               return PTR_ERR(hws[PLL_E_2P5]);
+       hws[PLL_E_25] = sp_pll_register(dev, "plle_25", &pd_e, PLLE_CTL,
+                                       12, -1, 25000000, 0, 0, 0);
+       if (IS_ERR(hws[PLL_E_25]))
+               return PTR_ERR(hws[PLL_E_25]);
+       hws[PLL_E_112P5] = sp_pll_register(dev, "plle_112p5", &pd_e, PLLE_CTL,
+                                          11, -1, 112500000, 0, 0, 0);
+       if (IS_ERR(hws[PLL_E_112P5]))
+               return PTR_ERR(hws[PLL_E_112P5]);
+
+       hws[PLL_F] = sp_pll_register(dev, "pllf", &pd_ext, PLLF_CTL,
+                                    0, 10, 13500000, 1, 4, 0);
+       if (IS_ERR(hws[PLL_F]))
+               return PTR_ERR(hws[PLL_F]);
+
+       hws[PLL_TV] = sp_pll_register(dev, "plltv", &pd_ext, PLLTV_CTL,
+                                     0, 15, 27000000, 0, DIV_TV, 0);
+       if (IS_ERR(hws[PLL_TV]))
+               return PTR_ERR(hws[PLL_TV]);
+       hws[PLL_TV_A] = devm_clk_hw_register_divider(dev, "plltv_a", "plltv", 0,
+                                                    PLLTV_CTL + 4, 5, 1,
+                                                    CLK_DIVIDER_POWER_OF_TWO,
+                                                    &to_sp_pll(hws[PLL_TV])->lock);
+       if (IS_ERR(hws[PLL_TV_A]))
+               return PTR_ERR(hws[PLL_TV_A]);
+
+       /* system clock, should not be disabled */
+       hws[PLL_SYS] = sp_pll_register(dev, "pllsys", &pd_ext, sys_base,
+                                      10, 9, 13500000, 0, 4, CLK_IS_CRITICAL);
+       if (IS_ERR(hws[PLL_SYS]))
+               return PTR_ERR(hws[PLL_SYS]);
+       pd_sys.hw = hws[PLL_SYS];
+
+       /* gates */
+       for (i = 0; i < ARRAY_SIZE(sp_clk_gates); i++) {
+               char name[10];
+               u32 j = sp_clk_gates[i].reg;
+               struct clk_parent_data *pd = sp_clk_gates[i].ext_parent ? &pd_ext : &pd_sys;
+
+               sprintf(name, "%02d_0x%02x", i, j);
+               hws[i] = devm_clk_hw_register_gate_parent_data(dev, name, pd, 0,
+                                                              clk_base + (j >> 4) * 4,
+                                                              j & 0x0f,
+                                                              CLK_GATE_HIWORD_MASK,
+                                                              NULL);
+               if (IS_ERR(hws[i]))
+                       return PTR_ERR(hws[i]);
+       }
+
+       clk_data->num = CLK_MAX;
+
+       return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
+}
+
+static const struct of_device_id sp7021_clk_dt_ids[] = {
+       { .compatible = "sunplus,sp7021-clkc" },
+       { }
+};
+MODULE_DEVICE_TABLE(of, sp7021_clk_dt_ids);
+
+static struct platform_driver sp7021_clk_driver = {
+       .probe  = sp7021_clk_probe,
+       .driver = {
+               .name = "sp7021-clk",
+               .of_match_table = sp7021_clk_dt_ids,
+       },
+};
+module_platform_driver(sp7021_clk_driver);
+
+MODULE_AUTHOR("Sunplus Technology");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Clock driver for Sunplus SP7021 SoC");
index 1a701eada0c1a3c8d99e486455f129ae91814eb6..04c18a1d45d348c2c74364dc79e21d6635a31d5b 100644 (file)
@@ -667,7 +667,6 @@ struct stm32_fractional_divider {
        void __iomem    *mreg;
        u8              mshift;
        u8              mwidth;
-       u32             mmask;
 
        void __iomem    *nreg;
        u8              nshift;
index 01e5a466897f8e4f80e99f39a764500e3ddc853d..939779f66867e01af304e9a3c68aa459298ca565 100644 (file)
@@ -2434,15 +2434,13 @@ static int stm32mp1_rcc_clocks_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int stm32mp1_rcc_clocks_remove(struct platform_device *pdev)
+static void stm32mp1_rcc_clocks_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct device_node *child, *np = dev_of_node(dev);
 
        for_each_available_child_of_node(np, child)
                of_clk_del_provider(child);
-
-       return 0;
 }
 
 static struct platform_driver stm32mp1_rcc_clocks_driver = {
@@ -2451,7 +2449,7 @@ static struct platform_driver stm32mp1_rcc_clocks_driver = {
                .of_match_table = stm32mp1_match_data,
        },
        .probe = stm32mp1_rcc_clocks_probe,
-       .remove = stm32mp1_rcc_clocks_remove,
+       .remove_new = stm32mp1_rcc_clocks_remove,
 };
 
 static int __init stm32mp1_clocks_init(void)
index ae07685c7588b0bef2136ff4f00f5904af3fa906..27c30a533759ad390b3576f8aceebe5a3c3bbfc9 100644 (file)
@@ -1406,6 +1406,8 @@ static int __init clk_disable_unused(void)
                return 0;
        }
 
+       pr_info("clk: Disabling unused clocks\n");
+
        clk_prepare_lock();
 
        hlist_for_each_entry(core, &clk_root_list, child_node)
@@ -3194,7 +3196,7 @@ static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c,
 static int clk_summary_show(struct seq_file *s, void *data)
 {
        struct clk_core *c;
-       struct hlist_head **lists = (struct hlist_head **)s->private;
+       struct hlist_head **lists = s->private;
 
        seq_puts(s, "                                 enable  prepare  protect                                duty  hardware\n");
        seq_puts(s, "   clock                          count    count    count        rate   accuracy phase  cycle    enable\n");
@@ -3253,7 +3255,7 @@ static int clk_dump_show(struct seq_file *s, void *data)
 {
        struct clk_core *c;
        bool first_node = true;
-       struct hlist_head **lists = (struct hlist_head **)s->private;
+       struct hlist_head **lists = s->private;
 
        seq_putc(s, '{');
        clk_prepare_lock();
@@ -4880,8 +4882,8 @@ static struct device_node *get_clk_provider_node(struct device *dev)
        np = dev->of_node;
        parent_np = dev->parent ? dev->parent->of_node : NULL;
 
-       if (!of_find_property(np, "#clock-cells", NULL))
-               if (of_find_property(parent_np, "#clock-cells", NULL))
+       if (!of_property_present(np, "#clock-cells"))
+               if (of_property_present(parent_np, "#clock-cells"))
                        np = parent_np;
 
        return np;
index ad0c7f350cf0314845edff48b053accd0a187b3b..b871872d9960db03e1493bbc64d5b1499f0f6367 100644 (file)
@@ -162,13 +162,12 @@ static int hi3519_clk_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int hi3519_clk_remove(struct platform_device *pdev)
+static void hi3519_clk_remove(struct platform_device *pdev)
 {
        struct hi3519_crg_data *crg = platform_get_drvdata(pdev);
 
        hisi_reset_exit(crg->rstc);
        hi3519_clk_unregister(pdev);
-       return 0;
 }
 
 
@@ -180,7 +179,7 @@ MODULE_DEVICE_TABLE(of, hi3519_clk_match_table);
 
 static struct platform_driver hi3519_clk_driver = {
        .probe          = hi3519_clk_probe,
-       .remove         = hi3519_clk_remove,
+       .remove_new     = hi3519_clk_remove,
        .driver         = {
                .name   = "hi3519-clk",
                .of_match_table = hi3519_clk_match_table,
index 9ea1a80acbe8b5be6475d2f729e5609c0a61d3a9..4f97638809b7b6fab648343ee439f879bdbf24f7 100644 (file)
@@ -810,18 +810,17 @@ static int hi3559av100_crg_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int hi3559av100_crg_remove(struct platform_device *pdev)
+static void hi3559av100_crg_remove(struct platform_device *pdev)
 {
        struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
 
        hisi_reset_exit(crg->rstc);
        crg->funcs->unregister_clks(pdev);
-       return 0;
 }
 
 static struct platform_driver hi3559av100_crg_driver = {
        .probe          = hi3559av100_crg_probe,
-       .remove         = hi3559av100_crg_remove,
+       .remove_new     = hi3559av100_crg_remove,
        .driver         = {
                .name   = "hi3559av100-clock",
                .of_match_table = hi3559av100_crg_match_table,
index 5d4e61c7a42952a1895e740ab304db7a934946c8..fe1bd3e3f98841324318f2a489f2ba5dbf5a78dc 100644 (file)
@@ -284,18 +284,17 @@ static int hi3516cv300_crg_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int hi3516cv300_crg_remove(struct platform_device *pdev)
+static void hi3516cv300_crg_remove(struct platform_device *pdev)
 {
        struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
 
        hisi_reset_exit(crg->rstc);
        crg->funcs->unregister_clks(pdev);
-       return 0;
 }
 
 static struct platform_driver hi3516cv300_crg_driver = {
        .probe          = hi3516cv300_crg_probe,
-       .remove         = hi3516cv300_crg_remove,
+       .remove_new     = hi3516cv300_crg_remove,
        .driver         = {
                .name   = "hi3516cv300-crg",
                .of_match_table = hi3516cv300_crg_match_table,
index 08a19ba776e62efe3dd421a8733fef9fb1007652..a0b16be1e25d9166808b238af3772376eea5e009 100644 (file)
@@ -367,18 +367,17 @@ static int hi3798cv200_crg_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int hi3798cv200_crg_remove(struct platform_device *pdev)
+static void hi3798cv200_crg_remove(struct platform_device *pdev)
 {
        struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
 
        hisi_reset_exit(crg->rstc);
        crg->funcs->unregister_clks(pdev);
-       return 0;
 }
 
 static struct platform_driver hi3798cv200_crg_driver = {
        .probe          = hi3798cv200_crg_probe,
-       .remove         = hi3798cv200_crg_remove,
+       .remove_new     = hi3798cv200_crg_remove,
        .driver         = {
                .name   = "hi3798cv200-crg",
                .of_match_table = hi3798cv200_crg_match_table,
index 4eedd45dbaa832bdece3f3714a02271a959a32a4..e208ddc511339ea398d15bcf7055e1daf8ed4502 100644 (file)
 #define PCG_CGC_SHIFT  30
 #define PCG_FRAC_SHIFT 3
 #define PCG_FRAC_WIDTH 1
-#define PCG_FRAC_MASK  BIT(3)
 #define PCG_PCD_SHIFT  0
 #define PCG_PCD_WIDTH  3
-#define PCG_PCD_MASK   0x7
 
 #define SW_RST         BIT(28)
 
@@ -102,10 +100,8 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name,
                fd->reg = reg;
                fd->mshift = PCG_FRAC_SHIFT;
                fd->mwidth = PCG_FRAC_WIDTH;
-               fd->mmask  = PCG_FRAC_MASK;
                fd->nshift = PCG_PCD_SHIFT;
                fd->nwidth = PCG_PCD_WIDTH;
-               fd->nmask = PCG_PCD_MASK;
                fd->flags = CLK_FRAC_DIVIDER_ZERO_BASED;
                if (has_swrst)
                        fd->lock = &imx_ccm_lock;
index d4b4e74e22da60f72cd6a5ad141fe54a762c4fe6..910ecd58c4ca2e7eae7496adf81faca55e97600a 100644 (file)
@@ -689,16 +689,14 @@ static int ti_sci_clk_probe(struct platform_device *pdev)
  * via common clock framework. Any memory allocated for the device will
  * be free'd silently via the devm framework. Returns 0 always.
  */
-static int ti_sci_clk_remove(struct platform_device *pdev)
+static void ti_sci_clk_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-
-       return 0;
 }
 
 static struct platform_driver ti_sci_clk_driver = {
        .probe = ti_sci_clk_probe,
-       .remove = ti_sci_clk_remove,
+       .remove_new = ti_sci_clk_remove,
        .driver = {
                .name = "ti-sci-clk",
                .of_match_table = of_match_ptr(ti_sci_clk_of_match),
diff --git a/drivers/clk/loongson1/Makefile b/drivers/clk/loongson1/Makefile
deleted file mode 100644 (file)
index 251d0fe..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-obj-y                          += clk.o
-obj-$(CONFIG_LOONGSON1_LS1B)   += clk-loongson1b.o
-obj-$(CONFIG_LOONGSON1_LS1C)   += clk-loongson1c.o
diff --git a/drivers/clk/loongson1/clk-loongson1b.c b/drivers/clk/loongson1/clk-loongson1b.c
deleted file mode 100644 (file)
index 13a2ca2..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com>
- */
-
-#include <linux/clkdev.h>
-#include <linux/clk-provider.h>
-#include <linux/io.h>
-#include <linux/err.h>
-
-#include <loongson1.h>
-#include "clk.h"
-
-#define OSC            (33 * 1000000)
-#define DIV_APB                2
-
-static DEFINE_SPINLOCK(_lock);
-
-static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw,
-                                         unsigned long parent_rate)
-{
-       u32 pll, rate;
-
-       pll = __raw_readl(LS1X_CLK_PLL_FREQ);
-       rate = 12 + (pll & GENMASK(5, 0));
-       rate *= OSC;
-       rate >>= 1;
-
-       return rate;
-}
-
-static const struct clk_ops ls1x_pll_clk_ops = {
-       .recalc_rate = ls1x_pll_recalc_rate,
-};
-
-static const char *const cpu_parents[] = { "cpu_clk_div", "osc_clk", };
-static const char *const ahb_parents[] = { "ahb_clk_div", "osc_clk", };
-static const char *const dc_parents[] = { "dc_clk_div", "osc_clk", };
-
-void __init ls1x_clk_init(void)
-{
-       struct clk_hw *hw;
-
-       hw = clk_hw_register_fixed_rate(NULL, "osc_clk", NULL, 0, OSC);
-       clk_hw_register_clkdev(hw, "osc_clk", NULL);
-
-       /* clock derived from 33 MHz OSC clk */
-       hw = clk_hw_register_pll(NULL, "pll_clk", "osc_clk",
-                                &ls1x_pll_clk_ops, 0);
-       clk_hw_register_clkdev(hw, "pll_clk", NULL);
-
-       /* clock derived from PLL clk */
-       /*                                 _____
-        *         _______________________|     |
-        * OSC ___/                       | MUX |___ CPU CLK
-        *        \___ PLL ___ CPU DIV ___|     |
-        *                                |_____|
-        */
-       hw = clk_hw_register_divider(NULL, "cpu_clk_div", "pll_clk",
-                                  CLK_GET_RATE_NOCACHE, LS1X_CLK_PLL_DIV,
-                                  DIV_CPU_SHIFT, DIV_CPU_WIDTH,
-                                  CLK_DIVIDER_ONE_BASED |
-                                  CLK_DIVIDER_ROUND_CLOSEST, &_lock);
-       clk_hw_register_clkdev(hw, "cpu_clk_div", NULL);
-       hw = clk_hw_register_mux(NULL, "cpu_clk", cpu_parents,
-                              ARRAY_SIZE(cpu_parents),
-                              CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV,
-                              BYPASS_CPU_SHIFT, BYPASS_CPU_WIDTH, 0, &_lock);
-       clk_hw_register_clkdev(hw, "cpu_clk", NULL);
-
-       /*                                 _____
-        *         _______________________|     |
-        * OSC ___/                       | MUX |___ DC  CLK
-        *        \___ PLL ___ DC  DIV ___|     |
-        *                                |_____|
-        */
-       hw = clk_hw_register_divider(NULL, "dc_clk_div", "pll_clk",
-                                  0, LS1X_CLK_PLL_DIV, DIV_DC_SHIFT,
-                                  DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock);
-       clk_hw_register_clkdev(hw, "dc_clk_div", NULL);
-       hw = clk_hw_register_mux(NULL, "dc_clk", dc_parents,
-                              ARRAY_SIZE(dc_parents),
-                              CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV,
-                              BYPASS_DC_SHIFT, BYPASS_DC_WIDTH, 0, &_lock);
-       clk_hw_register_clkdev(hw, "dc_clk", NULL);
-
-       /*                                 _____
-        *         _______________________|     |
-        * OSC ___/                       | MUX |___ DDR CLK
-        *        \___ PLL ___ DDR DIV ___|     |
-        *                                |_____|
-        */
-       hw = clk_hw_register_divider(NULL, "ahb_clk_div", "pll_clk",
-                                  0, LS1X_CLK_PLL_DIV, DIV_DDR_SHIFT,
-                                  DIV_DDR_WIDTH, CLK_DIVIDER_ONE_BASED,
-                                  &_lock);
-       clk_hw_register_clkdev(hw, "ahb_clk_div", NULL);
-       hw = clk_hw_register_mux(NULL, "ahb_clk", ahb_parents,
-                              ARRAY_SIZE(ahb_parents),
-                              CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV,
-                              BYPASS_DDR_SHIFT, BYPASS_DDR_WIDTH, 0, &_lock);
-       clk_hw_register_clkdev(hw, "ahb_clk", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-dma", NULL);
-       clk_hw_register_clkdev(hw, "stmmaceth", NULL);
-
-       /* clock derived from AHB clk */
-       /* APB clk is always half of the AHB clk */
-       hw = clk_hw_register_fixed_factor(NULL, "apb_clk", "ahb_clk", 0, 1,
-                                       DIV_APB);
-       clk_hw_register_clkdev(hw, "apb_clk", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-ac97", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-i2c", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-nand", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-pwmtimer", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-spi", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-wdt", NULL);
-       clk_hw_register_clkdev(hw, "serial8250", NULL);
-}
diff --git a/drivers/clk/loongson1/clk-loongson1c.c b/drivers/clk/loongson1/clk-loongson1c.c
deleted file mode 100644 (file)
index 1ebf740..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (c) 2016 Yang Ling <gnaygnil@gmail.com>
- */
-
-#include <linux/clkdev.h>
-#include <linux/clk-provider.h>
-#include <linux/io.h>
-
-#include <loongson1.h>
-#include "clk.h"
-
-#define OSC            (24 * 1000000)
-#define DIV_APB                1
-
-static DEFINE_SPINLOCK(_lock);
-
-static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw,
-                                         unsigned long parent_rate)
-{
-       u32 pll, rate;
-
-       pll = __raw_readl(LS1X_CLK_PLL_FREQ);
-       rate = ((pll >> 8) & 0xff) + ((pll >> 16) & 0xff);
-       rate *= OSC;
-       rate >>= 2;
-
-       return rate;
-}
-
-static const struct clk_ops ls1x_pll_clk_ops = {
-       .recalc_rate = ls1x_pll_recalc_rate,
-};
-
-static const struct clk_div_table ahb_div_table[] = {
-       [0] = { .val = 0, .div = 2 },
-       [1] = { .val = 1, .div = 4 },
-       [2] = { .val = 2, .div = 3 },
-       [3] = { .val = 3, .div = 3 },
-       [4] = { /* sentinel */ }
-};
-
-void __init ls1x_clk_init(void)
-{
-       struct clk_hw *hw;
-
-       hw = clk_hw_register_fixed_rate(NULL, "osc_clk", NULL, 0, OSC);
-       clk_hw_register_clkdev(hw, "osc_clk", NULL);
-
-       /* clock derived from 24 MHz OSC clk */
-       hw = clk_hw_register_pll(NULL, "pll_clk", "osc_clk",
-                               &ls1x_pll_clk_ops, 0);
-       clk_hw_register_clkdev(hw, "pll_clk", NULL);
-
-       hw = clk_hw_register_divider(NULL, "cpu_clk_div", "pll_clk",
-                                  CLK_GET_RATE_NOCACHE, LS1X_CLK_PLL_DIV,
-                                  DIV_CPU_SHIFT, DIV_CPU_WIDTH,
-                                  CLK_DIVIDER_ONE_BASED |
-                                  CLK_DIVIDER_ROUND_CLOSEST, &_lock);
-       clk_hw_register_clkdev(hw, "cpu_clk_div", NULL);
-       hw = clk_hw_register_fixed_factor(NULL, "cpu_clk", "cpu_clk_div",
-                                       0, 1, 1);
-       clk_hw_register_clkdev(hw, "cpu_clk", NULL);
-
-       hw = clk_hw_register_divider(NULL, "dc_clk_div", "pll_clk",
-                                  0, LS1X_CLK_PLL_DIV, DIV_DC_SHIFT,
-                                  DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock);
-       clk_hw_register_clkdev(hw, "dc_clk_div", NULL);
-       hw = clk_hw_register_fixed_factor(NULL, "dc_clk", "dc_clk_div",
-                                       0, 1, 1);
-       clk_hw_register_clkdev(hw, "dc_clk", NULL);
-
-       hw = clk_hw_register_divider_table(NULL, "ahb_clk_div", "cpu_clk_div",
-                               0, LS1X_CLK_PLL_FREQ, DIV_DDR_SHIFT,
-                               DIV_DDR_WIDTH, CLK_DIVIDER_ALLOW_ZERO,
-                               ahb_div_table, &_lock);
-       clk_hw_register_clkdev(hw, "ahb_clk_div", NULL);
-       hw = clk_hw_register_fixed_factor(NULL, "ahb_clk", "ahb_clk_div",
-                                       0, 1, 1);
-       clk_hw_register_clkdev(hw, "ahb_clk", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-dma", NULL);
-       clk_hw_register_clkdev(hw, "stmmaceth", NULL);
-
-       /* clock derived from AHB clk */
-       hw = clk_hw_register_fixed_factor(NULL, "apb_clk", "ahb_clk", 0, 1,
-                                       DIV_APB);
-       clk_hw_register_clkdev(hw, "apb_clk", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-ac97", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-i2c", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-nand", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-pwmtimer", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-spi", NULL);
-       clk_hw_register_clkdev(hw, "ls1x-wdt", NULL);
-       clk_hw_register_clkdev(hw, "serial8250", NULL);
-}
diff --git a/drivers/clk/loongson1/clk.c b/drivers/clk/loongson1/clk.c
deleted file mode 100644 (file)
index f336a31..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com>
- */
-
-#include <linux/clk-provider.h>
-#include <linux/slab.h>
-
-#include "clk.h"
-
-struct clk_hw *__init clk_hw_register_pll(struct device *dev,
-                                         const char *name,
-                                         const char *parent_name,
-                                         const struct clk_ops *ops,
-                                         unsigned long flags)
-{
-       int ret;
-       struct clk_hw *hw;
-       struct clk_init_data init;
-
-       /* allocate the divider */
-       hw = kzalloc(sizeof(*hw), GFP_KERNEL);
-       if (!hw)
-               return ERR_PTR(-ENOMEM);
-
-       init.name = name;
-       init.ops = ops;
-       init.flags = flags;
-       init.parent_names = parent_name ? &parent_name : NULL;
-       init.num_parents = parent_name ? 1 : 0;
-       hw->init = &init;
-
-       /* register the clock */
-       ret = clk_hw_register(dev, hw);
-       if (ret) {
-               kfree(hw);
-               hw = ERR_PTR(ret);
-       }
-
-       return hw;
-}
diff --git a/drivers/clk/loongson1/clk.h b/drivers/clk/loongson1/clk.h
deleted file mode 100644 (file)
index 1246423..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com>
- */
-
-#ifndef __LOONGSON1_CLK_H
-#define __LOONGSON1_CLK_H
-
-struct clk_hw *clk_hw_register_pll(struct device *dev,
-                                  const char *name,
-                                  const char *parent_name,
-                                  const struct clk_ops *ops,
-                                  unsigned long flags);
-
-#endif /* __LOONGSON1_CLK_H */
index 2d14855dd37ef8b538c64e6ea7fdad41def42258..99e67c07e6385a3c76206241c7ac1ed8a9925223 100644 (file)
@@ -75,7 +75,7 @@ config COMMON_CLK_MT2701_G3DSYS
          This driver supports MediaTek MT2701 g3dsys clocks.
 
 config COMMON_CLK_MT2712
-       bool "Clock driver for MediaTek MT2712"
+       tristate "Clock driver for MediaTek MT2712"
        depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
        default ARCH_MEDIATEK && ARM64
@@ -83,43 +83,43 @@ config COMMON_CLK_MT2712
          This driver supports MediaTek MT2712 basic clocks.
 
 config COMMON_CLK_MT2712_BDPSYS
-       bool "Clock driver for MediaTek MT2712 bdpsys"
+       tristate "Clock driver for MediaTek MT2712 bdpsys"
        depends on COMMON_CLK_MT2712
        help
          This driver supports MediaTek MT2712 bdpsys clocks.
 
 config COMMON_CLK_MT2712_IMGSYS
-       bool "Clock driver for MediaTek MT2712 imgsys"
+       tristate "Clock driver for MediaTek MT2712 imgsys"
        depends on COMMON_CLK_MT2712
        help
          This driver supports MediaTek MT2712 imgsys clocks.
 
 config COMMON_CLK_MT2712_JPGDECSYS
-       bool "Clock driver for MediaTek MT2712 jpgdecsys"
+       tristate "Clock driver for MediaTek MT2712 jpgdecsys"
        depends on COMMON_CLK_MT2712
        help
          This driver supports MediaTek MT2712 jpgdecsys clocks.
 
 config COMMON_CLK_MT2712_MFGCFG
-       bool "Clock driver for MediaTek MT2712 mfgcfg"
+       tristate "Clock driver for MediaTek MT2712 mfgcfg"
        depends on COMMON_CLK_MT2712
        help
          This driver supports MediaTek MT2712 mfgcfg clocks.
 
 config COMMON_CLK_MT2712_MMSYS
-       bool "Clock driver for MediaTek MT2712 mmsys"
+       tristate "Clock driver for MediaTek MT2712 mmsys"
        depends on COMMON_CLK_MT2712
        help
          This driver supports MediaTek MT2712 mmsys clocks.
 
 config COMMON_CLK_MT2712_VDECSYS
-       bool "Clock driver for MediaTek MT2712 vdecsys"
+       tristate "Clock driver for MediaTek MT2712 vdecsys"
        depends on COMMON_CLK_MT2712
        help
          This driver supports MediaTek MT2712 vdecsys clocks.
 
 config COMMON_CLK_MT2712_VENCSYS
-       bool "Clock driver for MediaTek MT2712 vencsys"
+       tristate "Clock driver for MediaTek MT2712 vencsys"
        depends on COMMON_CLK_MT2712
        help
          This driver supports MediaTek MT2712 vencsys clocks.
@@ -133,79 +133,79 @@ config COMMON_CLK_MT6765
          This driver supports MediaTek MT6765 basic clocks.
 
 config COMMON_CLK_MT6765_AUDIOSYS
-       bool "Clock driver for MediaTek MT6765 audiosys"
+       tristate "Clock driver for MediaTek MT6765 audiosys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 audiosys clocks.
 
 config COMMON_CLK_MT6765_CAMSYS
-       bool "Clock driver for MediaTek MT6765 camsys"
+       tristate "Clock driver for MediaTek MT6765 camsys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 camsys clocks.
 
 config COMMON_CLK_MT6765_GCESYS
-       bool "Clock driver for MediaTek MT6765 gcesys"
+       tristate "Clock driver for MediaTek MT6765 gcesys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 gcesys clocks.
 
 config COMMON_CLK_MT6765_MMSYS
-       bool "Clock driver for MediaTek MT6765 mmsys"
+       tristate "Clock driver for MediaTek MT6765 mmsys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 mmsys clocks.
 
 config COMMON_CLK_MT6765_IMGSYS
-       bool "Clock driver for MediaTek MT6765 imgsys"
+       tristate "Clock driver for MediaTek MT6765 imgsys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 imgsys clocks.
 
 config COMMON_CLK_MT6765_VCODECSYS
-       bool "Clock driver for MediaTek MT6765 vcodecsys"
+       tristate "Clock driver for MediaTek MT6765 vcodecsys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 vcodecsys clocks.
 
 config COMMON_CLK_MT6765_MFGSYS
-       bool "Clock driver for MediaTek MT6765 mfgsys"
+       tristate "Clock driver for MediaTek MT6765 mfgsys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 mfgsys clocks.
 
 config COMMON_CLK_MT6765_MIPI0ASYS
-       bool "Clock driver for MediaTek MT6765 mipi0asys"
+       tristate "Clock driver for MediaTek MT6765 mipi0asys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 mipi0asys clocks.
 
 config COMMON_CLK_MT6765_MIPI0BSYS
-       bool "Clock driver for MediaTek MT6765 mipi0bsys"
+       tristate "Clock driver for MediaTek MT6765 mipi0bsys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 mipi0bsys clocks.
 
 config COMMON_CLK_MT6765_MIPI1ASYS
-       bool "Clock driver for MediaTek MT6765 mipi1asys"
+       tristate "Clock driver for MediaTek MT6765 mipi1asys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 mipi1asys clocks.
 
 config COMMON_CLK_MT6765_MIPI1BSYS
-       bool "Clock driver for MediaTek MT6765 mipi1bsys"
+       tristate "Clock driver for MediaTek MT6765 mipi1bsys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 mipi1bsys clocks.
 
 config COMMON_CLK_MT6765_MIPI2ASYS
-       bool "Clock driver for MediaTek MT6765 mipi2asys"
+       tristate "Clock driver for MediaTek MT6765 mipi2asys"
        depends on COMMON_CLK_MT6765
       help
          This driver supports MediaTek MT6765 mipi2asys clocks.
 
 config COMMON_CLK_MT6765_MIPI2BSYS
-       bool "Clock driver for MediaTek MT6765 mipi2bsys"
+       tristate "Clock driver for MediaTek MT6765 mipi2bsys"
        depends on COMMON_CLK_MT6765
        help
          This driver supports MediaTek MT6765 mipi2bsys clocks.
@@ -270,6 +270,7 @@ config COMMON_CLK_MT6795
        tristate "Clock driver for MediaTek MT6795"
        depends on ARCH_MEDIATEK || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
+       select COMMON_CLK_MEDIATEK_FHCTL
        default ARCH_MEDIATEK
        help
          This driver supports MediaTek MT6795 basic clocks and clocks
@@ -312,31 +313,31 @@ config COMMON_CLK_MT6797
          This driver supports MediaTek MT6797 basic clocks.
 
 config COMMON_CLK_MT6797_MMSYS
-       bool "Clock driver for MediaTek MT6797 mmsys"
+       tristate "Clock driver for MediaTek MT6797 mmsys"
        depends on COMMON_CLK_MT6797
        help
          This driver supports MediaTek MT6797 mmsys clocks.
 
 config COMMON_CLK_MT6797_IMGSYS
-       bool "Clock driver for MediaTek MT6797 imgsys"
+       tristate "Clock driver for MediaTek MT6797 imgsys"
        depends on COMMON_CLK_MT6797
        help
          This driver supports MediaTek MT6797 imgsys clocks.
 
 config COMMON_CLK_MT6797_VDECSYS
-       bool "Clock driver for MediaTek MT6797 vdecsys"
+       tristate "Clock driver for MediaTek MT6797 vdecsys"
        depends on COMMON_CLK_MT6797
        help
          This driver supports MediaTek MT6797 vdecsys clocks.
 
 config COMMON_CLK_MT6797_VENCSYS
-       bool "Clock driver for MediaTek MT6797 vencsys"
+       tristate "Clock driver for MediaTek MT6797 vencsys"
        depends on COMMON_CLK_MT6797
        help
          This driver supports MediaTek MT6797 vencsys clocks.
 
 config COMMON_CLK_MT7622
-       bool "Clock driver for MediaTek MT7622"
+       tristate "Clock driver for MediaTek MT7622"
        depends on ARCH_MEDIATEK || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
        default ARCH_MEDIATEK
@@ -345,21 +346,21 @@ config COMMON_CLK_MT7622
          required for various periperals found on MediaTek.
 
 config COMMON_CLK_MT7622_ETHSYS
-       bool "Clock driver for MediaTek MT7622 ETHSYS"
+       tristate "Clock driver for MediaTek MT7622 ETHSYS"
        depends on COMMON_CLK_MT7622
        help
          This driver add support for clocks for Ethernet and SGMII
          required on MediaTek MT7622 SoC.
 
 config COMMON_CLK_MT7622_HIFSYS
-       bool "Clock driver for MediaTek MT7622 HIFSYS"
+       tristate "Clock driver for MediaTek MT7622 HIFSYS"
        depends on COMMON_CLK_MT7622
        help
          This driver supports MediaTek MT7622 HIFSYS clocks providing
          to PCI-E and USB.
 
 config COMMON_CLK_MT7622_AUDSYS
-       bool "Clock driver for MediaTek MT7622 AUDSYS"
+       tristate "Clock driver for MediaTek MT7622 AUDSYS"
        depends on COMMON_CLK_MT7622
        help
          This driver supports MediaTek MT7622 AUDSYS clocks providing
@@ -406,7 +407,7 @@ config COMMON_CLK_MT7981_ETHSYS
          required on MediaTek MT7981 SoC.
 
 config COMMON_CLK_MT7986
-       bool "Clock driver for MediaTek MT7986"
+       tristate "Clock driver for MediaTek MT7986"
        depends on ARCH_MEDIATEK || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
        default ARCH_MEDIATEK
@@ -415,7 +416,7 @@ config COMMON_CLK_MT7986
          required for various peripherals found on MediaTek.
 
 config COMMON_CLK_MT7986_ETHSYS
-       bool "Clock driver for MediaTek MT7986 ETHSYS"
+       tristate "Clock driver for MediaTek MT7986 ETHSYS"
        depends on COMMON_CLK_MT7986
        default COMMON_CLK_MT7986
        help
@@ -423,7 +424,7 @@ config COMMON_CLK_MT7986_ETHSYS
          required on MediaTek MT7986 SoC.
 
 config COMMON_CLK_MT8135
-       bool "Clock driver for MediaTek MT8135"
+       tristate "Clock driver for MediaTek MT8135"
        depends on (ARCH_MEDIATEK && ARM) || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
        default ARCH_MEDIATEK && ARM
@@ -431,7 +432,7 @@ config COMMON_CLK_MT8135
          This driver supports MediaTek MT8135 clocks.
 
 config COMMON_CLK_MT8167
-       bool "Clock driver for MediaTek MT8167"
+       tristate "Clock driver for MediaTek MT8167"
        depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
        default ARCH_MEDIATEK
@@ -439,35 +440,35 @@ config COMMON_CLK_MT8167
          This driver supports MediaTek MT8167 basic clocks.
 
 config COMMON_CLK_MT8167_AUDSYS
-       bool "Clock driver for MediaTek MT8167 audsys"
+       tristate "Clock driver for MediaTek MT8167 audsys"
        depends on COMMON_CLK_MT8167
        default COMMON_CLK_MT8167
        help
          This driver supports MediaTek MT8167 audsys clocks.
 
 config COMMON_CLK_MT8167_IMGSYS
-       bool "Clock driver for MediaTek MT8167 imgsys"
+       tristate "Clock driver for MediaTek MT8167 imgsys"
        depends on COMMON_CLK_MT8167
        default COMMON_CLK_MT8167
        help
          This driver supports MediaTek MT8167 imgsys clocks.
 
 config COMMON_CLK_MT8167_MFGCFG
-       bool "Clock driver for MediaTek MT8167 mfgcfg"
+       tristate "Clock driver for MediaTek MT8167 mfgcfg"
        depends on COMMON_CLK_MT8167
        default COMMON_CLK_MT8167
        help
          This driver supports MediaTek MT8167 mfgcfg clocks.
 
 config COMMON_CLK_MT8167_MMSYS
-       bool "Clock driver for MediaTek MT8167 mmsys"
+       tristate "Clock driver for MediaTek MT8167 mmsys"
        depends on COMMON_CLK_MT8167
        default COMMON_CLK_MT8167
        help
          This driver supports MediaTek MT8167 mmsys clocks.
 
 config COMMON_CLK_MT8167_VDECSYS
-       bool "Clock driver for MediaTek MT8167 vdecsys"
+       tristate "Clock driver for MediaTek MT8167 vdecsys"
        depends on COMMON_CLK_MT8167
        default COMMON_CLK_MT8167
        help
@@ -477,6 +478,7 @@ config COMMON_CLK_MT8173
        tristate "Clock driver for MediaTek MT8173"
        depends on ARM64 || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
+       select COMMON_CLK_MEDIATEK_FHCTL
        default ARCH_MEDIATEK
        help
          This driver supports MediaTek MT8173 basic clocks and clocks
@@ -511,7 +513,7 @@ config COMMON_CLK_MT8173_VENCSYS
          This driver supports MediaTek MT8173 vencsys clocks.
 
 config COMMON_CLK_MT8183
-       bool "Clock driver for MediaTek MT8183"
+       tristate "Clock driver for MediaTek MT8183"
        depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
        default ARCH_MEDIATEK && ARM64
@@ -519,84 +521,84 @@ config COMMON_CLK_MT8183
          This driver supports MediaTek MT8183 basic clocks.
 
 config COMMON_CLK_MT8183_AUDIOSYS
-       bool "Clock driver for MediaTek MT8183 audiosys"
+       tristate "Clock driver for MediaTek MT8183 audiosys"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 audiosys clocks.
 
 config COMMON_CLK_MT8183_CAMSYS
-       bool "Clock driver for MediaTek MT8183 camsys"
+       tristate "Clock driver for MediaTek MT8183 camsys"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 camsys clocks.
 
 config COMMON_CLK_MT8183_IMGSYS
-       bool "Clock driver for MediaTek MT8183 imgsys"
+       tristate "Clock driver for MediaTek MT8183 imgsys"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 imgsys clocks.
 
 config COMMON_CLK_MT8183_IPU_CORE0
-       bool "Clock driver for MediaTek MT8183 ipu_core0"
+       tristate "Clock driver for MediaTek MT8183 ipu_core0"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 ipu_core0 clocks.
 
 config COMMON_CLK_MT8183_IPU_CORE1
-       bool "Clock driver for MediaTek MT8183 ipu_core1"
+       tristate "Clock driver for MediaTek MT8183 ipu_core1"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 ipu_core1 clocks.
 
 config COMMON_CLK_MT8183_IPU_ADL
-       bool "Clock driver for MediaTek MT8183 ipu_adl"
+       tristate "Clock driver for MediaTek MT8183 ipu_adl"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 ipu_adl clocks.
 
 config COMMON_CLK_MT8183_IPU_CONN
-       bool "Clock driver for MediaTek MT8183 ipu_conn"
+       tristate "Clock driver for MediaTek MT8183 ipu_conn"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 ipu_conn clocks.
 
 config COMMON_CLK_MT8183_MFGCFG
-       bool "Clock driver for MediaTek MT8183 mfgcfg"
+       tristate "Clock driver for MediaTek MT8183 mfgcfg"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 mfgcfg clocks.
 
 config COMMON_CLK_MT8183_MMSYS
-       bool "Clock driver for MediaTek MT8183 mmsys"
+       tristate "Clock driver for MediaTek MT8183 mmsys"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 mmsys clocks.
 
 config COMMON_CLK_MT8183_VDECSYS
-       bool "Clock driver for MediaTek MT8183 vdecsys"
+       tristate "Clock driver for MediaTek MT8183 vdecsys"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 vdecsys clocks.
 
 config COMMON_CLK_MT8183_VENCSYS
-       bool "Clock driver for MediaTek MT8183 vencsys"
+       tristate "Clock driver for MediaTek MT8183 vencsys"
        depends on COMMON_CLK_MT8183
        default COMMON_CLK_MT8183
        help
          This driver supports MediaTek MT8183 vencsys clocks.
 
 config COMMON_CLK_MT8186
-       bool "Clock driver for MediaTek MT8186"
+       tristate "Clock driver for MediaTek MT8186"
        depends on ARM64 || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
        select COMMON_CLK_MEDIATEK_FHCTL
@@ -604,82 +606,246 @@ config COMMON_CLK_MT8186
        help
          This driver supports MediaTek MT8186 clocks.
 
+config COMMON_CLK_MT8186_CAMSYS
+       tristate "Clock driver for MediaTek MT8186 camsys"
+       depends on COMMON_CLK_MT8186
+       default COMMON_CLK_MT8186
+       help
+         This driver supports MediaTek MT8186 camsys and camsys_raw clocks.
+
+config COMMON_CLK_MT8186_IMGSYS
+       tristate "Clock driver for MediaTek MT8186 imgsys"
+       depends on COMMON_CLK_MT8186
+       default COMMON_CLK_MT8186
+       help
+         This driver supports MediaTek MT8186 imgsys and imgsys2 clocks.
+
+config COMMON_CLK_MT8186_IPESYS
+       tristate "Clock driver for MediaTek MT8186 ipesys"
+       depends on COMMON_CLK_MT8186_IMGSYS
+       default COMMON_CLK_MT8186_IMGSYS
+       help
+         This driver supports MediaTek MT8186 ipesys clocks.
+
+config COMMON_CLK_MT8186_WPESYS
+       tristate "Clock driver for MediaTek MT8186 wpesys"
+       depends on COMMON_CLK_MT8186_IMGSYS
+       default COMMON_CLK_MT8186_IMGSYS
+       help
+         This driver supports MediaTek MT8186 Warp Engine clocks.
+
+config COMMON_CLK_MT8186_IMP_IIC_WRAP
+       tristate "Clock driver for MediaTek MT8186 imp_iic_wrap"
+       depends on COMMON_CLK_MT8186
+       default COMMON_CLK_MT8186
+       help
+         This driver supports MediaTek MT8186 imp_iic_wrap clocks.
+
+config COMMON_CLK_MT8186_MCUSYS
+       tristate "Clock driver for MediaTek MT8186 mcusys"
+       depends on COMMON_CLK_MT8186
+       default COMMON_CLK_MT8186
+       help
+         This driver supports MediaTek MT8186 mcusys clocks.
+
+config COMMON_CLK_MT8186_MDPSYS
+       tristate "Clock driver for MediaTek MT8186 mdpsys"
+       depends on COMMON_CLK_MT8186
+       default COMMON_CLK_MT8186
+       help
+         This driver supports MediaTek MT8186 mdpsys clocks.
+
+config COMMON_CLK_MT8186_MFGCFG
+       tristate "Clock driver for MediaTek MT8186 mfgcfg"
+       depends on COMMON_CLK_MT8186
+       default COMMON_CLK_MT8186
+       help
+         This driver supports MediaTek MT8186 mfgcfg clocks.
+
+config COMMON_CLK_MT8186_MMSYS
+       tristate "Clock driver for MediaTek MT8186 mmsys"
+       depends on COMMON_CLK_MT8186
+       default COMMON_CLK_MT8186
+       help
+         This driver supports MediaTek MT8186 mmsys clocks.
+
+config COMMON_CLK_MT8186_VDECSYS
+       tristate "Clock driver for MediaTek MT8186 vdecsys"
+       depends on COMMON_CLK_MT8186
+       default COMMON_CLK_MT8186
+       help
+         This driver supports MediaTek MT8186 vdecsys and vdecsys_soc clocks.
+
+config COMMON_CLK_MT8186_VENCSYS
+       tristate "Clock driver for MediaTek MT8186 vencsys"
+       depends on COMMON_CLK_MT8186
+       default COMMON_CLK_MT8186
+       help
+         This driver supports MediaTek MT8186 vencsys clocks.
+
+config COMMON_CLK_MT8188
+       tristate "Clock driver for MediaTek MT8188"
+       depends on ARM64 || COMPILE_TEST
+       select COMMON_CLK_MEDIATEK
+       select COMMON_CLK_MEDIATEK_FHCTL
+       default ARCH_MEDIATEK
+       help
+          This driver supports MediaTek MT8188 clocks.
+
+config COMMON_CLK_MT8188_ADSP_AUDIO26M
+       tristate "Clock driver for MediaTek MT8188 adsp audio26m"
+       depends on COMMON_CLK_MT8188
+       default COMMON_CLK_MT8188
+       help
+         This driver supports MediaTek MT8188 adsp audio26m clocks.
+
+config COMMON_CLK_MT8188_CAMSYS
+       tristate "Clock driver for MediaTek MT8188 camsys"
+       depends on COMMON_CLK_MT8188_VPPSYS
+       default COMMON_CLK_MT8188_VPPSYS
+       help
+         This driver supports MediaTek MT8188 camsys and camsys_raw clocks.
+
+config COMMON_CLK_MT8188_IMGSYS
+       tristate "Clock driver for MediaTek MT8188 imgsys"
+       depends on COMMON_CLK_MT8188_VPPSYS
+       default COMMON_CLK_MT8188_VPPSYS
+       help
+         This driver supports MediaTek MT8188 imgsys and imgsys2 clocks.
+
+config COMMON_CLK_MT8188_IMP_IIC_WRAP
+       tristate "Clock driver for MediaTek MT8188 imp_iic_wrap"
+       depends on COMMON_CLK_MT8188
+       default COMMON_CLK_MT8188
+       help
+         This driver supports MediaTek MT8188 I2C/I3C clocks.
+
+config COMMON_CLK_MT8188_IPESYS
+       tristate "Clock driver for MediaTek MT8188 ipesys"
+       depends on COMMON_CLK_MT8188_IMGSYS
+       default COMMON_CLK_MT8188_IMGSYS
+       help
+         This driver supports MediaTek MT8188 ipesys clocks.
+
+config COMMON_CLK_MT8188_MFGCFG
+       tristate "Clock driver for MediaTek MT8188 mfgcfg"
+       depends on COMMON_CLK_MT8188
+       default COMMON_CLK_MT8188
+       help
+         This driver supports MediaTek MT8188 mfgcfg clocks.
+
+config COMMON_CLK_MT8188_VDECSYS
+       tristate "Clock driver for MediaTek MT8188 vdecsys"
+       depends on COMMON_CLK_MT8188_VPPSYS
+       default COMMON_CLK_MT8188_VPPSYS
+       help
+         This driver supports MediaTek MT8188 vdecsys and vdecsys_soc clocks.
+
+config COMMON_CLK_MT8188_VDOSYS
+       tristate "Clock driver for MediaTek MT8188 vdosys"
+       depends on COMMON_CLK_MT8188
+       default COMMON_CLK_MT8188
+       help
+         This driver supports MediaTek MT8188 vdosys0/1 (multimedia) clocks.
+
+config COMMON_CLK_MT8188_VENCSYS
+       tristate "Clock driver for MediaTek MT8188 vencsys"
+       depends on COMMON_CLK_MT8188_VPPSYS
+       default COMMON_CLK_MT8188_VPPSYS
+       help
+         This driver supports MediaTek MT8188 vencsys clocks.
+
+config COMMON_CLK_MT8188_VPPSYS
+       tristate "Clock driver for MediaTek MT8188 vppsys"
+       depends on COMMON_CLK_MT8188
+       default COMMON_CLK_MT8188
+       help
+         This driver supports MediaTek MT8188 vppsys0/1 clocks.
+
+config COMMON_CLK_MT8188_WPESYS
+       tristate "Clock driver for MediaTek MT8188 wpesys"
+       depends on COMMON_CLK_MT8188_IMGSYS
+       default COMMON_CLK_MT8188_IMGSYS
+       help
+         This driver supports MediaTek MT8188 Warp Engine clocks.
+
 config COMMON_CLK_MT8192
-       bool "Clock driver for MediaTek MT8192"
+       tristate "Clock driver for MediaTek MT8192"
        depends on ARM64 || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
+       select COMMON_CLK_MEDIATEK_FHCTL
        default ARM64
        help
          This driver supports MediaTek MT8192 basic clocks.
 
 config COMMON_CLK_MT8192_AUDSYS
-       bool "Clock driver for MediaTek MT8192 audsys"
+       tristate "Clock driver for MediaTek MT8192 audsys"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 audsys clocks.
 
 config COMMON_CLK_MT8192_CAMSYS
-       bool "Clock driver for MediaTek MT8192 camsys"
+       tristate "Clock driver for MediaTek MT8192 camsys"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 camsys and camsys_raw clocks.
 
 config COMMON_CLK_MT8192_IMGSYS
-       bool "Clock driver for MediaTek MT8192 imgsys"
+       tristate "Clock driver for MediaTek MT8192 imgsys"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 imgsys and imgsys2 clocks.
 
 config COMMON_CLK_MT8192_IMP_IIC_WRAP
-       bool "Clock driver for MediaTek MT8192 imp_iic_wrap"
+       tristate "Clock driver for MediaTek MT8192 imp_iic_wrap"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 imp_iic_wrap clocks.
 
 config COMMON_CLK_MT8192_IPESYS
-       bool "Clock driver for MediaTek MT8192 ipesys"
+       tristate "Clock driver for MediaTek MT8192 ipesys"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 ipesys clocks.
 
 config COMMON_CLK_MT8192_MDPSYS
-       bool "Clock driver for MediaTek MT8192 mdpsys"
+       tristate "Clock driver for MediaTek MT8192 mdpsys"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 mdpsys clocks.
 
 config COMMON_CLK_MT8192_MFGCFG
-       bool "Clock driver for MediaTek MT8192 mfgcfg"
+       tristate "Clock driver for MediaTek MT8192 mfgcfg"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 mfgcfg clocks.
 
 config COMMON_CLK_MT8192_MMSYS
-       bool "Clock driver for MediaTek MT8192 mmsys"
+       tristate "Clock driver for MediaTek MT8192 mmsys"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 mmsys clocks.
 
 config COMMON_CLK_MT8192_MSDC
-       bool "Clock driver for MediaTek MT8192 msdc"
+       tristate "Clock driver for MediaTek MT8192 msdc"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 msdc and msdc_top clocks.
 
 config COMMON_CLK_MT8192_SCP_ADSP
-       bool "Clock driver for MediaTek MT8192 scp_adsp"
+       tristate "Clock driver for MediaTek MT8192 scp_adsp"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 scp_adsp clocks.
 
 config COMMON_CLK_MT8192_VDECSYS
-       bool "Clock driver for MediaTek MT8192 vdecsys"
+       tristate "Clock driver for MediaTek MT8192 vdecsys"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 vdecsys and vdecsys_soc clocks.
 
 config COMMON_CLK_MT8192_VENCSYS
-       bool "Clock driver for MediaTek MT8192 vencsys"
+       tristate "Clock driver for MediaTek MT8192 vencsys"
        depends on COMMON_CLK_MT8192
        help
          This driver supports MediaTek MT8192 vencsys clocks.
@@ -688,10 +854,111 @@ config COMMON_CLK_MT8195
         bool "Clock driver for MediaTek MT8195"
         depends on ARM64 || COMPILE_TEST
         select COMMON_CLK_MEDIATEK
+       select COMMON_CLK_MEDIATEK_FHCTL
         default ARCH_MEDIATEK
         help
           This driver supports MediaTek MT8195 clocks.
 
+config COMMON_CLK_MT8195_APUSYS
+       tristate "Clock driver for MediaTek MT8195 apusys"
+       depends on COMMON_CLK_MT8195
+       default COMMON_CLK_MT8195
+       help
+         This driver supports MediaTek MT8195 AI Processor Unit System clocks.
+
+config COMMON_CLK_MT8195_AUDSYS
+       tristate "Clock driver for MediaTek MT8195 audsys"
+       depends on COMMON_CLK_MT8195
+       default COMMON_CLK_MT8195
+       help
+         This driver supports MediaTek MT8195 audsys clocks.
+
+config COMMON_CLK_MT8195_IMP_IIC_WRAP
+       tristate "Clock driver for MediaTek MT8195 imp_iic_wrap"
+       depends on COMMON_CLK_MT8195
+       default COMMON_CLK_MT8195
+       help
+         This driver supports MediaTek MT8195 I2C/I3C clocks.
+
+config COMMON_CLK_MT8195_MFGCFG
+       tristate "Clock driver for MediaTek MT8195 mfgcfg"
+       depends on COMMON_CLK_MT8195
+       default COMMON_CLK_MT8195
+       help
+         This driver supports MediaTek MT8195 mfgcfg clocks.
+
+config COMMON_CLK_MT8195_MSDC
+       tristate "Clock driver for MediaTek MT8195 msdc"
+       depends on COMMON_CLK_MT8195
+       default COMMON_CLK_MT8195
+       help
+         This driver supports MediaTek MT8195 MMC and SD Controller's
+         msdc and msdc_top clocks.
+
+config COMMON_CLK_MT8195_SCP_ADSP
+       tristate "Clock driver for MediaTek MT8195 scp_adsp"
+       depends on COMMON_CLK_MT8195
+       default COMMON_CLK_MT8195
+       help
+         This driver supports MediaTek MT8195 System Companion Processor
+         Audio DSP clocks.
+
+config COMMON_CLK_MT8195_VDOSYS
+       tristate "Clock driver for MediaTek MT8195 vdosys"
+       depends on COMMON_CLK_MT8195
+       default COMMON_CLK_MT8195
+       help
+         This driver supports MediaTek MT8195 vdosys0/1 (multimedia) clocks.
+
+config COMMON_CLK_MT8195_VPPSYS
+       tristate "Clock driver for MediaTek MT8195 vppsys"
+       depends on COMMON_CLK_MT8195
+       default COMMON_CLK_MT8195
+       help
+         This driver supports MediaTek MT8195 vppsys0/1 clocks.
+
+config COMMON_CLK_MT8195_CAMSYS
+       tristate "Clock driver for MediaTek MT8195 camsys"
+       depends on COMMON_CLK_MT8195_VPPSYS
+       default COMMON_CLK_MT8195_VPPSYS
+       help
+         This driver supports MediaTek MT8195 camsys and camsys_raw clocks.
+
+config COMMON_CLK_MT8195_IMGSYS
+       tristate "Clock driver for MediaTek MT8195 imgsys"
+       depends on COMMON_CLK_MT8195_VPPSYS
+       default COMMON_CLK_MT8195_VPPSYS
+       help
+         This driver supports MediaTek MT8195 imgsys and imgsys2 clocks.
+
+config COMMON_CLK_MT8195_IPESYS
+       tristate "Clock driver for MediaTek MT8195 ipesys"
+       depends on COMMON_CLK_MT8195_IMGSYS
+       default COMMON_CLK_MT8195_IMGSYS
+       help
+         This driver supports MediaTek MT8195 ipesys clocks.
+
+config COMMON_CLK_MT8195_WPESYS
+       tristate "Clock driver for MediaTek MT8195 wpesys"
+       depends on COMMON_CLK_MT8195_IMGSYS
+       default COMMON_CLK_MT8195_IMGSYS
+       help
+         This driver supports MediaTek MT8195 Warp Engine clocks.
+
+config COMMON_CLK_MT8195_VDECSYS
+       tristate "Clock driver for MediaTek MT8195 vdecsys"
+       depends on COMMON_CLK_MT8195_VPPSYS
+       default COMMON_CLK_MT8195_VPPSYS
+       help
+         This driver supports MediaTek MT8195 vdecsys and vdecsys_soc clocks.
+
+config COMMON_CLK_MT8195_VENCSYS
+       tristate "Clock driver for MediaTek MT8195 vencsys"
+       depends on COMMON_CLK_MT8195_VPPSYS
+       default COMMON_CLK_MT8195_VPPSYS
+       help
+         This driver supports MediaTek MT8195 vencsys clocks.
+
 config COMMON_CLK_MT8365
        tristate "Clock driver for MediaTek MT8365"
        depends on ARCH_MEDIATEK || COMPILE_TEST
@@ -743,7 +1010,7 @@ config COMMON_CLK_MT8365_VENC
          This driver supports MediaTek MT8365 venc clocks.
 
 config COMMON_CLK_MT8516
-       bool "Clock driver for MediaTek MT8516"
+       tristate "Clock driver for MediaTek MT8516"
        depends on ARCH_MEDIATEK || COMPILE_TEST
        select COMMON_CLK_MEDIATEK
        default ARCH_MEDIATEK
@@ -751,7 +1018,7 @@ config COMMON_CLK_MT8516
          This driver supports MediaTek MT8516 clocks.
 
 config COMMON_CLK_MT8516_AUDSYS
-       bool "Clock driver for MediaTek MT8516 audsys"
+       tristate "Clock driver for MediaTek MT8516 audsys"
        depends on COMMON_CLK_MT8516
        help
          This driver supports MediaTek MT8516 audsys clocks.
index e5d018270ed0d691cff8873395512e766ea5ed73..dbeaa5b41177dc699bf4b302c183914a95d280b8 100644 (file)
@@ -38,7 +38,7 @@ obj-$(CONFIG_COMMON_CLK_MT2701_HIFSYS) += clk-mt2701-hif.o
 obj-$(CONFIG_COMMON_CLK_MT2701_IMGSYS) += clk-mt2701-img.o
 obj-$(CONFIG_COMMON_CLK_MT2701_MMSYS) += clk-mt2701-mm.o
 obj-$(CONFIG_COMMON_CLK_MT2701_VDECSYS) += clk-mt2701-vdec.o
-obj-$(CONFIG_COMMON_CLK_MT2712) += clk-mt2712.o
+obj-$(CONFIG_COMMON_CLK_MT2712) += clk-mt2712-apmixedsys.o clk-mt2712.o
 obj-$(CONFIG_COMMON_CLK_MT2712_BDPSYS) += clk-mt2712-bdp.o
 obj-$(CONFIG_COMMON_CLK_MT2712_IMGSYS) += clk-mt2712-img.o
 obj-$(CONFIG_COMMON_CLK_MT2712_JPGDECSYS) += clk-mt2712-jpgdec.o
@@ -46,7 +46,8 @@ obj-$(CONFIG_COMMON_CLK_MT2712_MFGCFG) += clk-mt2712-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT2712_MMSYS) += clk-mt2712-mm.o
 obj-$(CONFIG_COMMON_CLK_MT2712_VDECSYS) += clk-mt2712-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT2712_VENCSYS) += clk-mt2712-venc.o
-obj-$(CONFIG_COMMON_CLK_MT7622) += clk-mt7622.o
+obj-$(CONFIG_COMMON_CLK_MT7622) += clk-mt7622-apmixedsys.o clk-mt7622.o \
+                                  clk-mt7622-infracfg.o
 obj-$(CONFIG_COMMON_CLK_MT7622_ETHSYS) += clk-mt7622-eth.o
 obj-$(CONFIG_COMMON_CLK_MT7622_HIFSYS) += clk-mt7622-hif.o
 obj-$(CONFIG_COMMON_CLK_MT7622_AUDSYS) += clk-mt7622-aud.o
@@ -61,8 +62,8 @@ obj-$(CONFIG_COMMON_CLK_MT7986) += clk-mt7986-apmixed.o
 obj-$(CONFIG_COMMON_CLK_MT7986) += clk-mt7986-topckgen.o
 obj-$(CONFIG_COMMON_CLK_MT7986) += clk-mt7986-infracfg.o
 obj-$(CONFIG_COMMON_CLK_MT7986_ETHSYS) += clk-mt7986-eth.o
-obj-$(CONFIG_COMMON_CLK_MT8135) += clk-mt8135.o
-obj-$(CONFIG_COMMON_CLK_MT8167) += clk-mt8167.o
+obj-$(CONFIG_COMMON_CLK_MT8135) += clk-mt8135-apmixedsys.o clk-mt8135.o
+obj-$(CONFIG_COMMON_CLK_MT8167) += clk-mt8167-apmixedsys.o clk-mt8167.o
 obj-$(CONFIG_COMMON_CLK_MT8167_AUDSYS) += clk-mt8167-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8167_IMGSYS) += clk-mt8167-img.o
 obj-$(CONFIG_COMMON_CLK_MT8167_MFGCFG) += clk-mt8167-mfgcfg.o
@@ -74,7 +75,7 @@ obj-$(CONFIG_COMMON_CLK_MT8173_IMGSYS) += clk-mt8173-img.o
 obj-$(CONFIG_COMMON_CLK_MT8173_MMSYS) += clk-mt8173-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8173_VDECSYS) += clk-mt8173-vdecsys.o
 obj-$(CONFIG_COMMON_CLK_MT8173_VENCSYS) += clk-mt8173-vencsys.o
-obj-$(CONFIG_COMMON_CLK_MT8183) += clk-mt8183.o
+obj-$(CONFIG_COMMON_CLK_MT8183) += clk-mt8183-apmixedsys.o clk-mt8183.o
 obj-$(CONFIG_COMMON_CLK_MT8183_AUDIOSYS) += clk-mt8183-audio.o
 obj-$(CONFIG_COMMON_CLK_MT8183_CAMSYS) += clk-mt8183-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8183_IMGSYS) += clk-mt8183-img.o
@@ -86,12 +87,33 @@ obj-$(CONFIG_COMMON_CLK_MT8183_MFGCFG) += clk-mt8183-mfgcfg.o
 obj-$(CONFIG_COMMON_CLK_MT8183_MMSYS) += clk-mt8183-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VDECSYS) += clk-mt8183-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VENCSYS) += clk-mt8183-venc.o
-obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt8186-infra_ao.o \
-                                  clk-mt8186-apmixedsys.o clk-mt8186-imp_iic_wrap.o \
-                                  clk-mt8186-mfg.o clk-mt8186-mm.o clk-mt8186-wpe.o \
-                                  clk-mt8186-img.o clk-mt8186-vdec.o clk-mt8186-venc.o \
-                                  clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
-obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
+obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-apmixedsys.o clk-mt8186-topckgen.o \
+                                  clk-mt8186-infra_ao.o
+obj-$(CONFIG_COMMON_CLK_MT8186_CAMSYS) += clk-mt8186-cam.o
+obj-$(CONFIG_COMMON_CLK_MT8186_IMGSYS) += clk-mt8186-img.o
+obj-$(CONFIG_COMMON_CLK_MT8186_IMP_IIC_WRAP) += clk-mt8186-imp_iic_wrap.o
+obj-$(CONFIG_COMMON_CLK_MT8186_IPESYS) += clk-mt8186-ipe.o
+obj-$(CONFIG_COMMON_CLK_MT8186_MCUSYS) += clk-mt8186-mcu.o
+obj-$(CONFIG_COMMON_CLK_MT8186_MDPSYS) += clk-mt8186-mdp.o
+obj-$(CONFIG_COMMON_CLK_MT8186_MFGCFG) += clk-mt8186-mfg.o
+obj-$(CONFIG_COMMON_CLK_MT8186_MMSYS) += clk-mt8186-mm.o
+obj-$(CONFIG_COMMON_CLK_MT8186_VDECSYS) += clk-mt8186-vdec.o
+obj-$(CONFIG_COMMON_CLK_MT8186_VENCSYS) += clk-mt8186-venc.o
+obj-$(CONFIG_COMMON_CLK_MT8186_WPESYS) += clk-mt8186-wpe.o
+obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
+                                  clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o
+obj-$(CONFIG_COMMON_CLK_MT8188_ADSP_AUDIO26M) += clk-mt8188-adsp_audio26m.o
+obj-$(CONFIG_COMMON_CLK_MT8188_CAMSYS) += clk-mt8188-cam.o clk-mt8188-ccu.o
+obj-$(CONFIG_COMMON_CLK_MT8188_IMGSYS) += clk-mt8188-img.o
+obj-$(CONFIG_COMMON_CLK_MT8188_IMP_IIC_WRAP) += clk-mt8188-imp_iic_wrap.o
+obj-$(CONFIG_COMMON_CLK_MT8188_IPESYS) += clk-mt8188-ipe.o
+obj-$(CONFIG_COMMON_CLK_MT8188_MFGCFG) += clk-mt8188-mfg.o
+obj-$(CONFIG_COMMON_CLK_MT8188_VDECSYS) += clk-mt8188-vdec.o
+obj-$(CONFIG_COMMON_CLK_MT8188_VDOSYS) += clk-mt8188-vdo0.o clk-mt8188-vdo1.o
+obj-$(CONFIG_COMMON_CLK_MT8188_VENCSYS) += clk-mt8188-venc.o
+obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o
+obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o
+obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
@@ -105,19 +127,25 @@ obj-$(CONFIG_COMMON_CLK_MT8192_SCP_ADSP) += clk-mt8192-scp_adsp.o
 obj-$(CONFIG_COMMON_CLK_MT8192_VDECSYS) += clk-mt8192-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8192_VENCSYS) += clk-mt8192-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8195) += clk-mt8195-apmixedsys.o clk-mt8195-topckgen.o \
-                                  clk-mt8195-peri_ao.o clk-mt8195-infra_ao.o \
-                                  clk-mt8195-cam.o clk-mt8195-ccu.o clk-mt8195-img.o \
-                                  clk-mt8195-ipe.o clk-mt8195-mfg.o clk-mt8195-scp_adsp.o \
-                                  clk-mt8195-vdec.o clk-mt8195-vdo0.o clk-mt8195-vdo1.o \
-                                  clk-mt8195-venc.o clk-mt8195-vpp0.o clk-mt8195-vpp1.o \
-                                  clk-mt8195-wpe.o clk-mt8195-imp_iic_wrap.o \
-                                  clk-mt8195-apusys_pll.o
-obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365.o
+                                  clk-mt8195-peri_ao.o clk-mt8195-infra_ao.o
+obj-$(CONFIG_COMMON_CLK_MT8195_APUSYS) += clk-mt8195-apusys_pll.o
+obj-$(CONFIG_COMMON_CLK_MT8195_CAMSYS) += clk-mt8195-cam.o clk-mt8195-ccu.o
+obj-$(CONFIG_COMMON_CLK_MT8195_IMGSYS) += clk-mt8195-img.o
+obj-$(CONFIG_COMMON_CLK_MT8195_IMP_IIC_WRAP) += clk-mt8195-imp_iic_wrap.o
+obj-$(CONFIG_COMMON_CLK_MT8195_IPESYS) += clk-mt8195-ipe.o
+obj-$(CONFIG_COMMON_CLK_MT8195_MFGCFG) += clk-mt8195-mfg.o
+obj-$(CONFIG_COMMON_CLK_MT8195_SCP_ADSP) += clk-mt8195-scp_adsp.o
+obj-$(CONFIG_COMMON_CLK_MT8195_VDECSYS) += clk-mt8195-vdec.o
+obj-$(CONFIG_COMMON_CLK_MT8195_VDOSYS) += clk-mt8195-vdo0.o clk-mt8195-vdo1.o
+obj-$(CONFIG_COMMON_CLK_MT8195_VENCSYS) += clk-mt8195-venc.o
+obj-$(CONFIG_COMMON_CLK_MT8195_VPPSYS) += clk-mt8195-vpp0.o clk-mt8195-vpp1.o
+obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o
+obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o
 obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o
 obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8365_MFG) += clk-mt8365-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8365_MMSYS) += clk-mt8365-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8365_VDEC) += clk-mt8365-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8365_VENC) += clk-mt8365-venc.o
-obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
+obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516-apmixedsys.o clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
index 4f271acef5fe83e809e4eda0d92e917e165a385f..33b6ad8fdc2efa1386199e26fa1f337d51a3fd71 100644 (file)
 #define PERCENT_TO_DDSLMT(dds, percent_m10) \
        ((((dds) * (percent_m10)) >> 5) / 100)
 
-static const struct fhctl_offset fhctl_offset = {
+static const struct fhctl_offset fhctl_offset_v1 = {
+       .offset_hp_en = 0x0,
+       .offset_clk_con = 0x4,
+       .offset_rst_con = 0x8,
+       .offset_slope0 = 0xc,
+       .offset_slope1 = 0x10,
+       .offset_cfg = 0x0,
+       .offset_updnlmt = 0x4,
+       .offset_dds = 0x8,
+       .offset_dvfs = 0xc,
+       .offset_mon = 0x10,
+};
+
+static const struct fhctl_offset fhctl_offset_v2 = {
        .offset_hp_en = 0x0,
        .offset_clk_con = 0x8,
        .offset_rst_con = 0xc,
@@ -27,9 +40,16 @@ static const struct fhctl_offset fhctl_offset = {
        .offset_mon = 0x10,
 };
 
-const struct fhctl_offset *fhctl_get_offset_table(void)
+const struct fhctl_offset *fhctl_get_offset_table(enum fhctl_variant v)
 {
-       return &fhctl_offset;
+       switch (v) {
+       case FHCTL_PLLFH_V1:
+               return &fhctl_offset_v1;
+       case FHCTL_PLLFH_V2:
+               return &fhctl_offset_v2;
+       default:
+               return ERR_PTR(-EINVAL);
+       };
 }
 
 static void dump_hw(struct mtk_clk_pll *pll, struct fh_pll_regs *regs,
index 51275febf08667f1b550d1373f905c9ad69f4ed2..bfa6d281a3ee3f830a31b32c81a74f9ea304c33b 100644 (file)
@@ -7,6 +7,13 @@
 #ifndef __CLK_FHCTL_H
 #define __CLK_FHCTL_H
 
+#include "clk-pllfh.h"
+
+enum fhctl_variant {
+       FHCTL_PLLFH_V1,
+       FHCTL_PLLFH_V2,
+};
+
 struct fhctl_offset {
        u32 offset_hp_en;
        u32 offset_clk_con;
@@ -19,7 +26,7 @@ struct fhctl_offset {
        u32 offset_dvfs;
        u32 offset_mon;
 };
-const struct fhctl_offset *fhctl_get_offset_table(void);
+const struct fhctl_offset *fhctl_get_offset_table(enum fhctl_variant v);
 const struct fh_operation *fhctl_get_ops(void);
 void fhctl_hw_init(struct mtk_fh *fh);
 
index 1a32d8b7db84f17dbed2141f0187e4feb3a4fd75..5cd343b98685830c2ae0c05e14fea92cb4747fbc 100644 (file)
 
 #include <dt-bindings/clock/mt2701-clk.h>
 
-#define GATE_AUDIO0(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &audio0_cg_regs,                        \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_AUDIO0(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &audio0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-#define GATE_AUDIO1(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &audio1_cg_regs,                        \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_AUDIO1(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &audio1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-#define GATE_AUDIO2(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &audio2_cg_regs,                        \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_AUDIO2(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &audio2_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-#define GATE_AUDIO3(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &audio3_cg_regs,                        \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_AUDIO3(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &audio3_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
 static const struct mtk_gate_regs audio0_cg_regs = {
        .set_ofs = 0x0,
@@ -148,6 +124,7 @@ static const struct of_device_id of_match_clk_mt2701_aud[] = {
        { .compatible = "mediatek,mt2701-audsys", .data = &audio_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_aud);
 
 static int clk_mt2701_aud_probe(struct platform_device *pdev)
 {
@@ -187,5 +164,5 @@ static struct platform_driver clk_mt2701_aud_drv = {
                .of_match_table = of_match_clk_mt2701_aud,
        },
 };
-
-builtin_platform_driver(clk_mt2701_aud_drv);
+module_platform_driver(clk_mt2701_aud_drv);
+MODULE_LICENSE("GPL");
index 435ed4819d5633e05e3eaef111a0487ef2efc54a..4c5b70d48df944ac40670ad32bdf7966eae799da 100644 (file)
@@ -24,23 +24,11 @@ static const struct mtk_gate_regs bdp1_cg_regs = {
        .sta_ofs = 0x0110,
 };
 
-#define GATE_BDP0(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &bdp0_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_BDP0(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &bdp0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
-#define GATE_BDP1(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &bdp1_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_BDP1(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &bdp1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
 static const struct mtk_gate bdp_clks[] = {
        GATE_BDP0(CLK_BDP_BRG_BA, "brg_baclk", "mm_sel", 0),
@@ -107,6 +95,7 @@ static const struct of_device_id of_match_clk_mt2701_bdp[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_bdp);
 
 static struct platform_driver clk_mt2701_bdp_drv = {
        .probe = mtk_clk_simple_probe,
@@ -116,5 +105,5 @@ static struct platform_driver clk_mt2701_bdp_drv = {
                .of_match_table = of_match_clk_mt2701_bdp,
        },
 };
-
-builtin_platform_driver(clk_mt2701_bdp_drv);
+module_platform_driver(clk_mt2701_bdp_drv);
+MODULE_LICENSE("GPL");
index f3cb78e7f6e9ef43434ec689f7ee787e2fae5cd2..9a1fb0c93964776273dcf2bb6102181c89677779 100644 (file)
@@ -16,14 +16,8 @@ static const struct mtk_gate_regs eth_cg_regs = {
        .sta_ofs = 0x0030,
 };
 
-#define GATE_ETH(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &eth_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_ETH(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &eth_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate eth_clks[] = {
        GATE_DUMMY(CLK_DUMMY, "eth_dummy"),
@@ -55,6 +49,7 @@ static const struct of_device_id of_match_clk_mt2701_eth[] = {
        { .compatible = "mediatek,mt2701-ethsys", .data = &eth_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_eth);
 
 static struct platform_driver clk_mt2701_eth_drv = {
        .probe = mtk_clk_simple_probe,
@@ -64,5 +59,5 @@ static struct platform_driver clk_mt2701_eth_drv = {
                .of_match_table = of_match_clk_mt2701_eth,
        },
 };
-
-builtin_platform_driver(clk_mt2701_eth_drv);
+module_platform_driver(clk_mt2701_eth_drv);
+MODULE_LICENSE("GPL");
index 499a170ba5f92278ae916fb5d1d87564ea270a0f..c0006861a3170da7363bac1b8272551bf2da72aa 100644 (file)
 
 #include <dt-bindings/clock/mt2701-clk.h>
 
-#define GATE_G3D(_id, _name, _parent, _shift) {        \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &g3d_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_G3D(_id, _name, _parent, _shift)                          \
+       GATE_MTK(_id, _name, _parent, &g3d_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate_regs g3d_cg_regs = {
        .sta_ofs = 0x0,
@@ -54,6 +48,7 @@ static const struct of_device_id of_match_clk_mt2701_g3d[] = {
        { .compatible = "mediatek,mt2701-g3dsys", .data = &g3d_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_g3d);
 
 static struct platform_driver clk_mt2701_g3d_drv = {
        .probe = mtk_clk_simple_probe,
@@ -63,5 +58,5 @@ static struct platform_driver clk_mt2701_g3d_drv = {
                .of_match_table = of_match_clk_mt2701_g3d,
        },
 };
-
-builtin_platform_driver(clk_mt2701_g3d_drv);
+module_platform_driver(clk_mt2701_g3d_drv);
+MODULE_LICENSE("GPL");
index d5465d7829935c396fc48a5b77517cbb55a6afc2..ff7c0b3228e46026b4c2cfe36359ee9a54c5a60c 100644 (file)
@@ -16,14 +16,8 @@ static const struct mtk_gate_regs hif_cg_regs = {
        .sta_ofs = 0x0030,
 };
 
-#define GATE_HIF(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &hif_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_HIF(_id, _name, _parent, _shift)                          \
+       GATE_MTK(_id, _name, _parent, &hif_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate hif_clks[] = {
        GATE_DUMMY(CLK_DUMMY, "hif_dummy"),
@@ -52,6 +46,7 @@ static const struct of_device_id of_match_clk_mt2701_hif[] = {
        { .compatible = "mediatek,mt2701-hifsys", .data = &hif_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_hif);
 
 static struct platform_driver clk_mt2701_hif_drv = {
        .probe = mtk_clk_simple_probe,
@@ -61,5 +56,5 @@ static struct platform_driver clk_mt2701_hif_drv = {
                .of_match_table = of_match_clk_mt2701_hif,
        },
 };
-
-builtin_platform_driver(clk_mt2701_hif_drv);
+module_platform_driver(clk_mt2701_hif_drv);
+MODULE_LICENSE("GPL");
index 7e53deb7f9905d2f17153962366d6e6fdaeffc2a..baa1194eb01ea54eef1fde3f16dc9a6b4628c2d5 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs img_cg_regs = {
        .sta_ofs = 0x0000,
 };
 
-#define GATE_IMG(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &img_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_IMG(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate img_clks[] = {
        GATE_IMG(CLK_IMG_SMI_COMM, "img_smi_comm", "mm_sel", 0),
@@ -49,6 +43,7 @@ static const struct of_device_id of_match_clk_mt2701_img[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_img);
 
 static struct platform_driver clk_mt2701_img_drv = {
        .probe = mtk_clk_simple_probe,
@@ -58,5 +53,5 @@ static struct platform_driver clk_mt2701_img_drv = {
                .of_match_table = of_match_clk_mt2701_img,
        },
 };
-
-builtin_platform_driver(clk_mt2701_img_drv);
+module_platform_driver(clk_mt2701_img_drv);
+MODULE_LICENSE("GPL");
index 23d5ddcc1d37297de46682f487b8e02f24f75958..c62c56fd2b7ec80da982c581f93802975e18de88 100644 (file)
@@ -24,23 +24,11 @@ static const struct mtk_gate_regs disp1_cg_regs = {
        .sta_ofs = 0x0110,
 };
 
-#define GATE_DISP0(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &disp0_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_DISP0(_id, _name, _parent, _shift)        \
+       GATE_MTK(_id, _name, _parent, &disp0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_DISP1(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &disp1_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_DISP1(_id, _name, _parent, _shift)        \
+       GATE_MTK(_id, _name, _parent, &disp1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate mm_clks[] = {
        GATE_DISP0(CLK_MM_SMI_COMMON, "mm_smi_comm", "mm_sel", 0),
@@ -79,32 +67,24 @@ static const struct mtk_gate mm_clks[] = {
        GATE_DISP1(CLK_MM_TVE_FMM, "mm_tve_fmm", "mm_sel", 14),
 };
 
-static int clk_mt2701_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR);
-
-       mtk_clk_register_gates(&pdev->dev, node, mm_clks,
-                              ARRAY_SIZE(mm_clks), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               dev_err(&pdev->dev,
-                       "could not register clock provider: %s: %d\n",
-                       pdev->name, r);
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mm_clks,
+       .num_clks = ARRAY_SIZE(mm_clks),
+};
 
-       return r;
-}
+static const struct platform_device_id clk_mt2701_mm_id_table[] = {
+       { .name = "clk-mt2701-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt2701_mm_id_table);
 
 static struct platform_driver clk_mt2701_mm_drv = {
-       .probe = clk_mt2701_mm_probe,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt2701-mm",
        },
+       .id_table = clk_mt2701_mm_id_table,
 };
-
-builtin_platform_driver(clk_mt2701_mm_drv);
+module_platform_driver(clk_mt2701_mm_drv);
+MODULE_LICENSE("GPL");
index d3089da0ab62eb3f96016850af8f18eaef65da78..b7f97bc51c166737078b766314d493c83436bcd7 100644 (file)
@@ -24,23 +24,11 @@ static const struct mtk_gate_regs vdec1_cg_regs = {
        .sta_ofs = 0x0008,
 };
 
-#define GATE_VDEC0(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &vdec0_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_VDEC0(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
-#define GATE_VDEC1(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &vdec1_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_VDEC1(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
 static const struct mtk_gate vdec_clks[] = {
        GATE_VDEC0(CLK_VDEC_CKGEN, "vdec_cken", "vdec_sel", 0),
@@ -60,6 +48,7 @@ static const struct of_device_id of_match_clk_mt2701_vdec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_vdec);
 
 static struct platform_driver clk_mt2701_vdec_drv = {
        .probe = mtk_clk_simple_probe,
@@ -69,5 +58,5 @@ static struct platform_driver clk_mt2701_vdec_drv = {
                .of_match_table = of_match_clk_mt2701_vdec,
        },
 };
-
-builtin_platform_driver(clk_mt2701_vdec_drv);
+module_platform_driver(clk_mt2701_vdec_drv);
+MODULE_LICENSE("GPL");
index 06ca81359d35063510b3f9002d999e7ad64c5624..4a154da8a54309232c6f0599580a2181b80cd4ea 100644 (file)
@@ -636,14 +636,8 @@ static const struct mtk_gate_regs top_aud_cg_regs = {
        .sta_ofs = 0x012C,
 };
 
-#define GATE_TOP_AUD(_id, _name, _parent, _shift) {    \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top_aud_cg_regs,               \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_TOP_AUD(_id, _name, _parent, _shift)                      \
+       GATE_MTK(_id, _name, _parent, &top_aud_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
 static const struct mtk_gate top_clks[] = {
        GATE_TOP_AUD(CLK_TOP_AUD_48K_TIMING, "a1sys_hp_ck", "aud_mux1_div",
@@ -687,7 +681,7 @@ static int mtk_topckgen_init(struct platform_device *pdev)
                                    ARRAY_SIZE(top_muxes), base,
                                    &mt2701_clk_lock, clk_data);
 
-       mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs),
+       mtk_clk_register_dividers(&pdev->dev, top_adj_divs, ARRAY_SIZE(top_adj_divs),
                                base, &mt2701_clk_lock, clk_data);
 
        mtk_clk_register_gates(&pdev->dev, node, top_clks,
@@ -702,14 +696,8 @@ static const struct mtk_gate_regs infra_cg_regs = {
        .sta_ofs = 0x0048,
 };
 
-#define GATE_ICG(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &infra_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_ICG(_id, _name, _parent, _shift)                          \
+       GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate infra_clks[] = {
        GATE_ICG(CLK_INFRA_DBG, "dbgclk", "axi_sel", 0),
@@ -823,23 +811,11 @@ static const struct mtk_gate_regs peri1_cg_regs = {
        .sta_ofs = 0x001c,
 };
 
-#define GATE_PERI0(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &peri0_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_PERI0(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_PERI1(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &peri1_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_PERI1(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate peri_clks[] = {
        GATE_PERI0(CLK_PERI_USB0_MCU, "usb0_mcu_ck", "axi_sel", 31),
@@ -1023,6 +999,7 @@ static const struct of_device_id of_match_clk_mt2701[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2701);
 
 static int clk_mt2701_probe(struct platform_device *pdev)
 {
@@ -1056,3 +1033,4 @@ static int __init clk_mt2701_init(void)
 }
 
 arch_initcall(clk_mt2701_init);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt2712-apmixedsys.c b/drivers/clk/mediatek/clk-mt2712-apmixedsys.c
new file mode 100644 (file)
index 0000000..9d2fcda
--- /dev/null
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2017 MediaTek Inc.
+ *                    Weiyi Lu <weiyi.lu@mediatek.com>
+ * Copyright (c) 2023 Collabora Ltd.
+ *                    AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+ */
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "clk-pll.h"
+#include "clk-mtk.h"
+
+#include <dt-bindings/clock/mt2712-clk.h>
+
+#define MT2712_PLL_FMAX                (3000UL * MHZ)
+
+#define CON0_MT2712_RST_BAR    BIT(24)
+
+#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,  \
+                       _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg,  \
+                       _tuner_en_bit, _pcw_reg, _pcw_shift,            \
+                       _div_table) {                                   \
+               .id = _id,                                              \
+               .name = _name,                                          \
+               .reg = _reg,                                            \
+               .pwr_reg = _pwr_reg,                                    \
+               .en_mask = _en_mask,                                    \
+               .flags = _flags,                                        \
+               .rst_bar_mask = CON0_MT2712_RST_BAR,                    \
+               .fmax = MT2712_PLL_FMAX,                                \
+               .pcwbits = _pcwbits,                                    \
+               .pd_reg = _pd_reg,                                      \
+               .pd_shift = _pd_shift,                                  \
+               .tuner_reg = _tuner_reg,                                \
+               .tuner_en_reg = _tuner_en_reg,                          \
+               .tuner_en_bit = _tuner_en_bit,                          \
+               .pcw_reg = _pcw_reg,                                    \
+               .pcw_shift = _pcw_shift,                                \
+               .div_table = _div_table,                                \
+       }
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,    \
+                       _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg,  \
+                       _tuner_en_bit, _pcw_reg, _pcw_shift)            \
+               PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,     \
+                       _pcwbits, _pd_reg, _pd_shift, _tuner_reg,       \
+                       _tuner_en_reg, _tuner_en_bit, _pcw_reg,         \
+                       _pcw_shift, NULL)
+
+static const struct mtk_pll_div_table armca35pll_div_table[] = {
+       { .div = 0, .freq = MT2712_PLL_FMAX },
+       { .div = 1, .freq = 1202500000 },
+       { .div = 2, .freq = 500500000 },
+       { .div = 3, .freq = 315250000 },
+       { .div = 4, .freq = 157625000 },
+       { /* sentinel */ }
+};
+
+static const struct mtk_pll_div_table armca72pll_div_table[] = {
+       { .div = 0, .freq = MT2712_PLL_FMAX },
+       { .div = 1, .freq = 994500000 },
+       { .div = 2, .freq = 520000000 },
+       { .div = 3, .freq = 315250000 },
+       { .div = 4, .freq = 157625000 },
+       { /* sentinel */ }
+};
+
+static const struct mtk_pll_div_table mmpll_div_table[] = {
+       { .div = 0, .freq = MT2712_PLL_FMAX },
+       { .div = 1, .freq = 1001000000 },
+       { .div = 2, .freq = 601250000 },
+       { .div = 3, .freq = 250250000 },
+       { .div = 4, .freq = 125125000 },
+       { /* sentinel */ }
+};
+
+static const struct mtk_pll_data plls[] = {
+       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, 0xf0000100,
+           HAVE_RST_BAR, 31, 0x0230, 4, 0, 0, 0, 0x0234, 0),
+       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0240, 0x024C, 0xfe000100,
+           HAVE_RST_BAR, 31, 0x0240, 4, 0, 0, 0, 0x0244, 0),
+       PLL(CLK_APMIXED_VCODECPLL, "vcodecpll", 0x0320, 0x032C, 0xc0000100,
+           0, 31, 0x0320, 4, 0, 0, 0, 0x0324, 0),
+       PLL(CLK_APMIXED_VENCPLL, "vencpll", 0x0280, 0x028C, 0x00000100,
+           0, 31, 0x0280, 4, 0, 0, 0, 0x0284, 0),
+       PLL(CLK_APMIXED_APLL1, "apll1", 0x0330, 0x0340, 0x00000100,
+           0, 31, 0x0330, 4, 0x0338, 0x0014, 0, 0x0334, 0),
+       PLL(CLK_APMIXED_APLL2, "apll2", 0x0350, 0x0360, 0x00000100,
+           0, 31, 0x0350, 4, 0x0358, 0x0014, 1, 0x0354, 0),
+       PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0370, 0x037c, 0x00000100,
+           0, 31, 0x0370, 4, 0, 0, 0, 0x0374, 0),
+       PLL(CLK_APMIXED_LVDSPLL2, "lvdspll2", 0x0390, 0x039C, 0x00000100,
+           0, 31, 0x0390, 4, 0, 0, 0, 0x0394, 0),
+       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0270, 0x027C, 0x00000100,
+           0, 31, 0x0270, 4, 0, 0, 0, 0x0274, 0),
+       PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x0410, 0x041C, 0x00000100,
+           0, 31, 0x0410, 4, 0, 0, 0, 0x0414, 0),
+       PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0290, 0x029C, 0xc0000100,
+           0, 31, 0x0290, 4, 0, 0, 0, 0x0294, 0),
+       PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0250, 0x0260, 0x00000100,
+             0, 31, 0x0250, 4, 0, 0, 0, 0x0254, 0, mmpll_div_table),
+       PLL_B(CLK_APMIXED_ARMCA35PLL, "armca35pll", 0x0100, 0x0110, 0xf0000100,
+             HAVE_RST_BAR, 31, 0x0100, 4, 0, 0, 0, 0x0104, 0, armca35pll_div_table),
+       PLL_B(CLK_APMIXED_ARMCA72PLL, "armca72pll", 0x0210, 0x0220, 0x00000100,
+             0, 31, 0x0210, 4, 0, 0, 0, 0x0214, 0, armca72pll_div_table),
+       PLL(CLK_APMIXED_ETHERPLL, "etherpll", 0x0300, 0x030C, 0xc0000100,
+           0, 31, 0x0300, 4, 0, 0, 0, 0x0304, 0),
+};
+
+static int clk_mt2712_apmixed_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+       struct device_node *node = pdev->dev.of_node;
+
+       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       if (r)
+               goto free_clk_data;
+
+       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (r) {
+               dev_err(&pdev->dev, "Cannot register clock provider: %d\n", r);
+               goto unregister_plls;
+       }
+
+       return 0;
+
+unregister_plls:
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+free_clk_data:
+       mtk_free_clk_data(clk_data);
+       return r;
+}
+
+static int clk_mt2712_apmixed_remove(struct platform_device *pdev)
+{
+       struct device_node *node = pdev->dev.of_node;
+       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+       of_clk_del_provider(node);
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+       mtk_free_clk_data(clk_data);
+
+       return 0;
+}
+
+static const struct of_device_id of_match_clk_mt2712_apmixed[] = {
+       { .compatible = "mediatek,mt2712-apmixedsys" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_apmixed);
+
+static struct platform_driver clk_mt2712_apmixed_drv = {
+       .probe = clk_mt2712_apmixed_probe,
+       .remove = clk_mt2712_apmixed_remove,
+       .driver = {
+               .name = "clk-mt2712-apmixed",
+               .of_match_table = of_match_clk_mt2712_apmixed,
+       },
+};
+module_platform_driver(clk_mt2712_apmixed_drv)
+MODULE_LICENSE("GPL");
index 684d03e9f6de17e4d70db7d3788152b489dc35bc..f78e0181931612c8e96686526e541f0cfb14d600 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs bdp_cg_regs = {
        .sta_ofs = 0x100,
 };
 
-#define GATE_BDP(_id, _name, _parent, _shift) {        \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &bdp_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_BDP(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &bdp_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
 static const struct mtk_gate bdp_clks[] = {
        GATE_BDP(CLK_BDP_BRIDGE_B, "bdp_bridge_b", "mm_sel", 0),
@@ -71,6 +65,7 @@ static const struct of_device_id of_match_clk_mt2712_bdp[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_bdp);
 
 static struct platform_driver clk_mt2712_bdp_drv = {
        .probe = mtk_clk_simple_probe,
@@ -80,5 +75,5 @@ static struct platform_driver clk_mt2712_bdp_drv = {
                .of_match_table = of_match_clk_mt2712_bdp,
        },
 };
-
-builtin_platform_driver(clk_mt2712_bdp_drv);
+module_platform_driver(clk_mt2712_bdp_drv);
+MODULE_LICENSE("GPL");
index 335049cdc856c6f2a97e29d7fe12b708c577264a..fbe7084886a0ffa34c20cdda6c2bbea84333ebe2 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs img_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_IMG(_id, _name, _parent, _shift) {        \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &img_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_IMG(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
 static const struct mtk_gate img_clks[] = {
        GATE_IMG(CLK_IMG_SMI_LARB2, "img_smi_larb2", "mm_sel", 0),
@@ -49,6 +43,7 @@ static const struct of_device_id of_match_clk_mt2712_img[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_img);
 
 static struct platform_driver clk_mt2712_img_drv = {
        .probe = mtk_clk_simple_probe,
@@ -58,5 +53,5 @@ static struct platform_driver clk_mt2712_img_drv = {
                .of_match_table = of_match_clk_mt2712_img,
        },
 };
-
-builtin_platform_driver(clk_mt2712_img_drv);
+module_platform_driver(clk_mt2712_img_drv);
+MODULE_LICENSE("GPL");
index 07ba7c5e80aff3a6b39887c416425559ca78a15a..7e8c2ebcdee03f3538106d0eab3f1862bf352167 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs jpgdec_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_JPGDEC(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &jpgdec_cg_regs,                        \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_JPGDEC(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &jpgdec_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
 static const struct mtk_gate jpgdec_clks[] = {
        GATE_JPGDEC(CLK_JPGDEC_JPGDEC1, "jpgdec_jpgdec1", "jpgdec_sel", 0),
@@ -45,6 +39,7 @@ static const struct of_device_id of_match_clk_mt2712_jpgdec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_jpgdec);
 
 static struct platform_driver clk_mt2712_jpgdec_drv = {
        .probe = mtk_clk_simple_probe,
@@ -54,5 +49,5 @@ static struct platform_driver clk_mt2712_jpgdec_drv = {
                .of_match_table = of_match_clk_mt2712_jpgdec,
        },
 };
-
-builtin_platform_driver(clk_mt2712_jpgdec_drv);
+module_platform_driver(clk_mt2712_jpgdec_drv);
+MODULE_LICENSE("GPL");
index 42f8cf3ecf4cb2e529fadc68cb19eacd49d1beb9..932ea449d29964f1c54e428c2e251a835a3e5a35 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs mfg_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_MFG(_id, _name, _parent, _shift) {        \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &mfg_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_MFG(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &mfg_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate mfg_clks[] = {
        GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_sel", 0),
@@ -44,6 +38,7 @@ static const struct of_device_id of_match_clk_mt2712_mfg[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_mfg);
 
 static struct platform_driver clk_mt2712_mfg_drv = {
        .probe = mtk_clk_simple_probe,
@@ -53,5 +48,5 @@ static struct platform_driver clk_mt2712_mfg_drv = {
                .of_match_table = of_match_clk_mt2712_mfg,
        },
 };
-
-builtin_platform_driver(clk_mt2712_mfg_drv);
+module_platform_driver(clk_mt2712_mfg_drv);
+MODULE_LICENSE("GPL");
index 25b8af640c1287cc29bef21fdb9acad2989fed5a..204a3eae08dc5c26225a16bfad2c85472bf2322c 100644 (file)
@@ -30,32 +30,14 @@ static const struct mtk_gate_regs mm2_cg_regs = {
        .sta_ofs = 0x220,
 };
 
-#define GATE_MM0(_id, _name, _parent, _shift) {        \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &mm0_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_MM0(_id, _name, _parent, _shift)  \
+       GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_MM1(_id, _name, _parent, _shift) {        \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &mm1_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_MM1(_id, _name, _parent, _shift)  \
+       GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_MM2(_id, _name, _parent, _shift) {        \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &mm2_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_MM2(_id, _name, _parent, _shift)  \
+       GATE_MTK(_id, _name, _parent, &mm2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate mm_clks[] = {
        /* MM0 */
@@ -126,32 +108,24 @@ static const struct mtk_gate mm_clks[] = {
        GATE_MM2(CLK_MM_DSI3_DIGITAL, "mm_dsi3_digital", "dsi1_lntc", 6),
 };
 
-static int clk_mt2712_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
-
-       mtk_clk_register_gates(&pdev->dev, node, mm_clks,
-                              ARRAY_SIZE(mm_clks), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-
-       if (r != 0)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mm_clks,
+       .num_clks = ARRAY_SIZE(mm_clks),
+};
 
-       return r;
-}
+static const struct platform_device_id clk_mt2712_mm_id_table[] = {
+       { .name = "clk-mt2712-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt2712_mm_id_table);
 
 static struct platform_driver clk_mt2712_mm_drv = {
-       .probe = clk_mt2712_mm_probe,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt2712-mm",
        },
+       .id_table = clk_mt2712_mm_id_table,
 };
-
-builtin_platform_driver(clk_mt2712_mm_drv);
+module_platform_driver(clk_mt2712_mm_drv);
+MODULE_LICENSE("GPL");
index 6296ed5c5b5559cdb48d552242626739df044c8b..2fc1f82ebf5dbaded76fb82930acc307f213116a 100644 (file)
@@ -24,23 +24,11 @@ static const struct mtk_gate_regs vdec1_cg_regs = {
        .sta_ofs = 0x8,
 };
 
-#define GATE_VDEC0(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &vdec0_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_VDEC0(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
-#define GATE_VDEC1(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &vdec1_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_VDEC1(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
 static const struct mtk_gate vdec_clks[] = {
        /* VDEC0 */
@@ -63,6 +51,7 @@ static const struct of_device_id of_match_clk_mt2712_vdec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_vdec);
 
 static struct platform_driver clk_mt2712_vdec_drv = {
        .probe = mtk_clk_simple_probe,
@@ -72,5 +61,5 @@ static struct platform_driver clk_mt2712_vdec_drv = {
                .of_match_table = of_match_clk_mt2712_vdec,
        },
 };
-
-builtin_platform_driver(clk_mt2712_vdec_drv);
+module_platform_driver(clk_mt2712_vdec_drv);
+MODULE_LICENSE("GPL");
index b9bfc35de629c6a5a64873a8884ec35d6a3bb890..6d053a00cf95a8f62807ca94ebd08da8bf7b0587 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs venc_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_VENC(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &venc_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_VENC(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &venc_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
 static const struct mtk_gate venc_clks[] = {
        GATE_VENC(CLK_VENC_SMI_COMMON_CON, "venc_smi", "mm_sel", 0),
@@ -46,6 +40,7 @@ static const struct of_device_id of_match_clk_mt2712_venc[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_venc);
 
 static struct platform_driver clk_mt2712_venc_drv = {
        .probe = mtk_clk_simple_probe,
@@ -55,5 +50,5 @@ static struct platform_driver clk_mt2712_venc_drv = {
                .of_match_table = of_match_clk_mt2712_venc,
        },
 };
-
-builtin_platform_driver(clk_mt2712_venc_drv);
+module_platform_driver(clk_mt2712_venc_drv);
+MODULE_LICENSE("GPL");
index 94f8fc2a4f7bdbd880d74ca2914a6002cc33fb48..74c529f6163d91d9477aaeca15a85c598e11206b 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/slab.h>
 
 #include "clk-gate.h"
-#include "clk-pll.h"
 #include "clk-mtk.h"
 
 #include <dt-bindings/clock/mt2712-clk.h>
@@ -36,188 +35,96 @@ static const struct mtk_fixed_clk top_fixed_clks[] = {
        FIXED_CLK(CLK_TOP_CVBSPLL, "cvbspll", NULL, 108000000),
 };
 
-static const struct mtk_fixed_factor top_early_divs[] = {
-       FACTOR(CLK_TOP_SYS_26M, "sys_26m", "clk26m", 1,
-               1),
-       FACTOR(CLK_TOP_CLK26M_D2, "clk26m_d2", "sys_26m", 1,
-               2),
-};
-
 static const struct mtk_fixed_factor top_divs[] = {
-       FACTOR(CLK_TOP_ARMCA35PLL, "armca35pll_ck", "armca35pll", 1,
-               1),
-       FACTOR(CLK_TOP_ARMCA35PLL_600M, "armca35pll_600m", "armca35pll_ck", 1,
-               2),
-       FACTOR(CLK_TOP_ARMCA35PLL_400M, "armca35pll_400m", "armca35pll_ck", 1,
-               3),
-       FACTOR(CLK_TOP_ARMCA72PLL, "armca72pll_ck", "armca72pll", 1,
-               1),
-       FACTOR(CLK_TOP_SYSPLL, "syspll_ck", "mainpll", 1,
-               1),
-       FACTOR(CLK_TOP_SYSPLL_D2, "syspll_d2", "syspll_ck", 1,
-               2),
-       FACTOR(CLK_TOP_SYSPLL1_D2, "syspll1_d2", "syspll_d2", 1,
-               2),
-       FACTOR(CLK_TOP_SYSPLL1_D4, "syspll1_d4", "syspll_d2", 1,
-               4),
-       FACTOR(CLK_TOP_SYSPLL1_D8, "syspll1_d8", "syspll_d2", 1,
-               8),
-       FACTOR(CLK_TOP_SYSPLL1_D16, "syspll1_d16", "syspll_d2", 1,
-               16),
-       FACTOR(CLK_TOP_SYSPLL_D3, "syspll_d3", "syspll_ck", 1,
-               3),
-       FACTOR(CLK_TOP_SYSPLL2_D2, "syspll2_d2", "syspll_d3", 1,
-               2),
-       FACTOR(CLK_TOP_SYSPLL2_D4, "syspll2_d4", "syspll_d3", 1,
-               4),
-       FACTOR(CLK_TOP_SYSPLL_D5, "syspll_d5", "syspll_ck", 1,
-               5),
-       FACTOR(CLK_TOP_SYSPLL3_D2, "syspll3_d2", "syspll_d5", 1,
-               2),
-       FACTOR(CLK_TOP_SYSPLL3_D4, "syspll3_d4", "syspll_d5", 1,
-               4),
-       FACTOR(CLK_TOP_SYSPLL_D7, "syspll_d7", "syspll_ck", 1,
-               7),
-       FACTOR(CLK_TOP_SYSPLL4_D2, "syspll4_d2", "syspll_d7", 1,
-               2),
-       FACTOR(CLK_TOP_SYSPLL4_D4, "syspll4_d4", "syspll_d7", 1,
-               4),
-       FACTOR(CLK_TOP_UNIVPLL, "univpll_ck", "univpll", 1,
-               1),
-       FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll_ck", 1,
-               7),
-       FACTOR(CLK_TOP_UNIVPLL_D26, "univpll_d26", "univpll_ck", 1,
-               26),
-       FACTOR(CLK_TOP_UNIVPLL_D52, "univpll_d52", "univpll_ck", 1,
-               52),
-       FACTOR(CLK_TOP_UNIVPLL_D104, "univpll_d104", "univpll_ck", 1,
-               104),
-       FACTOR(CLK_TOP_UNIVPLL_D208, "univpll_d208", "univpll_ck", 1,
-               208),
-       FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll_ck", 1,
-               2),
-       FACTOR(CLK_TOP_UNIVPLL1_D2, "univpll1_d2", "univpll_d2", 1,
-               2),
-       FACTOR(CLK_TOP_UNIVPLL1_D4, "univpll1_d4", "univpll_d2", 1,
-               4),
-       FACTOR(CLK_TOP_UNIVPLL1_D8, "univpll1_d8", "univpll_d2", 1,
-               8),
-       FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll_ck", 1,
-               3),
-       FACTOR(CLK_TOP_UNIVPLL2_D2, "univpll2_d2", "univpll_d3", 1,
-               2),
-       FACTOR(CLK_TOP_UNIVPLL2_D4, "univpll2_d4", "univpll_d3", 1,
-               4),
-       FACTOR(CLK_TOP_UNIVPLL2_D8, "univpll2_d8", "univpll_d3", 1,
-               8),
-       FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll_ck", 1,
-               5),
-       FACTOR(CLK_TOP_UNIVPLL3_D2, "univpll3_d2", "univpll_d5", 1,
-               2),
-       FACTOR(CLK_TOP_UNIVPLL3_D4, "univpll3_d4", "univpll_d5", 1,
-               4),
-       FACTOR(CLK_TOP_UNIVPLL3_D8, "univpll3_d8", "univpll_d5", 1,
-               8),
-       FACTOR(CLK_TOP_F_MP0_PLL1, "f_mp0_pll1_ck", "univpll_d2", 1,
-               1),
-       FACTOR(CLK_TOP_F_MP0_PLL2, "f_mp0_pll2_ck", "univpll1_d2", 1,
-               1),
-       FACTOR(CLK_TOP_F_BIG_PLL1, "f_big_pll1_ck", "univpll_d2", 1,
-               1),
-       FACTOR(CLK_TOP_F_BIG_PLL2, "f_big_pll2_ck", "univpll1_d2", 1,
-               1),
-       FACTOR(CLK_TOP_F_BUS_PLL1, "f_bus_pll1_ck", "univpll_d2", 1,
-               1),
-       FACTOR(CLK_TOP_F_BUS_PLL2, "f_bus_pll2_ck", "univpll1_d2", 1,
-               1),
-       FACTOR(CLK_TOP_APLL1, "apll1_ck", "apll1", 1,
-               1),
-       FACTOR(CLK_TOP_APLL1_D2, "apll1_d2", "apll1_ck", 1,
-               2),
-       FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1_ck", 1,
-               4),
-       FACTOR(CLK_TOP_APLL1_D8, "apll1_d8", "apll1_ck", 1,
-               8),
-       FACTOR(CLK_TOP_APLL1_D16, "apll1_d16", "apll1_ck", 1,
-               16),
-       FACTOR(CLK_TOP_APLL2, "apll2_ck", "apll2", 1,
-               1),
-       FACTOR(CLK_TOP_APLL2_D2, "apll2_d2", "apll2_ck", 1,
-               2),
-       FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2_ck", 1,
-               4),
-       FACTOR(CLK_TOP_APLL2_D8, "apll2_d8", "apll2_ck", 1,
-               8),
-       FACTOR(CLK_TOP_APLL2_D16, "apll2_d16", "apll2_ck", 1,
-               16),
-       FACTOR(CLK_TOP_LVDSPLL, "lvdspll_ck", "lvdspll", 1,
-               1),
-       FACTOR(CLK_TOP_LVDSPLL_D2, "lvdspll_d2", "lvdspll_ck", 1,
-               2),
-       FACTOR(CLK_TOP_LVDSPLL_D4, "lvdspll_d4", "lvdspll_ck", 1,
-               4),
-       FACTOR(CLK_TOP_LVDSPLL_D8, "lvdspll_d8", "lvdspll_ck", 1,
-               8),
-       FACTOR(CLK_TOP_LVDSPLL2, "lvdspll2_ck", "lvdspll2", 1,
-               1),
-       FACTOR(CLK_TOP_LVDSPLL2_D2, "lvdspll2_d2", "lvdspll2_ck", 1,
-               2),
-       FACTOR(CLK_TOP_LVDSPLL2_D4, "lvdspll2_d4", "lvdspll2_ck", 1,
-               4),
-       FACTOR(CLK_TOP_LVDSPLL2_D8, "lvdspll2_d8", "lvdspll2_ck", 1,
-               8),
-       FACTOR(CLK_TOP_ETHERPLL_125M, "etherpll_125m", "etherpll", 1,
-               1),
-       FACTOR(CLK_TOP_ETHERPLL_50M, "etherpll_50m", "etherpll", 1,
-               1),
-       FACTOR(CLK_TOP_CVBS, "cvbs", "cvbspll", 1,
-               1),
-       FACTOR(CLK_TOP_CVBS_D2, "cvbs_d2", "cvbs", 1,
-               2),
-       FACTOR(CLK_TOP_MMPLL, "mmpll_ck", "mmpll", 1,
-               1),
-       FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", "mmpll_ck", 1,
-               2),
-       FACTOR(CLK_TOP_VENCPLL, "vencpll_ck", "vencpll", 1,
-               1),
-       FACTOR(CLK_TOP_VENCPLL_D2, "vencpll_d2", "vencpll_ck", 1,
-               2),
-       FACTOR(CLK_TOP_VCODECPLL, "vcodecpll_ck", "vcodecpll", 1,
-               1),
-       FACTOR(CLK_TOP_VCODECPLL_D2, "vcodecpll_d2", "vcodecpll_ck", 1,
-               2),
-       FACTOR(CLK_TOP_TVDPLL, "tvdpll_ck", "tvdpll", 1,
-               1),
-       FACTOR(CLK_TOP_TVDPLL_D2, "tvdpll_d2", "tvdpll_ck", 1,
-               2),
-       FACTOR(CLK_TOP_TVDPLL_D4, "tvdpll_d4", "tvdpll_ck", 1,
-               4),
-       FACTOR(CLK_TOP_TVDPLL_D8, "tvdpll_d8", "tvdpll_ck", 1,
-               8),
-       FACTOR(CLK_TOP_TVDPLL_429M, "tvdpll_429m", "tvdpll", 1,
-               1),
-       FACTOR(CLK_TOP_TVDPLL_429M_D2, "tvdpll_429m_d2", "tvdpll_429m", 1,
-               2),
-       FACTOR(CLK_TOP_TVDPLL_429M_D4, "tvdpll_429m_d4", "tvdpll_429m", 1,
-               4),
-       FACTOR(CLK_TOP_MSDCPLL, "msdcpll_ck", "msdcpll", 1,
-               1),
-       FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll_ck", 1,
-               2),
-       FACTOR(CLK_TOP_MSDCPLL_D4, "msdcpll_d4", "msdcpll_ck", 1,
-               4),
-       FACTOR(CLK_TOP_MSDCPLL2, "msdcpll2_ck", "msdcpll2", 1,
-               1),
-       FACTOR(CLK_TOP_MSDCPLL2_D2, "msdcpll2_d2", "msdcpll2_ck", 1,
-               2),
-       FACTOR(CLK_TOP_MSDCPLL2_D4, "msdcpll2_d4", "msdcpll2_ck", 1,
-               4),
-       FACTOR(CLK_TOP_D2A_ULCLK_6P5M, "d2a_ulclk_6p5m", "clk26m", 1,
-               4),
-       FACTOR(CLK_TOP_APLL1_D3, "apll1_d3", "apll1_ck", 1,
-               3),
-       FACTOR(CLK_TOP_APLL2_D3, "apll2_d3", "apll2_ck", 1,
-               3),
+       FACTOR(CLK_TOP_SYS_26M, "sys_26m", "clk26m", 1, 1),
+       FACTOR(CLK_TOP_CLK26M_D2, "clk26m_d2", "sys_26m", 1, 2),
+       FACTOR(CLK_TOP_ARMCA35PLL, "armca35pll_ck", "armca35pll", 1, 1),
+       FACTOR(CLK_TOP_ARMCA35PLL_600M, "armca35pll_600m", "armca35pll_ck", 1, 2),
+       FACTOR(CLK_TOP_ARMCA35PLL_400M, "armca35pll_400m", "armca35pll_ck", 1, 3),
+       FACTOR(CLK_TOP_ARMCA72PLL, "armca72pll_ck", "armca72pll", 1, 1),
+       FACTOR(CLK_TOP_SYSPLL, "syspll_ck", "mainpll", 1, 1),
+       FACTOR(CLK_TOP_SYSPLL_D2, "syspll_d2", "syspll_ck", 1, 2),
+       FACTOR(CLK_TOP_SYSPLL1_D2, "syspll1_d2", "syspll_d2", 1, 2),
+       FACTOR(CLK_TOP_SYSPLL1_D4, "syspll1_d4", "syspll_d2", 1, 4),
+       FACTOR(CLK_TOP_SYSPLL1_D8, "syspll1_d8", "syspll_d2", 1, 8),
+       FACTOR(CLK_TOP_SYSPLL1_D16, "syspll1_d16", "syspll_d2", 1, 16),
+       FACTOR(CLK_TOP_SYSPLL_D3, "syspll_d3", "syspll_ck", 1, 3),
+       FACTOR(CLK_TOP_SYSPLL2_D2, "syspll2_d2", "syspll_d3", 1, 2),
+       FACTOR(CLK_TOP_SYSPLL2_D4, "syspll2_d4", "syspll_d3", 1, 4),
+       FACTOR(CLK_TOP_SYSPLL_D5, "syspll_d5", "syspll_ck", 1, 5),
+       FACTOR(CLK_TOP_SYSPLL3_D2, "syspll3_d2", "syspll_d5", 1, 2),
+       FACTOR(CLK_TOP_SYSPLL3_D4, "syspll3_d4", "syspll_d5", 1, 4),
+       FACTOR(CLK_TOP_SYSPLL_D7, "syspll_d7", "syspll_ck", 1, 7),
+       FACTOR(CLK_TOP_SYSPLL4_D2, "syspll4_d2", "syspll_d7", 1, 2),
+       FACTOR(CLK_TOP_SYSPLL4_D4, "syspll4_d4", "syspll_d7", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL, "univpll_ck", "univpll", 1, 1),
+       FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll_ck", 1, 7),
+       FACTOR(CLK_TOP_UNIVPLL_D26, "univpll_d26", "univpll_ck", 1, 26),
+       FACTOR(CLK_TOP_UNIVPLL_D52, "univpll_d52", "univpll_ck", 1, 52),
+       FACTOR(CLK_TOP_UNIVPLL_D104, "univpll_d104", "univpll_ck", 1, 104),
+       FACTOR(CLK_TOP_UNIVPLL_D208, "univpll_d208", "univpll_ck", 1, 208),
+       FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll_ck", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL1_D2, "univpll1_d2", "univpll_d2", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL1_D4, "univpll1_d4", "univpll_d2", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL1_D8, "univpll1_d8", "univpll_d2", 1, 8),
+       FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll_ck", 1, 3),
+       FACTOR(CLK_TOP_UNIVPLL2_D2, "univpll2_d2", "univpll_d3", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL2_D4, "univpll2_d4", "univpll_d3", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL2_D8, "univpll2_d8", "univpll_d3", 1, 8),
+       FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll_ck", 1, 5),
+       FACTOR(CLK_TOP_UNIVPLL3_D2, "univpll3_d2", "univpll_d5", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL3_D4, "univpll3_d4", "univpll_d5", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL3_D8, "univpll3_d8", "univpll_d5", 1, 8),
+       FACTOR(CLK_TOP_F_MP0_PLL1, "f_mp0_pll1_ck", "univpll_d2", 1, 1),
+       FACTOR(CLK_TOP_F_MP0_PLL2, "f_mp0_pll2_ck", "univpll1_d2", 1, 1),
+       FACTOR(CLK_TOP_F_BIG_PLL1, "f_big_pll1_ck", "univpll_d2", 1, 1),
+       FACTOR(CLK_TOP_F_BIG_PLL2, "f_big_pll2_ck", "univpll1_d2", 1, 1),
+       FACTOR(CLK_TOP_F_BUS_PLL1, "f_bus_pll1_ck", "univpll_d2", 1, 1),
+       FACTOR(CLK_TOP_F_BUS_PLL2, "f_bus_pll2_ck", "univpll1_d2", 1, 1),
+       FACTOR(CLK_TOP_APLL1, "apll1_ck", "apll1", 1, 1),
+       FACTOR(CLK_TOP_APLL1_D2, "apll1_d2", "apll1_ck", 1, 2),
+       FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1_ck", 1, 4),
+       FACTOR(CLK_TOP_APLL1_D8, "apll1_d8", "apll1_ck", 1, 8),
+       FACTOR(CLK_TOP_APLL1_D16, "apll1_d16", "apll1_ck", 1, 16),
+       FACTOR(CLK_TOP_APLL2, "apll2_ck", "apll2", 1, 1),
+       FACTOR(CLK_TOP_APLL2_D2, "apll2_d2", "apll2_ck", 1, 2),
+       FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2_ck", 1, 4),
+       FACTOR(CLK_TOP_APLL2_D8, "apll2_d8", "apll2_ck", 1, 8),
+       FACTOR(CLK_TOP_APLL2_D16, "apll2_d16", "apll2_ck", 1, 16),
+       FACTOR(CLK_TOP_LVDSPLL, "lvdspll_ck", "lvdspll", 1, 1),
+       FACTOR(CLK_TOP_LVDSPLL_D2, "lvdspll_d2", "lvdspll_ck", 1, 2),
+       FACTOR(CLK_TOP_LVDSPLL_D4, "lvdspll_d4", "lvdspll_ck", 1, 4),
+       FACTOR(CLK_TOP_LVDSPLL_D8, "lvdspll_d8", "lvdspll_ck", 1, 8),
+       FACTOR(CLK_TOP_LVDSPLL2, "lvdspll2_ck", "lvdspll2", 1, 1),
+       FACTOR(CLK_TOP_LVDSPLL2_D2, "lvdspll2_d2", "lvdspll2_ck", 1, 2),
+       FACTOR(CLK_TOP_LVDSPLL2_D4, "lvdspll2_d4", "lvdspll2_ck", 1, 4),
+       FACTOR(CLK_TOP_LVDSPLL2_D8, "lvdspll2_d8", "lvdspll2_ck", 1, 8),
+       FACTOR(CLK_TOP_ETHERPLL_125M, "etherpll_125m", "etherpll", 1, 1),
+       FACTOR(CLK_TOP_ETHERPLL_50M, "etherpll_50m", "etherpll", 1, 1),
+       FACTOR(CLK_TOP_CVBS, "cvbs", "cvbspll", 1, 1),
+       FACTOR(CLK_TOP_CVBS_D2, "cvbs_d2", "cvbs", 1, 2),
+       FACTOR(CLK_TOP_MMPLL, "mmpll_ck", "mmpll", 1, 1),
+       FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", "mmpll_ck", 1, 2),
+       FACTOR(CLK_TOP_VENCPLL, "vencpll_ck", "vencpll", 1, 1),
+       FACTOR(CLK_TOP_VENCPLL_D2, "vencpll_d2", "vencpll_ck", 1, 2),
+       FACTOR(CLK_TOP_VCODECPLL, "vcodecpll_ck", "vcodecpll", 1, 1),
+       FACTOR(CLK_TOP_VCODECPLL_D2, "vcodecpll_d2", "vcodecpll_ck", 1, 2),
+       FACTOR(CLK_TOP_TVDPLL, "tvdpll_ck", "tvdpll", 1, 1),
+       FACTOR(CLK_TOP_TVDPLL_D2, "tvdpll_d2", "tvdpll_ck", 1, 2),
+       FACTOR(CLK_TOP_TVDPLL_D4, "tvdpll_d4", "tvdpll_ck", 1, 4),
+       FACTOR(CLK_TOP_TVDPLL_D8, "tvdpll_d8", "tvdpll_ck", 1, 8),
+       FACTOR(CLK_TOP_TVDPLL_429M, "tvdpll_429m", "tvdpll", 1, 1),
+       FACTOR(CLK_TOP_TVDPLL_429M_D2, "tvdpll_429m_d2", "tvdpll_429m", 1, 2),
+       FACTOR(CLK_TOP_TVDPLL_429M_D4, "tvdpll_429m_d4", "tvdpll_429m", 1, 4),
+       FACTOR(CLK_TOP_MSDCPLL, "msdcpll_ck", "msdcpll", 1, 1),
+       FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll_ck", 1, 2),
+       FACTOR(CLK_TOP_MSDCPLL_D4, "msdcpll_d4", "msdcpll_ck", 1, 4),
+       FACTOR(CLK_TOP_MSDCPLL2, "msdcpll2_ck", "msdcpll2", 1, 1),
+       FACTOR(CLK_TOP_MSDCPLL2_D2, "msdcpll2_d2", "msdcpll2_ck", 1, 2),
+       FACTOR(CLK_TOP_MSDCPLL2_D4, "msdcpll2_d4", "msdcpll2_ck", 1, 4),
+       FACTOR(CLK_TOP_D2A_ULCLK_6P5M, "d2a_ulclk_6p5m", "clk26m", 1, 4),
+       FACTOR(CLK_TOP_APLL1_D3, "apll1_d3", "apll1_ck", 1, 3),
+       FACTOR(CLK_TOP_APLL2_D3, "apll2_d3", "apll2_ck", 1, 3),
 };
 
 static const char * const axi_parents[] = {
@@ -737,169 +644,118 @@ static const char * const audull_vtx_parents[] = {
 static struct mtk_composite top_muxes[] = {
        /* CLK_CFG_0 */
        MUX_GATE_FLAGS(CLK_TOP_AXI_SEL, "axi_sel", axi_parents, 0x040, 0, 3,
-               7, CLK_IS_CRITICAL),
+                      7, CLK_IS_CRITICAL),
        MUX_GATE_FLAGS(CLK_TOP_MEM_SEL, "mem_sel", mem_parents, 0x040, 8, 1,
-               15, CLK_IS_CRITICAL),
-       MUX_GATE(CLK_TOP_MM_SEL, "mm_sel",
-               mm_parents, 0x040, 24, 3, 31),
+                      15, CLK_IS_CRITICAL),
+       MUX_GATE(CLK_TOP_MM_SEL, "mm_sel", mm_parents, 0x040, 24, 3, 31),
        /* CLK_CFG_1 */
-       MUX_GATE(CLK_TOP_PWM_SEL, "pwm_sel",
-               pwm_parents, 0x050, 0, 2, 7),
-       MUX_GATE(CLK_TOP_VDEC_SEL, "vdec_sel",
-               vdec_parents, 0x050, 8, 4, 15),
-       MUX_GATE(CLK_TOP_VENC_SEL, "venc_sel",
-               venc_parents, 0x050, 16, 4, 23),
-       MUX_GATE(CLK_TOP_MFG_SEL, "mfg_sel",
-               mfg_parents, 0x050, 24, 4, 31),
+       MUX_GATE(CLK_TOP_PWM_SEL, "pwm_sel", pwm_parents, 0x050, 0, 2, 7),
+       MUX_GATE(CLK_TOP_VDEC_SEL, "vdec_sel", vdec_parents, 0x050, 8, 4, 15),
+       MUX_GATE(CLK_TOP_VENC_SEL, "venc_sel", venc_parents, 0x050, 16, 4, 23),
+       MUX_GATE(CLK_TOP_MFG_SEL, "mfg_sel", mfg_parents, 0x050, 24, 4, 31),
        /* CLK_CFG_2 */
-       MUX_GATE(CLK_TOP_CAMTG_SEL, "camtg_sel",
-               camtg_parents, 0x060, 0, 4, 7),
-       MUX_GATE(CLK_TOP_UART_SEL, "uart_sel",
-               uart_parents, 0x060, 8, 1, 15),
-       MUX_GATE(CLK_TOP_SPI_SEL, "spi_sel",
-               spi_parents, 0x060, 16, 3, 23),
-       MUX_GATE(CLK_TOP_USB20_SEL, "usb20_sel",
-               usb20_parents, 0x060, 24, 2, 31),
+       MUX_GATE(CLK_TOP_CAMTG_SEL, "camtg_sel", camtg_parents, 0x060, 0, 4, 7),
+       MUX_GATE(CLK_TOP_UART_SEL, "uart_sel", uart_parents, 0x060, 8, 1, 15),
+       MUX_GATE(CLK_TOP_SPI_SEL, "spi_sel", spi_parents, 0x060, 16, 3, 23),
+       MUX_GATE(CLK_TOP_USB20_SEL, "usb20_sel", usb20_parents, 0x060, 24, 2, 31),
        /* CLK_CFG_3 */
-       MUX_GATE(CLK_TOP_USB30_SEL, "usb30_sel",
-               usb30_parents, 0x070, 0, 2, 7),
-       MUX_GATE(CLK_TOP_MSDC50_0_HCLK_SEL, "msdc50_0_h_sel",
-               msdc50_0_h_parents, 0x070, 8, 3, 15),
-       MUX_GATE(CLK_TOP_MSDC50_0_SEL, "msdc50_0_sel",
-               msdc50_0_parents, 0x070, 16, 4, 23),
-       MUX_GATE(CLK_TOP_MSDC30_1_SEL, "msdc30_1_sel",
-               msdc30_1_parents, 0x070, 24, 3, 31),
+       MUX_GATE(CLK_TOP_USB30_SEL, "usb30_sel", usb30_parents, 0x070, 0, 2, 7),
+       MUX_GATE(CLK_TOP_MSDC50_0_HCLK_SEL, "msdc50_0_h_sel", msdc50_0_h_parents,
+                0x070, 8, 3, 15),
+       MUX_GATE(CLK_TOP_MSDC50_0_SEL, "msdc50_0_sel", msdc50_0_parents,
+                0x070, 16, 4, 23),
+       MUX_GATE(CLK_TOP_MSDC30_1_SEL, "msdc30_1_sel", msdc30_1_parents,
+                0x070, 24, 3, 31),
        /* CLK_CFG_4 */
-       MUX_GATE(CLK_TOP_MSDC30_2_SEL, "msdc30_2_sel",
-               msdc30_1_parents, 0x080, 0, 3, 7),
-       MUX_GATE(CLK_TOP_MSDC30_3_SEL, "msdc30_3_sel",
-               msdc30_3_parents, 0x080, 8, 4, 15),
-       MUX_GATE(CLK_TOP_AUDIO_SEL, "audio_sel",
-               audio_parents, 0x080, 16, 2, 23),
-       MUX_GATE(CLK_TOP_AUD_INTBUS_SEL, "aud_intbus_sel",
-               aud_intbus_parents, 0x080, 24, 3, 31),
+       MUX_GATE(CLK_TOP_MSDC30_2_SEL, "msdc30_2_sel", msdc30_1_parents,
+                0x080, 0, 3, 7),
+       MUX_GATE(CLK_TOP_MSDC30_3_SEL, "msdc30_3_sel", msdc30_3_parents,
+                0x080, 8, 4, 15),
+       MUX_GATE(CLK_TOP_AUDIO_SEL, "audio_sel", audio_parents,
+                0x080, 16, 2, 23),
+       MUX_GATE(CLK_TOP_AUD_INTBUS_SEL, "aud_intbus_sel", aud_intbus_parents,
+                0x080, 24, 3, 31),
        /* CLK_CFG_5 */
-       MUX_GATE(CLK_TOP_PMICSPI_SEL, "pmicspi_sel",
-               pmicspi_parents, 0x090, 0, 3, 7),
-       MUX_GATE(CLK_TOP_DPILVDS1_SEL, "dpilvds1_sel",
-               dpilvds1_parents, 0x090, 8, 3, 15),
-       MUX_GATE(CLK_TOP_ATB_SEL, "atb_sel",
-               atb_parents, 0x090, 16, 2, 23),
-       MUX_GATE(CLK_TOP_NR_SEL, "nr_sel",
-               nr_parents, 0x090, 24, 3, 31),
+       MUX_GATE(CLK_TOP_PMICSPI_SEL, "pmicspi_sel", pmicspi_parents, 0x090, 0, 3, 7),
+       MUX_GATE(CLK_TOP_DPILVDS1_SEL, "dpilvds1_sel", dpilvds1_parents,
+                0x090, 8, 3, 15),
+       MUX_GATE(CLK_TOP_ATB_SEL, "atb_sel", atb_parents, 0x090, 16, 2, 23),
+       MUX_GATE(CLK_TOP_NR_SEL, "nr_sel", nr_parents, 0x090, 24, 3, 31),
        /* CLK_CFG_6 */
-       MUX_GATE(CLK_TOP_NFI2X_SEL, "nfi2x_sel",
-               nfi2x_parents, 0x0a0, 0, 4, 7),
-       MUX_GATE(CLK_TOP_IRDA_SEL, "irda_sel",
-               irda_parents, 0x0a0, 8, 2, 15),
-       MUX_GATE(CLK_TOP_CCI400_SEL, "cci400_sel",
-               cci400_parents, 0x0a0, 16, 3, 23),
-       MUX_GATE(CLK_TOP_AUD_1_SEL, "aud_1_sel",
-               aud_1_parents, 0x0a0, 24, 2, 31),
+       MUX_GATE(CLK_TOP_NFI2X_SEL, "nfi2x_sel", nfi2x_parents, 0x0a0, 0, 4, 7),
+       MUX_GATE(CLK_TOP_IRDA_SEL, "irda_sel", irda_parents, 0x0a0, 8, 2, 15),
+       MUX_GATE(CLK_TOP_CCI400_SEL, "cci400_sel", cci400_parents, 0x0a0, 16, 3, 23),
+       MUX_GATE(CLK_TOP_AUD_1_SEL, "aud_1_sel", aud_1_parents, 0x0a0, 24, 2, 31),
        /* CLK_CFG_7 */
-       MUX_GATE(CLK_TOP_AUD_2_SEL, "aud_2_sel",
-               aud_2_parents, 0x0b0, 0, 2, 7),
-       MUX_GATE(CLK_TOP_MEM_MFG_IN_AS_SEL, "mem_mfg_sel",
-               mem_mfg_parents, 0x0b0, 8, 2, 15),
-       MUX_GATE(CLK_TOP_AXI_MFG_IN_AS_SEL, "axi_mfg_sel",
-               axi_mfg_parents, 0x0b0, 16, 2, 23),
-       MUX_GATE(CLK_TOP_SCAM_SEL, "scam_sel",
-               scam_parents, 0x0b0, 24, 2, 31),
+       MUX_GATE(CLK_TOP_AUD_2_SEL, "aud_2_sel", aud_2_parents, 0x0b0, 0, 2, 7),
+       MUX_GATE(CLK_TOP_MEM_MFG_IN_AS_SEL, "mem_mfg_sel", mem_mfg_parents,
+                0x0b0, 8, 2, 15),
+       MUX_GATE(CLK_TOP_AXI_MFG_IN_AS_SEL, "axi_mfg_sel", axi_mfg_parents,
+                0x0b0, 16, 2, 23),
+       MUX_GATE(CLK_TOP_SCAM_SEL, "scam_sel", scam_parents, 0x0b0, 24, 2, 31),
        /* CLK_CFG_8 */
-       MUX_GATE(CLK_TOP_NFIECC_SEL, "nfiecc_sel",
-               nfiecc_parents, 0x0c0, 0, 3, 7),
-       MUX_GATE(CLK_TOP_PE2_MAC_P0_SEL, "pe2_mac_p0_sel",
-               pe2_mac_p0_parents, 0x0c0, 8, 3, 15),
-       MUX_GATE(CLK_TOP_PE2_MAC_P1_SEL, "pe2_mac_p1_sel",
-               pe2_mac_p0_parents, 0x0c0, 16, 3, 23),
-       MUX_GATE(CLK_TOP_DPILVDS_SEL, "dpilvds_sel",
-               dpilvds_parents, 0x0c0, 24, 3, 31),
+       MUX_GATE(CLK_TOP_NFIECC_SEL, "nfiecc_sel", nfiecc_parents, 0x0c0, 0, 3, 7),
+       MUX_GATE(CLK_TOP_PE2_MAC_P0_SEL, "pe2_mac_p0_sel", pe2_mac_p0_parents,
+                0x0c0, 8, 3, 15),
+       MUX_GATE(CLK_TOP_PE2_MAC_P1_SEL, "pe2_mac_p1_sel", pe2_mac_p0_parents,
+                0x0c0, 16, 3, 23),
+       MUX_GATE(CLK_TOP_DPILVDS_SEL, "dpilvds_sel", dpilvds_parents, 0x0c0, 24, 3, 31),
        /* CLK_CFG_9 */
-       MUX_GATE(CLK_TOP_MSDC50_3_HCLK_SEL, "msdc50_3_h_sel",
-               msdc50_0_h_parents, 0x0d0, 0, 3, 7),
-       MUX_GATE(CLK_TOP_HDCP_SEL, "hdcp_sel",
-               hdcp_parents, 0x0d0, 8, 2, 15),
-       MUX_GATE(CLK_TOP_HDCP_24M_SEL, "hdcp_24m_sel",
-               hdcp_24m_parents, 0x0d0, 16, 2, 23),
-       MUX_GATE_FLAGS(CLK_TOP_RTC_SEL, "rtc_sel", rtc_parents, 0x0d0, 24, 2,
-               31, CLK_IS_CRITICAL),
+       MUX_GATE(CLK_TOP_MSDC50_3_HCLK_SEL, "msdc50_3_h_sel", msdc50_0_h_parents,
+                0x0d0, 0, 3, 7),
+       MUX_GATE(CLK_TOP_HDCP_SEL, "hdcp_sel", hdcp_parents, 0x0d0, 8, 2, 15),
+       MUX_GATE(CLK_TOP_HDCP_24M_SEL, "hdcp_24m_sel", hdcp_24m_parents,
+                0x0d0, 16, 2, 23),
+       MUX_GATE_FLAGS(CLK_TOP_RTC_SEL, "rtc_sel", rtc_parents,
+                      0x0d0, 24, 2, 31, CLK_IS_CRITICAL),
        /* CLK_CFG_10 */
-       MUX_GATE(CLK_TOP_SPINOR_SEL, "spinor_sel",
-               spinor_parents, 0x500, 0, 4, 7),
-       MUX_GATE(CLK_TOP_APLL_SEL, "apll_sel",
-               apll_parents, 0x500, 8, 4, 15),
-       MUX_GATE(CLK_TOP_APLL2_SEL, "apll2_sel",
-               apll_parents, 0x500, 16, 4, 23),
-       MUX_GATE(CLK_TOP_A1SYS_HP_SEL, "a1sys_hp_sel",
-               a1sys_hp_parents, 0x500, 24, 3, 31),
+       MUX_GATE(CLK_TOP_SPINOR_SEL, "spinor_sel", spinor_parents, 0x500, 0, 4, 7),
+       MUX_GATE(CLK_TOP_APLL_SEL, "apll_sel", apll_parents, 0x500, 8, 4, 15),
+       MUX_GATE(CLK_TOP_APLL2_SEL, "apll2_sel", apll_parents, 0x500, 16, 4, 23),
+       MUX_GATE(CLK_TOP_A1SYS_HP_SEL, "a1sys_hp_sel", a1sys_hp_parents,
+                0x500, 24, 3, 31),
        /* CLK_CFG_11 */
-       MUX_GATE(CLK_TOP_A2SYS_HP_SEL, "a2sys_hp_sel",
-               a2sys_hp_parents, 0x510, 0, 3, 7),
-       MUX_GATE(CLK_TOP_ASM_L_SEL, "asm_l_sel",
-               asm_l_parents, 0x510, 8, 2, 15),
-       MUX_GATE(CLK_TOP_ASM_M_SEL, "asm_m_sel",
-               asm_l_parents, 0x510, 16, 2, 23),
-       MUX_GATE(CLK_TOP_ASM_H_SEL, "asm_h_sel",
-               asm_l_parents, 0x510, 24, 2, 31),
+       MUX_GATE(CLK_TOP_A2SYS_HP_SEL, "a2sys_hp_sel", a2sys_hp_parents, 0x510, 0, 3, 7),
+       MUX_GATE(CLK_TOP_ASM_L_SEL, "asm_l_sel", asm_l_parents, 0x510, 8, 2, 15),
+       MUX_GATE(CLK_TOP_ASM_M_SEL, "asm_m_sel", asm_l_parents, 0x510, 16, 2, 23),
+       MUX_GATE(CLK_TOP_ASM_H_SEL, "asm_h_sel", asm_l_parents, 0x510, 24, 2, 31),
        /* CLK_CFG_12 */
-       MUX_GATE(CLK_TOP_I2SO1_SEL, "i2so1_sel",
-               i2so1_parents, 0x520, 0, 2, 7),
-       MUX_GATE(CLK_TOP_I2SO2_SEL, "i2so2_sel",
-               i2so1_parents, 0x520, 8, 2, 15),
-       MUX_GATE(CLK_TOP_I2SO3_SEL, "i2so3_sel",
-               i2so1_parents, 0x520, 16, 2, 23),
-       MUX_GATE(CLK_TOP_TDMO0_SEL, "tdmo0_sel",
-               i2so1_parents, 0x520, 24, 2, 31),
+       MUX_GATE(CLK_TOP_I2SO1_SEL, "i2so1_sel", i2so1_parents, 0x520, 0, 2, 7),
+       MUX_GATE(CLK_TOP_I2SO2_SEL, "i2so2_sel", i2so1_parents, 0x520, 8, 2, 15),
+       MUX_GATE(CLK_TOP_I2SO3_SEL, "i2so3_sel", i2so1_parents, 0x520, 16, 2, 23),
+       MUX_GATE(CLK_TOP_TDMO0_SEL, "tdmo0_sel", i2so1_parents, 0x520, 24, 2, 31),
        /* CLK_CFG_13 */
-       MUX_GATE(CLK_TOP_TDMO1_SEL, "tdmo1_sel",
-               i2so1_parents, 0x530, 0, 2, 7),
-       MUX_GATE(CLK_TOP_I2SI1_SEL, "i2si1_sel",
-               i2so1_parents, 0x530, 8, 2, 15),
-       MUX_GATE(CLK_TOP_I2SI2_SEL, "i2si2_sel",
-               i2so1_parents, 0x530, 16, 2, 23),
-       MUX_GATE(CLK_TOP_I2SI3_SEL, "i2si3_sel",
-               i2so1_parents, 0x530, 24, 2, 31),
+       MUX_GATE(CLK_TOP_TDMO1_SEL, "tdmo1_sel", i2so1_parents, 0x530, 0, 2, 7),
+       MUX_GATE(CLK_TOP_I2SI1_SEL, "i2si1_sel", i2so1_parents, 0x530, 8, 2, 15),
+       MUX_GATE(CLK_TOP_I2SI2_SEL, "i2si2_sel", i2so1_parents, 0x530, 16, 2, 23),
+       MUX_GATE(CLK_TOP_I2SI3_SEL, "i2si3_sel", i2so1_parents, 0x530, 24, 2, 31),
        /* CLK_CFG_14 */
-       MUX_GATE(CLK_TOP_ETHER_125M_SEL, "ether_125m_sel",
-               ether_125m_parents, 0x540, 0, 2, 7),
-       MUX_GATE(CLK_TOP_ETHER_50M_SEL, "ether_50m_sel",
-               ether_50m_parents, 0x540, 8, 2, 15),
-       MUX_GATE(CLK_TOP_JPGDEC_SEL, "jpgdec_sel",
-               jpgdec_parents, 0x540, 16, 4, 23),
-       MUX_GATE(CLK_TOP_SPISLV_SEL, "spislv_sel",
-               spislv_parents, 0x540, 24, 3, 31),
+       MUX_GATE(CLK_TOP_ETHER_125M_SEL, "ether_125m_sel", ether_125m_parents,
+                0x540, 0, 2, 7),
+       MUX_GATE(CLK_TOP_ETHER_50M_SEL, "ether_50m_sel", ether_50m_parents,
+                0x540, 8, 2, 15),
+       MUX_GATE(CLK_TOP_JPGDEC_SEL, "jpgdec_sel", jpgdec_parents, 0x540, 16, 4, 23),
+       MUX_GATE(CLK_TOP_SPISLV_SEL, "spislv_sel", spislv_parents, 0x540, 24, 3, 31),
        /* CLK_CFG_15 */
-       MUX_GATE(CLK_TOP_ETHER_50M_RMII_SEL, "ether_sel",
-               ether_parents, 0x550, 0, 2, 7),
-       MUX_GATE(CLK_TOP_CAM2TG_SEL, "cam2tg_sel",
-               camtg_parents, 0x550, 8, 4, 15),
-       MUX_GATE(CLK_TOP_DI_SEL, "di_sel",
-               di_parents, 0x550, 16, 3, 23),
-       MUX_GATE(CLK_TOP_TVD_SEL, "tvd_sel",
-               tvd_parents, 0x550, 24, 2, 31),
+       MUX_GATE(CLK_TOP_ETHER_50M_RMII_SEL, "ether_sel", ether_parents, 0x550, 0, 2, 7),
+       MUX_GATE(CLK_TOP_CAM2TG_SEL, "cam2tg_sel", camtg_parents, 0x550, 8, 4, 15),
+       MUX_GATE(CLK_TOP_DI_SEL, "di_sel", di_parents, 0x550, 16, 3, 23),
+       MUX_GATE(CLK_TOP_TVD_SEL, "tvd_sel", tvd_parents, 0x550, 24, 2, 31),
        /* CLK_CFG_16 */
-       MUX_GATE(CLK_TOP_I2C_SEL, "i2c_sel",
-               i2c_parents, 0x560, 0, 3, 7),
-       MUX_GATE(CLK_TOP_PWM_INFRA_SEL, "pwm_infra_sel",
-               pwm_parents, 0x560, 8, 2, 15),
-       MUX_GATE(CLK_TOP_MSDC0P_AES_SEL, "msdc0p_aes_sel",
-               msdc0p_aes_parents, 0x560, 16, 2, 23),
-       MUX_GATE(CLK_TOP_CMSYS_SEL, "cmsys_sel",
-               cmsys_parents, 0x560, 24, 3, 31),
+       MUX_GATE(CLK_TOP_I2C_SEL, "i2c_sel", i2c_parents, 0x560, 0, 3, 7),
+       MUX_GATE(CLK_TOP_PWM_INFRA_SEL, "pwm_infra_sel", pwm_parents, 0x560, 8, 2, 15),
+       MUX_GATE(CLK_TOP_MSDC0P_AES_SEL, "msdc0p_aes_sel", msdc0p_aes_parents,
+                0x560, 16, 2, 23),
+       MUX_GATE(CLK_TOP_CMSYS_SEL, "cmsys_sel", cmsys_parents, 0x560, 24, 3, 31),
        /* CLK_CFG_17 */
-       MUX_GATE(CLK_TOP_GCPU_SEL, "gcpu_sel",
-               gcpu_parents, 0x570, 0, 3, 7),
+       MUX_GATE(CLK_TOP_GCPU_SEL, "gcpu_sel", gcpu_parents, 0x570, 0, 3, 7),
        /* CLK_AUDDIV_4 */
-       MUX(CLK_TOP_AUD_APLL1_SEL, "aud_apll1_sel",
-               aud_apll1_parents, 0x134, 0, 1),
-       MUX(CLK_TOP_AUD_APLL2_SEL, "aud_apll2_sel",
-               aud_apll2_parents, 0x134, 1, 1),
-       MUX(CLK_TOP_DA_AUDULL_VTX_6P5M_SEL, "audull_vtx_sel",
-               audull_vtx_parents, 0x134, 31, 1),
-       MUX(CLK_TOP_APLL1_REF_SEL, "apll1_ref_sel",
-               apll1_ref_parents, 0x134, 4, 3),
-       MUX(CLK_TOP_APLL2_REF_SEL, "apll2_ref_sel",
-               apll1_ref_parents, 0x134, 7, 3),
+       MUX(CLK_TOP_AUD_APLL1_SEL, "aud_apll1_sel", aud_apll1_parents, 0x134, 0, 1),
+       MUX(CLK_TOP_AUD_APLL2_SEL, "aud_apll2_sel", aud_apll2_parents, 0x134, 1, 1),
+       MUX(CLK_TOP_DA_AUDULL_VTX_6P5M_SEL, "audull_vtx_sel", audull_vtx_parents,
+           0x134, 31, 1),
+       MUX(CLK_TOP_APLL1_REF_SEL, "apll1_ref_sel", apll1_ref_parents, 0x134, 4, 3),
+       MUX(CLK_TOP_APLL2_REF_SEL, "apll2_ref_sel", apll1_ref_parents, 0x134, 7, 3),
 };
 
 static const char * const mcu_mp0_parents[] = {
@@ -926,13 +782,13 @@ static const char * const mcu_bus_parents[] = {
 static struct mtk_composite mcu_muxes[] = {
        /* mp0_pll_divider_cfg */
        MUX_GATE_FLAGS(CLK_MCU_MP0_SEL, "mcu_mp0_sel", mcu_mp0_parents, 0x7A0,
-               9, 2, -1, CLK_IS_CRITICAL),
+                      9, 2, -1, CLK_IS_CRITICAL),
        /* mp2_pll_divider_cfg */
        MUX_GATE_FLAGS(CLK_MCU_MP2_SEL, "mcu_mp2_sel", mcu_mp2_parents, 0x7A8,
-               9, 2, -1, CLK_IS_CRITICAL),
+                      9, 2, -1, CLK_IS_CRITICAL),
        /* bus_pll_divider_cfg */
        MUX_GATE_FLAGS(CLK_MCU_BUS_SEL, "mcu_bus_sel", mcu_bus_parents, 0x7C0,
-               9, 2, -1, CLK_IS_CRITICAL),
+                      9, 2, -1, CLK_IS_CRITICAL),
 };
 
 static const struct mtk_clk_divider top_adj_divs[] = {
@@ -958,23 +814,11 @@ static const struct mtk_gate_regs top1_cg_regs = {
        .sta_ofs = 0x424,
 };
 
-#define GATE_TOP0(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top0_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
-
-#define GATE_TOP1(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top1_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_TOP0(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
+
+#define GATE_TOP1(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate top_clks[] = {
        /* TOP0 */
@@ -998,14 +842,8 @@ static const struct mtk_gate_regs infra_cg_regs = {
        .sta_ofs = 0x48,
 };
 
-#define GATE_INFRA(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &infra_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_INFRA(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate infra_clks[] = {
        GATE_INFRA(CLK_INFRA_DBGCLK, "infra_dbgclk", "axi_sel", 0),
@@ -1035,227 +873,65 @@ static const struct mtk_gate_regs peri2_cg_regs = {
        .sta_ofs = 0x42c,
 };
 
-#define GATE_PERI0(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &peri0_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_PERI1(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &peri1_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_PERI2(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &peri2_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_PERI0(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_PERI1(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_PERI2(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &peri2_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate peri_clks[] = {
        /* PERI0 */
-       GATE_PERI0(CLK_PERI_NFI, "per_nfi",
-               "axi_sel", 0),
-       GATE_PERI0(CLK_PERI_THERM, "per_therm",
-               "axi_sel", 1),
-       GATE_PERI0(CLK_PERI_PWM0, "per_pwm0",
-               "pwm_sel", 2),
-       GATE_PERI0(CLK_PERI_PWM1, "per_pwm1",
-               "pwm_sel", 3),
-       GATE_PERI0(CLK_PERI_PWM2, "per_pwm2",
-               "pwm_sel", 4),
-       GATE_PERI0(CLK_PERI_PWM3, "per_pwm3",
-               "pwm_sel", 5),
-       GATE_PERI0(CLK_PERI_PWM4, "per_pwm4",
-               "pwm_sel", 6),
-       GATE_PERI0(CLK_PERI_PWM5, "per_pwm5",
-               "pwm_sel", 7),
-       GATE_PERI0(CLK_PERI_PWM6, "per_pwm6",
-               "pwm_sel", 8),
-       GATE_PERI0(CLK_PERI_PWM7, "per_pwm7",
-               "pwm_sel", 9),
-       GATE_PERI0(CLK_PERI_PWM, "per_pwm",
-               "pwm_sel", 10),
-       GATE_PERI0(CLK_PERI_AP_DMA, "per_ap_dma",
-               "axi_sel", 13),
-       GATE_PERI0(CLK_PERI_MSDC30_0, "per_msdc30_0",
-               "msdc50_0_sel", 14),
-       GATE_PERI0(CLK_PERI_MSDC30_1, "per_msdc30_1",
-               "msdc30_1_sel", 15),
-       GATE_PERI0(CLK_PERI_MSDC30_2, "per_msdc30_2",
-               "msdc30_2_sel", 16),
-       GATE_PERI0(CLK_PERI_MSDC30_3, "per_msdc30_3",
-               "msdc30_3_sel", 17),
-       GATE_PERI0(CLK_PERI_UART0, "per_uart0",
-               "uart_sel", 20),
-       GATE_PERI0(CLK_PERI_UART1, "per_uart1",
-               "uart_sel", 21),
-       GATE_PERI0(CLK_PERI_UART2, "per_uart2",
-               "uart_sel", 22),
-       GATE_PERI0(CLK_PERI_UART3, "per_uart3",
-               "uart_sel", 23),
-       GATE_PERI0(CLK_PERI_I2C0, "per_i2c0",
-               "axi_sel", 24),
-       GATE_PERI0(CLK_PERI_I2C1, "per_i2c1",
-               "axi_sel", 25),
-       GATE_PERI0(CLK_PERI_I2C2, "per_i2c2",
-               "axi_sel", 26),
-       GATE_PERI0(CLK_PERI_I2C3, "per_i2c3",
-               "axi_sel", 27),
-       GATE_PERI0(CLK_PERI_I2C4, "per_i2c4",
-               "axi_sel", 28),
-       GATE_PERI0(CLK_PERI_AUXADC, "per_auxadc",
-               "ltepll_fs26m", 29),
-       GATE_PERI0(CLK_PERI_SPI0, "per_spi0",
-               "spi_sel", 30),
+       GATE_PERI0(CLK_PERI_NFI, "per_nfi", "axi_sel", 0),
+       GATE_PERI0(CLK_PERI_THERM, "per_therm", "axi_sel", 1),
+       GATE_PERI0(CLK_PERI_PWM0, "per_pwm0", "pwm_sel", 2),
+       GATE_PERI0(CLK_PERI_PWM1, "per_pwm1", "pwm_sel", 3),
+       GATE_PERI0(CLK_PERI_PWM2, "per_pwm2", "pwm_sel", 4),
+       GATE_PERI0(CLK_PERI_PWM3, "per_pwm3", "pwm_sel", 5),
+       GATE_PERI0(CLK_PERI_PWM4, "per_pwm4", "pwm_sel", 6),
+       GATE_PERI0(CLK_PERI_PWM5, "per_pwm5", "pwm_sel", 7),
+       GATE_PERI0(CLK_PERI_PWM6, "per_pwm6", "pwm_sel", 8),
+       GATE_PERI0(CLK_PERI_PWM7, "per_pwm7", "pwm_sel", 9),
+       GATE_PERI0(CLK_PERI_PWM, "per_pwm", "pwm_sel", 10),
+       GATE_PERI0(CLK_PERI_AP_DMA, "per_ap_dma", "axi_sel", 13),
+       GATE_PERI0(CLK_PERI_MSDC30_0, "per_msdc30_0", "msdc50_0_sel", 14),
+       GATE_PERI0(CLK_PERI_MSDC30_1, "per_msdc30_1", "msdc30_1_sel", 15),
+       GATE_PERI0(CLK_PERI_MSDC30_2, "per_msdc30_2", "msdc30_2_sel", 16),
+       GATE_PERI0(CLK_PERI_MSDC30_3, "per_msdc30_3", "msdc30_3_sel", 17),
+       GATE_PERI0(CLK_PERI_UART0, "per_uart0", "uart_sel", 20),
+       GATE_PERI0(CLK_PERI_UART1, "per_uart1", "uart_sel", 21),
+       GATE_PERI0(CLK_PERI_UART2, "per_uart2", "uart_sel", 22),
+       GATE_PERI0(CLK_PERI_UART3, "per_uart3", "uart_sel", 23),
+       GATE_PERI0(CLK_PERI_I2C0, "per_i2c0", "axi_sel", 24),
+       GATE_PERI0(CLK_PERI_I2C1, "per_i2c1", "axi_sel", 25),
+       GATE_PERI0(CLK_PERI_I2C2, "per_i2c2", "axi_sel", 26),
+       GATE_PERI0(CLK_PERI_I2C3, "per_i2c3", "axi_sel", 27),
+       GATE_PERI0(CLK_PERI_I2C4, "per_i2c4", "axi_sel", 28),
+       GATE_PERI0(CLK_PERI_AUXADC, "per_auxadc", "ltepll_fs26m", 29),
+       GATE_PERI0(CLK_PERI_SPI0, "per_spi0", "spi_sel", 30),
        /* PERI1 */
-       GATE_PERI1(CLK_PERI_SPI, "per_spi",
-               "spinor_sel", 1),
-       GATE_PERI1(CLK_PERI_I2C5, "per_i2c5",
-               "axi_sel", 3),
-       GATE_PERI1(CLK_PERI_SPI2, "per_spi2",
-               "spi_sel", 5),
-       GATE_PERI1(CLK_PERI_SPI3, "per_spi3",
-               "spi_sel", 6),
-       GATE_PERI1(CLK_PERI_SPI5, "per_spi5",
-               "spi_sel", 8),
-       GATE_PERI1(CLK_PERI_UART4, "per_uart4",
-               "uart_sel", 9),
-       GATE_PERI1(CLK_PERI_SFLASH, "per_sflash",
-               "uart_sel", 11),
-       GATE_PERI1(CLK_PERI_GMAC, "per_gmac",
-               "uart_sel", 12),
-       GATE_PERI1(CLK_PERI_PCIE0, "per_pcie0",
-               "uart_sel", 14),
-       GATE_PERI1(CLK_PERI_PCIE1, "per_pcie1",
-               "uart_sel", 15),
-       GATE_PERI1(CLK_PERI_GMAC_PCLK, "per_gmac_pclk",
-               "uart_sel", 16),
+       GATE_PERI1(CLK_PERI_SPI, "per_spi", "spinor_sel", 1),
+       GATE_PERI1(CLK_PERI_I2C5, "per_i2c5", "axi_sel", 3),
+       GATE_PERI1(CLK_PERI_SPI2, "per_spi2", "spi_sel", 5),
+       GATE_PERI1(CLK_PERI_SPI3, "per_spi3", "spi_sel", 6),
+       GATE_PERI1(CLK_PERI_SPI5, "per_spi5", "spi_sel", 8),
+       GATE_PERI1(CLK_PERI_UART4, "per_uart4", "uart_sel", 9),
+       GATE_PERI1(CLK_PERI_SFLASH, "per_sflash", "uart_sel", 11),
+       GATE_PERI1(CLK_PERI_GMAC, "per_gmac", "uart_sel", 12),
+       GATE_PERI1(CLK_PERI_PCIE0, "per_pcie0", "uart_sel", 14),
+       GATE_PERI1(CLK_PERI_PCIE1, "per_pcie1", "uart_sel", 15),
+       GATE_PERI1(CLK_PERI_GMAC_PCLK, "per_gmac_pclk", "uart_sel", 16),
        /* PERI2 */
-       GATE_PERI2(CLK_PERI_MSDC50_0_EN, "per_msdc50_0_en",
-               "msdc50_0_sel", 0),
-       GATE_PERI2(CLK_PERI_MSDC30_1_EN, "per_msdc30_1_en",
-               "msdc30_1_sel", 1),
-       GATE_PERI2(CLK_PERI_MSDC30_2_EN, "per_msdc30_2_en",
-               "msdc30_2_sel", 2),
-       GATE_PERI2(CLK_PERI_MSDC30_3_EN, "per_msdc30_3_en",
-               "msdc30_3_sel", 3),
-       GATE_PERI2(CLK_PERI_MSDC50_0_HCLK_EN, "per_msdc50_0_h",
-               "msdc50_0_h_sel", 4),
-       GATE_PERI2(CLK_PERI_MSDC50_3_HCLK_EN, "per_msdc50_3_h",
-               "msdc50_3_h_sel", 5),
-       GATE_PERI2(CLK_PERI_MSDC30_0_QTR_EN, "per_msdc30_0_q",
-               "axi_sel", 6),
-       GATE_PERI2(CLK_PERI_MSDC30_3_QTR_EN, "per_msdc30_3_q",
-               "mem_sel", 7),
-};
-
-#define MT2712_PLL_FMAX                (3000UL * MHZ)
-
-#define CON0_MT2712_RST_BAR    BIT(24)
-
-#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,  \
-                       _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg,  \
-                       _tuner_en_bit, _pcw_reg, _pcw_shift,            \
-                       _div_table) {                                   \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .reg = _reg,                                            \
-               .pwr_reg = _pwr_reg,                                    \
-               .en_mask = _en_mask,                                    \
-               .flags = _flags,                                        \
-               .rst_bar_mask = CON0_MT2712_RST_BAR,                    \
-               .fmax = MT2712_PLL_FMAX,                                \
-               .pcwbits = _pcwbits,                                    \
-               .pd_reg = _pd_reg,                                      \
-               .pd_shift = _pd_shift,                                  \
-               .tuner_reg = _tuner_reg,                                \
-               .tuner_en_reg = _tuner_en_reg,                          \
-               .tuner_en_bit = _tuner_en_bit,                          \
-               .pcw_reg = _pcw_reg,                                    \
-               .pcw_shift = _pcw_shift,                                \
-               .div_table = _div_table,                                \
-       }
-
-#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,    \
-                       _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg,  \
-                       _tuner_en_bit, _pcw_reg, _pcw_shift)            \
-               PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,     \
-                       _pcwbits, _pd_reg, _pd_shift, _tuner_reg,       \
-                       _tuner_en_reg, _tuner_en_bit, _pcw_reg,         \
-                       _pcw_shift, NULL)
-
-static const struct mtk_pll_div_table armca35pll_div_table[] = {
-       { .div = 0, .freq = MT2712_PLL_FMAX },
-       { .div = 1, .freq = 1202500000 },
-       { .div = 2, .freq = 500500000 },
-       { .div = 3, .freq = 315250000 },
-       { .div = 4, .freq = 157625000 },
-       { } /* sentinel */
-};
-
-static const struct mtk_pll_div_table armca72pll_div_table[] = {
-       { .div = 0, .freq = MT2712_PLL_FMAX },
-       { .div = 1, .freq = 994500000 },
-       { .div = 2, .freq = 520000000 },
-       { .div = 3, .freq = 315250000 },
-       { .div = 4, .freq = 157625000 },
-       { } /* sentinel */
-};
-
-static const struct mtk_pll_div_table mmpll_div_table[] = {
-       { .div = 0, .freq = MT2712_PLL_FMAX },
-       { .div = 1, .freq = 1001000000 },
-       { .div = 2, .freq = 601250000 },
-       { .div = 3, .freq = 250250000 },
-       { .div = 4, .freq = 125125000 },
-       { } /* sentinel */
-};
-
-static const struct mtk_pll_data plls[] = {
-       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, 0xf0000100,
-               HAVE_RST_BAR, 31, 0x0230, 4, 0, 0, 0, 0x0234, 0),
-       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0240, 0x024C, 0xfe000100,
-               HAVE_RST_BAR, 31, 0x0240, 4, 0, 0, 0, 0x0244, 0),
-       PLL(CLK_APMIXED_VCODECPLL, "vcodecpll", 0x0320, 0x032C, 0xc0000100,
-               0, 31, 0x0320, 4, 0, 0, 0, 0x0324, 0),
-       PLL(CLK_APMIXED_VENCPLL, "vencpll", 0x0280, 0x028C, 0x00000100,
-               0, 31, 0x0280, 4, 0, 0, 0, 0x0284, 0),
-       PLL(CLK_APMIXED_APLL1, "apll1", 0x0330, 0x0340, 0x00000100,
-               0, 31, 0x0330, 4, 0x0338, 0x0014, 0, 0x0334, 0),
-       PLL(CLK_APMIXED_APLL2, "apll2", 0x0350, 0x0360, 0x00000100,
-               0, 31, 0x0350, 4, 0x0358, 0x0014, 1, 0x0354, 0),
-       PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0370, 0x037c, 0x00000100,
-               0, 31, 0x0370, 4, 0, 0, 0, 0x0374, 0),
-       PLL(CLK_APMIXED_LVDSPLL2, "lvdspll2", 0x0390, 0x039C, 0x00000100,
-               0, 31, 0x0390, 4, 0, 0, 0, 0x0394, 0),
-       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0270, 0x027C, 0x00000100,
-               0, 31, 0x0270, 4, 0, 0, 0, 0x0274, 0),
-       PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x0410, 0x041C, 0x00000100,
-               0, 31, 0x0410, 4, 0, 0, 0, 0x0414, 0),
-       PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0290, 0x029C, 0xc0000100,
-               0, 31, 0x0290, 4, 0, 0, 0, 0x0294, 0),
-       PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0250, 0x0260, 0x00000100,
-               0, 31, 0x0250, 4, 0, 0, 0, 0x0254, 0,
-               mmpll_div_table),
-       PLL_B(CLK_APMIXED_ARMCA35PLL, "armca35pll", 0x0100, 0x0110, 0xf0000100,
-               HAVE_RST_BAR, 31, 0x0100, 4, 0, 0, 0, 0x0104, 0,
-               armca35pll_div_table),
-       PLL_B(CLK_APMIXED_ARMCA72PLL, "armca72pll", 0x0210, 0x0220, 0x00000100,
-               0, 31, 0x0210, 4, 0, 0, 0, 0x0214, 0,
-               armca72pll_div_table),
-       PLL(CLK_APMIXED_ETHERPLL, "etherpll", 0x0300, 0x030C, 0xc0000100,
-               0, 31, 0x0300, 4, 0, 0, 0, 0x0304, 0),
+       GATE_PERI2(CLK_PERI_MSDC50_0_EN, "per_msdc50_0_en", "msdc50_0_sel", 0),
+       GATE_PERI2(CLK_PERI_MSDC30_1_EN, "per_msdc30_1_en", "msdc30_1_sel", 1),
+       GATE_PERI2(CLK_PERI_MSDC30_2_EN, "per_msdc30_2_en", "msdc30_2_sel", 2),
+       GATE_PERI2(CLK_PERI_MSDC30_3_EN, "per_msdc30_3_en", "msdc30_3_sel", 3),
+       GATE_PERI2(CLK_PERI_MSDC50_0_HCLK_EN, "per_msdc50_0_h", "msdc50_0_h_sel", 4),
+       GATE_PERI2(CLK_PERI_MSDC50_3_HCLK_EN, "per_msdc50_3_h", "msdc50_3_h_sel", 5),
+       GATE_PERI2(CLK_PERI_MSDC30_0_QTR_EN, "per_msdc30_0_q", "axi_sel", 6),
+       GATE_PERI2(CLK_PERI_MSDC30_3_QTR_EN, "per_msdc30_3_q", "mem_sel", 7),
 };
 
 static u16 infrasys_rst_ofs[] = { 0x30, 0x34, };
@@ -1276,155 +952,25 @@ static const struct mtk_clk_rst_desc clk_rst_desc[] = {
        },
 };
 
-static int clk_mt2712_apmixed_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
-
-       mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-
-       if (r != 0)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
-
-       return r;
-}
-
-static struct clk_hw_onecell_data *top_clk_data;
-
-static void clk_mt2712_top_init_early(struct device_node *node)
-{
-       int r, i;
-
-       if (!top_clk_data) {
-               top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
-
-               for (i = 0; i < CLK_TOP_NR_CLK; i++)
-                       top_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER);
-       }
-
-       mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
-                       top_clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
-}
-
-CLK_OF_DECLARE_DRIVER(mt2712_topckgen, "mediatek,mt2712-topckgen",
-                       clk_mt2712_top_init_early);
-
-static int clk_mt2712_top_probe(struct platform_device *pdev)
-{
-       int r, i;
-       struct device_node *node = pdev->dev.of_node;
-       void __iomem *base;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base)) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return PTR_ERR(base);
-       }
-
-       if (!top_clk_data) {
-               top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
-       } else {
-               for (i = 0; i < CLK_TOP_NR_CLK; i++) {
-                       if (top_clk_data->hws[i] == ERR_PTR(-EPROBE_DEFER))
-                               top_clk_data->hws[i] = ERR_PTR(-ENOENT);
-               }
-       }
-
-       mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
-                       top_clk_data);
-       mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
-                       top_clk_data);
-       mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
-       mtk_clk_register_composites(&pdev->dev, top_muxes,
-                                   ARRAY_SIZE(top_muxes), base,
-                                   &mt2712_clk_lock, top_clk_data);
-       mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), base,
-                       &mt2712_clk_lock, top_clk_data);
-       mtk_clk_register_gates(&pdev->dev, node, top_clks,
-                              ARRAY_SIZE(top_clks), top_clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data);
-
-       if (r != 0)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
-
-       return r;
-}
-
-static int clk_mt2712_mcu_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-       struct device_node *node = pdev->dev.of_node;
-       void __iomem *base;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base)) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return PTR_ERR(base);
-       }
-
-       clk_data = mtk_alloc_clk_data(CLK_MCU_NR_CLK);
-
-       r = mtk_clk_register_composites(&pdev->dev, mcu_muxes,
-                                       ARRAY_SIZE(mcu_muxes), base,
-                                       &mt2712_clk_lock, clk_data);
-       if (r)
-               dev_err(&pdev->dev, "Could not register composites: %d\n", r);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-
-       if (r != 0)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
-
-       return r;
-}
+static const struct mtk_clk_desc topck_desc = {
+       .clks = top_clks,
+       .num_clks = ARRAY_SIZE(top_clks),
+       .fixed_clks = top_fixed_clks,
+       .num_fixed_clks = ARRAY_SIZE(top_fixed_clks),
+       .factor_clks = top_divs,
+       .num_factor_clks = ARRAY_SIZE(top_divs),
+       .composite_clks = top_muxes,
+       .num_composite_clks = ARRAY_SIZE(top_muxes),
+       .divider_clks = top_adj_divs,
+       .num_divider_clks = ARRAY_SIZE(top_adj_divs),
+       .clk_lock = &mt2712_clk_lock,
+};
 
-static const struct of_device_id of_match_clk_mt2712[] = {
-       {
-               .compatible = "mediatek,mt2712-apmixedsys",
-               .data = clk_mt2712_apmixed_probe,
-       }, {
-               .compatible = "mediatek,mt2712-topckgen",
-               .data = clk_mt2712_top_probe,
-       }, {
-               .compatible = "mediatek,mt2712-mcucfg",
-               .data = clk_mt2712_mcu_probe,
-       }, {
-               /* sentinel */
-       }
-};
-
-static int clk_mt2712_probe(struct platform_device *pdev)
-{
-       int (*clk_probe)(struct platform_device *);
-       int r;
-
-       clk_probe = of_device_get_match_data(&pdev->dev);
-       if (!clk_probe)
-               return -EINVAL;
-
-       r = clk_probe(pdev);
-       if (r != 0)
-               dev_err(&pdev->dev,
-                       "could not register clock provider: %s: %d\n",
-                       pdev->name, r);
-
-       return r;
-}
+static const struct mtk_clk_desc mcu_desc = {
+       .composite_clks = mcu_muxes,
+       .num_composite_clks = ARRAY_SIZE(mcu_muxes),
+       .clk_lock = &mt2712_clk_lock,
+};
 
 static const struct mtk_clk_desc infra_desc = {
        .clks = infra_clks,
@@ -1438,36 +984,22 @@ static const struct mtk_clk_desc peri_desc = {
        .rst_desc = &clk_rst_desc[1],
 };
 
-static const struct of_device_id of_match_clk_mt2712_simple[] = {
+static const struct of_device_id of_match_clk_mt2712[] = {
        { .compatible = "mediatek,mt2712-infracfg", .data = &infra_desc },
+       { .compatible = "mediatek,mt2712-mcucfg", .data = &mcu_desc },
        { .compatible = "mediatek,mt2712-pericfg", .data = &peri_desc, },
+       { .compatible = "mediatek,mt2712-topckgen", .data = &topck_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt2712);
 
-static struct platform_driver clk_mt2712_simple_drv = {
+static struct platform_driver clk_mt2712_drv = {
        .probe = mtk_clk_simple_probe,
        .remove = mtk_clk_simple_remove,
-       .driver = {
-               .name = "clk-mt2712-simple",
-               .of_match_table = of_match_clk_mt2712_simple,
-       },
-};
-
-static struct platform_driver clk_mt2712_drv = {
-       .probe = clk_mt2712_probe,
        .driver = {
                .name = "clk-mt2712",
                .of_match_table = of_match_clk_mt2712,
        },
 };
-
-static int __init clk_mt2712_init(void)
-{
-       int ret = platform_driver_register(&clk_mt2712_drv);
-
-       if (ret)
-               return ret;
-       return platform_driver_register(&clk_mt2712_simple_drv);
-}
-
-arch_initcall(clk_mt2712_init);
+module_platform_driver(clk_mt2712_drv);
+MODULE_LICENSE("GPL");
index 0aa6c0d352ca56720b2f76407df16913a40478e1..9e98d699732907a14ef6f7e5b07eaa6e8ba90b63 100644 (file)
@@ -24,23 +24,11 @@ static const struct mtk_gate_regs audio1_cg_regs = {
        .sta_ofs = 0x4,
 };
 
-#define GATE_AUDIO0(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &audio0_cg_regs,                \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_AUDIO0(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &audio0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-#define GATE_AUDIO1(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &audio1_cg_regs,                \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_AUDIO1(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &audio1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
 static const struct mtk_gate audio_clks[] = {
        /* AUDIO0 */
@@ -77,6 +65,7 @@ static const struct of_device_id of_match_clk_mt6765_audio[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_audio);
 
 static struct platform_driver clk_mt6765_audio_drv = {
        .probe = mtk_clk_simple_probe,
@@ -86,5 +75,5 @@ static struct platform_driver clk_mt6765_audio_drv = {
                .of_match_table = of_match_clk_mt6765_audio,
        },
 };
-
-builtin_platform_driver(clk_mt6765_audio_drv);
+module_platform_driver(clk_mt6765_audio_drv);
+MODULE_LICENSE("GPL");
index 25f2bef38126e376add3a16e83a64ce5178670bb..6f6b29d8b29a7225b781e4ba1c8b9d68cfe0efed 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs cam_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_CAM(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &cam_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_CAM(_id, _name, _parent, _shift)                          \
+       GATE_MTK(_id, _name, _parent, &cam_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate cam_clks[] = {
        GATE_CAM(CLK_CAM_LARB3, "cam_larb3", "mm_ck", 0),
@@ -52,6 +46,7 @@ static const struct of_device_id of_match_clk_mt6765_cam[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_cam);
 
 static struct platform_driver clk_mt6765_cam_drv = {
        .probe = mtk_clk_simple_probe,
@@ -61,5 +56,5 @@ static struct platform_driver clk_mt6765_cam_drv = {
                .of_match_table = of_match_clk_mt6765_cam,
        },
 };
-
-builtin_platform_driver(clk_mt6765_cam_drv);
+module_platform_driver(clk_mt6765_cam_drv);
+MODULE_LICENSE("GPL");
index a62303ef4f41df8b0976c4aef9e8f4de9bd96e9e..984201077a20e6d046c0166b11e4cd05572fd1b9 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs img_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_IMG(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &img_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_IMG(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate img_clks[] = {
        GATE_IMG(CLK_IMG_LARB2, "img_larb2", "mm_ck", 0),
@@ -48,6 +42,7 @@ static const struct of_device_id of_match_clk_mt6765_img[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_img);
 
 static struct platform_driver clk_mt6765_img_drv = {
        .probe = mtk_clk_simple_probe,
@@ -57,5 +52,5 @@ static struct platform_driver clk_mt6765_img_drv = {
                .of_match_table = of_match_clk_mt6765_img,
        },
 };
-
-builtin_platform_driver(clk_mt6765_img_drv);
+module_platform_driver(clk_mt6765_img_drv);
+MODULE_LICENSE("GPL");
index 25c829fc386618b05b74063a6dd7d74d33fead31..a47937f4efe5a91289a3d2427ed5cacbcf176dbf 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs mipi0a_cg_regs = {
        .sta_ofs = 0x80,
 };
 
-#define GATE_MIPI0A(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &mipi0a_cg_regs,                        \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_MIPI0A(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &mipi0a_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate mipi0a_clks[] = {
        GATE_MIPI0A(CLK_MIPI0A_CSR_CSI_EN_0A,
@@ -45,6 +39,7 @@ static const struct of_device_id of_match_clk_mt6765_mipi0a[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_mipi0a);
 
 static struct platform_driver clk_mt6765_mipi0a_drv = {
        .probe = mtk_clk_simple_probe,
@@ -54,5 +49,5 @@ static struct platform_driver clk_mt6765_mipi0a_drv = {
                .of_match_table = of_match_clk_mt6765_mipi0a,
        },
 };
-
-builtin_platform_driver(clk_mt6765_mipi0a_drv);
+module_platform_driver(clk_mt6765_mipi0a_drv);
+MODULE_LICENSE("GPL");
index bda774668a3616a389a3cb9fd337fa25c30d33b4..2b8fc052558ee12bbf35ea49ec48a408c66d7410 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs mm_cg_regs = {
        .sta_ofs = 0x100,
 };
 
-#define GATE_MM(_id, _name, _parent, _shift) {         \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &mm_cg_regs,                    \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_MM(_id, _name, _parent, _shift)   \
+       GATE_MTK(_id, _name, _parent, &mm_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate mm_clks[] = {
        /* MM */
@@ -74,6 +68,7 @@ static const struct of_device_id of_match_clk_mt6765_mm[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_mm);
 
 static struct platform_driver clk_mt6765_mm_drv = {
        .probe = mtk_clk_simple_probe,
@@ -83,5 +78,5 @@ static struct platform_driver clk_mt6765_mm_drv = {
                .of_match_table = of_match_clk_mt6765_mm,
        },
 };
-
-builtin_platform_driver(clk_mt6765_mm_drv);
+module_platform_driver(clk_mt6765_mm_drv);
+MODULE_LICENSE("GPL");
index 2bc1fbde87da90a769e5d00ba727a1c37f253983..36df9615b1be421c3192e21e2b412fefa42de53e 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs venc_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_VENC(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &venc_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_VENC(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &venc_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
 static const struct mtk_gate venc_clks[] = {
        GATE_VENC(CLK_VENC_SET0_LARB, "venc_set0_larb", "mm_ck", 0),
@@ -47,6 +41,7 @@ static const struct of_device_id of_match_clk_mt6765_vcodec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_vcodec);
 
 static struct platform_driver clk_mt6765_vcodec_drv = {
        .probe = mtk_clk_simple_probe,
@@ -56,5 +51,5 @@ static struct platform_driver clk_mt6765_vcodec_drv = {
                .of_match_table = of_match_clk_mt6765_vcodec,
        },
 };
-
-builtin_platform_driver(clk_mt6765_vcodec_drv);
+module_platform_driver(clk_mt6765_vcodec_drv);
+MODULE_LICENSE("GPL");
index 6f5c92a7f62041ee0808670137c47c884febe7fa..fa7948ef1e68b2f1cd1851ae712f8299644e09e1 100644 (file)
@@ -483,32 +483,14 @@ static const struct mtk_gate_regs top2_cg_regs = {
        .sta_ofs = 0x320,
 };
 
-#define GATE_TOP0(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top0_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_TOP0(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-#define GATE_TOP1(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top1_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_TOP1(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
-#define GATE_TOP2(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top2_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_TOP2(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top2_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
 static const struct mtk_gate top_clks[] = {
        /* TOP0 */
@@ -559,41 +541,17 @@ static const struct mtk_gate_regs ifr5_cg_regs = {
        .sta_ofs = 0xc8,
 };
 
-#define GATE_IFR2(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ifr2_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_IFR2(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &ifr2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_IFR3(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ifr3_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_IFR3(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &ifr3_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_IFR4(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ifr4_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_IFR4(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &ifr4_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_IFR5(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ifr5_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_IFR5(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &ifr5_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate ifr_clks[] = {
        /* INFRA_TOPAXI */
@@ -674,14 +632,8 @@ static const struct mtk_gate_regs apmixed_cg_regs = {
        .sta_ofs = 0x14,
 };
 
-#define GATE_APMIXED(_id, _name, _parent, _shift) {    \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &apmixed_cg_regs,               \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv,         \
-       }
+#define GATE_APMIXED(_id, _name, _parent, _shift)                      \
+       GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate apmixed_clks[] = {
        /* AUDIO0 */
@@ -888,6 +840,7 @@ static const struct of_device_id of_match_clk_mt6765[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6765);
 
 static int clk_mt6765_probe(struct platform_device *pdev)
 {
@@ -921,3 +874,4 @@ static int __init clk_mt6765_init(void)
 }
 
 arch_initcall(clk_mt6765_init);
+MODULE_LICENSE("GPL");
index 6e473ae1fd903c3b02db25861515592bd9170a4a..6e3280d3a2e60a5f750368c2ccc191d9c0b5d850 100644 (file)
@@ -102,6 +102,7 @@ static const struct of_device_id of_match_clk_mt6779_aud[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_aud);
 
 static struct platform_driver clk_mt6779_aud_drv = {
        .probe = mtk_clk_simple_probe,
index 7be3db90fa4a8a28174b9d068ee6468376c0db85..b4c4c7248672c099126f47eed6e1b77dea505233 100644 (file)
@@ -51,6 +51,7 @@ static const struct of_device_id of_match_clk_mt6779_cam[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_cam);
 
 static struct platform_driver clk_mt6779_cam_drv = {
        .probe = mtk_clk_simple_probe,
index 9bc51fc82dbd2bb250fc419a96a6d8b7f6e61ddc..b760a8af3462d82299b9b52f3e727ec63a797e5b 100644 (file)
@@ -43,6 +43,7 @@ static const struct of_device_id of_match_clk_mt6779_img[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_img);
 
 static struct platform_driver clk_mt6779_img_drv = {
        .probe = mtk_clk_simple_probe,
index 92e9d1ade42215087d28dbe2a022a9dff22b990a..9285a792c59b21e491acd4e622742432d440b5d7 100644 (file)
@@ -45,6 +45,7 @@ static const struct of_device_id of_match_clk_mt6779_ipe[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_ipe);
 
 static struct platform_driver clk_mt6779_ipe_drv = {
        .probe = mtk_clk_simple_probe,
index efc793a1969a21c4a0ba819372e9fc84b5c2169f..d20f32d4f827108854944d643a2b3e0331c0affb 100644 (file)
@@ -40,6 +40,7 @@ static const struct of_device_id of_match_clk_mt6779_mfg[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_mfg);
 
 static struct platform_driver clk_mt6779_mfg_drv = {
        .probe = mtk_clk_simple_probe,
index 2cccf62d3b36f024288423d0f5a238aa3de3e7ba..c2f700ae6c2c82be110339310ec94134610fcf2d 100644 (file)
@@ -85,25 +85,24 @@ static const struct mtk_gate mm_clks[] = {
        GATE_MM1(CLK_MM_DISP_OVL_FBDC, "mm_disp_ovl_fbdc", "mm_sel", 16),
 };
 
-static int clk_mt6779_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
-
-       mtk_clk_register_gates(&pdev->dev, node, mm_clks,
-                              ARRAY_SIZE(mm_clks), clk_data);
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mm_clks,
+       .num_clks = ARRAY_SIZE(mm_clks),
+};
 
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct platform_device_id clk_mt6779_mm_id_table[] = {
+       { .name = "clk-mt6779-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt6779_mm_id_table);
 
 static struct platform_driver clk_mt6779_mm_drv = {
-       .probe = clk_mt6779_mm_probe,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt6779-mm",
        },
+       .id_table = clk_mt6779_mm_id_table,
 };
 
 module_platform_driver(clk_mt6779_mm_drv);
index 3209a6518d5b1e35c00ca1a5f12ba6b8d5d8cd15..e062ed5aa45fde8e0e601a4135f25e8f7af9c1ea 100644 (file)
@@ -52,6 +52,7 @@ static const struct of_device_id of_match_clk_mt6779_vdec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_vdec);
 
 static struct platform_driver clk_mt6779_vdec_drv = {
        .probe = mtk_clk_simple_probe,
index c25035c0f334c18173f2a2497d0261053699cdc7..0ae8ac28f8386c42da82373235f679e400f80225 100644 (file)
@@ -43,6 +43,7 @@ static const struct of_device_id of_match_clk_mt6779_venc[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_venc);
 
 static struct platform_driver clk_mt6779_venc_drv = {
        .probe = mtk_clk_simple_probe,
index 827025d127d99d25c76174a9f8a04f522e300c5a..1f5ea1508f612a12a642dd238513a405a7d13656 100644 (file)
@@ -1299,6 +1299,7 @@ static const struct of_device_id of_match_clk_mt6779_infra[] = {
        { .compatible = "mediatek,mt6779-infracfg_ao", .data = &infra_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6779);
 
 static struct platform_driver clk_mt6779_infra_drv  = {
        .probe = mtk_clk_simple_probe,
index 59761c72d3bc2f0d1c1d980eaba47c6b65dca4e8..8b30109f253cf910b2f3db2d23e45d9b33b6efb5 100644 (file)
@@ -7,8 +7,10 @@
 #include <dt-bindings/clock/mediatek,mt6795-clk.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include "clk-fhctl.h"
 #include "clk-mtk.h"
 #include "clk-pll.h"
+#include "clk-pllfh.h"
 
 #define REG_REF2USB            0x8
 #define REG_AP_PLL_CON7                0x1c
@@ -58,6 +60,56 @@ static const struct mtk_pll_data plls[] = {
        PLL(CLK_APMIXED_APLL2, "apll2", 0x2b4, 0x2c4, 0, 0, 31, 0x2b4, 4, 0x2bc, 0x2b8, 0),
 };
 
+enum fh_pll_id {
+       FH_CA53PLL_LL,
+       FH_CA53PLL_BL,
+       FH_MAINPLL,
+       FH_MPLL,
+       FH_MSDCPLL,
+       FH_MMPLL,
+       FH_VENCPLL,
+       FH_TVDPLL,
+       FH_VCODECPLL,
+       FH_NR_FH,
+};
+
+#define _FH(_pllid, _fhid, _slope, _offset) {                          \
+               .data = {                                               \
+                       .pll_id = _pllid,                               \
+                       .fh_id = _fhid,                                 \
+                       .fh_ver = FHCTL_PLLFH_V1,                       \
+                       .fhx_offset = _offset,                          \
+                       .dds_mask = GENMASK(21, 0),                     \
+                       .slope0_value = _slope,                         \
+                       .slope1_value = _slope,                         \
+                       .sfstrx_en = BIT(2),                            \
+                       .frddsx_en = BIT(1),                            \
+                       .fhctlx_en = BIT(0),                            \
+                       .tgl_org = BIT(31),                             \
+                       .dvfs_tri = BIT(31),                            \
+                       .pcwchg = BIT(31),                              \
+                       .dt_val = 0x0,                                  \
+                       .df_val = 0x9,                                  \
+                       .updnlmt_shft = 16,                             \
+                       .msk_frddsx_dys = GENMASK(23, 20),              \
+                       .msk_frddsx_dts = GENMASK(19, 16),              \
+               },                                                      \
+       }
+
+#define FH(_pllid, _fhid, _offset)     _FH(_pllid, _fhid, 0x6003c97, _offset)
+#define FH_M(_pllid, _fhid, _offset)   _FH(_pllid, _fhid, 0x6000140, _offset)
+
+static struct mtk_pllfh_data pllfhs[] = {
+       FH(CLK_APMIXED_ARMCA53PLL, FH_CA53PLL_BL, 0x38),
+       FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x60),
+       FH_M(CLK_APMIXED_MPLL, FH_MPLL, 0x74),
+       FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x88),
+       FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0x9c),
+       FH(CLK_APMIXED_VENCPLL, FH_VENCPLL, 0xb0),
+       FH(CLK_APMIXED_TVDPLL, FH_TVDPLL, 0xc4),
+       FH(CLK_APMIXED_VCODECPLL, FH_VCODECPLL, 0xd8),
+};
+
 static void clk_mt6795_apmixed_setup_md1(void __iomem *base)
 {
        void __iomem *reg = base + REG_AP_PLL_CON7;
@@ -79,12 +131,14 @@ static const struct of_device_id of_match_clk_mt6795_apmixed[] = {
        { .compatible = "mediatek,mt6795-apmixedsys" },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_apmixed);
 
 static int clk_mt6795_apmixed_probe(struct platform_device *pdev)
 {
        struct clk_hw_onecell_data *clk_data;
        struct device *dev = &pdev->dev;
        struct device_node *node = dev->of_node;
+       const u8 *fhctl_node = "mediatek,mt6795-fhctl";
        void __iomem *base;
        struct clk_hw *hw;
        int ret;
@@ -97,7 +151,9 @@ static int clk_mt6795_apmixed_probe(struct platform_device *pdev)
        if (!clk_data)
                return -ENOMEM;
 
-       ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
+       ret = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
+                                     pllfhs, ARRAY_SIZE(pllfhs), clk_data);
        if (ret)
                goto free_clk_data;
 
@@ -124,7 +180,8 @@ static int clk_mt6795_apmixed_probe(struct platform_device *pdev)
 unregister_ref2usb:
        mtk_clk_unregister_ref2usb_tx(clk_data->hws[CLK_APMIXED_REF2USB_TX]);
 unregister_plls:
-       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+       mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs,
+                                 ARRAY_SIZE(pllfhs), clk_data);
 free_clk_data:
        mtk_free_clk_data(clk_data);
        return ret;
@@ -137,7 +194,8 @@ static int clk_mt6795_apmixed_remove(struct platform_device *pdev)
 
        of_clk_del_provider(node);
        mtk_clk_unregister_ref2usb_tx(clk_data->hws[CLK_APMIXED_REF2USB_TX]);
-       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+       mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs,
+                                 ARRAY_SIZE(pllfhs), clk_data);
        mtk_free_clk_data(clk_data);
 
        return 0;
index 23d9fc057e611f4f09ec79827af21f049522f48e..086ea1438564f35473b549ccba43cd5bc00debe8 100644 (file)
@@ -81,6 +81,7 @@ static const struct of_device_id of_match_clk_mt6795_infracfg[] = {
        { .compatible = "mediatek,mt6795-infracfg" },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_infracfg);
 
 static int clk_mt6795_infracfg_probe(struct platform_device *pdev)
 {
index ee7aab24eb24cb1c2be9abf62b2af5de949b54cc..1d658bb19e822f739eeb73678d0a1c6f45149317 100644 (file)
@@ -35,6 +35,7 @@ static const struct of_device_id of_match_clk_mt6795_mfg[] = {
        { .compatible = "mediatek,mt6795-mfgcfg", .data = &mfg_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_mfg);
 
 static struct platform_driver clk_mt6795_mfg_drv = {
        .driver = {
index eebb6143ada221a470a066b93203344eba264f6a..8acc9cad2875b67de1cc0f8cad74c2aa03df461f 100644 (file)
@@ -76,56 +76,24 @@ static const struct mtk_gate mm_gates[] = {
        GATE_MM1(CLK_MM_DPI_ENGINE, "mm_dpi_engine", "mm_sel", 9),
 };
 
-static int clk_mt6795_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int ret;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       ret = mtk_clk_register_gates(&pdev->dev, node, mm_gates,
-                                    ARRAY_SIZE(mm_gates), clk_data);
-       if (ret)
-               goto free_clk_data;
-
-       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (ret)
-               goto unregister_gates;
-
-       platform_set_drvdata(pdev, clk_data);
-
-       return 0;
-
-unregister_gates:
-       mtk_clk_unregister_gates(mm_gates, ARRAY_SIZE(mm_gates), clk_data);
-free_clk_data:
-       mtk_free_clk_data(clk_data);
-       return ret;
-}
-
-static int clk_mt6795_mm_remove(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-
-       of_clk_del_provider(node);
-       mtk_clk_unregister_gates(mm_gates, ARRAY_SIZE(mm_gates), clk_data);
-       mtk_free_clk_data(clk_data);
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mm_gates,
+       .num_clks = ARRAY_SIZE(mm_gates),
+};
 
-       return 0;
-}
+static const struct platform_device_id clk_mt6795_mm_id_table[] = {
+       { .name = "clk-mt6795-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt6795_mm_id_table);
 
 static struct platform_driver clk_mt6795_mm_drv = {
        .driver = {
                .name = "clk-mt6795-mm",
        },
-       .probe = clk_mt6795_mm_probe,
-       .remove = clk_mt6795_mm_remove,
+       .id_table = clk_mt6795_mm_id_table,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
 };
 module_platform_driver(clk_mt6795_mm_drv);
 
index 08aaa9b09c363e77db3443ba8d4b62f41a38aea5..62cc19eee2c787be69b8c7acbd0cc56b7d925aa5 100644 (file)
@@ -89,6 +89,7 @@ static const struct of_device_id of_match_clk_mt6795_pericfg[] = {
        { .compatible = "mediatek,mt6795-pericfg" },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_pericfg);
 
 static int clk_mt6795_pericfg_probe(struct platform_device *pdev)
 {
index e80fa588e30981a2e3db812d4dde2c04a7009eb5..9c6d63a80b19b8ede1b6349fc1e1007a3dba2e5a 100644 (file)
@@ -539,6 +539,7 @@ static const struct of_device_id of_match_clk_mt6795_topckgen[] = {
        { .compatible = "mediatek,mt6795-topckgen", .data = &topck_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_topckgen);
 
 static struct platform_driver clk_mt6795_topckgen_drv = {
        .driver = {
index d85d04e0d0169da106fa882fba2bd876f0ffa21c..f2968f859dca09a538640e36fa6bdda9b9f84a59 100644 (file)
@@ -40,6 +40,7 @@ static const struct of_device_id of_match_clk_mt6795_vdecsys[] = {
        { .compatible = "mediatek,mt6795-vdecsys", .data = &vdec_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_vdecsys);
 
 static struct platform_driver clk_mt6795_vdecsys_drv = {
        .probe = mtk_clk_simple_probe,
index de40a982ca962f0ce5db240ede5580c7c9ffd514..2f8d48da1a8599e1b9d790cb3cdb95c2e9f10758 100644 (file)
@@ -35,6 +35,7 @@ static const struct of_device_id of_match_clk_mt6795_vencsys[] = {
        { .compatible = "mediatek,mt6795-vencsys", .data = &venc_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_vencsys);
 
 static struct platform_driver clk_mt6795_vencsys_drv = {
        .driver = {
index 7c6a53fbb8be68211b8e23f0ad02b429e62d22fc..00fc0a03e646e3ca3b7d5bc88f299bdcb4724151 100644 (file)
@@ -16,14 +16,8 @@ static const struct mtk_gate_regs img_cg_regs = {
        .sta_ofs = 0x0000,
 };
 
-#define GATE_IMG(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &img_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_IMG(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate img_clks[] = {
        GATE_IMG(CLK_IMG_FDVT, "img_fdvt", "mm_sel", 11),
@@ -45,6 +39,7 @@ static const struct of_device_id of_match_clk_mt6797_img[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6797_img);
 
 static struct platform_driver clk_mt6797_img_drv = {
        .probe = mtk_clk_simple_probe,
@@ -54,5 +49,5 @@ static struct platform_driver clk_mt6797_img_drv = {
                .of_match_table = of_match_clk_mt6797_img,
        },
 };
-
-builtin_platform_driver(clk_mt6797_img_drv);
+module_platform_driver(clk_mt6797_img_drv);
+MODULE_LICENSE("GPL");
index deb16a6b16a5e04b15ec61ba8156872b85fc6a9c..caacfa40a5bc37c31f7414a26e7deee82398d61e 100644 (file)
@@ -23,23 +23,11 @@ static const struct mtk_gate_regs mm1_cg_regs = {
        .sta_ofs = 0x0110,
 };
 
-#define GATE_MM0(_id, _name, _parent, _shift) {                        \
-       .id = _id,                                      \
-       .name = _name,                                  \
-       .parent_name = _parent,                         \
-       .regs = &mm0_cg_regs,                           \
-       .shift = _shift,                                \
-       .ops = &mtk_clk_gate_ops_setclr,                \
-}
+#define GATE_MM0(_id, _name, _parent, _shift)  \
+       GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_MM1(_id, _name, _parent, _shift) {                        \
-       .id = _id,                                      \
-       .name = _name,                                  \
-       .parent_name = _parent,                         \
-       .regs = &mm1_cg_regs,                           \
-       .shift = _shift,                                \
-       .ops = &mtk_clk_gate_ops_setclr,                \
-}
+#define GATE_MM1(_id, _name, _parent, _shift)  \
+       GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate mm_clks[] = {
        GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0),
@@ -92,32 +80,24 @@ static const struct mtk_gate mm_clks[] = {
                 "clk26m", 3),
 };
 
-static int clk_mt6797_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR);
-
-       mtk_clk_register_gates(&pdev->dev, node, mm_clks,
-                              ARRAY_SIZE(mm_clks), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               dev_err(&pdev->dev,
-                       "could not register clock provider: %s: %d\n",
-                       pdev->name, r);
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mm_clks,
+       .num_clks = ARRAY_SIZE(mm_clks),
+};
 
-       return r;
-}
+static const struct platform_device_id clk_mt6797_mm_id_table[] = {
+       { .name = "clk-mt6797-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt6797_mm_id_table);
 
 static struct platform_driver clk_mt6797_mm_drv = {
-       .probe = clk_mt6797_mm_probe,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt6797-mm",
        },
+       .id_table = clk_mt6797_mm_id_table,
 };
-
-builtin_platform_driver(clk_mt6797_mm_drv);
+module_platform_driver(clk_mt6797_mm_drv);
+MODULE_LICENSE("GPL");
index 6120fccc859f1b9fa9a7458bf43588878e3cc3cb..447fe6fa8e15a9b2e60d6f3b9c23ae4cc82e5ee3 100644 (file)
@@ -24,23 +24,11 @@ static const struct mtk_gate_regs vdec1_cg_regs = {
        .sta_ofs = 0x0008,
 };
 
-#define GATE_VDEC0(_id, _name, _parent, _shift) {              \
-       .id = _id,                                      \
-       .name = _name,                                  \
-       .parent_name = _parent,                         \
-       .regs = &vdec0_cg_regs,                         \
-       .shift = _shift,                                \
-       .ops = &mtk_clk_gate_ops_setclr_inv,            \
-}
+#define GATE_VDEC0(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
-#define GATE_VDEC1(_id, _name, _parent, _shift) {              \
-       .id = _id,                                      \
-       .name = _name,                                  \
-       .parent_name = _parent,                         \
-       .regs = &vdec1_cg_regs,                         \
-       .shift = _shift,                                \
-       .ops = &mtk_clk_gate_ops_setclr_inv,            \
-}
+#define GATE_VDEC1(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
 static const struct mtk_gate vdec_clks[] = {
        GATE_VDEC0(CLK_VDEC_CKEN_ENG, "vdec_cken_eng", "vdec_sel", 8),
@@ -62,6 +50,7 @@ static const struct of_device_id of_match_clk_mt6797_vdec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6797_vdec);
 
 static struct platform_driver clk_mt6797_vdec_drv = {
        .probe = mtk_clk_simple_probe,
@@ -71,5 +60,5 @@ static struct platform_driver clk_mt6797_vdec_drv = {
                .of_match_table = of_match_clk_mt6797_vdec,
        },
 };
-
-builtin_platform_driver(clk_mt6797_vdec_drv);
+module_platform_driver(clk_mt6797_vdec_drv);
+MODULE_LICENSE("GPL");
index 834d3834d2bbcccbf616bd20a5984ae0213a5d42..95b89ff8fd1975601336dc88e83469df2bdfe05a 100644 (file)
@@ -18,14 +18,8 @@ static const struct mtk_gate_regs venc_cg_regs = {
        .sta_ofs = 0x0000,
 };
 
-#define GATE_VENC(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &venc_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_VENC(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &venc_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
 static const struct mtk_gate venc_clks[] = {
        GATE_VENC(CLK_VENC_0, "venc_0", "mm_sel", 0),
@@ -47,6 +41,7 @@ static const struct of_device_id of_match_clk_mt6797_venc[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6797_venc);
 
 static struct platform_driver clk_mt6797_venc_drv = {
        .probe = mtk_clk_simple_probe,
@@ -56,5 +51,5 @@ static struct platform_driver clk_mt6797_venc_drv = {
                .of_match_table = of_match_clk_mt6797_venc,
        },
 };
-
-builtin_platform_driver(clk_mt6797_venc_drv);
+module_platform_driver(clk_mt6797_venc_drv);
+MODULE_LICENSE("GPL");
index 105a512857b3c03cd81603c6782c8c09e17b43a5..4c87c0348e5f4683be6f294ca784ec4f0c757711 100644 (file)
@@ -421,40 +421,22 @@ static const struct mtk_gate_regs infra2_cg_regs = {
        .sta_ofs = 0x00b0,
 };
 
-#define GATE_ICG0(_id, _name, _parent, _shift) {               \
-       .id = _id,                                              \
-       .name = _name,                                          \
-       .parent_name = _parent,                                 \
-       .regs = &infra0_cg_regs,                                \
-       .shift = _shift,                                        \
-       .ops = &mtk_clk_gate_ops_setclr,                        \
-}
+#define GATE_ICG0(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &infra0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_ICG1(_id, _name, _parent, _shift)                 \
-       GATE_ICG1_FLAGS(_id, _name, _parent, _shift, 0)
+#define GATE_ICG1(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &infra1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_ICG1_FLAGS(_id, _name, _parent, _shift, _flags) { \
-       .id = _id,                                              \
-       .name = _name,                                          \
-       .parent_name = _parent,                                 \
-       .regs = &infra1_cg_regs,                                \
-       .shift = _shift,                                        \
-       .ops = &mtk_clk_gate_ops_setclr,                        \
-       .flags = _flags,                                        \
-}
+#define GATE_ICG1_FLAGS(_id, _name, _parent, _shift, _flags)           \
+       GATE_MTK_FLAGS(_id, _name, _parent, &infra1_cg_regs, _shift,    \
+                      &mtk_clk_gate_ops_setclr, _flags)
 
-#define GATE_ICG2(_id, _name, _parent, _shift)                 \
-       GATE_ICG2_FLAGS(_id, _name, _parent, _shift, 0)
+#define GATE_ICG2(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &infra2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_ICG2_FLAGS(_id, _name, _parent, _shift, _flags) { \
-       .id = _id,                                              \
-       .name = _name,                                          \
-       .parent_name = _parent,                                 \
-       .regs = &infra2_cg_regs,                                \
-       .shift = _shift,                                        \
-       .ops = &mtk_clk_gate_ops_setclr,                        \
-       .flags = _flags,                                        \
-}
+#define GATE_ICG2_FLAGS(_id, _name, _parent, _shift, _flags)           \
+       GATE_MTK_FLAGS(_id, _name, _parent, &infra2_cg_regs, _shift,    \
+                      &mtk_clk_gate_ops_setclr, _flags)
 
 /*
  * Clock gates dramc and dramc_b are needed by the DRAM controller.
@@ -688,6 +670,7 @@ static const struct of_device_id of_match_clk_mt6797[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt6797);
 
 static int clk_mt6797_probe(struct platform_device *pdev)
 {
@@ -721,3 +704,4 @@ static int __init clk_mt6797_init(void)
 }
 
 arch_initcall(clk_mt6797_init);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt7622-apmixedsys.c b/drivers/clk/mediatek/clk-mt7622-apmixedsys.c
new file mode 100644 (file)
index 0000000..a36808d
--- /dev/null
@@ -0,0 +1,152 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2017 MediaTek Inc.
+ * Copyright (c) 2023 Collabora, Ltd.
+ *               AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+ */
+
+#include <dt-bindings/clock/mt7622-clk.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+#include "clk-pll.h"
+
+#define MT7622_PLL_FMAX                (2500UL * MHZ)
+#define CON0_MT7622_RST_BAR    BIT(27)
+
+#define PLL_xtal(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,\
+                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
+                       _pcw_shift, _div_table, _parent_name) {         \
+               .id = _id,                                              \
+               .name = _name,                                          \
+               .reg = _reg,                                            \
+               .pwr_reg = _pwr_reg,                                    \
+               .en_mask = _en_mask,                                    \
+               .flags = _flags,                                        \
+               .rst_bar_mask = CON0_MT7622_RST_BAR,                    \
+               .fmax = MT7622_PLL_FMAX,                                \
+               .pcwbits = _pcwbits,                                    \
+               .pd_reg = _pd_reg,                                      \
+               .pd_shift = _pd_shift,                                  \
+               .tuner_reg = _tuner_reg,                                \
+               .pcw_reg = _pcw_reg,                                    \
+               .pcw_shift = _pcw_shift,                                \
+               .div_table = _div_table,                                \
+               .parent_name = _parent_name,                            \
+       }
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,    \
+                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
+                       _pcw_shift)                                     \
+       PLL_xtal(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,\
+                _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift,  \
+                NULL, "clkxtal")
+
+static const struct mtk_gate_regs apmixed_cg_regs = {
+       .set_ofs = 0x8,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x8,
+};
+
+#define GATE_APMIXED_AO(_id, _name, _parent, _shift)                   \
+       GATE_MTK_FLAGS(_id, _name, _parent, &apmixed_cg_regs, _shift,   \
+                &mtk_clk_gate_ops_no_setclr_inv, CLK_IS_CRITICAL)
+
+static const struct mtk_pll_data plls[] = {
+       PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0,
+           PLL_AO, 21, 0x0204, 24, 0, 0x0204, 0),
+       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0,
+           HAVE_RST_BAR, 21, 0x0214, 24, 0, 0x0214, 0),
+       PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0,
+           HAVE_RST_BAR, 7, 0x0224, 24, 0, 0x0224, 14),
+       PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0,
+           0, 21, 0x0300, 1, 0, 0x0304, 0),
+       PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0,
+           0, 21, 0x0314, 1, 0, 0x0318, 0),
+       PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x0324, 0x0330, 0,
+           0, 31, 0x0324, 1, 0, 0x0328, 0),
+       PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x0334, 0x0340, 0,
+           0, 31, 0x0334, 1, 0, 0x0338, 0),
+       PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x0344, 0x0354, 0,
+           0, 21, 0x0344, 1, 0, 0x0348, 0),
+       PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0,
+           0, 21, 0x0358, 1, 0, 0x035C, 0),
+};
+
+static const struct mtk_gate apmixed_clks[] = {
+       GATE_APMIXED_AO(CLK_APMIXED_MAIN_CORE_EN, "main_core_en", "mainpll", 5),
+};
+
+static int clk_mt7622_apmixed_probe(struct platform_device *pdev)
+{
+       void __iomem *base;
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       struct device *dev = &pdev->dev;
+       int ret;
+
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       clk_data = mtk_devm_alloc_clk_data(dev, CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       if (ret)
+               return ret;
+
+       ret = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks,
+                                    ARRAY_SIZE(apmixed_clks), clk_data);
+       if (ret)
+               goto unregister_plls;
+
+       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (ret)
+               goto unregister_gates;
+
+       return 0;
+
+unregister_gates:
+       mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
+unregister_plls:
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+
+       return ret;
+}
+
+static int clk_mt7622_apmixed_remove(struct platform_device *pdev)
+{
+       struct device_node *node = pdev->dev.of_node;
+       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+       of_clk_del_provider(node);
+       mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+       mtk_free_clk_data(clk_data);
+
+       return 0;
+}
+
+static const struct of_device_id of_match_clk_mt7622_apmixed[] = {
+       { .compatible = "mediatek,mt7622-apmixedsys" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_apmixed);
+
+static struct platform_driver clk_mt7622_apmixed_drv = {
+       .probe = clk_mt7622_apmixed_probe,
+       .remove = clk_mt7622_apmixed_remove,
+       .driver = {
+               .name = "clk-mt7622-apmixed",
+               .of_match_table = of_match_clk_mt7622_apmixed,
+       },
+};
+module_platform_driver(clk_mt7622_apmixed_drv)
+
+MODULE_DESCRIPTION("MediaTek MT7622 apmixedsys clocks driver");
+MODULE_LICENSE("GPL");
index b8aabfeb1cba40a84da76d3c4adf2649ae173fd1..dd1799dd843590d45800e9d600d1a675e27b65eb 100644 (file)
 
 #include <dt-bindings/clock/mt7622-clk.h>
 
-#define GATE_AUDIO0(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &audio0_cg_regs,                        \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_AUDIO0(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &audio0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-#define GATE_AUDIO1(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &audio1_cg_regs,                        \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_AUDIO1(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &audio1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-#define GATE_AUDIO2(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &audio2_cg_regs,                        \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_AUDIO2(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &audio2_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-#define GATE_AUDIO3(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &audio3_cg_regs,                        \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_AUDIO3(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &audio3_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
 static const struct mtk_gate_regs audio0_cg_regs = {
        .set_ofs = 0x0,
@@ -169,6 +145,7 @@ static const struct of_device_id of_match_clk_mt7622_aud[] = {
        { .compatible = "mediatek,mt7622-audsys", .data = &audio_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_aud);
 
 static struct platform_driver clk_mt7622_aud_drv = {
        .probe = clk_mt7622_aud_probe,
@@ -178,5 +155,5 @@ static struct platform_driver clk_mt7622_aud_drv = {
                .of_match_table = of_match_clk_mt7622_aud,
        },
 };
-
-builtin_platform_driver(clk_mt7622_aud_drv);
+module_platform_driver(clk_mt7622_aud_drv);
+MODULE_LICENSE("GPL");
index aee583fa77d0ce4fdc0086a5fb0328f5e23d9039..f96b3673702959c76288e9b78791b5b211070575 100644 (file)
 
 #include <dt-bindings/clock/mt7622-clk.h>
 
-#define GATE_ETH(_id, _name, _parent, _shift) {        \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &eth_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_ETH(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &eth_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate_regs eth_cg_regs = {
        .set_ofs = 0x30,
@@ -45,14 +39,8 @@ static const struct mtk_gate_regs sgmii_cg_regs = {
        .sta_ofs = 0xE4,
 };
 
-#define GATE_SGMII(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &sgmii_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_SGMII(_id, _name, _parent, _shift)                        \
+       GATE_MTK(_id, _name, _parent, &sgmii_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate sgmii_clks[] = {
        GATE_SGMII(CLK_SGMII_TX250M_EN, "sgmii_tx250m_en",
@@ -89,6 +77,7 @@ static const struct of_device_id of_match_clk_mt7622_eth[] = {
        { .compatible = "mediatek,mt7622-sgmiisys", .data = &sgmii_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_eth);
 
 static struct platform_driver clk_mt7622_eth_drv = {
        .probe = mtk_clk_simple_probe,
@@ -98,5 +87,5 @@ static struct platform_driver clk_mt7622_eth_drv = {
                .of_match_table = of_match_clk_mt7622_eth,
        },
 };
-
-builtin_platform_driver(clk_mt7622_eth_drv);
+module_platform_driver(clk_mt7622_eth_drv);
+MODULE_LICENSE("GPL");
index ab5cad0c2b1c923e13c0471fcf5cf8a3fec7351c..f440943f0d46729e97f8584d55ceae1b83478b25 100644 (file)
 
 #include <dt-bindings/clock/mt7622-clk.h>
 
-#define GATE_PCIE(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &pcie_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_PCIE(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &pcie_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
-#define GATE_SSUSB(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ssusb_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_SSUSB(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &ssusb_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate_regs pcie_cg_regs = {
        .set_ofs = 0x30,
@@ -101,6 +89,7 @@ static const struct of_device_id of_match_clk_mt7622_hif[] = {
        { .compatible = "mediatek,mt7622-ssusbsys", .data = &ssusb_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_hif);
 
 static struct platform_driver clk_mt7622_hif_drv = {
        .probe = mtk_clk_simple_probe,
@@ -110,5 +99,5 @@ static struct platform_driver clk_mt7622_hif_drv = {
                .of_match_table = of_match_clk_mt7622_hif,
        },
 };
-
-builtin_platform_driver(clk_mt7622_hif_drv);
+module_platform_driver(clk_mt7622_hif_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt7622-infracfg.c b/drivers/clk/mediatek/clk-mt7622-infracfg.c
new file mode 100644 (file)
index 0000000..9dc0552
--- /dev/null
@@ -0,0 +1,128 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2017 MediaTek Inc.
+ * Copyright (c) 2023 Collabora, Ltd.
+ *               AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+ */
+
+#include <dt-bindings/clock/mt7622-clk.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#include "clk-cpumux.h"
+#include "clk-gate.h"
+#include "clk-mtk.h"
+#include "reset.h"
+
+#define GATE_INFRA(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate_regs infra_cg_regs = {
+       .set_ofs = 0x40,
+       .clr_ofs = 0x44,
+       .sta_ofs = 0x48,
+};
+
+static const char * const infra_mux1_parents[] = {
+       "clkxtal",
+       "armpll",
+       "main_core_en",
+       "armpll"
+};
+
+static const struct mtk_composite cpu_muxes[] = {
+       MUX(CLK_INFRA_MUX1_SEL, "infra_mux1_sel", infra_mux1_parents, 0x000, 2, 2),
+};
+
+static const struct mtk_gate infra_clks[] = {
+       GATE_INFRA(CLK_INFRA_DBGCLK_PD, "infra_dbgclk_pd", "axi_sel", 0),
+       GATE_INFRA(CLK_INFRA_TRNG, "trng_ck", "axi_sel", 2),
+       GATE_INFRA(CLK_INFRA_AUDIO_PD, "infra_audio_pd", "aud_intbus_sel", 5),
+       GATE_INFRA(CLK_INFRA_IRRX_PD, "infra_irrx_pd", "irrx_sel", 16),
+       GATE_INFRA(CLK_INFRA_APXGPT_PD, "infra_apxgpt_pd", "f10m_ref_sel", 18),
+       GATE_INFRA(CLK_INFRA_PMIC_PD, "infra_pmic_pd", "pmicspi_sel", 22),
+};
+
+static u16 infrasys_rst_ofs[] = { 0x30 };
+
+static const struct mtk_clk_rst_desc clk_rst_desc = {
+       .version = MTK_RST_SIMPLE,
+       .rst_bank_ofs = infrasys_rst_ofs,
+       .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs),
+};
+
+static const struct of_device_id of_match_clk_mt7622_infracfg[] = {
+       { .compatible = "mediatek,mt7622-infracfg" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_infracfg);
+
+static int clk_mt7622_infracfg_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       void __iomem *base;
+       int ret;
+
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       ret = mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+       if (ret)
+               goto free_clk_data;
+
+       ret = mtk_clk_register_gates(&pdev->dev, node, infra_clks,
+                                    ARRAY_SIZE(infra_clks), clk_data);
+       if (ret)
+               goto free_clk_data;
+
+       ret = mtk_clk_register_cpumuxes(&pdev->dev, node, cpu_muxes,
+                                       ARRAY_SIZE(cpu_muxes), clk_data);
+       if (ret)
+               goto unregister_gates;
+
+       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (ret)
+               goto unregister_cpumuxes;
+
+       return 0;
+
+unregister_cpumuxes:
+       mtk_clk_unregister_cpumuxes(cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data);
+unregister_gates:
+       mtk_clk_unregister_gates(infra_clks, ARRAY_SIZE(infra_clks), clk_data);
+free_clk_data:
+       mtk_free_clk_data(clk_data);
+       return ret;
+}
+
+static int clk_mt7622_infracfg_remove(struct platform_device *pdev)
+{
+       struct device_node *node = pdev->dev.of_node;
+       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+       of_clk_del_provider(node);
+       mtk_clk_unregister_cpumuxes(cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data);
+       mtk_clk_unregister_gates(infra_clks, ARRAY_SIZE(infra_clks), clk_data);
+       mtk_free_clk_data(clk_data);
+
+       return 0;
+}
+
+static struct platform_driver clk_mt7622_infracfg_drv = {
+       .driver = {
+               .name = "clk-mt7622-infracfg",
+               .of_match_table = of_match_clk_mt7622_infracfg,
+       },
+       .probe = clk_mt7622_infracfg_probe,
+       .remove = clk_mt7622_infracfg_remove,
+};
+module_platform_driver(clk_mt7622_infracfg_drv);
+
+MODULE_DESCRIPTION("MediaTek MT7622 infracfg clocks driver");
+MODULE_LICENSE("GPL");
index 5a82c2270bfbc24811d61d0e94ad2590324890b8..274895264427af01c7825d6d8e251119884b2ff4 100644 (file)
 #include "clk-cpumux.h"
 #include "clk-gate.h"
 #include "clk-mtk.h"
-#include "clk-pll.h"
 
 #include <dt-bindings/clock/mt7622-clk.h>
 #include <linux/clk.h> /* for consumer */
 
-#define MT7622_PLL_FMAX                (2500UL * MHZ)
-#define CON0_MT7622_RST_BAR    BIT(27)
-
-#define PLL_xtal(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,\
-                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
-                       _pcw_shift, _div_table, _parent_name) {         \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .reg = _reg,                                            \
-               .pwr_reg = _pwr_reg,                                    \
-               .en_mask = _en_mask,                                    \
-               .flags = _flags,                                        \
-               .rst_bar_mask = CON0_MT7622_RST_BAR,                    \
-               .fmax = MT7622_PLL_FMAX,                                \
-               .pcwbits = _pcwbits,                                    \
-               .pd_reg = _pd_reg,                                      \
-               .pd_shift = _pd_shift,                                  \
-               .tuner_reg = _tuner_reg,                                \
-               .pcw_reg = _pcw_reg,                                    \
-               .pcw_shift = _pcw_shift,                                \
-               .div_table = _div_table,                                \
-               .parent_name = _parent_name,                            \
-       }
-
-#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,    \
-                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
-                       _pcw_shift)                                     \
-       PLL_xtal(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,\
-                _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift,  \
-                NULL, "clkxtal")
-
-#define GATE_APMIXED(_id, _name, _parent, _shift) {                    \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .parent_name = _parent,                                 \
-               .regs = &apmixed_cg_regs,                               \
-               .shift = _shift,                                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv,                 \
-       }
-
-#define GATE_INFRA(_id, _name, _parent, _shift) {                      \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .parent_name = _parent,                                 \
-               .regs = &infra_cg_regs,                                 \
-               .shift = _shift,                                        \
-               .ops = &mtk_clk_gate_ops_setclr,                        \
-       }
-
-#define GATE_TOP0(_id, _name, _parent, _shift) {                       \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .parent_name = _parent,                                 \
-               .regs = &top0_cg_regs,                                  \
-               .shift = _shift,                                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,                     \
-       }
-
-#define GATE_TOP1(_id, _name, _parent, _shift) {                       \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .parent_name = _parent,                                 \
-               .regs = &top1_cg_regs,                                  \
-               .shift = _shift,                                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,                     \
-       }
-
-#define GATE_PERI0(_id, _name, _parent, _shift) {                      \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .parent_name = _parent,                                 \
-               .regs = &peri0_cg_regs,                                 \
-               .shift = _shift,                                        \
-               .ops = &mtk_clk_gate_ops_setclr,                        \
-       }
-
-#define GATE_PERI1(_id, _name, _parent, _shift) {                      \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .parent_name = _parent,                                 \
-               .regs = &peri1_cg_regs,                                 \
-               .shift = _shift,                                        \
-               .ops = &mtk_clk_gate_ops_setclr,                        \
-       }
+#define GATE_TOP0(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-static DEFINE_SPINLOCK(mt7622_clk_lock);
+#define GATE_TOP1(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-static const char * const infra_mux1_parents[] = {
-       "clkxtal",
-       "armpll",
-       "main_core_en",
-       "armpll"
-};
+#define GATE_PERI0(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_PERI0_AO(_id, _name, _parent, _shift)                     \
+       GATE_MTK_FLAGS(_id, _name, _parent, &peri0_cg_regs, _shift,     \
+                &mtk_clk_gate_ops_setclr, CLK_IS_CRITICAL)
+
+#define GATE_PERI1(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static DEFINE_SPINLOCK(mt7622_clk_lock);
 
 static const char * const axi_parents[] = {
        "clkxtal",
@@ -292,18 +215,6 @@ static const char * const peribus_ck_parents[] = {
        "syspll1_d4"
 };
 
-static const struct mtk_gate_regs apmixed_cg_regs = {
-       .set_ofs = 0x8,
-       .clr_ofs = 0x8,
-       .sta_ofs = 0x8,
-};
-
-static const struct mtk_gate_regs infra_cg_regs = {
-       .set_ofs = 0x40,
-       .clr_ofs = 0x44,
-       .sta_ofs = 0x48,
-};
-
 static const struct mtk_gate_regs top0_cg_regs = {
        .set_ofs = 0x120,
        .clr_ofs = 0x120,
@@ -328,40 +239,6 @@ static const struct mtk_gate_regs peri1_cg_regs = {
        .sta_ofs = 0x1C,
 };
 
-static const struct mtk_pll_data plls[] = {
-       PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0,
-           PLL_AO, 21, 0x0204, 24, 0, 0x0204, 0),
-       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0,
-           HAVE_RST_BAR, 21, 0x0214, 24, 0, 0x0214, 0),
-       PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0,
-           HAVE_RST_BAR, 7, 0x0224, 24, 0, 0x0224, 14),
-       PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0,
-           0, 21, 0x0300, 1, 0, 0x0304, 0),
-       PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0,
-           0, 21, 0x0314, 1, 0, 0x0318, 0),
-       PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x0324, 0x0330, 0,
-           0, 31, 0x0324, 1, 0, 0x0328, 0),
-       PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x0334, 0x0340, 0,
-           0, 31, 0x0334, 1, 0, 0x0338, 0),
-       PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x0344, 0x0354, 0,
-           0, 21, 0x0344, 1, 0, 0x0348, 0),
-       PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0,
-           0, 21, 0x0358, 1, 0, 0x035C, 0),
-};
-
-static const struct mtk_gate apmixed_clks[] = {
-       GATE_APMIXED(CLK_APMIXED_MAIN_CORE_EN, "main_core_en", "mainpll", 5),
-};
-
-static const struct mtk_gate infra_clks[] = {
-       GATE_INFRA(CLK_INFRA_DBGCLK_PD, "infra_dbgclk_pd", "axi_sel", 0),
-       GATE_INFRA(CLK_INFRA_TRNG, "trng_ck", "axi_sel", 2),
-       GATE_INFRA(CLK_INFRA_AUDIO_PD, "infra_audio_pd", "aud_intbus_sel", 5),
-       GATE_INFRA(CLK_INFRA_IRRX_PD, "infra_irrx_pd", "irrx_sel", 16),
-       GATE_INFRA(CLK_INFRA_APXGPT_PD, "infra_apxgpt_pd", "f10m_ref_sel", 18),
-       GATE_INFRA(CLK_INFRA_PMIC_PD, "infra_pmic_pd", "pmicspi_sel", 22),
-};
-
 static const struct mtk_fixed_clk top_fixed_clks[] = {
        FIXED_CLK(CLK_TOP_TO_U2_PHY, "to_u2_phy", "clkxtal",
                  31250000),
@@ -485,7 +362,7 @@ static const struct mtk_gate peri_clks[] = {
        GATE_PERI0(CLK_PERI_AP_DMA_PD, "peri_ap_dma_pd", "axi_sel", 12),
        GATE_PERI0(CLK_PERI_MSDC30_0_PD, "peri_msdc30_0", "msdc30_0_sel", 13),
        GATE_PERI0(CLK_PERI_MSDC30_1_PD, "peri_msdc30_1", "msdc30_1_sel", 14),
-       GATE_PERI0(CLK_PERI_UART0_PD, "peri_uart0_pd", "axi_sel", 17),
+       GATE_PERI0_AO(CLK_PERI_UART0_PD, "peri_uart0_pd", "axi_sel", 17),
        GATE_PERI0(CLK_PERI_UART1_PD, "peri_uart1_pd", "axi_sel", 18),
        GATE_PERI0(CLK_PERI_UART2_PD, "peri_uart2_pd", "axi_sel", 19),
        GATE_PERI0(CLK_PERI_UART3_PD, "peri_uart3_pd", "axi_sel", 20),
@@ -506,19 +383,14 @@ static const struct mtk_gate peri_clks[] = {
        GATE_PERI1(CLK_PERI_IRTX_PD, "peri_irtx_pd", "irtx_sel", 2),
 };
 
-static struct mtk_composite infra_muxes[] = {
-       MUX(CLK_INFRA_MUX1_SEL, "infra_mux1_sel", infra_mux1_parents,
-           0x000, 2, 2),
-};
-
 static struct mtk_composite top_muxes[] = {
        /* CLK_CFG_0 */
-       MUX_GATE(CLK_TOP_AXI_SEL, "axi_sel", axi_parents,
-                0x040, 0, 3, 7),
-       MUX_GATE(CLK_TOP_MEM_SEL, "mem_sel", mem_parents,
-                0x040, 8, 1, 15),
-       MUX_GATE(CLK_TOP_DDRPHYCFG_SEL, "ddrphycfg_sel", ddrphycfg_parents,
-                0x040, 16, 1, 23),
+       MUX_GATE_FLAGS(CLK_TOP_AXI_SEL, "axi_sel", axi_parents,
+                      0x040, 0, 3, 7, CLK_IS_CRITICAL),
+       MUX_GATE_FLAGS(CLK_TOP_MEM_SEL, "mem_sel", mem_parents,
+                      0x040, 8, 1, 15, CLK_IS_CRITICAL),
+       MUX_GATE_FLAGS(CLK_TOP_DDRPHYCFG_SEL, "ddrphycfg_sel", ddrphycfg_parents,
+                      0x040, 16, 1, 23, CLK_IS_CRITICAL),
        MUX_GATE(CLK_TOP_ETH_SEL, "eth_sel", eth_parents,
                 0x040, 24, 3, 31),
 
@@ -610,182 +482,53 @@ static struct mtk_composite peri_muxes[] = {
        MUX(CLK_PERIBUS_SEL, "peribus_ck_sel", peribus_ck_parents, 0x05C, 0, 1),
 };
 
-static u16 infrasys_rst_ofs[] = { 0x30, };
 static u16 pericfg_rst_ofs[] = { 0x0, 0x4, };
 
-static const struct mtk_clk_rst_desc clk_rst_desc[] = {
-       /* infrasys */
-       {
-               .version = MTK_RST_SIMPLE,
-               .rst_bank_ofs = infrasys_rst_ofs,
-               .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs),
-       },
-       /* pericfg */
-       {
-               .version = MTK_RST_SIMPLE,
-               .rst_bank_ofs = pericfg_rst_ofs,
-               .rst_bank_nr = ARRAY_SIZE(pericfg_rst_ofs),
-       },
+static const struct mtk_clk_rst_desc clk_rst_desc = {
+       .version = MTK_RST_SIMPLE,
+       .rst_bank_ofs = pericfg_rst_ofs,
+       .rst_bank_nr = ARRAY_SIZE(pericfg_rst_ofs),
 };
 
-static int mtk_topckgen_init(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       void __iomem *base;
-       struct device_node *node = pdev->dev.of_node;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
-
-       mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
-                                   clk_data);
-
-       mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs),
-                                clk_data);
-
-       mtk_clk_register_composites(&pdev->dev, top_muxes,
-                                   ARRAY_SIZE(top_muxes), base,
-                                   &mt7622_clk_lock, clk_data);
-
-       mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs),
-                                 base, &mt7622_clk_lock, clk_data);
-
-       mtk_clk_register_gates(&pdev->dev, node, top_clks,
-                              ARRAY_SIZE(top_clks), clk_data);
-
-       clk_prepare_enable(clk_data->hws[CLK_TOP_AXI_SEL]->clk);
-       clk_prepare_enable(clk_data->hws[CLK_TOP_MEM_SEL]->clk);
-       clk_prepare_enable(clk_data->hws[CLK_TOP_DDRPHYCFG_SEL]->clk);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
-
-static int mtk_infrasys_init(struct platform_device *pdev)
-{
-       struct device_node *node = pdev->dev.of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
-
-       mtk_clk_register_gates(&pdev->dev, node, infra_clks,
-                              ARRAY_SIZE(infra_clks), clk_data);
-
-       mtk_clk_register_cpumuxes(&pdev->dev, node, infra_muxes,
-                                 ARRAY_SIZE(infra_muxes), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
-                                  clk_data);
-       if (r)
-               return r;
-
-       mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[0]);
-
-       return 0;
-}
-
-static int mtk_apmixedsys_init(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls),
-                             clk_data);
-
-       mtk_clk_register_gates(&pdev->dev, node, apmixed_clks,
-                              ARRAY_SIZE(apmixed_clks), clk_data);
-
-       clk_prepare_enable(clk_data->hws[CLK_APMIXED_ARMPLL]->clk);
-       clk_prepare_enable(clk_data->hws[CLK_APMIXED_MAIN_CORE_EN]->clk);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
-
-static int mtk_pericfg_init(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       void __iomem *base;
-       int r;
-       struct device_node *node = pdev->dev.of_node;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
-
-       mtk_clk_register_gates(&pdev->dev, node, peri_clks,
-                              ARRAY_SIZE(peri_clks), clk_data);
-
-       mtk_clk_register_composites(&pdev->dev, peri_muxes,
-                                   ARRAY_SIZE(peri_muxes), base,
-                                   &mt7622_clk_lock, clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               return r;
-
-       clk_prepare_enable(clk_data->hws[CLK_PERI_UART0_PD]->clk);
-
-       mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[1]);
+static const struct mtk_clk_desc topck_desc = {
+       .clks = top_clks,
+       .num_clks = ARRAY_SIZE(top_clks),
+       .fixed_clks = top_fixed_clks,
+       .num_fixed_clks = ARRAY_SIZE(top_fixed_clks),
+       .factor_clks = top_divs,
+       .num_factor_clks = ARRAY_SIZE(top_divs),
+       .composite_clks = top_muxes,
+       .num_composite_clks = ARRAY_SIZE(top_muxes),
+       .divider_clks = top_adj_divs,
+       .num_divider_clks = ARRAY_SIZE(top_adj_divs),
+       .clk_lock = &mt7622_clk_lock,
+};
 
-       return 0;
-}
+static const struct mtk_clk_desc peri_desc = {
+       .clks = peri_clks,
+       .num_clks = ARRAY_SIZE(peri_clks),
+       .composite_clks = peri_muxes,
+       .num_composite_clks = ARRAY_SIZE(peri_muxes),
+       .rst_desc = &clk_rst_desc,
+       .clk_lock = &mt7622_clk_lock,
+};
 
 static const struct of_device_id of_match_clk_mt7622[] = {
-       {
-               .compatible = "mediatek,mt7622-apmixedsys",
-               .data = mtk_apmixedsys_init,
-       }, {
-               .compatible = "mediatek,mt7622-infracfg",
-               .data = mtk_infrasys_init,
-       }, {
-               .compatible = "mediatek,mt7622-topckgen",
-               .data = mtk_topckgen_init,
-       }, {
-               .compatible = "mediatek,mt7622-pericfg",
-               .data = mtk_pericfg_init,
-       }, {
-               /* sentinel */
-       }
-};
-
-static int clk_mt7622_probe(struct platform_device *pdev)
-{
-       int (*clk_init)(struct platform_device *);
-       int r;
-
-       clk_init = of_device_get_match_data(&pdev->dev);
-       if (!clk_init)
-               return -EINVAL;
-
-       r = clk_init(pdev);
-       if (r)
-               dev_err(&pdev->dev,
-                       "could not register clock provider: %s: %d\n",
-                       pdev->name, r);
-
-       return r;
-}
+       { .compatible = "mediatek,mt7622-topckgen", .data = &topck_desc },
+       { .compatible = "mediatek,mt7622-pericfg", .data = &peri_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7622);
 
 static struct platform_driver clk_mt7622_drv = {
-       .probe = clk_mt7622_probe,
        .driver = {
                .name = "clk-mt7622",
                .of_match_table = of_match_clk_mt7622,
        },
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
 };
+module_platform_driver(clk_mt7622_drv)
 
-static int clk_mt7622_init(void)
-{
-       return platform_driver_register(&clk_mt7622_drv);
-}
-
-arch_initcall(clk_mt7622_init);
+MODULE_DESCRIPTION("MediaTek MT7622 clocks driver");
+MODULE_LICENSE("GPL");
index a4ae7d6c7a71ac84ec393ff6ec48122aca0e2910..1e1c77cc14ba5f642c47f79bcc297c6296a5a7b6 100644 (file)
 
 #include <dt-bindings/clock/mt7629-clk.h>
 
-#define GATE_ETH(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &eth_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_ETH(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &eth_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate_regs eth_cg_regs = {
        .set_ofs = 0x30,
@@ -45,14 +39,8 @@ static const struct mtk_gate_regs sgmii_cg_regs = {
        .sta_ofs = 0xE4,
 };
 
-#define GATE_SGMII(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &sgmii_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_SGMII(_id, _name, _parent, _shift)                        \
+       GATE_MTK(_id, _name, _parent, &sgmii_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate sgmii_clks[2][4] = {
        {
@@ -138,6 +126,7 @@ static const struct of_device_id of_match_clk_mt7629_eth[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7629_eth);
 
 static int clk_mt7629_eth_probe(struct platform_device *pdev)
 {
@@ -166,3 +155,4 @@ static struct platform_driver clk_mt7629_eth_drv = {
 };
 
 builtin_platform_driver(clk_mt7629_eth_drv);
+MODULE_LICENSE("GPL");
index c3eb09ea6036f846398fda1edf18e7ee059e647e..c89036bee9a7284c4a51b825a862036c1b1ad7a0 100644 (file)
 
 #include <dt-bindings/clock/mt7629-clk.h>
 
-#define GATE_PCIE(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &pcie_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_PCIE(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &pcie_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
-#define GATE_SSUSB(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ssusb_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_SSUSB(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &ssusb_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
 static const struct mtk_gate_regs pcie_cg_regs = {
        .set_ofs = 0x30,
@@ -96,6 +84,7 @@ static const struct of_device_id of_match_clk_mt7629_hif[] = {
        { .compatible = "mediatek,mt7629-ssusbsys", .data = &ssusb_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7629_hif);
 
 static struct platform_driver clk_mt7629_hif_drv = {
        .probe = mtk_clk_simple_probe,
@@ -105,5 +94,5 @@ static struct platform_driver clk_mt7629_hif_drv = {
                .of_match_table = of_match_clk_mt7629_hif,
        },
 };
-
-builtin_platform_driver(clk_mt7629_hif_drv);
+module_platform_driver(clk_mt7629_hif_drv);
+MODULE_LICENSE("GPL");
index cf062d4a7ecc461b4d417c1b74daa5de49b2df63..0893fbbb68cc1e1367b70797f483a7762912126e 100644 (file)
                _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift,   \
                NULL, "clk20m")
 
-#define GATE_APMIXED(_id, _name, _parent, _shift) {    \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &apmixed_cg_regs,               \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv, \
-       }
+#define GATE_APMIXED(_id, _name, _parent, _shift)                      \
+       GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
-#define GATE_INFRA(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &infra_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_INFRA(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_PERI0(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &peri0_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_PERI0(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_PERI1(_id, _name, _parent, _shift) {      \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &peri1_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_PERI1(_id, _name, _parent, _shift)                                \
+       GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static DEFINE_SPINLOCK(mt7629_clk_lock);
 
@@ -684,6 +660,7 @@ static const struct of_device_id of_match_clk_mt7629[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7629);
 
 static int clk_mt7629_probe(struct platform_device *pdev)
 {
@@ -717,3 +694,4 @@ static int clk_mt7629_init(void)
 }
 
 arch_initcall(clk_mt7629_init);
+MODULE_LICENSE("GPL");
index 52b7123232bf014e7fd34163ee2e5b3b1a48be48..875813d8b4a9cd8e46c183739862ca55ff555087 100644 (file)
@@ -66,6 +66,7 @@ static const struct of_device_id of_match_clk_mt7981_apmixed[] = {
        { .compatible = "mediatek,mt7981-apmixedsys", },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7981_apmixed);
 
 static int clk_mt7981_apmixed_probe(struct platform_device *pdev)
 {
@@ -100,3 +101,4 @@ static struct platform_driver clk_mt7981_apmixed_drv = {
        },
 };
 builtin_platform_driver(clk_mt7981_apmixed_drv);
+MODULE_LICENSE("GPL");
index 773350911be232e1a940d4fa681b0a42ad49528a..b1f256b5ed4e7029ae7fabd3d40ef5ff7b22fae9 100644 (file)
@@ -105,6 +105,7 @@ static const struct of_device_id of_match_clk_mt7981_eth[] = {
        { .compatible = "mediatek,mt7981-sgmiisys_1", .data = &sgmii1_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7981_eth);
 
 static struct platform_driver clk_mt7981_eth_drv = {
        .probe = mtk_clk_simple_probe,
@@ -115,4 +116,4 @@ static struct platform_driver clk_mt7981_eth_drv = {
        },
 };
 module_platform_driver(clk_mt7981_eth_drv);
-MODULE_LICENSE("GPL v2");
+MODULE_LICENSE("GPL");
index 8cf5057419e8d88d66a445cec6c6e3a25a0011e9..293261ef71e62842bad475e856ff226b588f9cb9 100644 (file)
@@ -195,6 +195,7 @@ static const struct of_device_id of_match_clk_mt7981_infracfg[] = {
        { .compatible = "mediatek,mt7981-infracfg", .data = &infracfg_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7981_infracfg);
 
 static struct platform_driver clk_mt7981_infracfg_drv = {
        .probe = mtk_clk_simple_probe,
@@ -204,4 +205,5 @@ static struct platform_driver clk_mt7981_infracfg_drv = {
                .of_match_table = of_match_clk_mt7981_infracfg,
        },
 };
-builtin_platform_driver(clk_mt7981_infracfg_drv);
+module_platform_driver(clk_mt7981_infracfg_drv);
+MODULE_LICENSE("GPL");
index 74634d65f5f6d264f5b6c9edc73d1cb2d129166a..3aba1a9b9a36a60c574e9ebfefd072eadb5be36e 100644 (file)
@@ -410,6 +410,7 @@ static const struct of_device_id of_match_clk_mt7981_topckgen[] = {
        { .compatible = "mediatek,mt7981-topckgen", .data = &topck_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7981_topckgen);
 
 static struct platform_driver clk_mt7981_topckgen_drv = {
        .probe = mtk_clk_simple_probe,
@@ -419,4 +420,5 @@ static struct platform_driver clk_mt7981_topckgen_drv = {
                .of_match_table = of_match_clk_mt7981_topckgen,
        },
 };
-builtin_platform_driver(clk_mt7981_topckgen_drv);
+module_platform_driver(clk_mt7981_topckgen_drv);
+MODULE_LICENSE("GPL");
index 62080ee4dbe35dfd3acb352a8170cbb7eb0fc68c..6767e9c43886643fae2fc0b9bd52f8c6b2854b3d 100644 (file)
@@ -42,7 +42,7 @@
                 "clkxtal")
 
 static const struct mtk_pll_data plls[] = {
-       PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x0, 0, 32,
+       PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x0, PLL_AO, 32,
            0x0200, 4, 0, 0x0204, 0),
        PLL(CLK_APMIXED_NET2PLL, "net2pll", 0x0210, 0x021C, 0x0, 0, 32,
            0x0210, 4, 0, 0x0214, 0),
@@ -62,8 +62,9 @@ static const struct mtk_pll_data plls[] = {
 
 static const struct of_device_id of_match_clk_mt7986_apmixed[] = {
        { .compatible = "mediatek,mt7986-apmixedsys", },
-       {}
+       { }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7986_apmixed);
 
 static int clk_mt7986_apmixed_probe(struct platform_device *pdev)
 {
@@ -77,8 +78,6 @@ static int clk_mt7986_apmixed_probe(struct platform_device *pdev)
 
        mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
 
-       clk_prepare_enable(clk_data->hws[CLK_APMIXED_ARMPLL]->clk);
-
        r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
        if (r) {
                pr_err("%s(): could not register clock provider: %d\n",
@@ -100,3 +99,4 @@ static struct platform_driver clk_mt7986_apmixed_drv = {
        },
 };
 builtin_platform_driver(clk_mt7986_apmixed_drv);
+MODULE_LICENSE("GPL");
index 703872239eccad79c94653d83740b220bb1ead86..0681988960cc3ce4477de8f9054fd9fb7dba78e8 100644 (file)
@@ -22,14 +22,10 @@ static const struct mtk_gate_regs sgmii0_cg_regs = {
        .sta_ofs = 0xe4,
 };
 
-#define GATE_SGMII0(_id, _name, _parent, _shift)                               \
-       {                                                                      \
-               .id = _id, .name = _name, .parent_name = _parent,              \
-               .regs = &sgmii0_cg_regs, .shift = _shift,                      \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv,                        \
-       }
-
-static const struct mtk_gate sgmii0_clks[] __initconst = {
+#define GATE_SGMII0(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &sgmii0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+static const struct mtk_gate sgmii0_clks[] = {
        GATE_SGMII0(CLK_SGMII0_TX250M_EN, "sgmii0_tx250m_en", "top_xtal", 2),
        GATE_SGMII0(CLK_SGMII0_RX250M_EN, "sgmii0_rx250m_en", "top_xtal", 3),
        GATE_SGMII0(CLK_SGMII0_CDR_REF, "sgmii0_cdr_ref", "top_xtal", 4),
@@ -42,14 +38,10 @@ static const struct mtk_gate_regs sgmii1_cg_regs = {
        .sta_ofs = 0xe4,
 };
 
-#define GATE_SGMII1(_id, _name, _parent, _shift)                               \
-       {                                                                      \
-               .id = _id, .name = _name, .parent_name = _parent,              \
-               .regs = &sgmii1_cg_regs, .shift = _shift,                      \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv,                        \
-       }
+#define GATE_SGMII1(_id, _name, _parent, _shift)               \
+       GATE_MTK(_id, _name, _parent, &sgmii1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
-static const struct mtk_gate sgmii1_clks[] __initconst = {
+static const struct mtk_gate sgmii1_clks[] = {
        GATE_SGMII1(CLK_SGMII1_TX250M_EN, "sgmii1_tx250m_en", "top_xtal", 2),
        GATE_SGMII1(CLK_SGMII1_RX250M_EN, "sgmii1_rx250m_en", "top_xtal", 3),
        GATE_SGMII1(CLK_SGMII1_CDR_REF, "sgmii1_cdr_ref", "top_xtal", 4),
@@ -62,14 +54,10 @@ static const struct mtk_gate_regs eth_cg_regs = {
        .sta_ofs = 0x30,
 };
 
-#define GATE_ETH(_id, _name, _parent, _shift)                                  \
-       {                                                                      \
-               .id = _id, .name = _name, .parent_name = _parent,              \
-               .regs = &eth_cg_regs, .shift = _shift,                         \
-               .ops = &mtk_clk_gate_ops_no_setclr_inv,                        \
-       }
+#define GATE_ETH(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &eth_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
 
-static const struct mtk_gate eth_clks[] __initconst = {
+static const struct mtk_gate eth_clks[] = {
        GATE_ETH(CLK_ETH_FE_EN, "eth_fe_en", "netsys_2x_sel", 6),
        GATE_ETH(CLK_ETH_GP2_EN, "eth_gp2_en", "sgm_325m_sel", 7),
        GATE_ETH(CLK_ETH_GP1_EN, "eth_gp1_en", "sgm_325m_sel", 8),
@@ -77,56 +65,38 @@ static const struct mtk_gate eth_clks[] __initconst = {
        GATE_ETH(CLK_ETH_WOCPU0_EN, "eth_wocpu0_en", "netsys_mcu_sel", 15),
 };
 
-static void __init mtk_sgmiisys_0_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(ARRAY_SIZE(sgmii0_clks));
-
-       mtk_clk_register_gates(NULL, node, sgmii0_clks,
-                              ARRAY_SIZE(sgmii0_clks), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                      __func__, r);
-}
-CLK_OF_DECLARE(mtk_sgmiisys_0, "mediatek,mt7986-sgmiisys_0",
-              mtk_sgmiisys_0_init);
-
-static void __init mtk_sgmiisys_1_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(ARRAY_SIZE(sgmii1_clks));
-
-       mtk_clk_register_gates(NULL, node, sgmii1_clks,
-                              ARRAY_SIZE(sgmii1_clks), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                      __func__, r);
-}
-CLK_OF_DECLARE(mtk_sgmiisys_1, "mediatek,mt7986-sgmiisys_1",
-              mtk_sgmiisys_1_init);
-
-static void __init mtk_ethsys_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
+static const struct mtk_clk_desc eth_desc = {
+       .clks = eth_clks,
+       .num_clks = ARRAY_SIZE(eth_clks),
+};
 
-       clk_data = mtk_alloc_clk_data(ARRAY_SIZE(eth_clks));
+static const struct mtk_clk_desc sgmii0_desc = {
+       .clks = sgmii0_clks,
+       .num_clks = ARRAY_SIZE(sgmii0_clks),
+};
 
-       mtk_clk_register_gates(NULL, node, eth_clks, ARRAY_SIZE(eth_clks), clk_data);
+static const struct mtk_clk_desc sgmii1_desc = {
+       .clks = sgmii1_clks,
+       .num_clks = ARRAY_SIZE(sgmii1_clks),
+};
 
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+static const struct of_device_id of_match_clk_mt7986_eth[] = {
+       { .compatible = "mediatek,mt7986-ethsys", .data = &eth_desc },
+       { .compatible = "mediatek,mt7986-sgmiisys_0", .data = &sgmii0_desc },
+       { .compatible = "mediatek,mt7986-sgmiisys_1", .data = &sgmii1_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7986_eth);
+
+static struct platform_driver clk_mt7986_eth_drv = {
+       .driver = {
+               .name = "clk-mt7986-eth",
+               .of_match_table = of_match_clk_mt7986_eth,
+       },
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+};
+module_platform_driver(clk_mt7986_eth_drv);
 
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                      __func__, r);
-}
-CLK_OF_DECLARE(mtk_ethsys, "mediatek,mt7986-ethsys", mtk_ethsys_init);
+MODULE_DESCRIPTION("MediaTek MT7986 Ethernet clocks driver");
+MODULE_LICENSE("GPL");
index e80c92167c8fcffe486b45c7ae62a5277fd860a3..b7efa70c2d6c271c4fb57819a8b20fa6dbe2925c 100644 (file)
@@ -87,26 +87,14 @@ static const struct mtk_gate_regs infra2_cg_regs = {
        .sta_ofs = 0x68,
 };
 
-#define GATE_INFRA0(_id, _name, _parent, _shift)                               \
-       {                                                                      \
-               .id = _id, .name = _name, .parent_name = _parent,              \
-               .regs = &infra0_cg_regs, .shift = _shift,                      \
-               .ops = &mtk_clk_gate_ops_setclr,                               \
-       }
-
-#define GATE_INFRA1(_id, _name, _parent, _shift)                               \
-       {                                                                      \
-               .id = _id, .name = _name, .parent_name = _parent,              \
-               .regs = &infra1_cg_regs, .shift = _shift,                      \
-               .ops = &mtk_clk_gate_ops_setclr,                               \
-       }
-
-#define GATE_INFRA2(_id, _name, _parent, _shift)                               \
-       {                                                                      \
-               .id = _id, .name = _name, .parent_name = _parent,              \
-               .regs = &infra2_cg_regs, .shift = _shift,                      \
-               .ops = &mtk_clk_gate_ops_setclr,                               \
-       }
+#define GATE_INFRA0(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &infra0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_INFRA1(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &infra1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_INFRA2(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &infra2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate infra_clks[] = {
        /* INFRA0 */
@@ -169,57 +157,31 @@ static const struct mtk_gate infra_clks[] = {
        GATE_INFRA2(CLK_INFRA_IPCIEB_CK, "infra_ipcieb", "sysaxi_sel", 15),
 };
 
-static int clk_mt7986_infracfg_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-       int r;
-       void __iomem *base;
-       int nr = ARRAY_SIZE(infra_divs) + ARRAY_SIZE(infra_muxes) +
-                ARRAY_SIZE(infra_clks);
-
-       base = of_iomap(node, 0);
-       if (!base) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return -ENOMEM;
-       }
-
-       clk_data = mtk_alloc_clk_data(nr);
-
-       if (!clk_data)
-               return -ENOMEM;
-
-       mtk_clk_register_factors(infra_divs, ARRAY_SIZE(infra_divs), clk_data);
-       mtk_clk_register_muxes(&pdev->dev, infra_muxes,
-                              ARRAY_SIZE(infra_muxes), node,
-                              &mt7986_clk_lock, clk_data);
-       mtk_clk_register_gates(&pdev->dev, node, infra_clks,
-                              ARRAY_SIZE(infra_clks), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r) {
-               pr_err("%s(): could not register clock provider: %d\n",
-                      __func__, r);
-               goto free_infracfg_data;
-       }
-       return r;
-
-free_infracfg_data:
-       mtk_free_clk_data(clk_data);
-       return r;
-
-}
+static const struct mtk_clk_desc infra_desc = {
+       .clks = infra_clks,
+       .num_clks = ARRAY_SIZE(infra_clks),
+       .factor_clks = infra_divs,
+       .num_factor_clks = ARRAY_SIZE(infra_divs),
+       .mux_clks = infra_muxes,
+       .num_mux_clks = ARRAY_SIZE(infra_muxes),
+       .clk_lock = &mt7986_clk_lock,
+};
 
 static const struct of_device_id of_match_clk_mt7986_infracfg[] = {
-       { .compatible = "mediatek,mt7986-infracfg", },
-       {}
+       { .compatible = "mediatek,mt7986-infracfg", .data = &infra_desc },
+       { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7986_infracfg);
 
 static struct platform_driver clk_mt7986_infracfg_drv = {
-       .probe = clk_mt7986_infracfg_probe,
        .driver = {
                .name = "clk-mt7986-infracfg",
                .of_match_table = of_match_clk_mt7986_infracfg,
        },
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
 };
-builtin_platform_driver(clk_mt7986_infracfg_drv);
+module_platform_driver(clk_mt7986_infracfg_drv);
+
+MODULE_DESCRIPTION("MediaTek MT7986 infracfg clocks driver");
+MODULE_LICENSE("GPL");
index dff9976fa6890c8f0c9c2a2730030abfc64056a6..fbca3feded8f0f14bf246c1b05832a57f3d43690 100644 (file)
@@ -304,6 +304,7 @@ static const struct of_device_id of_match_clk_mt7986_topckgen[] = {
        { .compatible = "mediatek,mt7986-topckgen", .data = &topck_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt7986_topckgen);
 
 static struct platform_driver clk_mt7986_topckgen_drv = {
        .probe = mtk_clk_simple_probe,
@@ -313,4 +314,5 @@ static struct platform_driver clk_mt7986_topckgen_drv = {
                .of_match_table = of_match_clk_mt7986_topckgen,
        },
 };
-builtin_platform_driver(clk_mt7986_topckgen_drv);
+module_platform_driver(clk_mt7986_topckgen_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8135-apmixedsys.c b/drivers/clk/mediatek/clk-mt8135-apmixedsys.c
new file mode 100644 (file)
index 0000000..744aae0
--- /dev/null
@@ -0,0 +1,105 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ *               James Liao <jamesjj.liao@mediatek.com>
+ * Copyright (c) 2023 Collabora, Ltd.
+ *               AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+ */
+
+#include <dt-bindings/clock/mt8135-clk.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "clk-mtk.h"
+#include "clk-pll.h"
+
+#define MT8135_PLL_FMAX                (2000 * MHZ)
+#define CON0_MT8135_RST_BAR    BIT(27)
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift) { \
+               .id = _id,                                              \
+               .name = _name,                                          \
+               .reg = _reg,                                            \
+               .pwr_reg = _pwr_reg,                                    \
+               .en_mask = _en_mask,                                    \
+               .flags = _flags,                                        \
+               .rst_bar_mask = CON0_MT8135_RST_BAR,                    \
+               .fmax = MT8135_PLL_FMAX,                                \
+               .pcwbits = _pcwbits,                                    \
+               .pd_reg = _pd_reg,                                      \
+               .pd_shift = _pd_shift,                                  \
+               .tuner_reg = _tuner_reg,                                \
+               .pcw_reg = _pcw_reg,                                    \
+               .pcw_shift = _pcw_shift,                                \
+       }
+
+static const struct mtk_pll_data plls[] = {
+       PLL(CLK_APMIXED_ARMPLL1, "armpll1", 0x200, 0x218, 0x80000000, 0, 21, 0x204, 24, 0x0, 0x204, 0),
+       PLL(CLK_APMIXED_ARMPLL2, "armpll2", 0x2cc, 0x2e4, 0x80000000, 0, 21, 0x2d0, 24, 0x0, 0x2d0, 0),
+       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x21c, 0x234, 0xf0000000, HAVE_RST_BAR, 21, 0x21c, 6, 0x0, 0x220, 0),
+       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x238, 0x250, 0xf3000000, HAVE_RST_BAR, 7, 0x238, 6, 0x0, 0x238, 9),
+       PLL(CLK_APMIXED_MMPLL, "mmpll", 0x254, 0x26c, 0xf0000000, HAVE_RST_BAR, 21, 0x254, 6, 0x0, 0x258, 0),
+       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x278, 0x290, 0x80000000, 0, 21, 0x278, 6, 0x0, 0x27c, 0),
+       PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x294, 0x2ac, 0x80000000, 0, 31, 0x294, 6, 0x0, 0x298, 0),
+       PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2b0, 0x2c8, 0x80000000, 0, 21, 0x2b0, 6, 0x0, 0x2b4, 0),
+       PLL(CLK_APMIXED_AUDPLL, "audpll", 0x2e8, 0x300, 0x80000000, 0, 31, 0x2e8, 6, 0x2f8, 0x2ec, 0),
+       PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c, 0x80000000, 0, 21, 0x2b0, 6, 0x0, 0x308, 0),
+};
+
+static int clk_mt8135_apmixed_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       int ret;
+
+       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       if (ret)
+               return ret;
+
+       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (ret)
+               goto unregister_plls;
+
+       return 0;
+
+unregister_plls:
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+
+       return ret;
+}
+
+static int clk_mt8135_apmixed_remove(struct platform_device *pdev)
+{
+       struct device_node *node = pdev->dev.of_node;
+       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+       of_clk_del_provider(node);
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+       mtk_free_clk_data(clk_data);
+
+       return 0;
+}
+
+static const struct of_device_id of_match_clk_mt8135_apmixed[] = {
+       { .compatible = "mediatek,mt8135-apmixedsys" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8135_apmixed);
+
+static struct platform_driver clk_mt8135_apmixed_drv = {
+       .probe = clk_mt8135_apmixed_probe,
+       .remove = clk_mt8135_apmixed_remove,
+       .driver = {
+               .name = "clk-mt8135-apmixed",
+               .of_match_table = of_match_clk_mt8135_apmixed,
+       },
+};
+module_platform_driver(clk_mt8135_apmixed_drv)
+
+MODULE_DESCRIPTION("MediaTek MT8135 apmixedsys clocks driver");
+MODULE_LICENSE("GPL");
index 2b9c925c2a2bacde0fb9d449f9e6175af2c092d7..084e48a554c26297aad978359f6aab205f9ca2af 100644 (file)
@@ -5,8 +5,10 @@
  */
 
 #include <linux/clk.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/mfd/syscon.h>
 #include <dt-bindings/clock/mt8135-clk.h>
 
 static DEFINE_SPINLOCK(mt8135_clk_lock);
 
-static const struct mtk_fixed_factor root_clk_alias[] __initconst = {
+static const struct mtk_fixed_factor top_divs[] = {
+       FACTOR(CLK_DUMMY, "top_divs_dummy", "clk_null", 1, 1),
        FACTOR(CLK_TOP_DSI0_LNTC_DSICLK, "dsi0_lntc_dsiclk", "clk_null", 1, 1),
        FACTOR(CLK_TOP_HDMITX_CLKDIG_CTS, "hdmitx_clkdig_cts", "clk_null", 1, 1),
        FACTOR(CLK_TOP_CLKPH_MCK, "clkph_mck", "clk_null", 1, 1),
        FACTOR(CLK_TOP_CPUM_TCK_IN, "cpum_tck_in", "clk_null", 1, 1),
-};
 
-static const struct mtk_fixed_factor top_divs[] __initconst = {
        FACTOR(CLK_TOP_MAINPLL_806M, "mainpll_806m", "mainpll", 1, 2),
        FACTOR(CLK_TOP_MAINPLL_537P3M, "mainpll_537p3m", "mainpll", 1, 3),
        FACTOR(CLK_TOP_MAINPLL_322P4M, "mainpll_322p4m", "mainpll", 1, 5),
@@ -100,7 +101,7 @@ static const struct mtk_fixed_factor top_divs[] __initconst = {
        FACTOR(CLK_TOP_MEMPLL_MCK_D4, "mempll_mck_d4", "clkph_mck", 1, 4),
 };
 
-static const char * const axi_parents[] __initconst = {
+static const char * const axi_parents[] = {
        "clk26m",
        "syspll_d3",
        "syspll_d4",
@@ -110,7 +111,7 @@ static const char * const axi_parents[] __initconst = {
        "syspll_d3p5"
 };
 
-static const char * const smi_parents[] __initconst = {
+static const char * const smi_parents[] = {
        "clk26m",
        "clkph_mck",
        "syspll_d2p5",
@@ -128,7 +129,7 @@ static const char * const smi_parents[] __initconst = {
        "lvdspll"
 };
 
-static const char * const mfg_parents[] __initconst = {
+static const char * const mfg_parents[] = {
        "clk26m",
        "univpll1_d4",
        "syspll_d2",
@@ -144,13 +145,13 @@ static const char * const mfg_parents[] __initconst = {
        "mmpll_d7"
 };
 
-static const char * const irda_parents[] __initconst = {
+static const char * const irda_parents[] = {
        "clk26m",
        "univpll2_d8",
        "univpll1_d6"
 };
 
-static const char * const cam_parents[] __initconst = {
+static const char * const cam_parents[] = {
        "clk26m",
        "syspll_d3",
        "syspll_d3p5",
@@ -161,13 +162,13 @@ static const char * const cam_parents[] __initconst = {
        "univpll1_d4"
 };
 
-static const char * const aud_intbus_parents[] __initconst = {
+static const char * const aud_intbus_parents[] = {
        "clk26m",
        "syspll_d6",
        "univpll_d10"
 };
 
-static const char * const jpg_parents[] __initconst = {
+static const char * const jpg_parents[] = {
        "clk26m",
        "syspll_d5",
        "syspll_d4",
@@ -177,7 +178,7 @@ static const char * const jpg_parents[] __initconst = {
        "univpll_d5"
 };
 
-static const char * const disp_parents[] __initconst = {
+static const char * const disp_parents[] = {
        "clk26m",
        "syspll_d3p5",
        "syspll_d3",
@@ -188,7 +189,7 @@ static const char * const disp_parents[] __initconst = {
        "vdecpll"
 };
 
-static const char * const msdc30_parents[] __initconst = {
+static const char * const msdc30_parents[] = {
        "clk26m",
        "syspll_d6",
        "syspll_d5",
@@ -197,13 +198,13 @@ static const char * const msdc30_parents[] __initconst = {
        "msdcpll"
 };
 
-static const char * const usb20_parents[] __initconst = {
+static const char * const usb20_parents[] = {
        "clk26m",
        "univpll2_d6",
        "univpll1_d10"
 };
 
-static const char * const venc_parents[] __initconst = {
+static const char * const venc_parents[] = {
        "clk26m",
        "syspll_d3",
        "syspll_d8",
@@ -214,7 +215,7 @@ static const char * const venc_parents[] __initconst = {
        "mmpll_d6"
 };
 
-static const char * const spi_parents[] __initconst = {
+static const char * const spi_parents[] = {
        "clk26m",
        "syspll_d6",
        "syspll_d8",
@@ -223,17 +224,17 @@ static const char * const spi_parents[] __initconst = {
        "univpll1_d8"
 };
 
-static const char * const uart_parents[] __initconst = {
+static const char * const uart_parents[] = {
        "clk26m",
        "univpll2_d8"
 };
 
-static const char * const mem_parents[] __initconst = {
+static const char * const mem_parents[] = {
        "clk26m",
        "clkph_mck"
 };
 
-static const char * const camtg_parents[] __initconst = {
+static const char * const camtg_parents[] = {
        "clk26m",
        "univpll_d26",
        "univpll1_d6",
@@ -241,12 +242,12 @@ static const char * const camtg_parents[] __initconst = {
        "syspll_d8"
 };
 
-static const char * const audio_parents[] __initconst = {
+static const char * const audio_parents[] = {
        "clk26m",
        "syspll_d24"
 };
 
-static const char * const fix_parents[] __initconst = {
+static const char * const fix_parents[] = {
        "rtc32k",
        "clk26m",
        "univpll_d5",
@@ -257,7 +258,7 @@ static const char * const fix_parents[] __initconst = {
        "univpll1_d8"
 };
 
-static const char * const vdec_parents[] __initconst = {
+static const char * const vdec_parents[] = {
        "clk26m",
        "vdecpll",
        "clkph_mck",
@@ -276,13 +277,13 @@ static const char * const vdec_parents[] __initconst = {
        "lvdspll"
 };
 
-static const char * const ddrphycfg_parents[] __initconst = {
+static const char * const ddrphycfg_parents[] = {
        "clk26m",
        "axi_sel",
        "syspll_d12"
 };
 
-static const char * const dpilvds_parents[] __initconst = {
+static const char * const dpilvds_parents[] = {
        "clk26m",
        "lvdspll",
        "lvdspll_d2",
@@ -290,7 +291,7 @@ static const char * const dpilvds_parents[] __initconst = {
        "lvdspll_d8"
 };
 
-static const char * const pmicspi_parents[] __initconst = {
+static const char * const pmicspi_parents[] = {
        "clk26m",
        "univpll2_d6",
        "syspll_d8",
@@ -301,14 +302,14 @@ static const char * const pmicspi_parents[] __initconst = {
        "syspll_d24"
 };
 
-static const char * const smi_mfg_as_parents[] __initconst = {
+static const char * const smi_mfg_as_parents[] = {
        "clk26m",
        "smi_sel",
        "mfg_sel",
        "mem_sel"
 };
 
-static const char * const gcpu_parents[] __initconst = {
+static const char * const gcpu_parents[] = {
        "clk26m",
        "syspll_d4",
        "univpll_d7",
@@ -316,14 +317,14 @@ static const char * const gcpu_parents[] __initconst = {
        "syspll_d6"
 };
 
-static const char * const dpi1_parents[] __initconst = {
+static const char * const dpi1_parents[] = {
        "clk26m",
        "tvhdmi_h_ck",
        "tvhdmi_d2",
        "tvhdmi_d4"
 };
 
-static const char * const cci_parents[] __initconst = {
+static const char * const cci_parents[] = {
        "clk26m",
        "mainpll_537p3m",
        "univpll_d3",
@@ -332,7 +333,7 @@ static const char * const cci_parents[] __initconst = {
        "syspll_d5"
 };
 
-static const char * const apll_parents[] __initconst = {
+static const char * const apll_parents[] = {
        "clk26m",
        "apll_ck",
        "apll_d4",
@@ -341,14 +342,14 @@ static const char * const apll_parents[] __initconst = {
        "apll_d24"
 };
 
-static const char * const hdmipll_parents[] __initconst = {
+static const char * const hdmipll_parents[] = {
        "clk26m",
        "hdmitx_clkdig_cts",
        "hdmitx_clkdig_d2",
        "hdmitx_clkdig_d3"
 };
 
-static const struct mtk_composite top_muxes[] __initconst = {
+static const struct mtk_composite top_muxes[] = {
        /* CLK_CFG_0 */
        MUX_GATE(CLK_TOP_AXI_SEL, "axi_sel", axi_parents,
                0x0140, 0, 3, INVALID_MUX_GATE_BIT),
@@ -390,7 +391,7 @@ static const struct mtk_composite top_muxes[] __initconst = {
        MUX_GATE(CLK_TOP_GCPU_SEL, "gcpu_sel", gcpu_parents, 0x0164, 24, 3, 31),
        /* CLK_CFG_9 */
        MUX_GATE(CLK_TOP_DPI1_SEL, "dpi1_sel", dpi1_parents, 0x0168, 0, 2, 7),
-       MUX_GATE(CLK_TOP_CCI_SEL, "cci_sel", cci_parents, 0x0168, 8, 3, 15),
+       MUX_GATE_FLAGS(CLK_TOP_CCI_SEL, "cci_sel", cci_parents, 0x0168, 8, 3, 15, CLK_IS_CRITICAL),
        MUX_GATE(CLK_TOP_APLL_SEL, "apll_sel", apll_parents, 0x0168, 16, 3, 23),
        MUX_GATE(CLK_TOP_HDMIPLL_SEL, "hdmipll_sel", hdmipll_parents, 0x0168, 24, 2, 31),
 };
@@ -401,23 +402,22 @@ static const struct mtk_gate_regs infra_cg_regs = {
        .sta_ofs = 0x0048,
 };
 
-#define GATE_ICG(_id, _name, _parent, _shift) {        \
-               .id = _id,                                      \
-               .name = _name,                                  \
-               .parent_name = _parent,                         \
-               .regs = &infra_cg_regs,                         \
-               .shift = _shift,                                \
-               .ops = &mtk_clk_gate_ops_setclr,                \
-       }
+#define GATE_ICG(_id, _name, _parent, _shift)  \
+       GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_ICG_AO(_id, _name, _parent, _shift)       \
+       GATE_MTK_FLAGS(_id, _name, _parent, &infra_cg_regs, _shift,     \
+                      &mtk_clk_gate_ops_setclr, CLK_IS_CRITICAL)
 
-static const struct mtk_gate infra_clks[] __initconst = {
+static const struct mtk_gate infra_clks[] = {
+       GATE_DUMMY(CLK_DUMMY, "infra_dummy"),
        GATE_ICG(CLK_INFRA_PMIC_WRAP, "pmic_wrap_ck", "axi_sel", 23),
        GATE_ICG(CLK_INFRA_PMICSPI, "pmicspi_ck", "pmicspi_sel", 22),
        GATE_ICG(CLK_INFRA_CCIF1_AP_CTRL, "ccif1_ap_ctrl", "axi_sel", 21),
        GATE_ICG(CLK_INFRA_CCIF0_AP_CTRL, "ccif0_ap_ctrl", "axi_sel", 20),
        GATE_ICG(CLK_INFRA_KP, "kp_ck", "axi_sel", 16),
        GATE_ICG(CLK_INFRA_CPUM, "cpum_ck", "cpum_tck_in", 15),
-       GATE_ICG(CLK_INFRA_M4U, "m4u_ck", "mem_sel", 8),
+       GATE_ICG_AO(CLK_INFRA_M4U, "m4u_ck", "mem_sel", 8),
        GATE_ICG(CLK_INFRA_MFGAXI, "mfgaxi_ck", "axi_sel", 7),
        GATE_ICG(CLK_INFRA_DEVAPC, "devapc_ck", "axi_sel", 6),
        GATE_ICG(CLK_INFRA_AUDIO, "audio_ck", "aud_intbus_sel", 5),
@@ -438,25 +438,14 @@ static const struct mtk_gate_regs peri1_cg_regs = {
        .sta_ofs = 0x001c,
 };
 
-#define GATE_PERI0(_id, _name, _parent, _shift) {      \
-               .id = _id,                                      \
-               .name = _name,                                  \
-               .parent_name = _parent,                         \
-               .regs = &peri0_cg_regs,                         \
-               .shift = _shift,                                \
-               .ops = &mtk_clk_gate_ops_setclr,                \
-       }
+#define GATE_PERI0(_id, _name, _parent, _shift)        \
+       GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_PERI1(_id, _name, _parent, _shift) {      \
-               .id = _id,                                      \
-               .name = _name,                                  \
-               .parent_name = _parent,                         \
-               .regs = &peri1_cg_regs,                         \
-               .shift = _shift,                                \
-               .ops = &mtk_clk_gate_ops_setclr,                \
-       }
+#define GATE_PERI1(_id, _name, _parent, _shift)        \
+       GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-static const struct mtk_gate peri_gates[] __initconst = {
+static const struct mtk_gate peri_gates[] = {
+       GATE_DUMMY(CLK_DUMMY, "peri_dummy"),
        /* PERI0 */
        GATE_PERI0(CLK_PERI_I2C5, "i2c5_ck", "axi_sel", 31),
        GATE_PERI0(CLK_PERI_I2C4, "i2c4_ck", "axi_sel", 30),
@@ -502,12 +491,12 @@ static const struct mtk_gate peri_gates[] __initconst = {
        GATE_PERI1(CLK_PERI_I2C6, "i2c6_ck", "axi_sel", 0),
 };
 
-static const char * const uart_ck_sel_parents[] __initconst = {
+static const char * const uart_ck_sel_parents[] = {
        "clk26m",
        "uart_sel",
 };
 
-static const struct mtk_composite peri_clks[] __initconst = {
+static const struct mtk_composite peri_clks[] = {
        MUX(CLK_PERI_UART0_SEL, "uart0_ck_sel", uart_ck_sel_parents, 0x40c, 0, 1),
        MUX(CLK_PERI_UART1_SEL, "uart1_ck_sel", uart_ck_sel_parents, 0x40c, 1, 1),
        MUX(CLK_PERI_UART2_SEL, "uart2_ck_sel", uart_ck_sel_parents, 0x40c, 2, 1),
@@ -532,127 +521,46 @@ static const struct mtk_clk_rst_desc clk_rst_desc[] = {
        }
 };
 
-static void __init mtk_topckgen_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       void __iomem *base;
-       int r;
-
-       base = of_iomap(node, 0);
-       if (!base) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return;
-       }
-
-       clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
-
-       mtk_clk_register_factors(root_clk_alias, ARRAY_SIZE(root_clk_alias), clk_data);
-       mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
-       mtk_clk_register_composites(NULL, top_muxes,
-                                   ARRAY_SIZE(top_muxes), base,
-                                   &mt8135_clk_lock, clk_data);
-
-       clk_prepare_enable(clk_data->hws[CLK_TOP_CCI_SEL]->clk);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
-}
-CLK_OF_DECLARE(mtk_topckgen, "mediatek,mt8135-topckgen", mtk_topckgen_init);
-
-static void __init mtk_infrasys_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
-
-       mtk_clk_register_gates(NULL, node, infra_clks,
-                              ARRAY_SIZE(infra_clks), clk_data);
-
-       clk_prepare_enable(clk_data->hws[CLK_INFRA_M4U]->clk);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
+static const struct mtk_clk_desc infra_desc = {
+       .clks = infra_clks,
+       .num_clks = ARRAY_SIZE(infra_clks),
+       .rst_desc = &clk_rst_desc[0],
+};
 
-       mtk_register_reset_controller(node, &clk_rst_desc[0]);
-}
-CLK_OF_DECLARE(mtk_infrasys, "mediatek,mt8135-infracfg", mtk_infrasys_init);
+static const struct mtk_clk_desc peri_desc = {
+       .clks = peri_gates,
+       .num_clks = ARRAY_SIZE(peri_gates),
+       .composite_clks = peri_clks,
+       .num_composite_clks = ARRAY_SIZE(peri_clks),
+       .clk_lock = &mt8135_clk_lock,
+       .rst_desc = &clk_rst_desc[1],
+};
 
-static void __init mtk_pericfg_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-       void __iomem *base;
+static const struct mtk_clk_desc topck_desc = {
+       .factor_clks = top_divs,
+       .num_factor_clks = ARRAY_SIZE(top_divs),
+       .composite_clks = top_muxes,
+       .num_composite_clks = ARRAY_SIZE(top_muxes),
+       .clk_lock = &mt8135_clk_lock,
+};
 
-       base = of_iomap(node, 0);
-       if (!base) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return;
-       }
+static const struct of_device_id of_match_clk_mt8135[] = {
+       { .compatible = "mediatek,mt8135-infracfg", .data = &infra_desc },
+       { .compatible = "mediatek,mt8135-pericfg", .data = &peri_desc },
+       { .compatible = "mediatek,mt8135-topckgen", .data = &topck_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8135);
 
-       clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
-
-       mtk_clk_register_gates(NULL, node, peri_gates,
-                              ARRAY_SIZE(peri_gates), clk_data);
-       mtk_clk_register_composites(NULL, peri_clks,
-                                   ARRAY_SIZE(peri_clks), base,
-                                   &mt8135_clk_lock, clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
-
-       mtk_register_reset_controller(node, &clk_rst_desc[1]);
-}
-CLK_OF_DECLARE(mtk_pericfg, "mediatek,mt8135-pericfg", mtk_pericfg_init);
-
-#define MT8135_PLL_FMAX                (2000 * MHZ)
-#define CON0_MT8135_RST_BAR    BIT(27)
-
-#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift) { \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .reg = _reg,                                            \
-               .pwr_reg = _pwr_reg,                                    \
-               .en_mask = _en_mask,                                    \
-               .flags = _flags,                                        \
-               .rst_bar_mask = CON0_MT8135_RST_BAR,                    \
-               .fmax = MT8135_PLL_FMAX,                                \
-               .pcwbits = _pcwbits,                                    \
-               .pd_reg = _pd_reg,                                      \
-               .pd_shift = _pd_shift,                                  \
-               .tuner_reg = _tuner_reg,                                \
-               .pcw_reg = _pcw_reg,                                    \
-               .pcw_shift = _pcw_shift,                                \
-       }
+static struct platform_driver clk_mt8135_drv = {
+       .driver = {
+               .name = "clk-mt8135",
+               .of_match_table = of_match_clk_mt8135,
+       },
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+};
+module_platform_driver(clk_mt8135_drv);
 
-static const struct mtk_pll_data plls[] = {
-       PLL(CLK_APMIXED_ARMPLL1, "armpll1", 0x200, 0x218, 0x80000000, 0, 21, 0x204, 24, 0x0, 0x204, 0),
-       PLL(CLK_APMIXED_ARMPLL2, "armpll2", 0x2cc, 0x2e4, 0x80000000, 0, 21, 0x2d0, 24, 0x0, 0x2d0, 0),
-       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x21c, 0x234, 0xf0000000, HAVE_RST_BAR, 21, 0x21c, 6, 0x0, 0x220, 0),
-       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x238, 0x250, 0xf3000000, HAVE_RST_BAR, 7, 0x238, 6, 0x0, 0x238, 9),
-       PLL(CLK_APMIXED_MMPLL, "mmpll", 0x254, 0x26c, 0xf0000000, HAVE_RST_BAR, 21, 0x254, 6, 0x0, 0x258, 0),
-       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x278, 0x290, 0x80000000, 0, 21, 0x278, 6, 0x0, 0x27c, 0),
-       PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x294, 0x2ac, 0x80000000, 0, 31, 0x294, 6, 0x0, 0x298, 0),
-       PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2b0, 0x2c8, 0x80000000, 0, 21, 0x2b0, 6, 0x0, 0x2b4, 0),
-       PLL(CLK_APMIXED_AUDPLL, "audpll", 0x2e8, 0x300, 0x80000000, 0, 31, 0x2e8, 6, 0x2f8, 0x2ec, 0),
-       PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c, 0x80000000, 0, 21, 0x2b0, 6, 0x0, 0x308, 0),
-};
-
-static void __init mtk_apmixedsys_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-
-       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
-       if (!clk_data)
-               return;
-
-       mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
-}
-CLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8135-apmixedsys",
-               mtk_apmixedsys_init);
+MODULE_DESCRIPTION("MediaTek MT8135 clocks driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8167-apmixedsys.c b/drivers/clk/mediatek/clk-mt8167-apmixedsys.c
new file mode 100644 (file)
index 0000000..fca41f5
--- /dev/null
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2020 MediaTek Inc.
+ * Copyright (c) 2020 BayLibre, SAS
+ * Copyright (c) 2023 Collabora, Ltd.
+ */
+
+#include <dt-bindings/clock/mt8167-clk.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "clk-pll.h"
+#include "clk-mtk.h"
+
+static DEFINE_SPINLOCK(mt8167_apmixed_clk_lock);
+
+#define MT8167_PLL_FMAX                (2500UL * MHZ)
+
+#define CON0_MT8167_RST_BAR    BIT(27)
+
+#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,  \
+                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
+                       _pcw_shift, _div_table) {                       \
+               .id = _id,                                              \
+               .name = _name,                                          \
+               .reg = _reg,                                            \
+               .pwr_reg = _pwr_reg,                                    \
+               .en_mask = _en_mask,                                    \
+               .flags = _flags,                                        \
+               .rst_bar_mask = CON0_MT8167_RST_BAR,                    \
+               .fmax = MT8167_PLL_FMAX,                                \
+               .pcwbits = _pcwbits,                                    \
+               .pd_reg = _pd_reg,                                      \
+               .pd_shift = _pd_shift,                                  \
+               .tuner_reg = _tuner_reg,                                \
+               .pcw_reg = _pcw_reg,                                    \
+               .pcw_shift = _pcw_shift,                                \
+               .div_table = _div_table,                                \
+       }
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,    \
+                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
+                       _pcw_shift)                                     \
+               PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \
+                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \
+                       NULL)
+
+static const struct mtk_pll_div_table mmpll_div_table[] = {
+       { .div = 0, .freq = MT8167_PLL_FMAX },
+       { .div = 1, .freq = 1000000000 },
+       { .div = 2, .freq = 604500000 },
+       { .div = 3, .freq = 253500000 },
+       { .div = 4, .freq = 126750000 },
+       { /* sentinel */ }
+};
+
+static const struct mtk_pll_data plls[] = {
+       PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0,
+           21, 0x0104, 24, 0, 0x0104, 0),
+       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0,
+           HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0),
+       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x30000000,
+           HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0),
+       PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0,
+             21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table),
+       PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0,
+           31, 0x0180, 1, 0x0194, 0x0184, 0),
+       PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0,
+           31, 0x01A0, 1, 0x01B4, 0x01A4, 0),
+       PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x01C0, 0x01D0, 0, 0,
+           21, 0x01C4, 24, 0, 0x01C4, 0),
+       PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x01E0, 0x01F0, 0, 0,
+           21, 0x01E4, 24, 0, 0x01E4, 0),
+};
+
+#define DIV_ADJ_FLAG(_id, _name, _parent, _reg, _shift, _width, _flag) { \
+               .id = _id,                                      \
+               .name = _name,                                  \
+               .parent_name = _parent,                         \
+               .div_reg = _reg,                                \
+               .div_shift = _shift,                            \
+               .div_width = _width,                            \
+               .clk_divider_flags = _flag,                     \
+}
+
+static const struct mtk_clk_divider adj_divs[] = {
+       DIV_ADJ_FLAG(CLK_APMIXED_HDMI_REF, "hdmi_ref", "tvdpll",
+                    0x1c4, 24, 3, CLK_DIVIDER_POWER_OF_TWO),
+};
+
+static int clk_mt8167_apmixed_probe(struct platform_device *pdev)
+{
+       void __iomem *base;
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       struct device *dev = &pdev->dev;
+       int ret;
+
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       clk_data = mtk_devm_alloc_clk_data(dev, MT8167_CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       if (ret)
+               return ret;
+
+       ret = mtk_clk_register_dividers(dev, adj_divs, ARRAY_SIZE(adj_divs), base,
+                                       &mt8167_apmixed_clk_lock, clk_data);
+       if (ret)
+               goto unregister_plls;
+
+       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (ret)
+               goto unregister_dividers;
+
+       return 0;
+
+unregister_dividers:
+       mtk_clk_unregister_dividers(adj_divs, ARRAY_SIZE(adj_divs), clk_data);
+unregister_plls:
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+
+       return ret;
+}
+
+static const struct of_device_id of_match_clk_mt8167_apmixed[] = {
+       { .compatible = "mediatek,mt8167-apmixedsys" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_apmixed);
+
+static struct platform_driver clk_mt8167_apmixed_drv = {
+       .probe = clk_mt8167_apmixed_probe,
+       .driver = {
+               .name = "clk-mt8167-apmixed",
+               .of_match_table = of_match_clk_mt8167_apmixed,
+       },
+};
+builtin_platform_driver(clk_mt8167_apmixed_drv)
+MODULE_LICENSE("GPL");
index f6bea6e9e6a4ef8ccde9e2a9ee9dc5a0c325f2b6..86125635c8a6415d6ba5891bf2121aae95211efd 100644 (file)
@@ -23,16 +23,11 @@ static const struct mtk_gate_regs aud_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_AUD(_id, _name, _parent, _shift) {        \
-               .id = _id,                      \
-               .name = _name,                  \
-               .parent_name = _parent,         \
-               .regs = &aud_cg_regs,           \
-               .shift = _shift,                \
-               .ops = &mtk_clk_gate_ops_no_setclr,             \
-       }
+#define GATE_AUD(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &aud_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-static const struct mtk_gate aud_clks[] __initconst = {
+
+static const struct mtk_gate aud_clks[] = {
        GATE_AUD(CLK_AUD_AFE, "aud_afe", "clk26m_ck", 2),
        GATE_AUD(CLK_AUD_I2S, "aud_i2s", "i2s_infra_bck", 6),
        GATE_AUD(CLK_AUD_22M, "aud_22m", "rg_aud_engen1", 8),
@@ -48,19 +43,24 @@ static const struct mtk_gate aud_clks[] __initconst = {
        GATE_AUD(CLK_AUD_TML, "aud_tml", "aud_afe", 27),
 };
 
-static void __init mtk_audsys_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_AUD_NR_CLK);
-
-       mtk_clk_register_gates(NULL, node, aud_clks, ARRAY_SIZE(aud_clks), clk_data);
+static const struct mtk_clk_desc aud_desc = {
+       .clks = aud_clks,
+       .num_clks = ARRAY_SIZE(aud_clks),
+};
 
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
+static const struct of_device_id of_match_clk_mt8167_audsys[] = {
+       { .compatible = "mediatek,mt8167-audsys", .data = &aud_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_audsys);
 
-}
-CLK_OF_DECLARE(mtk_audsys, "mediatek,mt8167-audsys", mtk_audsys_init);
+static struct platform_driver clk_mt8167_audsys_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8167-audsys",
+               .of_match_table = of_match_clk_mt8167_audsys,
+       },
+};
+module_platform_driver(clk_mt8167_audsys_drv);
+MODULE_LICENSE("GPL");
index 77db13b177fcc1085949f61d8cd9a71caf1c6c33..315b7f64bad6d3f14482be088f8a8b52df7c490d 100644 (file)
@@ -23,16 +23,10 @@ static const struct mtk_gate_regs img_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_IMG(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &img_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-static const struct mtk_gate img_clks[] __initconst = {
+#define GATE_IMG(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate img_clks[] = {
        GATE_IMG(CLK_IMG_LARB1_SMI, "img_larb1_smi", "smi_mm", 0),
        GATE_IMG(CLK_IMG_CAM_SMI, "img_cam_smi", "smi_mm", 5),
        GATE_IMG(CLK_IMG_CAM_CAM, "img_cam_cam", "smi_mm", 6),
@@ -41,20 +35,24 @@ static const struct mtk_gate img_clks[] __initconst = {
        GATE_IMG(CLK_IMG_VENC, "img_venc", "smi_mm", 9),
 };
 
-static void __init mtk_imgsys_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK);
-
-       mtk_clk_register_gates(NULL, node, img_clks, ARRAY_SIZE(img_clks), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
+static const struct mtk_clk_desc img_desc = {
+       .clks = img_clks,
+       .num_clks = ARRAY_SIZE(img_clks),
+};
 
-}
-CLK_OF_DECLARE(mtk_imgsys, "mediatek,mt8167-imgsys", mtk_imgsys_init);
+static const struct of_device_id of_match_clk_mt8167_imgsys[] = {
+       { .compatible = "mediatek,mt8167-imgsys", .data = &img_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_imgsys);
+
+static struct platform_driver clk_mt8167_imgsys_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8167-imgsys",
+               .of_match_table = of_match_clk_mt8167_imgsys,
+       },
+};
+module_platform_driver(clk_mt8167_imgsys_drv);
+MODULE_LICENSE("GPL");
index 3c23591b02f7f2846e0d572a5babcd63cd667f60..4851f5bf3a9017f634796c41e69647c1204d5037 100644 (file)
@@ -23,36 +23,34 @@ static const struct mtk_gate_regs mfg_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_MFG(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &mfg_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-static const struct mtk_gate mfg_clks[] __initconst = {
+#define GATE_MFG(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &mfg_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate mfg_clks[] = {
        GATE_MFG(CLK_MFG_BAXI, "mfg_baxi", "ahb_infra_sel", 0),
        GATE_MFG(CLK_MFG_BMEM, "mfg_bmem", "gfmux_emi1x_sel", 1),
        GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_mm", 2),
        GATE_MFG(CLK_MFG_B26M, "mfg_b26m", "clk26m_ck", 3),
 };
 
-static void __init mtk_mfgcfg_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_MFG_NR_CLK);
-
-       mtk_clk_register_gates(NULL, node, mfg_clks, ARRAY_SIZE(mfg_clks), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
+static const struct mtk_clk_desc mfg_desc = {
+       .clks = mfg_clks,
+       .num_clks = ARRAY_SIZE(mfg_clks),
+};
 
-}
-CLK_OF_DECLARE(mtk_mfgcfg, "mediatek,mt8167-mfgcfg", mtk_mfgcfg_init);
+static const struct of_device_id of_match_clk_mt8167_mfgcfg[] = {
+       { .compatible = "mediatek,mt8167-mfgcfg", .data = &mfg_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_mfgcfg);
+
+static struct platform_driver clk_mt8167_mfgcfg_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8167-mfgcfg",
+               .of_match_table = of_match_clk_mt8167_mfgcfg,
+       },
+};
+module_platform_driver(clk_mt8167_mfgcfg_drv);
+MODULE_LICENSE("GPL");
index c0b44104c765adab50b59c62aac15ff371c9d5d2..4e053c61315dab2f7a249245216c76d1c0fa7c8e 100644 (file)
@@ -29,23 +29,11 @@ static const struct mtk_gate_regs mm1_cg_regs = {
        .sta_ofs = 0x110,
 };
 
-#define GATE_MM0(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &mm0_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_MM0(_id, _name, _parent, _shift)  \
+       GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_MM1(_id, _name, _parent, _shift) {                \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &mm1_cg_regs,                   \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_MM1(_id, _name, _parent, _shift)  \
+       GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate mm_clks[] = {
        /* MM0 */
@@ -86,47 +74,24 @@ static const struct mtk_gate mm_clks[] = {
        GATE_MM1(CLK_MM_HDMI_PLL, "mm_hdmi_pll", "hdmtx_dig_cts", 21),
 };
 
-struct clk_mt8167_mm_driver_data {
-       const struct mtk_gate *gates_clk;
-       int gates_num;
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mm_clks,
+       .num_clks = ARRAY_SIZE(mm_clks),
 };
 
-static const struct clk_mt8167_mm_driver_data mt8167_mmsys_driver_data = {
-       .gates_clk = mm_clks,
-       .gates_num = ARRAY_SIZE(mm_clks),
+static const struct platform_device_id clk_mt8167_mm_id_table[] = {
+       { .name = "clk-mt8167-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(platform, clk_mt8167_mm_id_table);
 
-static int clk_mt8167_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       const struct clk_mt8167_mm_driver_data *data;
-       struct clk_hw_onecell_data *clk_data;
-       int ret;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       data = &mt8167_mmsys_driver_data;
-
-       ret = mtk_clk_register_gates(&pdev->dev, node, data->gates_clk,
-                                    data->gates_num, clk_data);
-       if (ret)
-               return ret;
-
-       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (ret)
-               return ret;
-
-       return 0;
-}
-
-static struct platform_driver clk_mt8173_mm_drv = {
+static struct platform_driver clk_mt8167_mm_drv = {
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt8167-mm",
        },
-       .probe = clk_mt8167_mm_probe,
+       .id_table = clk_mt8167_mm_id_table,
 };
-
-builtin_platform_driver(clk_mt8173_mm_drv);
+module_platform_driver(clk_mt8167_mm_drv);
+MODULE_LICENSE("GPL");
index 759e5791599f032b80e5a30f9c1473b1e88d8766..76900f393d31dda173b1c2813fcabe03fc5e15aa 100644 (file)
@@ -29,46 +29,37 @@ static const struct mtk_gate_regs vdec1_cg_regs = {
        .sta_ofs = 0x8,
 };
 
-#define GATE_VDEC0_I(_id, _name, _parent, _shift) {    \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &vdec0_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_VDEC0_I(_id, _name, _parent, _shift)                      \
+       GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
-#define GATE_VDEC1_I(_id, _name, _parent, _shift) {    \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &vdec1_cg_regs,                 \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
+#define GATE_VDEC1_I(_id, _name, _parent, _shift)                      \
+       GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
 
-static const struct mtk_gate vdec_clks[] __initconst = {
+static const struct mtk_gate vdec_clks[] = {
        /* VDEC0 */
        GATE_VDEC0_I(CLK_VDEC_CKEN, "vdec_cken", "rg_vdec", 0),
        /* VDEC1 */
        GATE_VDEC1_I(CLK_VDEC_LARB1_CKEN, "vdec_larb1_cken", "smi_mm", 0),
 };
 
-static void __init mtk_vdecsys_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_VDEC_NR_CLK);
-
-       mtk_clk_register_gates(NULL, node, vdec_clks, ARRAY_SIZE(vdec_clks),
-                              clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+static const struct mtk_clk_desc vdec_desc = {
+       .clks = vdec_clks,
+       .num_clks = ARRAY_SIZE(vdec_clks),
+};
 
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
+static const struct of_device_id of_match_clk_mt8167_vdec[] = {
+       { .compatible = "mediatek,mt8167-vdecsys", .data = &vdec_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_vdec);
 
-}
-CLK_OF_DECLARE(mtk_vdecsys, "mediatek,mt8167-vdecsys", mtk_vdecsys_init);
+static struct platform_driver clk_mt8167_vdec_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8167-vdecsys",
+               .of_match_table = of_match_clk_mt8167_vdec,
+       },
+};
+module_platform_driver(clk_mt8167_vdec_drv);
+MODULE_LICENSE("GPL");
index 91669ebafaf9bc5b08fe221dba27f19066ab20ae..b9041f79cbbdf996d8d45eb8b7b80252402479ac 100644 (file)
 #include <linux/of_address.h>
 #include <linux/slab.h>
 #include <linux/mfd/syscon.h>
+#include <linux/platform_device.h>
 
 #include "clk-gate.h"
 #include "clk-mtk.h"
-#include "clk-pll.h"
 
 #include <dt-bindings/clock/mt8167-clk.h>
 
 static DEFINE_SPINLOCK(mt8167_clk_lock);
 
-static const struct mtk_fixed_clk fixed_clks[] __initconst = {
+static const struct mtk_fixed_clk fixed_clks[] = {
        FIXED_CLK(CLK_TOP_CLK_NULL, "clk_null", NULL, 0),
        FIXED_CLK(CLK_TOP_I2S_INFRA_BCK, "i2s_infra_bck", "clk_null", 26000000),
        FIXED_CLK(CLK_TOP_MEMPLL, "mempll", "clk26m", 800000000),
@@ -29,7 +29,7 @@ static const struct mtk_fixed_clk fixed_clks[] __initconst = {
        FIXED_CLK(CLK_TOP_LVDSTX_CLKDIG_CTS, "lvdstx_dig_cts", "clk26m", 52500000),
 };
 
-static const struct mtk_fixed_factor top_divs[] __initconst = {
+static const struct mtk_fixed_factor top_divs[] = {
        FACTOR(CLK_TOP_DMPLL, "dmpll_ck", "mempll", 1, 1),
        FACTOR(CLK_TOP_MAINPLL_D2, "mainpll_d2", "mainpll", 1, 2),
        FACTOR(CLK_TOP_MAINPLL_D4, "mainpll_d4", "mainpll", 1, 4),
@@ -85,22 +85,22 @@ static const struct mtk_fixed_factor top_divs[] __initconst = {
        FACTOR(CLK_TOP_ETH_D2, "eth_d2_ck", "eth_sel", 1, 2),
 };
 
-static const char * const uart0_parents[] __initconst = {
+static const char * const uart0_parents[] = {
        "clk26m_ck",
        "univpll_d24"
 };
 
-static const char * const gfmux_emi1x_parents[] __initconst = {
+static const char * const gfmux_emi1x_parents[] = {
        "clk26m_ck",
        "dmpll_ck"
 };
 
-static const char * const emi_ddrphy_parents[] __initconst = {
+static const char * const emi_ddrphy_parents[] = {
        "gfmux_emi1x_sel",
        "gfmux_emi1x_sel"
 };
 
-static const char * const ahb_infra_parents[] __initconst = {
+static const char * const ahb_infra_parents[] = {
        "clk_null",
        "clk26m_ck",
        "mainpll_d11",
@@ -116,7 +116,7 @@ static const char * const ahb_infra_parents[] __initconst = {
        "mainpll_d10"
 };
 
-static const char * const csw_mux_mfg_parents[] __initconst = {
+static const char * const csw_mux_mfg_parents[] = {
        "clk_null",
        "clk_null",
        "univpll_d3",
@@ -127,7 +127,7 @@ static const char * const csw_mux_mfg_parents[] __initconst = {
        "mmpll380m"
 };
 
-static const char * const msdc0_parents[] __initconst = {
+static const char * const msdc0_parents[] = {
        "clk26m_ck",
        "univpll_d6",
        "mainpll_d8",
@@ -138,7 +138,7 @@ static const char * const msdc0_parents[] __initconst = {
        "mmpll_d2"
 };
 
-static const char * const camtg_mm_parents[] __initconst = {
+static const char * const camtg_mm_parents[] = {
        "clk_null",
        "clk26m_ck",
        "usb_phy48m_ck",
@@ -146,17 +146,17 @@ static const char * const camtg_mm_parents[] __initconst = {
        "univpll_d6"
 };
 
-static const char * const pwm_mm_parents[] __initconst = {
+static const char * const pwm_mm_parents[] = {
        "clk26m_ck",
        "univpll_d12"
 };
 
-static const char * const uart1_parents[] __initconst = {
+static const char * const uart1_parents[] = {
        "clk26m_ck",
        "univpll_d24"
 };
 
-static const char * const msdc1_parents[] __initconst = {
+static const char * const msdc1_parents[] = {
        "clk26m_ck",
        "univpll_d6",
        "mainpll_d8",
@@ -167,24 +167,24 @@ static const char * const msdc1_parents[] __initconst = {
        "mmpll_d2"
 };
 
-static const char * const spm_52m_parents[] __initconst = {
+static const char * const spm_52m_parents[] = {
        "clk26m_ck",
        "univpll_d24"
 };
 
-static const char * const pmicspi_parents[] __initconst = {
+static const char * const pmicspi_parents[] = {
        "univpll_d20",
        "usb_phy48m_ck",
        "univpll_d16",
        "clk26m_ck"
 };
 
-static const char * const qaxi_aud26m_parents[] __initconst = {
+static const char * const qaxi_aud26m_parents[] = {
        "clk26m_ck",
        "ahb_infra_sel"
 };
 
-static const char * const aud_intbus_parents[] __initconst = {
+static const char * const aud_intbus_parents[] = {
        "clk_null",
        "clk26m_ck",
        "mainpll_d22",
@@ -192,7 +192,7 @@ static const char * const aud_intbus_parents[] __initconst = {
        "mainpll_d11"
 };
 
-static const char * const nfi2x_pad_parents[] __initconst = {
+static const char * const nfi2x_pad_parents[] = {
        "clk_null",
        "clk_null",
        "clk_null",
@@ -280,12 +280,12 @@ static const char * const nfi2x_pad_parents[] __initconst = {
        "mainpll_d5"
 };
 
-static const char * const nfi1x_pad_parents[] __initconst = {
+static const char * const nfi1x_pad_parents[] = {
        "ahb_infra_sel",
        "nfi1x_ck"
 };
 
-static const char * const mfg_mm_parents[] __initconst = {
+static const char * const mfg_mm_parents[] = {
        "clk_null",
        "clk_null",
        "clk_null",
@@ -325,12 +325,12 @@ static const char * const mfg_mm_parents[] __initconst = {
        "mainpll_d14"
 };
 
-static const char * const ddrphycfg_parents[] __initconst = {
+static const char * const ddrphycfg_parents[] = {
        "clk26m_ck",
        "mainpll_d16"
 };
 
-static const char * const smi_mm_parents[] __initconst = {
+static const char * const smi_mm_parents[] = {
        "clk26m_ck",
        "clk_null",
        "clk_null",
@@ -346,7 +346,7 @@ static const char * const smi_mm_parents[] __initconst = {
        "mainpll_d14"
 };
 
-static const char * const usb_78m_parents[] __initconst = {
+static const char * const usb_78m_parents[] = {
        "clk_null",
        "clk26m_ck",
        "univpll_d16",
@@ -354,7 +354,7 @@ static const char * const usb_78m_parents[] __initconst = {
        "mainpll_d20"
 };
 
-static const char * const scam_mm_parents[] __initconst = {
+static const char * const scam_mm_parents[] = {
        "clk_null",
        "clk26m_ck",
        "mainpll_d14",
@@ -362,7 +362,7 @@ static const char * const scam_mm_parents[] __initconst = {
        "mainpll_d12"
 };
 
-static const char * const spinor_parents[] __initconst = {
+static const char * const spinor_parents[] = {
        "clk26m_d2",
        "clk26m_ck",
        "mainpll_d40",
@@ -373,7 +373,7 @@ static const char * const spinor_parents[] __initconst = {
        "univpll_d12"
 };
 
-static const char * const msdc2_parents[] __initconst = {
+static const char * const msdc2_parents[] = {
        "clk26m_ck",
        "univpll_d6",
        "mainpll_d8",
@@ -384,7 +384,7 @@ static const char * const msdc2_parents[] __initconst = {
        "mmpll_d2"
 };
 
-static const char * const eth_parents[] __initconst = {
+static const char * const eth_parents[] = {
        "clk26m_ck",
        "mainpll_d40",
        "univpll_d24",
@@ -392,7 +392,7 @@ static const char * const eth_parents[] __initconst = {
        "mainpll_d20"
 };
 
-static const char * const vdec_mm_parents[] __initconst = {
+static const char * const vdec_mm_parents[] = {
        "clk26m_ck",
        "univpll_d4",
        "mainpll_d4",
@@ -401,7 +401,7 @@ static const char * const vdec_mm_parents[] __initconst = {
        "mainpll_d6"
 };
 
-static const char * const dpi0_mm_parents[] __initconst = {
+static const char * const dpi0_mm_parents[] = {
        "clk26m_ck",
        "lvdspll_ck",
        "lvdspll_d2",
@@ -409,7 +409,7 @@ static const char * const dpi0_mm_parents[] __initconst = {
        "lvdspll_d8"
 };
 
-static const char * const dpi1_mm_parents[] __initconst = {
+static const char * const dpi1_mm_parents[] = {
        "clk26m_ck",
        "tvdpll_d2",
        "tvdpll_d4",
@@ -417,85 +417,85 @@ static const char * const dpi1_mm_parents[] __initconst = {
        "tvdpll_d16"
 };
 
-static const char * const axi_mfg_in_parents[] __initconst = {
+static const char * const axi_mfg_in_parents[] = {
        "clk26m_ck",
        "mainpll_d11",
        "univpll_d24",
        "mmpll380m"
 };
 
-static const char * const slow_mfg_parents[] __initconst = {
+static const char * const slow_mfg_parents[] = {
        "clk26m_ck",
        "univpll_d12",
        "univpll_d24"
 };
 
-static const char * const aud1_parents[] __initconst = {
+static const char * const aud1_parents[] = {
        "clk26m_ck",
        "apll1_ck"
 };
 
-static const char * const aud2_parents[] __initconst = {
+static const char * const aud2_parents[] = {
        "clk26m_ck",
        "apll2_ck"
 };
 
-static const char * const aud_engen1_parents[] __initconst = {
+static const char * const aud_engen1_parents[] = {
        "clk26m_ck",
        "rg_apll1_d2_en",
        "rg_apll1_d4_en",
        "rg_apll1_d8_en"
 };
 
-static const char * const aud_engen2_parents[] __initconst = {
+static const char * const aud_engen2_parents[] = {
        "clk26m_ck",
        "rg_apll2_d2_en",
        "rg_apll2_d4_en",
        "rg_apll2_d8_en"
 };
 
-static const char * const i2c_parents[] __initconst = {
+static const char * const i2c_parents[] = {
        "clk26m_ck",
        "univpll_d20",
        "univpll_d16",
        "univpll_d12"
 };
 
-static const char * const aud_i2s0_m_parents[] __initconst = {
+static const char * const aud_i2s0_m_parents[] = {
        "rg_aud1",
        "rg_aud2"
 };
 
-static const char * const pwm_parents[] __initconst = {
+static const char * const pwm_parents[] = {
        "clk26m_ck",
        "univpll_d12"
 };
 
-static const char * const spi_parents[] __initconst = {
+static const char * const spi_parents[] = {
        "clk26m_ck",
        "univpll_d12",
        "univpll_d8",
        "univpll_d6"
 };
 
-static const char * const aud_spdifin_parents[] __initconst = {
+static const char * const aud_spdifin_parents[] = {
        "clk26m_ck",
        "univpll_d2"
 };
 
-static const char * const uart2_parents[] __initconst = {
+static const char * const uart2_parents[] = {
        "clk26m_ck",
        "univpll_d24"
 };
 
-static const char * const bsi_parents[] __initconst = {
+static const char * const bsi_parents[] = {
        "clk26m_ck",
        "mainpll_d10",
        "mainpll_d12",
        "mainpll_d20"
 };
 
-static const char * const dbg_atclk_parents[] __initconst = {
+static const char * const dbg_atclk_parents[] = {
        "clk_null",
        "clk26m_ck",
        "mainpll_d5",
@@ -503,7 +503,7 @@ static const char * const dbg_atclk_parents[] __initconst = {
        "univpll_d5"
 };
 
-static const char * const csw_nfiecc_parents[] __initconst = {
+static const char * const csw_nfiecc_parents[] = {
        "clk_null",
        "mainpll_d7",
        "mainpll_d6",
@@ -511,7 +511,7 @@ static const char * const csw_nfiecc_parents[] __initconst = {
        "mainpll_d5"
 };
 
-static const char * const nfiecc_parents[] __initconst = {
+static const char * const nfiecc_parents[] = {
        "clk_null",
        "nfi2x_pad_sel",
        "mainpll_d4",
@@ -625,24 +625,24 @@ static struct mtk_composite top_muxes[] __initdata = {
                0x07c, 13, 3),
 };
 
-static const char * const ifr_mux1_parents[] __initconst = {
+static const char * const ifr_mux1_parents[] = {
        "clk26m_ck",
        "armpll",
        "univpll",
        "mainpll_d2"
 };
 
-static const char * const ifr_eth_25m_parents[] __initconst = {
+static const char * const ifr_eth_25m_parents[] = {
        "eth_d2_ck",
        "rg_eth"
 };
 
-static const char * const ifr_i2c0_parents[] __initconst = {
+static const char * const ifr_i2c0_parents[] = {
        "ahb_infra_d2",
        "rg_i2c"
 };
 
-static const struct mtk_composite ifr_muxes[] __initconst = {
+static const struct mtk_composite ifr_muxes[] = {
        MUX(CLK_IFR_MUX1_SEL, "ifr_mux1_sel", ifr_mux1_parents, 0x000,
                2, 2),
        MUX(CLK_IFR_ETH_25M_SEL, "ifr_eth_25m_sel", ifr_eth_25m_parents, 0x080,
@@ -685,21 +685,6 @@ static const struct mtk_clk_divider top_adj_divs[] = {
                0x0078, 0, 8),
 };
 
-#define DIV_ADJ_FLAG(_id, _name, _parent, _reg, _shift, _width, _flag) {       \
-               .id = _id,                                      \
-               .name = _name,                                  \
-               .parent_name = _parent,                         \
-               .div_reg = _reg,                                \
-               .div_shift = _shift,                            \
-               .div_width = _width,                            \
-               .clk_divider_flags = _flag,                             \
-}
-
-static const struct mtk_clk_divider apmixed_adj_divs[] = {
-       DIV_ADJ_FLAG(CLK_APMIXED_HDMI_REF, "hdmi_ref", "tvdpll",
-               0x1c4, 24, 3, CLK_DIVIDER_POWER_OF_TWO),
-};
-
 static const struct mtk_gate_regs top0_cg_regs = {
        .set_ofs = 0x50,
        .clr_ofs = 0x80,
@@ -736,79 +721,31 @@ static const struct mtk_gate_regs top5_cg_regs = {
        .sta_ofs = 0x44,
 };
 
-#define GATE_TOP0(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top0_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_TOP0_I(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top0_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
-
-#define GATE_TOP1(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top1_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_TOP2(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top2_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_TOP2_I(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top2_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
-
-#define GATE_TOP3(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top3_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_TOP4_I(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top4_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
-
-#define GATE_TOP5(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top5_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
-
-static const struct mtk_gate top_clks[] __initconst = {
+#define GATE_TOP0(_id, _name, _parent, _shift) \
+       GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_TOP0_I(_id, _name, _parent, _shift) \
+       GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+#define GATE_TOP1(_id, _name, _parent, _shift) \
+       GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_TOP2(_id, _name, _parent, _shift) \
+       GATE_MTK(_id, _name, _parent, &top2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_TOP2_I(_id, _name, _parent, _shift) \
+       GATE_MTK(_id, _name, _parent, &top2_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+#define GATE_TOP3(_id, _name, _parent, _shift) \
+       GATE_MTK(_id, _name, _parent, &top3_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_TOP4_I(_id, _name, _parent, _shift) \
+       GATE_MTK(_id, _name, _parent, &top4_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+#define GATE_TOP5(_id, _name, _parent, _shift) \
+       GATE_MTK(_id, _name, _parent, &top5_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
+
+static const struct mtk_gate top_clks[] = {
        /* TOP0 */
        GATE_TOP0(CLK_TOP_PWM_MM, "pwm_mm", "pwm_mm_sel", 0),
        GATE_TOP0(CLK_TOP_CAM_MM, "cam_mm", "camtg_mm_sel", 1),
@@ -921,145 +858,40 @@ static const struct mtk_gate top_clks[] __initconst = {
        GATE_TOP5(CLK_TOP_APLL12_DIV6, "apll12_div6", "apll12_ck_div6", 8),
 };
 
-static void __init mtk_topckgen_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-       void __iomem *base;
-
-       base = of_iomap(node, 0);
-       if (!base) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return;
-       }
-
-       clk_data = mtk_alloc_clk_data(MT8167_CLK_TOP_NR_CLK);
-
-       mtk_clk_register_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks),
-                                   clk_data);
-       mtk_clk_register_gates(NULL, node, top_clks, ARRAY_SIZE(top_clks), clk_data);
-
-       mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
-       mtk_clk_register_composites(NULL, top_muxes,
-                                   ARRAY_SIZE(top_muxes), base,
-                                   &mt8167_clk_lock, clk_data);
-       mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs),
-                               base, &mt8167_clk_lock, clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
-}
-CLK_OF_DECLARE(mtk_topckgen, "mediatek,mt8167-topckgen", mtk_topckgen_init);
-
-static void __init mtk_infracfg_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-       void __iomem *base;
-
-       base = of_iomap(node, 0);
-       if (!base) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return;
-       }
-
-       clk_data = mtk_alloc_clk_data(CLK_IFR_NR_CLK);
-
-       mtk_clk_register_composites(NULL, ifr_muxes,
-                                   ARRAY_SIZE(ifr_muxes), base,
-                                   &mt8167_clk_lock, clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
-}
-CLK_OF_DECLARE(mtk_infracfg, "mediatek,mt8167-infracfg", mtk_infracfg_init);
-
-#define MT8167_PLL_FMAX                (2500UL * MHZ)
-
-#define CON0_MT8167_RST_BAR    BIT(27)
-
-#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,  \
-                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
-                       _pcw_shift, _div_table) {                       \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .reg = _reg,                                            \
-               .pwr_reg = _pwr_reg,                                    \
-               .en_mask = _en_mask,                                    \
-               .flags = _flags,                                        \
-               .rst_bar_mask = CON0_MT8167_RST_BAR,                    \
-               .fmax = MT8167_PLL_FMAX,                                \
-               .pcwbits = _pcwbits,                                    \
-               .pd_reg = _pd_reg,                                      \
-               .pd_shift = _pd_shift,                                  \
-               .tuner_reg = _tuner_reg,                                \
-               .pcw_reg = _pcw_reg,                                    \
-               .pcw_shift = _pcw_shift,                                \
-               .div_table = _div_table,                                \
-       }
-
-#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,    \
-                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
-                       _pcw_shift)                                     \
-               PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \
-                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \
-                       NULL)
-
-static const struct mtk_pll_div_table mmpll_div_table[] = {
-       { .div = 0, .freq = MT8167_PLL_FMAX },
-       { .div = 1, .freq = 1000000000 },
-       { .div = 2, .freq = 604500000 },
-       { .div = 3, .freq = 253500000 },
-       { .div = 4, .freq = 126750000 },
-       { } /* sentinel */
+static const struct mtk_clk_desc topck_desc = {
+       .clks = top_clks,
+       .num_clks = ARRAY_SIZE(top_clks),
+       .fixed_clks = fixed_clks,
+       .num_fixed_clks = ARRAY_SIZE(fixed_clks),
+       .factor_clks = top_divs,
+       .num_factor_clks = ARRAY_SIZE(top_divs),
+       .composite_clks = top_muxes,
+       .num_composite_clks = ARRAY_SIZE(top_muxes),
+       .divider_clks = top_adj_divs,
+       .num_divider_clks = ARRAY_SIZE(top_adj_divs),
+       .clk_lock = &mt8167_clk_lock,
 };
 
-static const struct mtk_pll_data plls[] = {
-       PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0,
-               21, 0x0104, 24, 0, 0x0104, 0),
-       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0,
-               HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0),
-       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x30000000,
-               HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0),
-       PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0,
-               21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table),
-       PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0,
-               31, 0x0180, 1, 0x0194, 0x0184, 0),
-       PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0,
-               31, 0x01A0, 1, 0x01B4, 0x01A4, 0),
-       PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x01C0, 0x01D0, 0, 0,
-               21, 0x01C4, 24, 0, 0x01C4, 0),
-       PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x01E0, 0x01F0, 0, 0,
-               21, 0x01E4, 24, 0, 0x01E4, 0),
+static const struct mtk_clk_desc infra_desc = {
+       .composite_clks = ifr_muxes,
+       .num_composite_clks = ARRAY_SIZE(ifr_muxes),
+       .clk_lock = &mt8167_clk_lock,
 };
 
-static void __init mtk_apmixedsys_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       void __iomem *base;
-       int r;
-
-       base = of_iomap(node, 0);
-       if (!base) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return;
-       }
-
-       clk_data = mtk_alloc_clk_data(MT8167_CLK_APMIXED_NR_CLK);
-
-       mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
-       mtk_clk_register_dividers(apmixed_adj_divs, ARRAY_SIZE(apmixed_adj_divs),
-               base, &mt8167_clk_lock, clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
+static const struct of_device_id of_match_clk_mt8167[] = {
+       { .compatible = "mediatek,mt8167-topckgen", .data = &topck_desc },
+       { .compatible = "mediatek,mt8167-infracfg", .data = &infra_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8167);
 
-}
-CLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8167-apmixedsys",
-               mtk_apmixedsys_init);
+static struct platform_driver clk_mt8167_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8167",
+               .of_match_table = of_match_clk_mt8167,
+       },
+};
+module_platform_driver(clk_mt8167_drv);
+MODULE_LICENSE("GPL");
index a56c5845d07a58334148a7263d6d0e471b4d3126..8c2aa8b0f39ead27eef7e3ed5641b750cb7ccf0f 100644 (file)
@@ -9,8 +9,10 @@
 #include <linux/of_address.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include "clk-fhctl.h"
 #include "clk-mtk.h"
 #include "clk-pll.h"
+#include "clk-pllfh.h"
 
 #define REGOFF_REF2USB         0x8
 #define REGOFF_HDMI_REF                0x40
@@ -77,13 +79,67 @@ static const struct mtk_pll_data plls[] = {
        PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x2f0, 0x2fc, 0, 0, 21, 0x2f0, 4, 0x0, 0x2f4, 0),
 };
 
+enum fh_pll_id {
+       FH_ARMCA7PLL,
+       FH_ARMCA15PLL,
+       FH_MAINPLL,
+       FH_MPLL,
+       FH_MSDCPLL,
+       FH_MMPLL,
+       FH_VENCPLL,
+       FH_TVDPLL,
+       FH_VCODECPLL,
+       FH_LVDSPLL,
+       FH_MSDC2PLL,
+       FH_NR_FH,
+};
+
+#define FH(_pllid, _fhid, _offset) {                                   \
+               .data = {                                               \
+                       .pll_id = _pllid,                               \
+                       .fh_id = _fhid,                                 \
+                       .fh_ver = FHCTL_PLLFH_V1,                       \
+                       .fhx_offset = _offset,                          \
+                       .dds_mask = GENMASK(21, 0),                     \
+                       .slope0_value = 0x6003c97,                      \
+                       .slope1_value = 0x6003c97,                      \
+                       .sfstrx_en = BIT(2),                            \
+                       .frddsx_en = BIT(1),                            \
+                       .fhctlx_en = BIT(0),                            \
+                       .tgl_org = BIT(31),                             \
+                       .dvfs_tri = BIT(31),                            \
+                       .pcwchg = BIT(31),                              \
+                       .dt_val = 0x0,                                  \
+                       .df_val = 0x9,                                  \
+                       .updnlmt_shft = 16,                             \
+                       .msk_frddsx_dys = GENMASK(23, 20),              \
+                       .msk_frddsx_dts = GENMASK(19, 16),              \
+               },                                                      \
+       }
+
+static struct mtk_pllfh_data pllfhs[] = {
+       FH(CLK_APMIXED_ARMCA7PLL, FH_ARMCA7PLL, 0x38),
+       FH(CLK_APMIXED_ARMCA15PLL, FH_ARMCA15PLL, 0x4c),
+       FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x60),
+       FH(CLK_APMIXED_MPLL, FH_MPLL, 0x74),
+       FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x88),
+       FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0x9c),
+       FH(CLK_APMIXED_VENCPLL, FH_VENCPLL, 0xb0),
+       FH(CLK_APMIXED_TVDPLL, FH_TVDPLL, 0xc4),
+       FH(CLK_APMIXED_VCODECPLL, FH_VCODECPLL, 0xd8),
+       FH(CLK_APMIXED_LVDSPLL, FH_LVDSPLL, 0xec),
+       FH(CLK_APMIXED_MSDCPLL2, FH_MSDC2PLL, 0x100),
+};
+
 static const struct of_device_id of_match_clk_mt8173_apmixed[] = {
        { .compatible = "mediatek,mt8173-apmixedsys" },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_apmixed);
 
 static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
 {
+       const u8 *fhctl_node = "mediatek,mt8173-fhctl";
        struct device_node *node = pdev->dev.of_node;
        struct clk_hw_onecell_data *clk_data;
        void __iomem *base;
@@ -98,7 +154,9 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
        if (IS_ERR_OR_NULL(clk_data))
                return -ENOMEM;
 
-       r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
+       r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
+                                   pllfhs, ARRAY_SIZE(pllfhs), clk_data);
        if (r)
                goto free_clk_data;
 
@@ -124,7 +182,8 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
 unregister_ref2usb:
        mtk_clk_unregister_ref2usb_tx(clk_data->hws[CLK_APMIXED_REF2USB_TX]);
 unregister_plls:
-       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+       mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs,
+                                 ARRAY_SIZE(pllfhs), clk_data);
 free_clk_data:
        mtk_free_clk_data(clk_data);
        return r;
@@ -137,7 +196,8 @@ static int clk_mt8173_apmixed_remove(struct platform_device *pdev)
 
        of_clk_del_provider(node);
        mtk_clk_unregister_ref2usb_tx(clk_data->hws[CLK_APMIXED_REF2USB_TX]);
-       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+       mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs,
+                                 ARRAY_SIZE(pllfhs), clk_data);
        mtk_free_clk_data(clk_data);
 
        return 0;
index 7b50ffb7a8a5b111002af9453bb58f6433172531..6db2b9ab2bc9194d34c2cf7cc15c242a7463f9e8 100644 (file)
@@ -40,6 +40,7 @@ static const struct of_device_id of_match_clk_mt8173_imgsys[] = {
        { .compatible = "mediatek,mt8173-imgsys", .data = &img_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_imgsys);
 
 static struct platform_driver clk_mt8173_vdecsys_drv = {
        .probe = mtk_clk_simple_probe,
index 729b3c408c7bf1f5fcdc9c0870059cf29a94abdf..4ed5043076ec731e4b383f39bc204853c627c26f 100644 (file)
@@ -74,6 +74,7 @@ static const struct of_device_id of_match_clk_mt8173_infracfg[] = {
        { .compatible = "mediatek,mt8173-infracfg" },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_infracfg);
 
 static void clk_mt8173_infra_init_early(struct device_node *node)
 {
index 315430ad15814cadbd49f2c2f3afebbd4b3276fe..18e466dbf610645a8e2402539b9957297c6e6be7 100644 (file)
@@ -25,25 +25,14 @@ static const struct mtk_gate_regs mm1_cg_regs = {
        .sta_ofs = 0x0110,
 };
 
-#define GATE_MM0(_id, _name, _parent, _shift) {                        \
-               .id = _id,                                      \
-               .name = _name,                                  \
-               .parent_name = _parent,                         \
-               .regs = &mm0_cg_regs,                           \
-               .shift = _shift,                                \
-               .ops = &mtk_clk_gate_ops_setclr,                \
-       }
+#define GATE_MM0(_id, _name, _parent, _shift)  \
+       GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
-#define GATE_MM1(_id, _name, _parent, _shift) {                        \
-               .id = _id,                                      \
-               .name = _name,                                  \
-               .parent_name = _parent,                         \
-               .regs = &mm1_cg_regs,                           \
-               .shift = _shift,                                \
-               .ops = &mtk_clk_gate_ops_setclr,                \
-       }
+#define GATE_MM1(_id, _name, _parent, _shift)  \
+       GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate mt8173_mm_clks[] = {
+       GATE_DUMMY(CLK_DUMMY, "mm_dummy"),
        /* MM0 */
        GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0),
        GATE_MM0(CLK_MM_SMI_LARB0, "mm_smi_larb0", "mm_sel", 1),
@@ -100,65 +89,26 @@ static const struct mtk_gate mt8173_mm_clks[] = {
        GATE_MM1(CLK_MM_HDMI_HDCP24M, "mm_hdmi_hdcp24m", "hdcp_24m_sel", 20),
 };
 
-struct clk_mt8173_mm_driver_data {
-       const struct mtk_gate *gates_clk;
-       int gates_num;
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mt8173_mm_clks,
+       .num_clks = ARRAY_SIZE(mt8173_mm_clks),
 };
 
-static const struct clk_mt8173_mm_driver_data mt8173_mmsys_driver_data = {
-       .gates_clk = mt8173_mm_clks,
-       .gates_num = ARRAY_SIZE(mt8173_mm_clks),
+static const struct platform_device_id clk_mt8173_mm_id_table[] = {
+       { .name = "clk-mt8173-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
 };
-
-static int clk_mt8173_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       const struct clk_mt8173_mm_driver_data *data;
-       struct clk_hw_onecell_data *clk_data;
-       int ret;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       data = &mt8173_mmsys_driver_data;
-
-       ret = mtk_clk_register_gates(&pdev->dev, node, data->gates_clk,
-                                    data->gates_num, clk_data);
-       if (ret)
-               return ret;
-
-       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (ret)
-               return ret;
-
-       return 0;
-}
-
-static int clk_mt8173_mm_remove(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-       const struct clk_mt8173_mm_driver_data *data = &mt8173_mmsys_driver_data;
-
-       of_clk_del_provider(node);
-       mtk_clk_unregister_gates(data->gates_clk, data->gates_num, clk_data);
-       mtk_free_clk_data(clk_data);
-
-       return 0;
-}
+MODULE_DEVICE_TABLE(platform, clk_mt8173_mm_id_table);
 
 static struct platform_driver clk_mt8173_mm_drv = {
        .driver = {
                .name = "clk-mt8173-mm",
        },
-       .probe = clk_mt8173_mm_probe,
-       .remove = clk_mt8173_mm_remove,
+       .id_table = clk_mt8173_mm_id_table,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
 };
-
-builtin_platform_driver(clk_mt8173_mm_drv);
+module_platform_driver(clk_mt8173_mm_drv);
 
 MODULE_DESCRIPTION("MediaTek MT8173 MultiMedia clocks driver");
 MODULE_LICENSE("GPL");
index e87294b72c2cdbe3839cbbaf51a6c04c6c6a2a1c..bebda74d0f4391493bdb0774db4db873200159ae 100644 (file)
@@ -107,6 +107,7 @@ static const struct of_device_id of_match_clk_mt8173_pericfg[] = {
        { .compatible = "mediatek,mt8173-pericfg", .data = &peri_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_pericfg);
 
 static struct platform_driver clk_mt8173_pericfg_drv = {
        .driver = {
index 257961528fe2fb80623e97802f8032efa0327c34..baa8fd6cb31266c88395898a9eea0b54e12d628b 100644 (file)
@@ -638,6 +638,7 @@ static const struct of_device_id of_match_clk_mt8173_topckgen[] = {
        { .compatible = "mediatek,mt8173-topckgen", .data = &topck_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_topckgen);
 
 static struct platform_driver clk_mt8173_topckgen_drv = {
        .driver = {
index 5105b8e0969d88d2884f965f204a195b9479cf03..625ca0b09cc225283b870264e7c6df68fd30a51d 100644 (file)
@@ -42,6 +42,7 @@ static const struct of_device_id of_match_clk_mt8173_vdecsys[] = {
        { .compatible = "mediatek,mt8173-vdecsys", .data = &vdec_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_vdecsys);
 
 static struct platform_driver clk_mt8173_vdecsys_drv = {
        .probe = mtk_clk_simple_probe,
index ff4f1cb735de87c89e450abeb91883cb4a83e2e8..87755dd1a337f9208578907239ef76e9fa8f75c6 100644 (file)
@@ -49,6 +49,7 @@ static const struct of_device_id of_match_clk_mt8173_vencsys[] = {
        { .compatible = "mediatek,mt8173-vencltsys", .data = &venc_lt_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_vencsys);
 
 static struct platform_driver clk_mt8173_vencsys_drv = {
        .driver = {
diff --git a/drivers/clk/mediatek/clk-mt8183-apmixedsys.c b/drivers/clk/mediatek/clk-mt8183-apmixedsys.c
new file mode 100644 (file)
index 0000000..2b261c0
--- /dev/null
@@ -0,0 +1,195 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018 MediaTek Inc.
+ *               Weiyi Lu <weiyi.lu@mediatek.com>
+ * Copyright (c) 2023 Collabora, Ltd.
+ *               AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+ */
+
+#include <dt-bindings/clock/mt8183-clk.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+#include "clk-pll.h"
+
+static const struct mtk_gate_regs apmixed_cg_regs = {
+       .set_ofs = 0x20,
+       .clr_ofs = 0x20,
+       .sta_ofs = 0x20,
+};
+
+#define GATE_APMIXED_FLAGS(_id, _name, _parent, _shift, _flags)                \
+       GATE_MTK_FLAGS(_id, _name, _parent, &apmixed_cg_regs,           \
+                      _shift, &mtk_clk_gate_ops_no_setclr_inv, _flags)
+
+#define GATE_APMIXED(_id, _name, _parent, _shift)                      \
+       GATE_APMIXED_FLAGS(_id, _name, _parent, _shift, 0)
+
+/*
+ * CRITICAL CLOCK:
+ * apmixed_appll26m is the toppest clock gate of all PLLs.
+ */
+static const struct mtk_gate apmixed_clks[] = {
+       /* AUDIO0 */
+       GATE_APMIXED(CLK_APMIXED_SSUSB_26M, "apmixed_ssusb26m", "f_f26m_ck", 4),
+       GATE_APMIXED_FLAGS(CLK_APMIXED_APPLL_26M, "apmixed_appll26m",
+                          "f_f26m_ck", 5, CLK_IS_CRITICAL),
+       GATE_APMIXED(CLK_APMIXED_MIPIC0_26M, "apmixed_mipic026m", "f_f26m_ck", 6),
+       GATE_APMIXED(CLK_APMIXED_MDPLLGP_26M, "apmixed_mdpll26m", "f_f26m_ck", 7),
+       GATE_APMIXED(CLK_APMIXED_MMSYS_26M, "apmixed_mmsys26m", "f_f26m_ck", 8),
+       GATE_APMIXED(CLK_APMIXED_UFS_26M, "apmixed_ufs26m", "f_f26m_ck", 9),
+       GATE_APMIXED(CLK_APMIXED_MIPIC1_26M, "apmixed_mipic126m", "f_f26m_ck", 11),
+       GATE_APMIXED(CLK_APMIXED_MEMPLL_26M, "apmixed_mempll26m", "f_f26m_ck", 13),
+       GATE_APMIXED(CLK_APMIXED_CLKSQ_LVPLL_26M, "apmixed_lvpll26m", "f_f26m_ck", 14),
+       GATE_APMIXED(CLK_APMIXED_MIPID0_26M, "apmixed_mipid026m", "f_f26m_ck", 16),
+       GATE_APMIXED(CLK_APMIXED_MIPID1_26M, "apmixed_mipid126m", "f_f26m_ck", 17),
+};
+
+#define MT8183_PLL_FMAX                (3800UL * MHZ)
+#define MT8183_PLL_FMIN                (1500UL * MHZ)
+
+#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,            \
+                       _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg,    \
+                       _pd_shift, _tuner_reg,  _tuner_en_reg,          \
+                       _tuner_en_bit, _pcw_reg, _pcw_shift,            \
+                       _pcw_chg_reg, _div_table) {                     \
+               .id = _id,                                              \
+               .name = _name,                                          \
+               .reg = _reg,                                            \
+               .pwr_reg = _pwr_reg,                                    \
+               .en_mask = _en_mask,                                    \
+               .flags = _flags,                                        \
+               .rst_bar_mask = _rst_bar_mask,                          \
+               .fmax = MT8183_PLL_FMAX,                                \
+               .fmin = MT8183_PLL_FMIN,                                \
+               .pcwbits = _pcwbits,                                    \
+               .pcwibits = _pcwibits,                                  \
+               .pd_reg = _pd_reg,                                      \
+               .pd_shift = _pd_shift,                                  \
+               .tuner_reg = _tuner_reg,                                \
+               .tuner_en_reg = _tuner_en_reg,                          \
+               .tuner_en_bit = _tuner_en_bit,                          \
+               .pcw_reg = _pcw_reg,                                    \
+               .pcw_shift = _pcw_shift,                                \
+               .pcw_chg_reg = _pcw_chg_reg,                            \
+               .div_table = _div_table,                                \
+       }
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags,              \
+                       _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg,    \
+                       _pd_shift, _tuner_reg, _tuner_en_reg,           \
+                       _tuner_en_bit, _pcw_reg, _pcw_shift,            \
+                       _pcw_chg_reg)                                   \
+               PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,     \
+                       _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg,    \
+                       _pd_shift, _tuner_reg, _tuner_en_reg,           \
+                       _tuner_en_bit, _pcw_reg, _pcw_shift,            \
+                       _pcw_chg_reg, NULL)
+
+static const struct mtk_pll_div_table armpll_div_table[] = {
+       { .div = 0, .freq = MT8183_PLL_FMAX },
+       { .div = 1, .freq = 1500 * MHZ },
+       { .div = 2, .freq = 750 * MHZ },
+       { .div = 3, .freq = 375 * MHZ },
+       { .div = 4, .freq = 187500000 },
+       { /* sentinel */ }
+};
+
+static const struct mtk_pll_div_table mfgpll_div_table[] = {
+       { .div = 0, .freq = MT8183_PLL_FMAX },
+       { .div = 1, .freq = 1600 * MHZ },
+       { .div = 2, .freq = 800 * MHZ },
+       { .div = 3, .freq = 400 * MHZ },
+       { .div = 4, .freq = 200 * MHZ },
+       { /* sentinel */ }
+};
+
+static const struct mtk_pll_data plls[] = {
+       PLL_B(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 0,
+             HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0204, 24, 0x0, 0x0, 0,
+             0x0204, 0, 0, armpll_div_table),
+       PLL_B(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x0210, 0x021C, 0,
+             HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0214, 24, 0x0, 0x0, 0,
+             0x0214, 0, 0, armpll_div_table),
+       PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x0290, 0x029C, 0,
+           HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0294, 24, 0x0, 0x0, 0,
+           0x0294, 0, 0),
+       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0,
+           HAVE_RST_BAR, BIT(24), 22, 8, 0x0224, 24, 0x0, 0x0, 0,
+           0x0224, 0, 0),
+       PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0230, 0x023C, 0,
+           HAVE_RST_BAR, BIT(24), 22, 8, 0x0234, 24, 0x0, 0x0, 0,
+           0x0234, 0, 0),
+       PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0,
+             0, 0, 22, 8, 0x0244, 24, 0x0, 0x0, 0, 0x0244, 0, 0,
+             mfgpll_div_table),
+       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0,
+           0, 0, 22, 8, 0x0254, 24, 0x0, 0x0, 0, 0x0254, 0, 0),
+       PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0260, 0x026C, 0,
+           0, 0, 22, 8, 0x0264, 24, 0x0, 0x0, 0, 0x0264, 0, 0),
+       PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0270, 0x027C, 0,
+           HAVE_RST_BAR, BIT(23), 22, 8, 0x0274, 24, 0x0, 0x0, 0,
+           0x0274, 0, 0),
+       PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0,
+           0, 0, 32, 8, 0x02A0, 1, 0x02A8, 0x0014, 0, 0x02A4, 0, 0x02A0),
+       PLL(CLK_APMIXED_APLL2, "apll2", 0x02b4, 0x02c4, 0,
+           0, 0, 32, 8, 0x02B4, 1, 0x02BC, 0x0014, 1, 0x02B8, 0, 0x02B4),
+};
+
+static int clk_mt8183_apmixed_probe(struct platform_device *pdev)
+{
+       void __iomem *base;
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       struct device *dev = &pdev->dev;
+       int ret;
+
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       clk_data = mtk_devm_alloc_clk_data(dev, CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       if (ret)
+               return ret;
+
+       ret = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks,
+                                    ARRAY_SIZE(apmixed_clks), clk_data);
+       if (ret)
+               goto unregister_plls;
+
+       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (ret)
+               goto unregister_gates;
+
+       return 0;
+
+unregister_gates:
+       mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
+unregister_plls:
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+
+       return ret;
+}
+
+static const struct of_device_id of_match_clk_mt8183_apmixed[] = {
+       { .compatible = "mediatek,mt8183-apmixedsys" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_apmixed);
+
+static struct platform_driver clk_mt8183_apmixed_drv = {
+       .probe = clk_mt8183_apmixed_probe,
+       .driver = {
+               .name = "clk-mt8183-apmixed",
+               .of_match_table = of_match_clk_mt8183_apmixed,
+       },
+};
+builtin_platform_driver(clk_mt8183_apmixed_drv)
+MODULE_LICENSE("GPL");
index 3f1630290b93930c1a8c5885a78db4cb84a3e3fa..9938c6466e762a4b5dedb12be72a82c3ed852504 100644 (file)
@@ -97,6 +97,7 @@ static const struct of_device_id of_match_clk_mt8183_audio[] = {
        { .compatible = "mediatek,mt8183-audiosys", .data = &audio_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_audio);
 
 static struct platform_driver clk_mt8183_audio_drv = {
        .probe = clk_mt8183_audio_probe,
@@ -106,5 +107,5 @@ static struct platform_driver clk_mt8183_audio_drv = {
                .of_match_table = of_match_clk_mt8183_audio,
        },
 };
-
-builtin_platform_driver(clk_mt8183_audio_drv);
+module_platform_driver(clk_mt8183_audio_drv);
+MODULE_LICENSE("GPL");
index 6907b1a6a8247cf4ea388e5ca4a5512d04b249cd..c0719624004fb633036bb5680e6b2a075928aed3 100644 (file)
@@ -47,6 +47,7 @@ static const struct of_device_id of_match_clk_mt8183_cam[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_cam);
 
 static struct platform_driver clk_mt8183_cam_drv = {
        .probe = mtk_clk_simple_probe,
@@ -56,5 +57,5 @@ static struct platform_driver clk_mt8183_cam_drv = {
                .of_match_table = of_match_clk_mt8183_cam,
        },
 };
-
-builtin_platform_driver(clk_mt8183_cam_drv);
+module_platform_driver(clk_mt8183_cam_drv);
+MODULE_LICENSE("GPL");
index 8d884425d79f27c7b124ddab0017c67bb8b8f7b0..55fc8061572424f14837941ba7f594f02c62c69a 100644 (file)
@@ -47,6 +47,7 @@ static const struct of_device_id of_match_clk_mt8183_img[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_img);
 
 static struct platform_driver clk_mt8183_img_drv = {
        .probe = mtk_clk_simple_probe,
@@ -56,5 +57,5 @@ static struct platform_driver clk_mt8183_img_drv = {
                .of_match_table = of_match_clk_mt8183_img,
        },
 };
-
-builtin_platform_driver(clk_mt8183_img_drv);
+module_platform_driver(clk_mt8183_img_drv);
+MODULE_LICENSE("GPL");
index 953a8a33d0487feb753f57c77a108ab1dc3f0e16..59255eab6fe250bdf3ccbf7fa7b36d2ba611fb7f 100644 (file)
@@ -40,6 +40,7 @@ static const struct of_device_id of_match_clk_mt8183_ipu_core0[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_ipu_core0);
 
 static struct platform_driver clk_mt8183_ipu_core0_drv = {
        .probe = mtk_clk_simple_probe,
@@ -49,5 +50,5 @@ static struct platform_driver clk_mt8183_ipu_core0_drv = {
                .of_match_table = of_match_clk_mt8183_ipu_core0,
        },
 };
-
-builtin_platform_driver(clk_mt8183_ipu_core0_drv);
+module_platform_driver(clk_mt8183_ipu_core0_drv);
+MODULE_LICENSE("GPL");
index 221d1226597457344b8abea1df16d40b046976bf..c4baa052c809948261983126f9cdc209020ef76b 100644 (file)
@@ -40,6 +40,7 @@ static const struct of_device_id of_match_clk_mt8183_ipu_core1[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_ipu_core1);
 
 static struct platform_driver clk_mt8183_ipu_core1_drv = {
        .probe = mtk_clk_simple_probe,
@@ -49,5 +50,5 @@ static struct platform_driver clk_mt8183_ipu_core1_drv = {
                .of_match_table = of_match_clk_mt8183_ipu_core1,
        },
 };
-
-builtin_platform_driver(clk_mt8183_ipu_core1_drv);
+module_platform_driver(clk_mt8183_ipu_core1_drv);
+MODULE_LICENSE("GPL");
index 8c4fd96df821e1d631f4e92544856b32faf0e9dc..74866e9c50d74ac5f7d2fc7f2656ddedf20bc13c 100644 (file)
@@ -38,6 +38,7 @@ static const struct of_device_id of_match_clk_mt8183_ipu_adl[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_ipu_adl);
 
 static struct platform_driver clk_mt8183_ipu_adl_drv = {
        .probe = mtk_clk_simple_probe,
@@ -47,5 +48,5 @@ static struct platform_driver clk_mt8183_ipu_adl_drv = {
                .of_match_table = of_match_clk_mt8183_ipu_adl,
        },
 };
-
-builtin_platform_driver(clk_mt8183_ipu_adl_drv);
+module_platform_driver(clk_mt8183_ipu_adl_drv);
+MODULE_LICENSE("GPL");
index 14a4c3ff82a1bcde3d715c6e69be91596a81d287..bd730310535785e23e59e416465d31b1c69e3594 100644 (file)
@@ -107,6 +107,7 @@ static const struct of_device_id of_match_clk_mt8183_ipu_conn[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_ipu_conn);
 
 static struct platform_driver clk_mt8183_ipu_conn_drv = {
        .probe = mtk_clk_simple_probe,
@@ -116,5 +117,5 @@ static struct platform_driver clk_mt8183_ipu_conn_drv = {
                .of_match_table = of_match_clk_mt8183_ipu_conn,
        },
 };
-
-builtin_platform_driver(clk_mt8183_ipu_conn_drv);
+module_platform_driver(clk_mt8183_ipu_conn_drv);
+MODULE_LICENSE("GPL");
index 730c9ae5ea124596cbf5f198779750f45bdfdc90..816ecf1191ee8b3b60feeb1958aff04eacd95683 100644 (file)
@@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8183_mfg[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_mfg);
 
 static struct platform_driver clk_mt8183_mfg_drv = {
        .probe = mtk_clk_simple_probe,
@@ -48,5 +49,5 @@ static struct platform_driver clk_mt8183_mfg_drv = {
                .of_match_table = of_match_clk_mt8183_mfg,
        },
 };
-
-builtin_platform_driver(clk_mt8183_mfg_drv);
+module_platform_driver(clk_mt8183_mfg_drv);
+MODULE_LICENSE("GPL");
index 3580315309132b821d3ede54098a9677ff0cdede..2f99828bff1b31c72fb1935b8cffcb0705454c92 100644 (file)
@@ -82,25 +82,24 @@ static const struct mtk_gate mm_clks[] = {
        GATE_MM1(CLK_MM_DBI_IF, "mm_dbi_if", "dpi0_sel", 13),
 };
 
-static int clk_mt8183_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
-
-       mtk_clk_register_gates(&pdev->dev, node, mm_clks,
-                              ARRAY_SIZE(mm_clks), clk_data);
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mm_clks,
+       .num_clks = ARRAY_SIZE(mm_clks),
+};
 
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct platform_device_id clk_mt8183_mm_id_table[] = {
+       { .name = "clk-mt8183-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8183_mm_id_table);
 
 static struct platform_driver clk_mt8183_mm_drv = {
-       .probe = clk_mt8183_mm_probe,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt8183-mm",
        },
+       .id_table = clk_mt8183_mm_id_table,
 };
-
-builtin_platform_driver(clk_mt8183_mm_drv);
+module_platform_driver(clk_mt8183_mm_drv);
+MODULE_LICENSE("GPL");
index c294e50b96b74bc84f256907945ee2f10c5a7b61..513b7956cbea095692aec57e1f02956bcafe0817 100644 (file)
@@ -51,6 +51,7 @@ static const struct of_device_id of_match_clk_mt8183_vdec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_vdec);
 
 static struct platform_driver clk_mt8183_vdec_drv = {
        .probe = mtk_clk_simple_probe,
@@ -60,5 +61,5 @@ static struct platform_driver clk_mt8183_vdec_drv = {
                .of_match_table = of_match_clk_mt8183_vdec,
        },
 };
-
-builtin_platform_driver(clk_mt8183_vdec_drv);
+module_platform_driver(clk_mt8183_vdec_drv);
+MODULE_LICENSE("GPL");
index 0051c5d92fc5d1f1dd33ad42dc6f9246f81f98db..532f6e12a56161fefbc3d25339096ad73ae48930 100644 (file)
@@ -43,6 +43,7 @@ static const struct of_device_id of_match_clk_mt8183_venc[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_venc);
 
 static struct platform_driver clk_mt8183_venc_drv = {
        .probe = mtk_clk_simple_probe,
@@ -52,5 +53,5 @@ static struct platform_driver clk_mt8183_venc_drv = {
                .of_match_table = of_match_clk_mt8183_venc,
        },
 };
-
-builtin_platform_driver(clk_mt8183_venc_drv);
+module_platform_driver(clk_mt8183_venc_drv);
+MODULE_LICENSE("GPL");
index 722d913f0b4d8c27bfdc25ad78bdff740a9773c0..2336a1b69c0937ac8c0325a9aa977509ecb66271 100644 (file)
@@ -14,7 +14,6 @@
 #include "clk-gate.h"
 #include "clk-mtk.h"
 #include "clk-mux.h"
-#include "clk-pll.h"
 
 #include <dt-bindings/clock/mt8183-clk.h>
 
@@ -26,11 +25,14 @@ static const struct mtk_fixed_clk top_fixed_clks[] = {
        FIXED_CLK(CLK_TOP_UNIVP_192M, "univpll_192m", "univpll", 192000000),
 };
 
-static const struct mtk_fixed_factor top_early_divs[] = {
-       FACTOR(CLK_TOP_CLK13M, "clk13m", "clk26m", 1, 2),
-};
-
+/*
+ * To retain compatibility with older devicetrees, we keep CLK_TOP_CLK13M
+ * valid, but renamed from "clk13m" (defined as fixed clock in the new
+ * devicetrees) to "clk26m_d2", satisfying the older clock assignments.
+ * This means that on new devicetrees "clk26m_d2" is unused.
+ */
 static const struct mtk_fixed_factor top_divs[] = {
+       FACTOR(CLK_TOP_CLK13M, "clk26m_d2", "clk26m", 1, 2),
        FACTOR(CLK_TOP_F26M_CK_D2, "csw_f26m_ck_d2", "clk26m", 1, 2),
        FACTOR_FLAGS(CLK_TOP_SYSPLL_CK, "syspll_ck", "mainpll", 1, 1, 0),
        FACTOR_FLAGS(CLK_TOP_SYSPLL_D2, "syspll_d2", "syspll_ck", 1, 2, 0),
@@ -449,138 +451,97 @@ static const char * const aud_2_parents[] = {
 static const struct mtk_mux top_muxes[] = {
        /* CLK_CFG_0 */
        MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MUX_AXI, "axi_sel",
-               axi_parents, 0x40,
-               0x44, 0x48, 0, 2, 7, 0x004, 0, CLK_IS_CRITICAL),
+               axi_parents, 0x40, 0x44, 0x48, 0, 2, 7, 0x004, 0, CLK_IS_CRITICAL),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MM, "mm_sel",
-               mm_parents, 0x40,
-               0x44, 0x48, 8, 3, 15, 0x004, 1),
+               mm_parents, 0x40, 0x44, 0x48, 8, 3, 15, 0x004, 1),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_IMG, "img_sel",
-               img_parents, 0x40,
-               0x44, 0x48, 16, 3, 23, 0x004, 2),
+               img_parents, 0x40, 0x44, 0x48, 16, 3, 23, 0x004, 2),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAM, "cam_sel",
-               cam_parents, 0x40,
-               0x44, 0x48, 24, 4, 31, 0x004, 3),
+               cam_parents, 0x40, 0x44, 0x48, 24, 4, 31, 0x004, 3),
        /* CLK_CFG_1 */
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DSP, "dsp_sel",
-               dsp_parents, 0x50,
-               0x54, 0x58, 0, 4, 7, 0x004, 4),
+               dsp_parents, 0x50, 0x54, 0x58, 0, 4, 7, 0x004, 4),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DSP1, "dsp1_sel",
-               dsp1_parents, 0x50,
-               0x54, 0x58, 8, 4, 15, 0x004, 5),
+               dsp1_parents, 0x50, 0x54, 0x58, 8, 4, 15, 0x004, 5),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DSP2, "dsp2_sel",
-               dsp2_parents, 0x50,
-               0x54, 0x58, 16, 4, 23, 0x004, 6),
+               dsp2_parents, 0x50, 0x54, 0x58, 16, 4, 23, 0x004, 6),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_IPU_IF, "ipu_if_sel",
-               ipu_if_parents, 0x50,
-               0x54, 0x58, 24, 4, 31, 0x004, 7),
+               ipu_if_parents, 0x50, 0x54, 0x58, 24, 4, 31, 0x004, 7),
        /* CLK_CFG_2 */
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MFG, "mfg_sel",
-               mfg_parents, 0x60,
-               0x64, 0x68, 0, 2, 7, 0x004, 8),
+               mfg_parents, 0x60, 0x64, 0x68, 0, 2, 7, 0x004, 8),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_F52M_MFG, "f52m_mfg_sel",
-               f52m_mfg_parents, 0x60,
-               0x64, 0x68, 8, 2, 15, 0x004, 9),
+               f52m_mfg_parents, 0x60, 0x64, 0x68, 8, 2, 15, 0x004, 9),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG, "camtg_sel",
-               camtg_parents, 0x60,
-               0x64, 0x68, 16, 3, 23, 0x004, 10),
+               camtg_parents, 0x60, 0x64, 0x68, 16, 3, 23, 0x004, 10),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG2, "camtg2_sel",
-               camtg2_parents, 0x60,
-               0x64, 0x68, 24, 3, 31, 0x004, 11),
+               camtg2_parents, 0x60, 0x64, 0x68, 24, 3, 31, 0x004, 11),
        /* CLK_CFG_3 */
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG3, "camtg3_sel",
-               camtg3_parents, 0x70,
-               0x74, 0x78, 0, 3, 7, 0x004, 12),
+               camtg3_parents, 0x70, 0x74, 0x78, 0, 3, 7, 0x004, 12),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG4, "camtg4_sel",
-               camtg4_parents, 0x70,
-               0x74, 0x78, 8, 3, 15, 0x004, 13),
+               camtg4_parents, 0x70, 0x74, 0x78, 8, 3, 15, 0x004, 13),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_UART, "uart_sel",
-               uart_parents, 0x70,
-               0x74, 0x78, 16, 1, 23, 0x004, 14),
+               uart_parents, 0x70, 0x74, 0x78, 16, 1, 23, 0x004, 14),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SPI, "spi_sel",
-               spi_parents, 0x70,
-               0x74, 0x78, 24, 2, 31, 0x004, 15),
+               spi_parents, 0x70, 0x74, 0x78, 24, 2, 31, 0x004, 15),
        /* CLK_CFG_4 */
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC50_0_HCLK, "msdc50_hclk_sel",
-               msdc50_hclk_parents, 0x80,
-               0x84, 0x88, 0, 2, 7, 0x004, 16),
+               msdc50_hclk_parents, 0x80, 0x84, 0x88, 0, 2, 7, 0x004, 16),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC50_0, "msdc50_0_sel",
-               msdc50_0_parents, 0x80,
-               0x84, 0x88, 8, 3, 15, 0x004, 17),
+               msdc50_0_parents, 0x80, 0x84, 0x88, 8, 3, 15, 0x004, 17),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC30_1, "msdc30_1_sel",
-               msdc30_1_parents, 0x80,
-               0x84, 0x88, 16, 3, 23, 0x004, 18),
+               msdc30_1_parents, 0x80, 0x84, 0x88, 16, 3, 23, 0x004, 18),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC30_2, "msdc30_2_sel",
-               msdc30_2_parents, 0x80,
-               0x84, 0x88, 24, 3, 31, 0x004, 19),
+               msdc30_2_parents, 0x80, 0x84, 0x88, 24, 3, 31, 0x004, 19),
        /* CLK_CFG_5 */
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUDIO, "audio_sel",
-               audio_parents, 0x90,
-               0x94, 0x98, 0, 2, 7, 0x004, 20),
+               audio_parents, 0x90, 0x94, 0x98, 0, 2, 7, 0x004, 20),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_INTBUS, "aud_intbus_sel",
-               aud_intbus_parents, 0x90,
-               0x94, 0x98, 8, 2, 15, 0x004, 21),
+               aud_intbus_parents, 0x90, 0x94, 0x98, 8, 2, 15, 0x004, 21),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_PMICSPI, "pmicspi_sel",
-               pmicspi_parents, 0x90,
-               0x94, 0x98, 16, 2, 23, 0x004, 22),
+               pmicspi_parents, 0x90, 0x94, 0x98, 16, 2, 23, 0x004, 22),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_FPWRAP_ULPOSC, "fpwrap_ulposc_sel",
-               fpwrap_ulposc_parents, 0x90,
-               0x94, 0x98, 24, 2, 31, 0x004, 23),
+               fpwrap_ulposc_parents, 0x90, 0x94, 0x98, 24, 2, 31, 0x004, 23),
        /* CLK_CFG_6 */
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_ATB, "atb_sel",
-               atb_parents, 0xa0,
-               0xa4, 0xa8, 0, 2, 7, 0x004, 24),
+               atb_parents, 0xa0, 0xa4, 0xa8, 0, 2, 7, 0x004, 24),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DPI0, "dpi0_sel",
-               dpi0_parents, 0xa0,
-               0xa4, 0xa8, 16, 4, 23, 0x004, 26),
+               dpi0_parents, 0xa0, 0xa4, 0xa8, 16, 4, 23, 0x004, 26),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SCAM, "scam_sel",
-               scam_parents, 0xa0,
-               0xa4, 0xa8, 24, 1, 31, 0x004, 27),
+               scam_parents, 0xa0, 0xa4, 0xa8, 24, 1, 31, 0x004, 27),
        /* CLK_CFG_7 */
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DISP_PWM, "disppwm_sel",
-               disppwm_parents, 0xb0,
-               0xb4, 0xb8, 0, 3, 7, 0x004, 28),
+               disppwm_parents, 0xb0, 0xb4, 0xb8, 0, 3, 7, 0x004, 28),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_USB_TOP, "usb_top_sel",
-               usb_top_parents, 0xb0,
-               0xb4, 0xb8, 8, 2, 15, 0x004, 29),
+               usb_top_parents, 0xb0, 0xb4, 0xb8, 8, 2, 15, 0x004, 29),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SSUSB_TOP_XHCI, "ssusb_top_xhci_sel",
-               ssusb_top_xhci_parents, 0xb0,
-               0xb4, 0xb8, 16, 2, 23, 0x004, 30),
+               ssusb_top_xhci_parents, 0xb0, 0xb4, 0xb8, 16, 2, 23, 0x004, 30),
        MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MUX_SPM, "spm_sel",
-               spm_parents, 0xb0,
-               0xb4, 0xb8, 24, 1, 31, 0x008, 0, CLK_IS_CRITICAL),
+               spm_parents, 0xb0, 0xb4, 0xb8, 24, 1, 31, 0x008, 0, CLK_IS_CRITICAL),
        /* CLK_CFG_8 */
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_I2C, "i2c_sel",
-               i2c_parents, 0xc0,
-               0xc4, 0xc8, 0, 2, 7, 0x008, 1),
+               i2c_parents, 0xc0, 0xc4, 0xc8, 0, 2, 7, 0x008, 1),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SCP, "scp_sel",
-               scp_parents, 0xc0,
-               0xc4, 0xc8, 8, 3, 15, 0x008, 2),
+               scp_parents, 0xc0, 0xc4, 0xc8, 8, 3, 15, 0x008, 2),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SENINF, "seninf_sel",
-               seninf_parents, 0xc0,
-               0xc4, 0xc8, 16, 2, 23, 0x008, 3),
+               seninf_parents, 0xc0, 0xc4, 0xc8, 16, 2, 23, 0x008, 3),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DXCC, "dxcc_sel",
-               dxcc_parents, 0xc0,
-               0xc4, 0xc8, 24, 2, 31, 0x008, 4),
+               dxcc_parents, 0xc0, 0xc4, 0xc8, 24, 2, 31, 0x008, 4),
        /* CLK_CFG_9 */
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_ENG1, "aud_eng1_sel",
-               aud_engen1_parents, 0xd0,
-               0xd4, 0xd8, 0, 2, 7, 0x008, 5),
+               aud_engen1_parents, 0xd0, 0xd4, 0xd8, 0, 2, 7, 0x008, 5),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_ENG2, "aud_eng2_sel",
-               aud_engen2_parents, 0xd0,
-               0xd4, 0xd8, 8, 2, 15, 0x008, 6),
+               aud_engen2_parents, 0xd0, 0xd4, 0xd8, 8, 2, 15, 0x008, 6),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_FAES_UFSFDE, "faes_ufsfde_sel",
-               faes_ufsfde_parents, 0xd0,
-               0xd4, 0xd8, 16, 3, 23, 0x008, 7),
+               faes_ufsfde_parents, 0xd0, 0xd4, 0xd8, 16, 3, 23, 0x008, 7),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_FUFS, "fufs_sel",
-               fufs_parents, 0xd0,
-               0xd4, 0xd8, 24, 2, 31, 0x008, 8),
+               fufs_parents, 0xd0, 0xd4, 0xd8, 24, 2, 31, 0x008, 8),
        /* CLK_CFG_10 */
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_1, "aud_1_sel",
-               aud_1_parents, 0xe0,
-               0xe4, 0xe8, 0, 1, 7, 0x008, 9),
+               aud_1_parents, 0xe0, 0xe4, 0xe8, 0, 1, 7, 0x008, 9),
        MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_2, "aud_2_sel",
-               aud_2_parents, 0xe0,
-               0xe4, 0xe8, 8, 1, 15, 0x008, 10),
+               aud_2_parents, 0xe0, 0xe4, 0xe8, 8, 1, 15, 0x008, 10),
 };
 
 static const char * const apll_i2s0_parents[] = {
@@ -644,30 +605,18 @@ static struct mtk_composite mcu_muxes[] = {
 };
 
 static struct mtk_composite top_aud_comp[] = {
-       MUX(CLK_TOP_MUX_APLL_I2S0, "apll_i2s0_sel", apll_i2s0_parents,
-               0x320, 8, 1),
-       MUX(CLK_TOP_MUX_APLL_I2S1, "apll_i2s1_sel", apll_i2s1_parents,
-               0x320, 9, 1),
-       MUX(CLK_TOP_MUX_APLL_I2S2, "apll_i2s2_sel", apll_i2s2_parents,
-               0x320, 10, 1),
-       MUX(CLK_TOP_MUX_APLL_I2S3, "apll_i2s3_sel", apll_i2s3_parents,
-               0x320, 11, 1),
-       MUX(CLK_TOP_MUX_APLL_I2S4, "apll_i2s4_sel", apll_i2s4_parents,
-               0x320, 12, 1),
-       MUX(CLK_TOP_MUX_APLL_I2S5, "apll_i2s5_sel", apll_i2s5_parents,
-               0x328, 20, 1),
-       DIV_GATE(CLK_TOP_APLL12_DIV0, "apll12_div0", "apll_i2s0_sel",
-               0x320, 2, 0x324, 8, 0),
-       DIV_GATE(CLK_TOP_APLL12_DIV1, "apll12_div1", "apll_i2s1_sel",
-               0x320, 3, 0x324, 8, 8),
-       DIV_GATE(CLK_TOP_APLL12_DIV2, "apll12_div2", "apll_i2s2_sel",
-               0x320, 4, 0x324, 8, 16),
-       DIV_GATE(CLK_TOP_APLL12_DIV3, "apll12_div3", "apll_i2s3_sel",
-               0x320, 5, 0x324, 8, 24),
-       DIV_GATE(CLK_TOP_APLL12_DIV4, "apll12_div4", "apll_i2s4_sel",
-               0x320, 6, 0x328, 8, 0),
-       DIV_GATE(CLK_TOP_APLL12_DIVB, "apll12_divb", "apll12_div4",
-               0x320, 7, 0x328, 8, 8),
+       MUX(CLK_TOP_MUX_APLL_I2S0, "apll_i2s0_sel", apll_i2s0_parents, 0x320, 8, 1),
+       MUX(CLK_TOP_MUX_APLL_I2S1, "apll_i2s1_sel", apll_i2s1_parents, 0x320, 9, 1),
+       MUX(CLK_TOP_MUX_APLL_I2S2, "apll_i2s2_sel", apll_i2s2_parents, 0x320, 10, 1),
+       MUX(CLK_TOP_MUX_APLL_I2S3, "apll_i2s3_sel", apll_i2s3_parents, 0x320, 11, 1),
+       MUX(CLK_TOP_MUX_APLL_I2S4, "apll_i2s4_sel", apll_i2s4_parents, 0x320, 12, 1),
+       MUX(CLK_TOP_MUX_APLL_I2S5, "apll_i2s5_sel", apll_i2s5_parents, 0x328, 20, 1),
+       DIV_GATE(CLK_TOP_APLL12_DIV0, "apll12_div0", "apll_i2s0_sel", 0x320, 2, 0x324, 8, 0),
+       DIV_GATE(CLK_TOP_APLL12_DIV1, "apll12_div1", "apll_i2s1_sel", 0x320, 3, 0x324, 8, 8),
+       DIV_GATE(CLK_TOP_APLL12_DIV2, "apll12_div2", "apll_i2s2_sel", 0x320, 4, 0x324, 8, 16),
+       DIV_GATE(CLK_TOP_APLL12_DIV3, "apll12_div3", "apll_i2s3_sel", 0x320, 5, 0x324, 8, 24),
+       DIV_GATE(CLK_TOP_APLL12_DIV4, "apll12_div4", "apll_i2s4_sel", 0x320, 6, 0x328, 8, 0),
+       DIV_GATE(CLK_TOP_APLL12_DIVB, "apll12_divb", "apll12_div4", 0x320, 7, 0x328, 8, 8),
 };
 
 static const struct mtk_gate_regs top_cg_regs = {
@@ -728,203 +677,106 @@ static const struct mtk_gate_regs infra3_cg_regs = {
 
 static const struct mtk_gate infra_clks[] = {
        /* INFRA0 */
-       GATE_INFRA0(CLK_INFRA_PMIC_TMR, "infra_pmic_tmr",
-               "axi_sel", 0),
-       GATE_INFRA0(CLK_INFRA_PMIC_AP, "infra_pmic_ap",
-               "axi_sel", 1),
-       GATE_INFRA0(CLK_INFRA_PMIC_MD, "infra_pmic_md",
-               "axi_sel", 2),
-       GATE_INFRA0(CLK_INFRA_PMIC_CONN, "infra_pmic_conn",
-               "axi_sel", 3),
-       GATE_INFRA0(CLK_INFRA_SCPSYS, "infra_scp",
-               "scp_sel", 4),
-       GATE_INFRA0(CLK_INFRA_SEJ, "infra_sej",
-               "f_f26m_ck", 5),
-       GATE_INFRA0(CLK_INFRA_APXGPT, "infra_apxgpt",
-               "axi_sel", 6),
-       GATE_INFRA0(CLK_INFRA_ICUSB, "infra_icusb",
-               "axi_sel", 8),
-       GATE_INFRA0(CLK_INFRA_GCE, "infra_gce",
-               "axi_sel", 9),
-       GATE_INFRA0(CLK_INFRA_THERM, "infra_therm",
-               "axi_sel", 10),
-       GATE_INFRA0(CLK_INFRA_I2C0, "infra_i2c0",
-               "i2c_sel", 11),
-       GATE_INFRA0(CLK_INFRA_I2C1, "infra_i2c1",
-               "i2c_sel", 12),
-       GATE_INFRA0(CLK_INFRA_I2C2, "infra_i2c2",
-               "i2c_sel", 13),
-       GATE_INFRA0(CLK_INFRA_I2C3, "infra_i2c3",
-               "i2c_sel", 14),
-       GATE_INFRA0(CLK_INFRA_PWM_HCLK, "infra_pwm_hclk",
-               "axi_sel", 15),
-       GATE_INFRA0(CLK_INFRA_PWM1, "infra_pwm1",
-               "i2c_sel", 16),
-       GATE_INFRA0(CLK_INFRA_PWM2, "infra_pwm2",
-               "i2c_sel", 17),
-       GATE_INFRA0(CLK_INFRA_PWM3, "infra_pwm3",
-               "i2c_sel", 18),
-       GATE_INFRA0(CLK_INFRA_PWM4, "infra_pwm4",
-               "i2c_sel", 19),
-       GATE_INFRA0(CLK_INFRA_PWM, "infra_pwm",
-               "i2c_sel", 21),
-       GATE_INFRA0(CLK_INFRA_UART0, "infra_uart0",
-               "uart_sel", 22),
-       GATE_INFRA0(CLK_INFRA_UART1, "infra_uart1",
-               "uart_sel", 23),
-       GATE_INFRA0(CLK_INFRA_UART2, "infra_uart2",
-               "uart_sel", 24),
-       GATE_INFRA0(CLK_INFRA_UART3, "infra_uart3",
-               "uart_sel", 25),
-       GATE_INFRA0(CLK_INFRA_GCE_26M, "infra_gce_26m",
-               "axi_sel", 27),
-       GATE_INFRA0(CLK_INFRA_CQ_DMA_FPC, "infra_cqdma_fpc",
-               "axi_sel", 28),
-       GATE_INFRA0(CLK_INFRA_BTIF, "infra_btif",
-               "axi_sel", 31),
+       GATE_INFRA0(CLK_INFRA_PMIC_TMR, "infra_pmic_tmr", "axi_sel", 0),
+       GATE_INFRA0(CLK_INFRA_PMIC_AP, "infra_pmic_ap", "axi_sel", 1),
+       GATE_INFRA0(CLK_INFRA_PMIC_MD, "infra_pmic_md", "axi_sel", 2),
+       GATE_INFRA0(CLK_INFRA_PMIC_CONN, "infra_pmic_conn", "axi_sel", 3),
+       GATE_INFRA0(CLK_INFRA_SCPSYS, "infra_scp", "scp_sel", 4),
+       GATE_INFRA0(CLK_INFRA_SEJ, "infra_sej", "f_f26m_ck", 5),
+       GATE_INFRA0(CLK_INFRA_APXGPT, "infra_apxgpt", "axi_sel", 6),
+       GATE_INFRA0(CLK_INFRA_ICUSB, "infra_icusb", "axi_sel", 8),
+       GATE_INFRA0(CLK_INFRA_GCE, "infra_gce", "axi_sel", 9),
+       GATE_INFRA0(CLK_INFRA_THERM, "infra_therm", "axi_sel", 10),
+       GATE_INFRA0(CLK_INFRA_I2C0, "infra_i2c0", "i2c_sel", 11),
+       GATE_INFRA0(CLK_INFRA_I2C1, "infra_i2c1", "i2c_sel", 12),
+       GATE_INFRA0(CLK_INFRA_I2C2, "infra_i2c2", "i2c_sel", 13),
+       GATE_INFRA0(CLK_INFRA_I2C3, "infra_i2c3", "i2c_sel", 14),
+       GATE_INFRA0(CLK_INFRA_PWM_HCLK, "infra_pwm_hclk", "axi_sel", 15),
+       GATE_INFRA0(CLK_INFRA_PWM1, "infra_pwm1", "i2c_sel", 16),
+       GATE_INFRA0(CLK_INFRA_PWM2, "infra_pwm2", "i2c_sel", 17),
+       GATE_INFRA0(CLK_INFRA_PWM3, "infra_pwm3", "i2c_sel", 18),
+       GATE_INFRA0(CLK_INFRA_PWM4, "infra_pwm4", "i2c_sel", 19),
+       GATE_INFRA0(CLK_INFRA_PWM, "infra_pwm", "i2c_sel", 21),
+       GATE_INFRA0(CLK_INFRA_UART0, "infra_uart0", "uart_sel", 22),
+       GATE_INFRA0(CLK_INFRA_UART1, "infra_uart1", "uart_sel", 23),
+       GATE_INFRA0(CLK_INFRA_UART2, "infra_uart2", "uart_sel", 24),
+       GATE_INFRA0(CLK_INFRA_UART3, "infra_uart3", "uart_sel", 25),
+       GATE_INFRA0(CLK_INFRA_GCE_26M, "infra_gce_26m", "axi_sel", 27),
+       GATE_INFRA0(CLK_INFRA_CQ_DMA_FPC, "infra_cqdma_fpc", "axi_sel", 28),
+       GATE_INFRA0(CLK_INFRA_BTIF, "infra_btif", "axi_sel", 31),
        /* INFRA1 */
-       GATE_INFRA1(CLK_INFRA_SPI0, "infra_spi0",
-               "spi_sel", 1),
-       GATE_INFRA1(CLK_INFRA_MSDC0, "infra_msdc0",
-               "msdc50_hclk_sel", 2),
-       GATE_INFRA1(CLK_INFRA_MSDC1, "infra_msdc1",
-               "axi_sel", 4),
-       GATE_INFRA1(CLK_INFRA_MSDC2, "infra_msdc2",
-               "axi_sel", 5),
-       GATE_INFRA1(CLK_INFRA_MSDC0_SCK, "infra_msdc0_sck",
-               "msdc50_0_sel", 6),
-       GATE_INFRA1(CLK_INFRA_DVFSRC, "infra_dvfsrc",
-               "f_f26m_ck", 7),
-       GATE_INFRA1(CLK_INFRA_GCPU, "infra_gcpu",
-               "axi_sel", 8),
-       GATE_INFRA1(CLK_INFRA_TRNG, "infra_trng",
-               "axi_sel", 9),
-       GATE_INFRA1(CLK_INFRA_AUXADC, "infra_auxadc",
-               "f_f26m_ck", 10),
-       GATE_INFRA1(CLK_INFRA_CPUM, "infra_cpum",
-               "axi_sel", 11),
-       GATE_INFRA1(CLK_INFRA_CCIF1_AP, "infra_ccif1_ap",
-               "axi_sel", 12),
-       GATE_INFRA1(CLK_INFRA_CCIF1_MD, "infra_ccif1_md",
-               "axi_sel", 13),
-       GATE_INFRA1(CLK_INFRA_AUXADC_MD, "infra_auxadc_md",
-               "f_f26m_ck", 14),
-       GATE_INFRA1(CLK_INFRA_MSDC1_SCK, "infra_msdc1_sck",
-               "msdc30_1_sel", 16),
-       GATE_INFRA1(CLK_INFRA_MSDC2_SCK, "infra_msdc2_sck",
-               "msdc30_2_sel", 17),
-       GATE_INFRA1(CLK_INFRA_AP_DMA, "infra_apdma",
-               "axi_sel", 18),
-       GATE_INFRA1(CLK_INFRA_XIU, "infra_xiu",
-               "axi_sel", 19),
-       GATE_INFRA1(CLK_INFRA_DEVICE_APC, "infra_device_apc",
-               "axi_sel", 20),
-       GATE_INFRA1(CLK_INFRA_CCIF_AP, "infra_ccif_ap",
-               "axi_sel", 23),
-       GATE_INFRA1(CLK_INFRA_DEBUGSYS, "infra_debugsys",
-               "axi_sel", 24),
-       GATE_INFRA1(CLK_INFRA_AUDIO, "infra_audio",
-               "axi_sel", 25),
-       GATE_INFRA1(CLK_INFRA_CCIF_MD, "infra_ccif_md",
-               "axi_sel", 26),
-       GATE_INFRA1(CLK_INFRA_DXCC_SEC_CORE, "infra_dxcc_sec_core",
-               "dxcc_sel", 27),
-       GATE_INFRA1(CLK_INFRA_DXCC_AO, "infra_dxcc_ao",
-               "dxcc_sel", 28),
-       GATE_INFRA1(CLK_INFRA_DEVMPU_BCLK, "infra_devmpu_bclk",
-               "axi_sel", 30),
-       GATE_INFRA1(CLK_INFRA_DRAMC_F26M, "infra_dramc_f26m",
-               "f_f26m_ck", 31),
+       GATE_INFRA1(CLK_INFRA_SPI0, "infra_spi0", "spi_sel", 1),
+       GATE_INFRA1(CLK_INFRA_MSDC0, "infra_msdc0", "msdc50_hclk_sel", 2),
+       GATE_INFRA1(CLK_INFRA_MSDC1, "infra_msdc1", "axi_sel", 4),
+       GATE_INFRA1(CLK_INFRA_MSDC2, "infra_msdc2", "axi_sel", 5),
+       GATE_INFRA1(CLK_INFRA_MSDC0_SCK, "infra_msdc0_sck", "msdc50_0_sel", 6),
+       GATE_INFRA1(CLK_INFRA_DVFSRC, "infra_dvfsrc", "f_f26m_ck", 7),
+       GATE_INFRA1(CLK_INFRA_GCPU, "infra_gcpu", "axi_sel", 8),
+       GATE_INFRA1(CLK_INFRA_TRNG, "infra_trng", "axi_sel", 9),
+       GATE_INFRA1(CLK_INFRA_AUXADC, "infra_auxadc", "f_f26m_ck", 10),
+       GATE_INFRA1(CLK_INFRA_CPUM, "infra_cpum", "axi_sel", 11),
+       GATE_INFRA1(CLK_INFRA_CCIF1_AP, "infra_ccif1_ap", "axi_sel", 12),
+       GATE_INFRA1(CLK_INFRA_CCIF1_MD, "infra_ccif1_md", "axi_sel", 13),
+       GATE_INFRA1(CLK_INFRA_AUXADC_MD, "infra_auxadc_md", "f_f26m_ck", 14),
+       GATE_INFRA1(CLK_INFRA_MSDC1_SCK, "infra_msdc1_sck", "msdc30_1_sel", 16),
+       GATE_INFRA1(CLK_INFRA_MSDC2_SCK, "infra_msdc2_sck", "msdc30_2_sel", 17),
+       GATE_INFRA1(CLK_INFRA_AP_DMA, "infra_apdma", "axi_sel", 18),
+       GATE_INFRA1(CLK_INFRA_XIU, "infra_xiu", "axi_sel", 19),
+       GATE_INFRA1(CLK_INFRA_DEVICE_APC, "infra_device_apc", "axi_sel", 20),
+       GATE_INFRA1(CLK_INFRA_CCIF_AP, "infra_ccif_ap", "axi_sel", 23),
+       GATE_INFRA1(CLK_INFRA_DEBUGSYS, "infra_debugsys", "axi_sel", 24),
+       GATE_INFRA1(CLK_INFRA_AUDIO, "infra_audio", "axi_sel", 25),
+       GATE_INFRA1(CLK_INFRA_CCIF_MD, "infra_ccif_md", "axi_sel", 26),
+       GATE_INFRA1(CLK_INFRA_DXCC_SEC_CORE, "infra_dxcc_sec_core", "dxcc_sel", 27),
+       GATE_INFRA1(CLK_INFRA_DXCC_AO, "infra_dxcc_ao", "dxcc_sel", 28),
+       GATE_INFRA1(CLK_INFRA_DEVMPU_BCLK, "infra_devmpu_bclk", "axi_sel", 30),
+       GATE_INFRA1(CLK_INFRA_DRAMC_F26M, "infra_dramc_f26m", "f_f26m_ck", 31),
        /* INFRA2 */
-       GATE_INFRA2(CLK_INFRA_IRTX, "infra_irtx",
-               "f_f26m_ck", 0),
-       GATE_INFRA2(CLK_INFRA_USB, "infra_usb",
-               "usb_top_sel", 1),
-       GATE_INFRA2(CLK_INFRA_DISP_PWM, "infra_disppwm",
-               "axi_sel", 2),
-       GATE_INFRA2(CLK_INFRA_CLDMA_BCLK, "infra_cldma_bclk",
-               "axi_sel", 3),
-       GATE_INFRA2(CLK_INFRA_AUDIO_26M_BCLK, "infra_audio_26m_bclk",
-               "f_f26m_ck", 4),
-       GATE_INFRA2(CLK_INFRA_SPI1, "infra_spi1",
-               "spi_sel", 6),
-       GATE_INFRA2(CLK_INFRA_I2C4, "infra_i2c4",
-               "i2c_sel", 7),
-       GATE_INFRA2(CLK_INFRA_MODEM_TEMP_SHARE, "infra_md_tmp_share",
-               "f_f26m_ck", 8),
-       GATE_INFRA2(CLK_INFRA_SPI2, "infra_spi2",
-               "spi_sel", 9),
-       GATE_INFRA2(CLK_INFRA_SPI3, "infra_spi3",
-               "spi_sel", 10),
-       GATE_INFRA2(CLK_INFRA_UNIPRO_SCK, "infra_unipro_sck",
-               "ssusb_top_xhci_sel", 11),
-       GATE_INFRA2(CLK_INFRA_UNIPRO_TICK, "infra_unipro_tick",
-               "fufs_sel", 12),
-       GATE_INFRA2(CLK_INFRA_UFS_MP_SAP_BCLK, "infra_ufs_mp_sap_bck",
-               "fufs_sel", 13),
-       GATE_INFRA2(CLK_INFRA_MD32_BCLK, "infra_md32_bclk",
-               "axi_sel", 14),
-       GATE_INFRA2(CLK_INFRA_UNIPRO_MBIST, "infra_unipro_mbist",
-               "axi_sel", 16),
-       GATE_INFRA2(CLK_INFRA_I2C5, "infra_i2c5",
-               "i2c_sel", 18),
-       GATE_INFRA2(CLK_INFRA_I2C5_ARBITER, "infra_i2c5_arbiter",
-               "i2c_sel", 19),
-       GATE_INFRA2(CLK_INFRA_I2C5_IMM, "infra_i2c5_imm",
-               "i2c_sel", 20),
-       GATE_INFRA2(CLK_INFRA_I2C1_ARBITER, "infra_i2c1_arbiter",
-               "i2c_sel", 21),
-       GATE_INFRA2(CLK_INFRA_I2C1_IMM, "infra_i2c1_imm",
-               "i2c_sel", 22),
-       GATE_INFRA2(CLK_INFRA_I2C2_ARBITER, "infra_i2c2_arbiter",
-               "i2c_sel", 23),
-       GATE_INFRA2(CLK_INFRA_I2C2_IMM, "infra_i2c2_imm",
-               "i2c_sel", 24),
-       GATE_INFRA2(CLK_INFRA_SPI4, "infra_spi4",
-               "spi_sel", 25),
-       GATE_INFRA2(CLK_INFRA_SPI5, "infra_spi5",
-               "spi_sel", 26),
-       GATE_INFRA2(CLK_INFRA_CQ_DMA, "infra_cqdma",
-               "axi_sel", 27),
-       GATE_INFRA2(CLK_INFRA_UFS, "infra_ufs",
-               "fufs_sel", 28),
-       GATE_INFRA2(CLK_INFRA_AES_UFSFDE, "infra_aes_ufsfde",
-               "faes_ufsfde_sel", 29),
-       GATE_INFRA2(CLK_INFRA_UFS_TICK, "infra_ufs_tick",
-               "fufs_sel", 30),
+       GATE_INFRA2(CLK_INFRA_IRTX, "infra_irtx", "f_f26m_ck", 0),
+       GATE_INFRA2(CLK_INFRA_USB, "infra_usb", "usb_top_sel", 1),
+       GATE_INFRA2(CLK_INFRA_DISP_PWM, "infra_disppwm", "axi_sel", 2),
+       GATE_INFRA2(CLK_INFRA_CLDMA_BCLK, "infra_cldma_bclk", "axi_sel", 3),
+       GATE_INFRA2(CLK_INFRA_AUDIO_26M_BCLK, "infra_audio_26m_bclk", "f_f26m_ck", 4),
+       GATE_INFRA2(CLK_INFRA_SPI1, "infra_spi1", "spi_sel", 6),
+       GATE_INFRA2(CLK_INFRA_I2C4, "infra_i2c4", "i2c_sel", 7),
+       GATE_INFRA2(CLK_INFRA_MODEM_TEMP_SHARE, "infra_md_tmp_share", "f_f26m_ck", 8),
+       GATE_INFRA2(CLK_INFRA_SPI2, "infra_spi2", "spi_sel", 9),
+       GATE_INFRA2(CLK_INFRA_SPI3, "infra_spi3", "spi_sel", 10),
+       GATE_INFRA2(CLK_INFRA_UNIPRO_SCK, "infra_unipro_sck", "ssusb_top_xhci_sel", 11),
+       GATE_INFRA2(CLK_INFRA_UNIPRO_TICK, "infra_unipro_tick", "fufs_sel", 12),
+       GATE_INFRA2(CLK_INFRA_UFS_MP_SAP_BCLK, "infra_ufs_mp_sap_bck", "fufs_sel", 13),
+       GATE_INFRA2(CLK_INFRA_MD32_BCLK, "infra_md32_bclk", "axi_sel", 14),
+       GATE_INFRA2(CLK_INFRA_UNIPRO_MBIST, "infra_unipro_mbist", "axi_sel", 16),
+       GATE_INFRA2(CLK_INFRA_I2C5, "infra_i2c5", "i2c_sel", 18),
+       GATE_INFRA2(CLK_INFRA_I2C5_ARBITER, "infra_i2c5_arbiter", "i2c_sel", 19),
+       GATE_INFRA2(CLK_INFRA_I2C5_IMM, "infra_i2c5_imm", "i2c_sel", 20),
+       GATE_INFRA2(CLK_INFRA_I2C1_ARBITER, "infra_i2c1_arbiter", "i2c_sel", 21),
+       GATE_INFRA2(CLK_INFRA_I2C1_IMM, "infra_i2c1_imm", "i2c_sel", 22),
+       GATE_INFRA2(CLK_INFRA_I2C2_ARBITER, "infra_i2c2_arbiter", "i2c_sel", 23),
+       GATE_INFRA2(CLK_INFRA_I2C2_IMM, "infra_i2c2_imm", "i2c_sel", 24),
+       GATE_INFRA2(CLK_INFRA_SPI4, "infra_spi4", "spi_sel", 25),
+       GATE_INFRA2(CLK_INFRA_SPI5, "infra_spi5", "spi_sel", 26),
+       GATE_INFRA2(CLK_INFRA_CQ_DMA, "infra_cqdma", "axi_sel", 27),
+       GATE_INFRA2(CLK_INFRA_UFS, "infra_ufs", "fufs_sel", 28),
+       GATE_INFRA2(CLK_INFRA_AES_UFSFDE, "infra_aes_ufsfde", "faes_ufsfde_sel", 29),
+       GATE_INFRA2(CLK_INFRA_UFS_TICK, "infra_ufs_tick", "fufs_sel", 30),
        /* INFRA3 */
-       GATE_INFRA3(CLK_INFRA_MSDC0_SELF, "infra_msdc0_self",
-               "msdc50_0_sel", 0),
-       GATE_INFRA3(CLK_INFRA_MSDC1_SELF, "infra_msdc1_self",
-               "msdc50_0_sel", 1),
-       GATE_INFRA3(CLK_INFRA_MSDC2_SELF, "infra_msdc2_self",
-               "msdc50_0_sel", 2),
-       GATE_INFRA3(CLK_INFRA_UFS_AXI, "infra_ufs_axi",
-               "axi_sel", 5),
-       GATE_INFRA3(CLK_INFRA_I2C6, "infra_i2c6",
-               "i2c_sel", 6),
-       GATE_INFRA3(CLK_INFRA_AP_MSDC0, "infra_ap_msdc0",
-               "msdc50_hclk_sel", 7),
-       GATE_INFRA3(CLK_INFRA_MD_MSDC0, "infra_md_msdc0",
-               "msdc50_hclk_sel", 8),
-       GATE_INFRA3(CLK_INFRA_CCIF2_AP, "infra_ccif2_ap",
-               "axi_sel", 16),
-       GATE_INFRA3(CLK_INFRA_CCIF2_MD, "infra_ccif2_md",
-               "axi_sel", 17),
-       GATE_INFRA3(CLK_INFRA_CCIF3_AP, "infra_ccif3_ap",
-               "axi_sel", 18),
-       GATE_INFRA3(CLK_INFRA_CCIF3_MD, "infra_ccif3_md",
-               "axi_sel", 19),
-       GATE_INFRA3(CLK_INFRA_SEJ_F13M, "infra_sej_f13m",
-               "f_f26m_ck", 20),
-       GATE_INFRA3(CLK_INFRA_AES_BCLK, "infra_aes_bclk",
-               "axi_sel", 21),
-       GATE_INFRA3(CLK_INFRA_I2C7, "infra_i2c7",
-               "i2c_sel", 22),
-       GATE_INFRA3(CLK_INFRA_I2C8, "infra_i2c8",
-               "i2c_sel", 23),
-       GATE_INFRA3(CLK_INFRA_FBIST2FPC, "infra_fbist2fpc",
-               "msdc50_0_sel", 24),
+       GATE_INFRA3(CLK_INFRA_MSDC0_SELF, "infra_msdc0_self", "msdc50_0_sel", 0),
+       GATE_INFRA3(CLK_INFRA_MSDC1_SELF, "infra_msdc1_self", "msdc50_0_sel", 1),
+       GATE_INFRA3(CLK_INFRA_MSDC2_SELF, "infra_msdc2_self", "msdc50_0_sel", 2),
+       GATE_INFRA3(CLK_INFRA_UFS_AXI, "infra_ufs_axi", "axi_sel", 5),
+       GATE_INFRA3(CLK_INFRA_I2C6, "infra_i2c6", "i2c_sel", 6),
+       GATE_INFRA3(CLK_INFRA_AP_MSDC0, "infra_ap_msdc0", "msdc50_hclk_sel", 7),
+       GATE_INFRA3(CLK_INFRA_MD_MSDC0, "infra_md_msdc0", "msdc50_hclk_sel", 8),
+       GATE_INFRA3(CLK_INFRA_CCIF2_AP, "infra_ccif2_ap", "axi_sel", 16),
+       GATE_INFRA3(CLK_INFRA_CCIF2_MD, "infra_ccif2_md", "axi_sel", 17),
+       GATE_INFRA3(CLK_INFRA_CCIF3_AP, "infra_ccif3_ap", "axi_sel", 18),
+       GATE_INFRA3(CLK_INFRA_CCIF3_MD, "infra_ccif3_md", "axi_sel", 19),
+       GATE_INFRA3(CLK_INFRA_SEJ_F13M, "infra_sej_f13m", "f_f26m_ck", 20),
+       GATE_INFRA3(CLK_INFRA_AES_BCLK, "infra_aes_bclk", "axi_sel", 21),
+       GATE_INFRA3(CLK_INFRA_I2C7, "infra_i2c7", "i2c_sel", 22),
+       GATE_INFRA3(CLK_INFRA_I2C8, "infra_i2c8", "i2c_sel", 23),
+       GATE_INFRA3(CLK_INFRA_FBIST2FPC, "infra_fbist2fpc", "msdc50_0_sel", 24),
 };
 
 static const struct mtk_gate_regs peri_cg_regs = {
@@ -941,140 +793,6 @@ static const struct mtk_gate peri_clks[] = {
        GATE_PERI(CLK_PERI_AXI, "peri_axi", "axi_sel", 31),
 };
 
-static const struct mtk_gate_regs apmixed_cg_regs = {
-       .set_ofs = 0x20,
-       .clr_ofs = 0x20,
-       .sta_ofs = 0x20,
-};
-
-#define GATE_APMIXED_FLAGS(_id, _name, _parent, _shift, _flags)        \
-       GATE_MTK_FLAGS(_id, _name, _parent, &apmixed_cg_regs,           \
-               _shift, &mtk_clk_gate_ops_no_setclr_inv, _flags)
-
-#define GATE_APMIXED(_id, _name, _parent, _shift)      \
-       GATE_APMIXED_FLAGS(_id, _name, _parent, _shift, 0)
-
-/*
- * CRITICAL CLOCK:
- * apmixed_appll26m is the toppest clock gate of all PLLs.
- */
-static const struct mtk_gate apmixed_clks[] = {
-       /* AUDIO0 */
-       GATE_APMIXED(CLK_APMIXED_SSUSB_26M, "apmixed_ssusb26m",
-               "f_f26m_ck", 4),
-       GATE_APMIXED_FLAGS(CLK_APMIXED_APPLL_26M, "apmixed_appll26m",
-               "f_f26m_ck", 5, CLK_IS_CRITICAL),
-       GATE_APMIXED(CLK_APMIXED_MIPIC0_26M, "apmixed_mipic026m",
-               "f_f26m_ck", 6),
-       GATE_APMIXED(CLK_APMIXED_MDPLLGP_26M, "apmixed_mdpll26m",
-               "f_f26m_ck", 7),
-       GATE_APMIXED(CLK_APMIXED_MMSYS_26M, "apmixed_mmsys26m",
-               "f_f26m_ck", 8),
-       GATE_APMIXED(CLK_APMIXED_UFS_26M, "apmixed_ufs26m",
-               "f_f26m_ck", 9),
-       GATE_APMIXED(CLK_APMIXED_MIPIC1_26M, "apmixed_mipic126m",
-               "f_f26m_ck", 11),
-       GATE_APMIXED(CLK_APMIXED_MEMPLL_26M, "apmixed_mempll26m",
-               "f_f26m_ck", 13),
-       GATE_APMIXED(CLK_APMIXED_CLKSQ_LVPLL_26M, "apmixed_lvpll26m",
-               "f_f26m_ck", 14),
-       GATE_APMIXED(CLK_APMIXED_MIPID0_26M, "apmixed_mipid026m",
-               "f_f26m_ck", 16),
-       GATE_APMIXED(CLK_APMIXED_MIPID1_26M, "apmixed_mipid126m",
-               "f_f26m_ck", 17),
-};
-
-#define MT8183_PLL_FMAX                (3800UL * MHZ)
-#define MT8183_PLL_FMIN                (1500UL * MHZ)
-
-#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,            \
-                       _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg,    \
-                       _pd_shift, _tuner_reg,  _tuner_en_reg,          \
-                       _tuner_en_bit, _pcw_reg, _pcw_shift,            \
-                       _pcw_chg_reg, _div_table) {                     \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .reg = _reg,                                            \
-               .pwr_reg = _pwr_reg,                                    \
-               .en_mask = _en_mask,                                    \
-               .flags = _flags,                                        \
-               .rst_bar_mask = _rst_bar_mask,                          \
-               .fmax = MT8183_PLL_FMAX,                                \
-               .fmin = MT8183_PLL_FMIN,                                \
-               .pcwbits = _pcwbits,                                    \
-               .pcwibits = _pcwibits,                                  \
-               .pd_reg = _pd_reg,                                      \
-               .pd_shift = _pd_shift,                                  \
-               .tuner_reg = _tuner_reg,                                \
-               .tuner_en_reg = _tuner_en_reg,                          \
-               .tuner_en_bit = _tuner_en_bit,                          \
-               .pcw_reg = _pcw_reg,                                    \
-               .pcw_shift = _pcw_shift,                                \
-               .pcw_chg_reg = _pcw_chg_reg,                            \
-               .div_table = _div_table,                                \
-       }
-
-#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags,              \
-                       _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg,    \
-                       _pd_shift, _tuner_reg, _tuner_en_reg,           \
-                       _tuner_en_bit, _pcw_reg, _pcw_shift,            \
-                       _pcw_chg_reg)                                   \
-               PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,     \
-                       _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg,    \
-                       _pd_shift, _tuner_reg, _tuner_en_reg,           \
-                       _tuner_en_bit, _pcw_reg, _pcw_shift,            \
-                       _pcw_chg_reg, NULL)
-
-static const struct mtk_pll_div_table armpll_div_table[] = {
-       { .div = 0, .freq = MT8183_PLL_FMAX },
-       { .div = 1, .freq = 1500 * MHZ },
-       { .div = 2, .freq = 750 * MHZ },
-       { .div = 3, .freq = 375 * MHZ },
-       { .div = 4, .freq = 187500000 },
-       { } /* sentinel */
-};
-
-static const struct mtk_pll_div_table mfgpll_div_table[] = {
-       { .div = 0, .freq = MT8183_PLL_FMAX },
-       { .div = 1, .freq = 1600 * MHZ },
-       { .div = 2, .freq = 800 * MHZ },
-       { .div = 3, .freq = 400 * MHZ },
-       { .div = 4, .freq = 200 * MHZ },
-       { } /* sentinel */
-};
-
-static const struct mtk_pll_data plls[] = {
-       PLL_B(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 0,
-               HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0204, 24, 0x0, 0x0, 0,
-               0x0204, 0, 0, armpll_div_table),
-       PLL_B(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x0210, 0x021C, 0,
-               HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0214, 24, 0x0, 0x0, 0,
-               0x0214, 0, 0, armpll_div_table),
-       PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x0290, 0x029C, 0,
-               HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0294, 24, 0x0, 0x0, 0,
-               0x0294, 0, 0),
-       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0,
-               HAVE_RST_BAR, BIT(24), 22, 8, 0x0224, 24, 0x0, 0x0, 0,
-               0x0224, 0, 0),
-       PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0230, 0x023C, 0,
-               HAVE_RST_BAR, BIT(24), 22, 8, 0x0234, 24, 0x0, 0x0, 0,
-               0x0234, 0, 0),
-       PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0,
-               0, 0, 22, 8, 0x0244, 24, 0x0, 0x0, 0, 0x0244, 0, 0,
-               mfgpll_div_table),
-       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0,
-               0, 0, 22, 8, 0x0254, 24, 0x0, 0x0, 0, 0x0254, 0, 0),
-       PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0260, 0x026C, 0,
-               0, 0, 22, 8, 0x0264, 24, 0x0, 0x0, 0, 0x0264, 0, 0),
-       PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0270, 0x027C, 0,
-               HAVE_RST_BAR, BIT(23), 22, 8, 0x0274, 24, 0x0, 0x0, 0,
-               0x0274, 0, 0),
-       PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0,
-               0, 0, 32, 8, 0x02A0, 1, 0x02A8, 0x0014, 0, 0x02A4, 0, 0x02A0),
-       PLL(CLK_APMIXED_APLL2, "apll2", 0x02b4, 0x02c4, 0,
-               0, 0, 32, 8, 0x02B4, 1, 0x02BC, 0x0014, 1, 0x02B8, 0, 0x02B4),
-};
-
 static u16 infra_rst_ofs[] = {
        INFRA_RST0_SET_OFFSET,
        INFRA_RST1_SET_OFFSET,
@@ -1088,41 +806,6 @@ static const struct mtk_clk_rst_desc clk_rst_desc = {
        .rst_bank_nr = ARRAY_SIZE(infra_rst_ofs),
 };
 
-static int clk_mt8183_apmixed_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
-
-       mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
-
-       mtk_clk_register_gates(&pdev->dev, node, apmixed_clks,
-                              ARRAY_SIZE(apmixed_clks), clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
-
-static struct clk_hw_onecell_data *top_clk_data;
-
-static void clk_mt8183_top_init_early(struct device_node *node)
-{
-       int i;
-
-       top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
-
-       for (i = 0; i < CLK_TOP_NR_CLK; i++)
-               top_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER);
-
-       mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
-                       top_clk_data);
-
-       of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data);
-}
-
-CLK_OF_DECLARE_DRIVER(mt8183_topckgen, "mediatek,mt8183-topckgen",
-                       clk_mt8183_top_init_early);
-
 /* Register mux notifier for MFG mux */
 static int clk_mt8183_reg_mfg_mux_notifier(struct device *dev, struct clk *clk)
 {
@@ -1145,137 +828,55 @@ static int clk_mt8183_reg_mfg_mux_notifier(struct device *dev, struct clk *clk)
        return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb);
 }
 
-static int clk_mt8183_top_probe(struct platform_device *pdev)
-{
-       void __iomem *base;
-       struct device_node *node = pdev->dev.of_node;
-       int ret;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
-               top_clk_data);
-
-       mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
-               top_clk_data);
-
-       mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
-
-       mtk_clk_register_muxes(&pdev->dev, top_muxes,
-                              ARRAY_SIZE(top_muxes), node,
-                              &mt8183_clk_lock, top_clk_data);
-
-       mtk_clk_register_composites(&pdev->dev, top_aud_comp,
-                                   ARRAY_SIZE(top_aud_comp), base,
-                                   &mt8183_clk_lock, top_clk_data);
-
-       mtk_clk_register_gates(&pdev->dev, node, top_clks,
-                              ARRAY_SIZE(top_clks), top_clk_data);
-
-       ret = clk_mt8183_reg_mfg_mux_notifier(&pdev->dev,
-                                             top_clk_data->hws[CLK_TOP_MUX_MFG]->clk);
-       if (ret)
-               return ret;
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
-                                     top_clk_data);
-}
-
-static int clk_mt8183_mcu_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-       void __iomem *base;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       clk_data = mtk_alloc_clk_data(CLK_MCU_NR_CLK);
-
-       mtk_clk_register_composites(&pdev->dev, mcu_muxes,
-                                   ARRAY_SIZE(mcu_muxes), base,
-                                   &mt8183_clk_lock, clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
-
-static const struct of_device_id of_match_clk_mt8183[] = {
-       {
-               .compatible = "mediatek,mt8183-apmixedsys",
-               .data = clk_mt8183_apmixed_probe,
-       }, {
-               .compatible = "mediatek,mt8183-topckgen",
-               .data = clk_mt8183_top_probe,
-       }, {
-               .compatible = "mediatek,mt8183-mcucfg",
-               .data = clk_mt8183_mcu_probe,
-       }, {
-               /* sentinel */
-       }
-};
-
-static int clk_mt8183_probe(struct platform_device *pdev)
-{
-       int (*clk_probe)(struct platform_device *pdev);
-       int r;
-
-       clk_probe = of_device_get_match_data(&pdev->dev);
-       if (!clk_probe)
-               return -EINVAL;
-
-       r = clk_probe(pdev);
-       if (r)
-               dev_err(&pdev->dev,
-                       "could not register clock provider: %s: %d\n",
-                       pdev->name, r);
-
-       return r;
-}
-
 static const struct mtk_clk_desc infra_desc = {
        .clks = infra_clks,
        .num_clks = ARRAY_SIZE(infra_clks),
        .rst_desc = &clk_rst_desc,
 };
 
+static const struct mtk_clk_desc mcu_desc = {
+       .composite_clks = mcu_muxes,
+       .num_composite_clks = ARRAY_SIZE(mcu_muxes),
+       .clk_lock = &mt8183_clk_lock,
+};
+
 static const struct mtk_clk_desc peri_desc = {
        .clks = peri_clks,
        .num_clks = ARRAY_SIZE(peri_clks),
 };
 
-static const struct of_device_id of_match_clk_mt8183_simple[] = {
+static const struct mtk_clk_desc topck_desc = {
+       .fixed_clks = top_fixed_clks,
+       .num_fixed_clks = ARRAY_SIZE(top_fixed_clks),
+       .factor_clks = top_divs,
+       .num_factor_clks = ARRAY_SIZE(top_divs),
+       .mux_clks = top_muxes,
+       .num_mux_clks = ARRAY_SIZE(top_muxes),
+       .composite_clks = top_aud_comp,
+       .num_composite_clks = ARRAY_SIZE(top_aud_comp),
+       .clks = top_clks,
+       .num_clks = ARRAY_SIZE(top_clks),
+       .clk_lock = &mt8183_clk_lock,
+       .clk_notifier_func = clk_mt8183_reg_mfg_mux_notifier,
+       .mfg_clk_idx = CLK_TOP_MUX_MFG,
+};
+
+static const struct of_device_id of_match_clk_mt8183[] = {
        { .compatible = "mediatek,mt8183-infracfg", .data = &infra_desc },
+       { .compatible = "mediatek,mt8183-mcucfg", .data = &mcu_desc },
        { .compatible = "mediatek,mt8183-pericfg", .data = &peri_desc, },
+       { .compatible = "mediatek,mt8183-topckgen", .data = &topck_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8183);
 
-static struct platform_driver clk_mt8183_simple_drv = {
+static struct platform_driver clk_mt8183_drv = {
        .probe = mtk_clk_simple_probe,
        .remove = mtk_clk_simple_remove,
-       .driver = {
-               .name = "clk-mt8183-simple",
-               .of_match_table = of_match_clk_mt8183_simple,
-       },
-};
-
-static struct platform_driver clk_mt8183_drv = {
-       .probe = clk_mt8183_probe,
        .driver = {
                .name = "clk-mt8183",
                .of_match_table = of_match_clk_mt8183,
        },
 };
-
-static int __init clk_mt8183_init(void)
-{
-       int ret = platform_driver_register(&clk_mt8183_drv);
-
-       if (ret)
-               return ret;
-       return platform_driver_register(&clk_mt8183_simple_drv);
-}
-
-arch_initcall(clk_mt8183_init);
+module_platform_driver(clk_mt8183_drv)
+MODULE_LICENSE("GPL");
index 1d673c6278a9dc354ae850eed32e2c44cf91fe5c..da7950d51c64e095f978b6583a010af939041ed8 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/platform_device.h>
 #include <dt-bindings/clock/mt8186-clk.h>
 
+#include "clk-fhctl.h"
 #include "clk-mtk.h"
 #include "clk-pll.h"
 #include "clk-pllfh.h"
@@ -98,6 +99,7 @@ enum fh_pll_id {
                .data = {                                               \
                        .pll_id = _pllid,                               \
                        .fh_id = _fhid,                                 \
+                       .fh_ver = FHCTL_PLLFH_V2,                       \
                        .fhx_offset = _offset,                          \
                        .dds_mask = GENMASK(21, 0),                     \
                        .slope0_value = 0x6003c97,                      \
@@ -134,6 +136,7 @@ static const struct of_device_id of_match_clk_mt8186_apmixed[] = {
        { .compatible = "mediatek,mt8186-apmixedsys", },
        {}
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_apmixed);
 
 static int clk_mt8186_apmixed_probe(struct platform_device *pdev)
 {
@@ -190,4 +193,5 @@ static struct platform_driver clk_mt8186_apmixed_drv = {
                .of_match_table = of_match_clk_mt8186_apmixed,
        },
 };
-builtin_platform_driver(clk_mt8186_apmixed_drv);
+module_platform_driver(clk_mt8186_apmixed_drv);
+MODULE_LICENSE("GPL");
index 9ec345a2ce66f8abfcf6967249bbe12ebfa217cd..656d9e6f3ee2b7fe3a834c2bbb9aa7e8c3d31d69 100644 (file)
@@ -78,6 +78,7 @@ static const struct of_device_id of_match_clk_mt8186_cam[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_cam);
 
 static struct platform_driver clk_mt8186_cam_drv = {
        .probe = mtk_clk_simple_probe,
@@ -87,4 +88,5 @@ static struct platform_driver clk_mt8186_cam_drv = {
                .of_match_table = of_match_clk_mt8186_cam,
        },
 };
-builtin_platform_driver(clk_mt8186_cam_drv);
+module_platform_driver(clk_mt8186_cam_drv);
+MODULE_LICENSE("GPL");
index 08a625475aeee28d6943e841e8f328fa04289d78..754b27f038176ae5f612138c5aff209019f5e18b 100644 (file)
@@ -56,6 +56,7 @@ static const struct of_device_id of_match_clk_mt8186_img[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_img);
 
 static struct platform_driver clk_mt8186_img_drv = {
        .probe = mtk_clk_simple_probe,
@@ -65,4 +66,5 @@ static struct platform_driver clk_mt8186_img_drv = {
                .of_match_table = of_match_clk_mt8186_img,
        },
 };
-builtin_platform_driver(clk_mt8186_img_drv);
+module_platform_driver(clk_mt8186_img_drv);
+MODULE_LICENSE("GPL");
index 47f2e480a05ebf98a18d510e699cf7fef222843b..7619c357b150d7fd40b3ac538e57da160a10ea31 100644 (file)
@@ -55,6 +55,7 @@ static const struct of_device_id of_match_clk_mt8186_imp_iic_wrap[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_imp_iic_wrap);
 
 static struct platform_driver clk_mt8186_imp_iic_wrap_drv = {
        .probe = mtk_clk_simple_probe,
@@ -64,4 +65,5 @@ static struct platform_driver clk_mt8186_imp_iic_wrap_drv = {
                .of_match_table = of_match_clk_mt8186_imp_iic_wrap,
        },
 };
-builtin_platform_driver(clk_mt8186_imp_iic_wrap_drv);
+module_platform_driver(clk_mt8186_imp_iic_wrap_drv);
+MODULE_LICENSE("GPL");
index df2a6bd1aefaf95a110d53bd20aa9cd0bc7ee44e..a907a5def5b8c3830c7568984d1f956f25e2a14e 100644 (file)
@@ -227,6 +227,7 @@ static const struct of_device_id of_match_clk_mt8186_infra_ao[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_infra_ao);
 
 static struct platform_driver clk_mt8186_infra_ao_drv = {
        .probe = mtk_clk_simple_probe,
@@ -236,4 +237,5 @@ static struct platform_driver clk_mt8186_infra_ao_drv = {
                .of_match_table = of_match_clk_mt8186_infra_ao,
        },
 };
-builtin_platform_driver(clk_mt8186_infra_ao_drv);
+module_platform_driver(clk_mt8186_infra_ao_drv);
+MODULE_LICENSE("GPL");
index 8fca148effa6f52dbae454ea6328287922f9e4f0..50e340035aa70e599b573fc97a3071eabe842d91 100644 (file)
@@ -43,6 +43,7 @@ static const struct of_device_id of_match_clk_mt8186_ipe[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_ipe);
 
 static struct platform_driver clk_mt8186_ipe_drv = {
        .probe = mtk_clk_simple_probe,
@@ -52,4 +53,5 @@ static struct platform_driver clk_mt8186_ipe_drv = {
                .of_match_table = of_match_clk_mt8186_ipe,
        },
 };
-builtin_platform_driver(clk_mt8186_ipe_drv);
+module_platform_driver(clk_mt8186_ipe_drv);
+MODULE_LICENSE("GPL");
index e52a2d986c99c9f4fbd8f5006fb2d3d58c7ca2cc..d1640e4dc2adbdc0683800416b19f8ea3c58785a 100644 (file)
@@ -43,67 +43,26 @@ static struct mtk_composite mcu_muxes[] = {
        MUX(CLK_MCU_ARMPLL_BUS_SEL, "mcu_armpll_bus_sel", mcu_armpll_bus_parents, 0x2E0, 9, 2),
 };
 
-static const struct of_device_id of_match_clk_mt8186_mcu[] = {
-       { .compatible = "mediatek,mt8186-mcusys", },
-       {}
+static const struct mtk_clk_desc mcu_desc = {
+       .composite_clks = mcu_muxes,
+       .num_composite_clks = ARRAY_SIZE(mcu_muxes),
 };
 
-static int clk_mt8186_mcu_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-       int r;
-       void __iomem *base;
-
-       clk_data = mtk_alloc_clk_data(CLK_MCU_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base)) {
-               r = PTR_ERR(base);
-               goto free_mcu_data;
-       }
-
-       r = mtk_clk_register_composites(&pdev->dev, mcu_muxes,
-                                       ARRAY_SIZE(mcu_muxes), base,
-                                       NULL, clk_data);
-       if (r)
-               goto free_mcu_data;
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               goto unregister_composite_muxes;
-
-       platform_set_drvdata(pdev, clk_data);
-
-       return r;
-
-unregister_composite_muxes:
-       mtk_clk_unregister_composites(mcu_muxes, ARRAY_SIZE(mcu_muxes), clk_data);
-free_mcu_data:
-       mtk_free_clk_data(clk_data);
-       return r;
-}
-
-static int clk_mt8186_mcu_remove(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-       struct device_node *node = pdev->dev.of_node;
-
-       of_clk_del_provider(node);
-       mtk_clk_unregister_composites(mcu_muxes, ARRAY_SIZE(mcu_muxes), clk_data);
-       mtk_free_clk_data(clk_data);
-
-       return 0;
-}
+static const struct of_device_id of_match_clk_mt8186_mcu[] = {
+       { .compatible = "mediatek,mt8186-mcusys", .data = &mcu_desc },
+       { /* sentinel */}
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_mcu);
 
 static struct platform_driver clk_mt8186_mcu_drv = {
-       .probe = clk_mt8186_mcu_probe,
-       .remove = clk_mt8186_mcu_remove,
        .driver = {
                .name = "clk-mt8186-mcu",
                .of_match_table = of_match_clk_mt8186_mcu,
        },
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
 };
-builtin_platform_driver(clk_mt8186_mcu_drv);
+module_platform_driver(clk_mt8186_mcu_drv);
+
+MODULE_DESCRIPTION("MediaTek MT8186 mcusys clocks driver");
+MODULE_LICENSE("GPL");
index 05174088ef20ad40d8a0c406876a0a19075d5162..e1d19007e3754f8309577818c5289badeefcac2a 100644 (file)
@@ -68,6 +68,7 @@ static const struct of_device_id of_match_clk_mt8186_mdp[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_mdp);
 
 static struct platform_driver clk_mt8186_mdp_drv = {
        .probe = mtk_clk_simple_probe,
@@ -77,4 +78,5 @@ static struct platform_driver clk_mt8186_mdp_drv = {
                .of_match_table = of_match_clk_mt8186_mdp,
        },
 };
-builtin_platform_driver(clk_mt8186_mdp_drv);
+module_platform_driver(clk_mt8186_mdp_drv);
+MODULE_LICENSE("GPL");
index 0142d741053afe68ca9b82b4ac2a939a396ef093..aeb098b54585e70ef391889ae0c78936f6abb1c9 100644 (file)
@@ -37,6 +37,7 @@ static const struct of_device_id of_match_clk_mt8186_mfg[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_mfg);
 
 static struct platform_driver clk_mt8186_mfg_drv = {
        .probe = mtk_clk_simple_probe,
@@ -46,4 +47,5 @@ static struct platform_driver clk_mt8186_mfg_drv = {
                .of_match_table = of_match_clk_mt8186_mfg,
        },
 };
-builtin_platform_driver(clk_mt8186_mfg_drv);
+module_platform_driver(clk_mt8186_mfg_drv);
+MODULE_LICENSE("GPL");
index 0b72607777fa1657615d8703995f199dec41b185..fc3bb6d1f7148411957ed0600d08bc55a011ced0 100644 (file)
@@ -58,55 +58,24 @@ static const struct mtk_gate mm_clks[] = {
        GATE_MM1(CLK_MM_DISP_26M, "mm_disp_26m_ck", "top_disp", 10),
 };
 
-static int clk_mt8186_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       r = mtk_clk_register_gates(&pdev->dev, node, mm_clks,
-                                  ARRAY_SIZE(mm_clks), clk_data);
-       if (r)
-               goto free_mm_data;
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               goto unregister_gates;
-
-       platform_set_drvdata(pdev, clk_data);
-
-       return r;
-
-unregister_gates:
-       mtk_clk_unregister_gates(mm_clks, ARRAY_SIZE(mm_clks), clk_data);
-free_mm_data:
-       mtk_free_clk_data(clk_data);
-       return r;
-}
-
-static int clk_mt8186_mm_remove(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-
-       of_clk_del_provider(node);
-       mtk_clk_unregister_gates(mm_clks, ARRAY_SIZE(mm_clks), clk_data);
-       mtk_free_clk_data(clk_data);
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mm_clks,
+       .num_clks = ARRAY_SIZE(mm_clks),
+};
 
-       return 0;
-}
+static const struct platform_device_id clk_mt8186_mm_id_table[] = {
+       { .name = "clk-mt8186-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8186_mm_id_table);
 
 static struct platform_driver clk_mt8186_mm_drv = {
-       .probe = clk_mt8186_mm_probe,
-       .remove = clk_mt8186_mm_remove,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt8186-mm",
        },
+       .id_table = clk_mt8186_mm_id_table,
 };
-builtin_platform_driver(clk_mt8186_mm_drv);
+module_platform_driver(clk_mt8186_mm_drv);
+MODULE_LICENSE("GPL");
index c6786c8b315ffea76273e515800cdf133a068dd8..1a0340a20bebecbbf698bf638c19e336d240b26a 100644 (file)
@@ -721,6 +721,7 @@ static const struct of_device_id of_match_clk_mt8186_topck[] = {
        { .compatible = "mediatek,mt8186-topckgen", .data = &topck_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_topck);
 
 static struct platform_driver clk_mt8186_topck_drv = {
        .probe = mtk_clk_simple_probe,
@@ -730,4 +731,5 @@ static struct platform_driver clk_mt8186_topck_drv = {
                .of_match_table = of_match_clk_mt8186_topck,
        },
 };
-builtin_platform_driver(clk_mt8186_topck_drv);
+module_platform_driver(clk_mt8186_topck_drv);
+MODULE_LICENSE("GPL");
index 5ad7e1ae0bacd5df120313503b2426fba5b98f37..9bf3b86328703887c960b835075bd3cccf826502 100644 (file)
@@ -76,6 +76,7 @@ static const struct of_device_id of_match_clk_mt8186_vdec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_vdec);
 
 static struct platform_driver clk_mt8186_vdec_drv = {
        .probe = mtk_clk_simple_probe,
@@ -85,4 +86,5 @@ static struct platform_driver clk_mt8186_vdec_drv = {
                .of_match_table = of_match_clk_mt8186_vdec,
        },
 };
-builtin_platform_driver(clk_mt8186_vdec_drv);
+module_platform_driver(clk_mt8186_vdec_drv);
+MODULE_LICENSE("GPL");
index f5519f794c4569d8005ff3c28250ac4ff1f76879..0c1bc94e84cf77ae3f55bf104a75c208a740fac0 100644 (file)
@@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8186_venc[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_venc);
 
 static struct platform_driver clk_mt8186_venc_drv = {
        .probe = mtk_clk_simple_probe,
@@ -48,4 +49,5 @@ static struct platform_driver clk_mt8186_venc_drv = {
                .of_match_table = of_match_clk_mt8186_venc,
        },
 };
-builtin_platform_driver(clk_mt8186_venc_drv);
+module_platform_driver(clk_mt8186_venc_drv);
+MODULE_LICENSE("GPL");
index 8db3e9178a1ec43d1580429378c2da722ca57dca..c4727b1cb64d8db44c087430675a03403562b2fd 100644 (file)
@@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8186_wpe[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_wpe);
 
 static struct platform_driver clk_mt8186_wpe_drv = {
        .probe = mtk_clk_simple_probe,
@@ -48,4 +49,5 @@ static struct platform_driver clk_mt8186_wpe_drv = {
                .of_match_table = of_match_clk_mt8186_wpe,
        },
 };
-builtin_platform_driver(clk_mt8186_wpe_drv);
+module_platform_driver(clk_mt8186_wpe_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c b/drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c
new file mode 100644 (file)
index 0000000..808f2ad
--- /dev/null
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs adsp_audio26m_cg_regs = {
+       .set_ofs = 0x80,
+       .clr_ofs = 0x80,
+       .sta_ofs = 0x80,
+};
+
+#define GATE_ADSP_FLAGS(_id, _name, _parent, _shift)           \
+       GATE_MTK(_id, _name, _parent, &adsp_audio26m_cg_regs, _shift,           \
+               &mtk_clk_gate_ops_no_setclr)
+
+static const struct mtk_gate adsp_audio26m_clks[] = {
+       GATE_ADSP_FLAGS(CLK_AUDIODSP_AUDIO26M, "audiodsp_audio26m", "clk26m", 3),
+};
+
+static const struct mtk_clk_desc adsp_audio26m_desc = {
+       .clks = adsp_audio26m_clks,
+       .num_clks = ARRAY_SIZE(adsp_audio26m_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_adsp_audio26m[] = {
+       { .compatible = "mediatek,mt8188-adsp-audio26m", .data = &adsp_audio26m_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_adsp_audio26m);
+
+static struct platform_driver clk_mt8188_adsp_audio26m_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-adsp_audio26m",
+               .of_match_table = of_match_clk_mt8188_adsp_audio26m,
+       },
+};
+module_platform_driver(clk_mt8188_adsp_audio26m_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-apmixedsys.c b/drivers/clk/mediatek/clk-mt8188-apmixedsys.c
new file mode 100644 (file)
index 0000000..9d21da2
--- /dev/null
@@ -0,0 +1,157 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+#include "clk-pll.h"
+
+static const struct mtk_gate_regs apmixed_cg_regs = {
+       .set_ofs = 0x8,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x8,
+};
+
+#define GATE_APMIXED(_id, _name, _parent, _shift)                      \
+       GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+static const struct mtk_gate apmixed_clks[] = {
+       GATE_APMIXED(CLK_APMIXED_PLL_SSUSB26M_EN, "pll_ssusb26m_en", "clk26m", 1),
+};
+
+#define MT8188_PLL_FMAX                (3800UL * MHZ)
+#define MT8188_PLL_FMIN                (1500UL * MHZ)
+#define MT8188_INTEGER_BITS    8
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags,              \
+           _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift,                \
+           _tuner_reg, _tuner_en_reg, _tuner_en_bit,                   \
+           _pcw_reg, _pcw_shift, _pcw_chg_reg,                         \
+           _en_reg, _pll_en_bit) {                                     \
+               .id = _id,                                              \
+               .name = _name,                                          \
+               .reg = _reg,                                            \
+               .pwr_reg = _pwr_reg,                                    \
+               .en_mask = _en_mask,                                    \
+               .flags = _flags,                                        \
+               .rst_bar_mask = _rst_bar_mask,                          \
+               .fmax = MT8188_PLL_FMAX,                                \
+               .fmin = MT8188_PLL_FMIN,                                \
+               .pcwbits = _pcwbits,                                    \
+               .pcwibits = MT8188_INTEGER_BITS,                        \
+               .pd_reg = _pd_reg,                                      \
+               .pd_shift = _pd_shift,                                  \
+               .tuner_reg = _tuner_reg,                                \
+               .tuner_en_reg = _tuner_en_reg,                          \
+               .tuner_en_bit = _tuner_en_bit,                          \
+               .pcw_reg = _pcw_reg,                                    \
+               .pcw_shift = _pcw_shift,                                \
+               .pcw_chg_reg = _pcw_chg_reg,                            \
+               .en_reg = _en_reg,                                      \
+               .pll_en_bit = _pll_en_bit,                              \
+       }
+
+static const struct mtk_pll_data plls[] = {
+       PLL(CLK_APMIXED_ETHPLL, "ethpll", 0x044C, 0x0458, 0,
+           0, 0, 22, 0x0450, 24, 0, 0, 0, 0x0450, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0514, 0x0520, 0,
+           0, 0, 22, 0x0518, 24, 0, 0, 0, 0x0518, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_TVDPLL1, "tvdpll1", 0x0524, 0x0530, 0,
+           0, 0, 22, 0x0528, 24, 0, 0, 0, 0x0528, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_TVDPLL2, "tvdpll2", 0x0534, 0x0540, 0,
+           0, 0, 22, 0x0538, 24, 0, 0, 0, 0x0538, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0544, 0x0550, 0xff000000,
+           HAVE_RST_BAR, BIT(23), 22, 0x0548, 24, 0, 0, 0, 0x0548, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x045C, 0x0468, 0xff000000,
+           HAVE_RST_BAR, BIT(23), 22, 0x0460, 24, 0, 0, 0, 0x0460, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_IMGPLL, "imgpll", 0x0554, 0x0560, 0,
+           0, 0, 22, 0x0558, 24, 0, 0, 0, 0x0558, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0504, 0x0510, 0xff000000,
+           HAVE_RST_BAR, BIT(23), 22, 0x0508, 24, 0, 0, 0, 0x0508, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_ADSPPLL, "adsppll", 0x042C, 0x0438, 0,
+           0, 0, 22, 0x0430, 24, 0, 0, 0, 0x0430, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL1, "apll1", 0x0304, 0x0314, 0,
+           0, 0, 32, 0x0308, 24, 0x0034, 0x0000, 12, 0x030C, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL2, "apll2", 0x0318, 0x0328, 0,
+           0, 0, 32, 0x031C, 24, 0x0038, 0x0000, 13, 0x0320, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL3, "apll3", 0x032C, 0x033C, 0,
+           0, 0, 32, 0x0330, 24, 0x003C, 0x0000, 14, 0x0334, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL4, "apll4", 0x0404, 0x0414, 0,
+           0, 0, 32, 0x0408, 24, 0x0040, 0x0000, 15, 0x040C, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL5, "apll5", 0x0418, 0x0428, 0,
+           0, 0, 32, 0x041C, 24, 0x0044, 0x0000, 16, 0x0420, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0340, 0x034C, 0,
+           0, 0, 22, 0x0344, 24, 0, 0, 0, 0x0344, 0, 0, 0, 9),
+};
+
+static const struct of_device_id of_match_clk_mt8188_apmixed[] = {
+       { .compatible = "mediatek,mt8188-apmixedsys" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_apmixed);
+
+static int clk_mt8188_apmixed_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       int r;
+
+       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       if (r)
+               goto free_apmixed_data;
+
+       r = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks,
+                                  ARRAY_SIZE(apmixed_clks), clk_data);
+       if (r)
+               goto unregister_plls;
+
+       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (r)
+               goto unregister_gates;
+
+       platform_set_drvdata(pdev, clk_data);
+
+       return 0;
+
+unregister_gates:
+       mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
+unregister_plls:
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+free_apmixed_data:
+       mtk_free_clk_data(clk_data);
+       return r;
+}
+
+static int clk_mt8188_apmixed_remove(struct platform_device *pdev)
+{
+       struct device_node *node = pdev->dev.of_node;
+       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+       of_clk_del_provider(node);
+       mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+       mtk_free_clk_data(clk_data);
+
+       return 0;
+}
+
+static struct platform_driver clk_mt8188_apmixed_drv = {
+       .probe = clk_mt8188_apmixed_probe,
+       .remove = clk_mt8188_apmixed_remove,
+       .driver = {
+               .name = "clk-mt8188-apmixed",
+               .of_match_table = of_match_clk_mt8188_apmixed,
+       },
+};
+module_platform_driver(clk_mt8188_apmixed_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-cam.c b/drivers/clk/mediatek/clk-mt8188-cam.c
new file mode 100644 (file)
index 0000000..c5a3856
--- /dev/null
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs cam_cg_regs = {
+       .set_ofs = 0x4,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_CAM(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &cam_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate cam_main_clks[] = {
+       GATE_CAM(CLK_CAM_MAIN_LARB13, "cam_main_larb13", "top_cam", 0),
+       GATE_CAM(CLK_CAM_MAIN_LARB14, "cam_main_larb14", "top_cam", 1),
+       GATE_CAM(CLK_CAM_MAIN_CAM, "cam_main_cam", "top_cam", 2),
+       GATE_CAM(CLK_CAM_MAIN_CAM_SUBA, "cam_main_cam_suba", "top_cam", 3),
+       GATE_CAM(CLK_CAM_MAIN_CAM_SUBB, "cam_main_cam_subb", "top_cam", 4),
+       GATE_CAM(CLK_CAM_MAIN_CAMTG, "cam_main_camtg", "top_cam", 7),
+       GATE_CAM(CLK_CAM_MAIN_SENINF, "cam_main_seninf", "top_cam", 8),
+       GATE_CAM(CLK_CAM_MAIN_GCAMSVA, "cam_main_gcamsva", "top_cam", 9),
+       GATE_CAM(CLK_CAM_MAIN_GCAMSVB, "cam_main_gcamsvb", "top_cam", 10),
+       GATE_CAM(CLK_CAM_MAIN_GCAMSVC, "cam_main_gcamsvc", "top_cam", 11),
+       GATE_CAM(CLK_CAM_MAIN_GCAMSVD, "cam_main_gcamsvd", "top_cam", 12),
+       GATE_CAM(CLK_CAM_MAIN_GCAMSVE, "cam_main_gcamsve", "top_cam", 13),
+       GATE_CAM(CLK_CAM_MAIN_GCAMSVF, "cam_main_gcamsvf", "top_cam", 14),
+       GATE_CAM(CLK_CAM_MAIN_GCAMSVG, "cam_main_gcamsvg", "top_cam", 15),
+       GATE_CAM(CLK_CAM_MAIN_GCAMSVH, "cam_main_gcamsvh", "top_cam", 16),
+       GATE_CAM(CLK_CAM_MAIN_GCAMSVI, "cam_main_gcamsvi", "top_cam", 17),
+       GATE_CAM(CLK_CAM_MAIN_GCAMSVJ, "cam_main_gcamsvj", "top_cam", 18),
+       GATE_CAM(CLK_CAM_MAIN_CAMSV_TOP, "cam_main_camsv", "top_cam", 19),
+       GATE_CAM(CLK_CAM_MAIN_CAMSV_CQ_A, "cam_main_camsv_cq_a", "top_cam", 20),
+       GATE_CAM(CLK_CAM_MAIN_CAMSV_CQ_B, "cam_main_camsv_cq_b", "top_cam", 21),
+       GATE_CAM(CLK_CAM_MAIN_CAMSV_CQ_C, "cam_main_camsv_cq_c", "top_cam", 22),
+       GATE_CAM(CLK_CAM_MAIN_FAKE_ENG, "cam_main_fake_eng", "top_cam", 28),
+       GATE_CAM(CLK_CAM_MAIN_CAM2MM0_GALS, "cam_main_cam2mm0_gals", "top_cam", 29),
+       GATE_CAM(CLK_CAM_MAIN_CAM2MM1_GALS, "cam_main_cam2mm1_gals", "top_cam", 30),
+       GATE_CAM(CLK_CAM_MAIN_CAM2SYS_GALS, "cam_main_cam2sys_gals", "top_cam", 31),
+};
+
+static const struct mtk_gate cam_rawa_clks[] = {
+       GATE_CAM(CLK_CAM_RAWA_LARBX, "cam_rawa_larbx", "top_cam", 0),
+       GATE_CAM(CLK_CAM_RAWA_CAM, "cam_rawa_cam", "top_cam", 1),
+       GATE_CAM(CLK_CAM_RAWA_CAMTG, "cam_rawa_camtg", "top_cam", 2),
+};
+
+static const struct mtk_gate cam_rawb_clks[] = {
+       GATE_CAM(CLK_CAM_RAWB_LARBX, "cam_rawb_larbx", "top_cam", 0),
+       GATE_CAM(CLK_CAM_RAWB_CAM, "cam_rawb_cam", "top_cam", 1),
+       GATE_CAM(CLK_CAM_RAWB_CAMTG, "cam_rawb_camtg", "top_cam", 2),
+};
+
+static const struct mtk_gate cam_yuva_clks[] = {
+       GATE_CAM(CLK_CAM_YUVA_LARBX, "cam_yuva_larbx", "top_cam", 0),
+       GATE_CAM(CLK_CAM_YUVA_CAM, "cam_yuva_cam", "top_cam", 1),
+       GATE_CAM(CLK_CAM_YUVA_CAMTG, "cam_yuva_camtg", "top_cam", 2),
+};
+
+static const struct mtk_gate cam_yuvb_clks[] = {
+       GATE_CAM(CLK_CAM_YUVB_LARBX, "cam_yuvb_larbx", "top_cam", 0),
+       GATE_CAM(CLK_CAM_YUVB_CAM, "cam_yuvb_cam", "top_cam", 1),
+       GATE_CAM(CLK_CAM_YUVB_CAMTG, "cam_yuvb_camtg", "top_cam", 2),
+};
+
+static const struct mtk_clk_desc cam_main_desc = {
+       .clks = cam_main_clks,
+       .num_clks = ARRAY_SIZE(cam_main_clks),
+};
+
+static const struct mtk_clk_desc cam_rawa_desc = {
+       .clks = cam_rawa_clks,
+       .num_clks = ARRAY_SIZE(cam_rawa_clks),
+};
+
+static const struct mtk_clk_desc cam_rawb_desc = {
+       .clks = cam_rawb_clks,
+       .num_clks = ARRAY_SIZE(cam_rawb_clks),
+};
+
+static const struct mtk_clk_desc cam_yuva_desc = {
+       .clks = cam_yuva_clks,
+       .num_clks = ARRAY_SIZE(cam_yuva_clks),
+};
+
+static const struct mtk_clk_desc cam_yuvb_desc = {
+       .clks = cam_yuvb_clks,
+       .num_clks = ARRAY_SIZE(cam_yuvb_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_cam[] = {
+       { .compatible = "mediatek,mt8188-camsys", .data = &cam_main_desc },
+       { .compatible = "mediatek,mt8188-camsys-rawa", .data = &cam_rawa_desc },
+       { .compatible = "mediatek,mt8188-camsys-rawb", .data = &cam_rawb_desc },
+       { .compatible = "mediatek,mt8188-camsys-yuva", .data = &cam_yuva_desc },
+       { .compatible = "mediatek,mt8188-camsys-yuvb", .data = &cam_yuvb_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_cam);
+
+static struct platform_driver clk_mt8188_cam_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-cam",
+               .of_match_table = of_match_clk_mt8188_cam,
+       },
+};
+
+module_platform_driver(clk_mt8188_cam_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-ccu.c b/drivers/clk/mediatek/clk-mt8188-ccu.c
new file mode 100644 (file)
index 0000000..ebc0d3a
--- /dev/null
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs ccu_cg_regs = {
+       .set_ofs = 0x4,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_CCU(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &ccu_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate ccu_clks[] = {
+       GATE_CCU(CLK_CCU_LARB27, "ccu_larb27", "top_ccu", 0),
+       GATE_CCU(CLK_CCU_AHB, "ccu_ahb", "top_ccu", 1),
+       GATE_CCU(CLK_CCU_CCU0, "ccu_ccu0", "top_ccu", 2),
+};
+
+static const struct mtk_clk_desc ccu_desc = {
+       .clks = ccu_clks,
+       .num_clks = ARRAY_SIZE(ccu_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_ccu[] = {
+       { .compatible = "mediatek,mt8188-ccusys", .data = &ccu_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_ccu);
+
+static struct platform_driver clk_mt8188_ccu_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-ccu",
+               .of_match_table = of_match_clk_mt8188_ccu,
+       },
+};
+
+module_platform_driver(clk_mt8188_ccu_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-img.c b/drivers/clk/mediatek/clk-mt8188-img.c
new file mode 100644 (file)
index 0000000..b462287
--- /dev/null
@@ -0,0 +1,112 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs imgsys_cg_regs = {
+       .set_ofs = 0x4,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_IMGSYS(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &imgsys_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate imgsys_main_clks[] = {
+       GATE_IMGSYS(CLK_IMGSYS_MAIN_LARB9, "imgsys_main_larb9", "top_img", 0),
+       GATE_IMGSYS(CLK_IMGSYS_MAIN_TRAW0, "imgsys_main_traw0", "top_img", 1),
+       GATE_IMGSYS(CLK_IMGSYS_MAIN_TRAW1, "imgsys_main_traw1", "top_img", 2),
+       GATE_IMGSYS(CLK_IMGSYS_MAIN_VCORE_GALS, "imgsys_main_vcore_gals", "top_img", 3),
+       GATE_IMGSYS(CLK_IMGSYS_MAIN_DIP0, "imgsys_main_dip0", "top_img", 8),
+       GATE_IMGSYS(CLK_IMGSYS_MAIN_WPE0, "imgsys_main_wpe0", "top_img", 9),
+       GATE_IMGSYS(CLK_IMGSYS_MAIN_IPE, "imgsys_main_ipe", "top_img", 10),
+       GATE_IMGSYS(CLK_IMGSYS_MAIN_WPE1, "imgsys_main_wpe1", "top_img", 12),
+       GATE_IMGSYS(CLK_IMGSYS_MAIN_WPE2, "imgsys_main_wpe2", "top_img", 13),
+       GATE_IMGSYS(CLK_IMGSYS_MAIN_GALS, "imgsys_main_gals", "top_img", 31),
+};
+
+static const struct mtk_gate imgsys_wpe1_clks[] = {
+       GATE_IMGSYS(CLK_IMGSYS_WPE1_LARB11, "imgsys_wpe1_larb11", "top_img", 0),
+       GATE_IMGSYS(CLK_IMGSYS_WPE1, "imgsys_wpe1", "top_img", 1),
+};
+
+static const struct mtk_gate imgsys_wpe2_clks[] = {
+       GATE_IMGSYS(CLK_IMGSYS_WPE2_LARB11, "imgsys_wpe2_larb11", "top_img", 0),
+       GATE_IMGSYS(CLK_IMGSYS_WPE2, "imgsys_wpe2", "top_img", 1),
+};
+
+static const struct mtk_gate imgsys_wpe3_clks[] = {
+       GATE_IMGSYS(CLK_IMGSYS_WPE3_LARB11, "imgsys_wpe3_larb11", "top_img", 0),
+       GATE_IMGSYS(CLK_IMGSYS_WPE3, "imgsys_wpe3", "top_img", 1),
+};
+
+static const struct mtk_gate imgsys1_dip_top_clks[] = {
+       GATE_IMGSYS(CLK_IMGSYS1_DIP_TOP_LARB10, "imgsys1_dip_larb10", "top_img", 0),
+       GATE_IMGSYS(CLK_IMGSYS1_DIP_TOP_DIP_TOP, "imgsys1_dip_dip_top", "top_img", 1),
+};
+
+static const struct mtk_gate imgsys1_dip_nr_clks[] = {
+       GATE_IMGSYS(CLK_IMGSYS1_DIP_NR_LARB15, "imgsys1_dip_nr_larb15", "top_img", 0),
+       GATE_IMGSYS(CLK_IMGSYS1_DIP_NR_DIP_NR, "imgsys1_dip_nr_dip_nr", "top_img", 1),
+};
+
+static const struct mtk_clk_desc imgsys_main_desc = {
+       .clks = imgsys_main_clks,
+       .num_clks = ARRAY_SIZE(imgsys_main_clks),
+};
+
+static const struct mtk_clk_desc imgsys_wpe1_desc = {
+       .clks = imgsys_wpe1_clks,
+       .num_clks = ARRAY_SIZE(imgsys_wpe1_clks),
+};
+
+static const struct mtk_clk_desc imgsys_wpe2_desc = {
+       .clks = imgsys_wpe2_clks,
+       .num_clks = ARRAY_SIZE(imgsys_wpe2_clks),
+};
+
+static const struct mtk_clk_desc imgsys_wpe3_desc = {
+       .clks = imgsys_wpe3_clks,
+       .num_clks = ARRAY_SIZE(imgsys_wpe3_clks),
+};
+
+static const struct mtk_clk_desc imgsys1_dip_top_desc = {
+       .clks = imgsys1_dip_top_clks,
+       .num_clks = ARRAY_SIZE(imgsys1_dip_top_clks),
+};
+
+static const struct mtk_clk_desc imgsys1_dip_nr_desc = {
+       .clks = imgsys1_dip_nr_clks,
+       .num_clks = ARRAY_SIZE(imgsys1_dip_nr_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_imgsys_main[] = {
+       { .compatible = "mediatek,mt8188-imgsys", .data = &imgsys_main_desc },
+       { .compatible = "mediatek,mt8188-imgsys-wpe1", .data = &imgsys_wpe1_desc },
+       { .compatible = "mediatek,mt8188-imgsys-wpe2", .data = &imgsys_wpe2_desc },
+       { .compatible = "mediatek,mt8188-imgsys-wpe3", .data = &imgsys_wpe3_desc },
+       { .compatible = "mediatek,mt8188-imgsys1-dip-top", .data = &imgsys1_dip_top_desc },
+       { .compatible = "mediatek,mt8188-imgsys1-dip-nr", .data = &imgsys1_dip_nr_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_imgsys_main);
+
+static struct platform_driver clk_mt8188_imgsys_main_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-imgsys_main",
+               .of_match_table = of_match_clk_mt8188_imgsys_main,
+       },
+};
+
+module_platform_driver(clk_mt8188_imgsys_main_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-imp_iic_wrap.c b/drivers/clk/mediatek/clk-mt8188-imp_iic_wrap.c
new file mode 100644 (file)
index 0000000..da41a3c
--- /dev/null
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs imp_iic_wrap_cg_regs = {
+       .set_ofs = 0xe08,
+       .clr_ofs = 0xe04,
+       .sta_ofs = 0xe00,
+};
+
+#define GATE_IMP_IIC_WRAP(_id, _name, _parent, _shift)                 \
+       GATE_MTK_FLAGS(_id, _name, _parent, &imp_iic_wrap_cg_regs, _shift,                      \
+               &mtk_clk_gate_ops_setclr, CLK_OPS_PARENT_ENABLE)
+
+static const struct mtk_gate imp_iic_wrap_c_clks[] = {
+       GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C0,
+                         "imp_iic_wrap_c_ap_clock_i2c0", "top_i2c", 0),
+       GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C2,
+                         "imp_iic_wrap_c_ap_clock_i2c2", "top_i2c", 1),
+       GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C3,
+                         "imp_iic_wrap_c_ap_clock_i2c3", "top_i2c", 2),
+};
+
+static const struct mtk_gate imp_iic_wrap_w_clks[] = {
+       GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_W_AP_CLOCK_I2C1,
+                         "imp_iic_wrap_w_ap_clock_i2c1", "top_i2c", 0),
+       GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_W_AP_CLOCK_I2C4,
+                         "imp_iic_wrap_w_ap_clock_i2c4", "top_i2c", 1),
+};
+
+static const struct mtk_gate imp_iic_wrap_en_clks[] = {
+       GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_EN_AP_CLOCK_I2C5,
+                         "imp_iic_wrap_en_ap_clock_i2c5", "top_i2c", 0),
+       GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_EN_AP_CLOCK_I2C6,
+                         "imp_iic_wrap_en_ap_clock_i2c6", "top_i2c", 1),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_c_desc = {
+       .clks = imp_iic_wrap_c_clks,
+       .num_clks = ARRAY_SIZE(imp_iic_wrap_c_clks),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_w_desc = {
+       .clks = imp_iic_wrap_w_clks,
+       .num_clks = ARRAY_SIZE(imp_iic_wrap_w_clks),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_en_desc = {
+       .clks = imp_iic_wrap_en_clks,
+       .num_clks = ARRAY_SIZE(imp_iic_wrap_en_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_imp_iic_wrap[] = {
+       { .compatible = "mediatek,mt8188-imp-iic-wrap-c", .data = &imp_iic_wrap_c_desc },
+       { .compatible = "mediatek,mt8188-imp-iic-wrap-w", .data = &imp_iic_wrap_w_desc },
+       { .compatible = "mediatek,mt8188-imp-iic-wrap-en", .data = &imp_iic_wrap_en_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_imp_iic_wrap);
+
+static struct platform_driver clk_mt8188_imp_iic_wrap_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-imp_iic_wrap",
+               .of_match_table = of_match_clk_mt8188_imp_iic_wrap,
+       },
+};
+
+module_platform_driver(clk_mt8188_imp_iic_wrap_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-infra_ao.c b/drivers/clk/mediatek/clk-mt8188-infra_ao.c
new file mode 100644 (file)
index 0000000..91c35db
--- /dev/null
@@ -0,0 +1,199 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs infra_ao0_cg_regs = {
+       .set_ofs = 0x80,
+       .clr_ofs = 0x84,
+       .sta_ofs = 0x90,
+};
+
+static const struct mtk_gate_regs infra_ao1_cg_regs = {
+       .set_ofs = 0x88,
+       .clr_ofs = 0x8c,
+       .sta_ofs = 0x94,
+};
+
+static const struct mtk_gate_regs infra_ao2_cg_regs = {
+       .set_ofs = 0xa4,
+       .clr_ofs = 0xa8,
+       .sta_ofs = 0xac,
+};
+
+static const struct mtk_gate_regs infra_ao3_cg_regs = {
+       .set_ofs = 0xc0,
+       .clr_ofs = 0xc4,
+       .sta_ofs = 0xc8,
+};
+
+static const struct mtk_gate_regs infra_ao4_cg_regs = {
+       .set_ofs = 0xe0,
+       .clr_ofs = 0xe4,
+       .sta_ofs = 0xe8,
+};
+
+#define GATE_INFRA_AO0_FLAGS(_id, _name, _parent, _shift, _flag)                \
+       GATE_MTK_FLAGS(_id, _name, _parent, &infra_ao0_cg_regs, _shift, \
+               &mtk_clk_gate_ops_setclr, _flag)
+
+#define GATE_INFRA_AO0(_id, _name, _parent, _shift)    \
+       GATE_INFRA_AO0_FLAGS(_id, _name, _parent, _shift, 0)
+
+#define GATE_INFRA_AO1_FLAGS(_id, _name, _parent, _shift, _flag)               \
+       GATE_MTK_FLAGS(_id, _name, _parent, &infra_ao1_cg_regs, _shift, \
+               &mtk_clk_gate_ops_setclr, _flag)
+
+#define GATE_INFRA_AO1(_id, _name, _parent, _shift)    \
+       GATE_INFRA_AO1_FLAGS(_id, _name, _parent, _shift, 0)
+
+#define GATE_INFRA_AO2(_id, _name, _parent, _shift)                    \
+       GATE_MTK(_id, _name, _parent, &infra_ao2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_INFRA_AO2_FLAGS(_id, _name, _parent, _shift, _flag)               \
+       GATE_MTK_FLAGS(_id, _name, _parent, &infra_ao2_cg_regs, _shift, \
+               &mtk_clk_gate_ops_setclr, _flag)
+
+#define GATE_INFRA_AO3_FLAGS(_id, _name, _parent, _shift, _flag)               \
+       GATE_MTK_FLAGS(_id, _name, _parent, &infra_ao3_cg_regs, _shift, \
+               &mtk_clk_gate_ops_setclr, _flag)
+
+#define GATE_INFRA_AO3(_id, _name, _parent, _shift)    \
+       GATE_INFRA_AO3_FLAGS(_id, _name, _parent, _shift, 0)
+
+#define GATE_INFRA_AO4_FLAGS(_id, _name, _parent, _shift, _flag)               \
+       GATE_MTK_FLAGS(_id, _name, _parent, &infra_ao4_cg_regs, _shift, \
+               &mtk_clk_gate_ops_setclr, _flag)
+
+#define GATE_INFRA_AO4(_id, _name, _parent, _shift)    \
+       GATE_INFRA_AO4_FLAGS(_id, _name, _parent, _shift, 0)
+
+static const struct mtk_gate infra_ao_clks[] = {
+       /* INFRA_AO0 */
+       GATE_INFRA_AO0(CLK_INFRA_AO_PMIC_TMR, "infra_ao_pmic_tmr", "top_pwrap_ulposc", 0),
+       GATE_INFRA_AO0(CLK_INFRA_AO_PMIC_AP, "infra_ao_pmic_ap", "top_pwrap_ulposc", 1),
+       GATE_INFRA_AO0(CLK_INFRA_AO_PMIC_MD, "infra_ao_pmic_md", "top_pwrap_ulposc", 2),
+       GATE_INFRA_AO0(CLK_INFRA_AO_PMIC_CONN, "infra_ao_pmic_conn", "top_pwrap_ulposc", 3),
+       /* infra_ao_sej is main clock is for secure engine with JTAG support */
+       GATE_INFRA_AO0_FLAGS(CLK_INFRA_AO_SEJ, "infra_ao_sej", "top_axi", 5, CLK_IS_CRITICAL),
+       GATE_INFRA_AO0(CLK_INFRA_AO_APXGPT, "infra_ao_apxgpt", "top_axi", 6),
+       GATE_INFRA_AO0(CLK_INFRA_AO_GCE, "infra_ao_gce", "top_axi", 8),
+       GATE_INFRA_AO0(CLK_INFRA_AO_GCE2, "infra_ao_gce2", "top_axi", 9),
+       GATE_INFRA_AO0(CLK_INFRA_AO_THERM, "infra_ao_therm", "top_axi", 10),
+       GATE_INFRA_AO0(CLK_INFRA_AO_PWM_HCLK, "infra_ao_pwm_h", "top_axi", 15),
+       GATE_INFRA_AO0(CLK_INFRA_AO_PWM1, "infra_ao_pwm1", "top_pwm", 16),
+       GATE_INFRA_AO0(CLK_INFRA_AO_PWM2, "infra_ao_pwm2", "top_pwm", 17),
+       GATE_INFRA_AO0(CLK_INFRA_AO_PWM3, "infra_ao_pwm3", "top_pwm", 18),
+       GATE_INFRA_AO0(CLK_INFRA_AO_PWM4, "infra_ao_pwm4", "top_pwm", 19),
+       GATE_INFRA_AO0(CLK_INFRA_AO_PWM, "infra_ao_pwm", "top_pwm", 21),
+       GATE_INFRA_AO0(CLK_INFRA_AO_UART0, "infra_ao_uart0", "top_uart", 22),
+       GATE_INFRA_AO0(CLK_INFRA_AO_UART1, "infra_ao_uart1", "top_uart", 23),
+       GATE_INFRA_AO0(CLK_INFRA_AO_UART2, "infra_ao_uart2", "top_uart", 24),
+       GATE_INFRA_AO0(CLK_INFRA_AO_UART3, "infra_ao_uart3", "top_uart", 25),
+       GATE_INFRA_AO0(CLK_INFRA_AO_UART4, "infra_ao_uart4", "top_uart", 26),
+       GATE_INFRA_AO0(CLK_INFRA_AO_GCE_26M, "infra_ao_gce_26m", "clk26m", 27),
+       GATE_INFRA_AO0(CLK_INFRA_AO_CQ_DMA_FPC, "infra_ao_dma", "pad_fpc_ck", 28),
+       GATE_INFRA_AO0(CLK_INFRA_AO_UART5, "infra_ao_uart5", "top_uart", 29),
+       /* INFRA_AO1 */
+       GATE_INFRA_AO1(CLK_INFRA_AO_HDMI_26M, "infra_ao_hdmi_26m", "clk26m", 0),
+       GATE_INFRA_AO1(CLK_INFRA_AO_SPI0, "infra_ao_spi0", "top_spi", 1),
+       GATE_INFRA_AO1(CLK_INFRA_AO_MSDC0, "infra_ao_msdc0", "top_msdc5hclk", 2),
+       GATE_INFRA_AO1(CLK_INFRA_AO_MSDC1, "infra_ao_msdc1", "top_axi", 4),
+       GATE_INFRA_AO1(CLK_INFRA_AO_MSDC2, "infra_ao_msdc2", "top_axi", 5),
+       GATE_INFRA_AO1(CLK_INFRA_AO_MSDC0_SRC, "infra_ao_msdc0_clk", "top_msdc50_0", 6),
+       /* infra_ao_dvfsrc is for internal DVFS usage, should not be handled by Linux. */
+       GATE_INFRA_AO1_FLAGS(CLK_INFRA_AO_DVFSRC, "infra_ao_dvfsrc",
+                            "clk26m", 7, CLK_IS_CRITICAL),
+       GATE_INFRA_AO1(CLK_INFRA_AO_TRNG, "infra_ao_trng", "top_axi", 9),
+       GATE_INFRA_AO1(CLK_INFRA_AO_AUXADC, "infra_ao_auxadc", "clk26m", 10),
+       GATE_INFRA_AO1(CLK_INFRA_AO_CPUM, "infra_ao_cpum", "top_axi", 11),
+       GATE_INFRA_AO1(CLK_INFRA_AO_HDMI_32K, "infra_ao_hdmi_32k", "clk32k", 12),
+       GATE_INFRA_AO1(CLK_INFRA_AO_CEC_66M_HCLK, "infra_ao_cec_66m_hclk", "top_axi", 13),
+       GATE_INFRA_AO1(CLK_INFRA_AO_PCIE_TL_26M, "infra_ao_pcie_tl_26m", "clk26m", 15),
+       GATE_INFRA_AO1(CLK_INFRA_AO_MSDC1_SRC, "infra_ao_msdc1_clk", "top_msdc30_1", 16),
+       GATE_INFRA_AO1(CLK_INFRA_AO_CEC_66M_BCLK, "infra_ao_cec_66m_bclk", "top_axi", 17),
+       GATE_INFRA_AO1(CLK_INFRA_AO_PCIE_TL_96M, "infra_ao_pcie_tl_96m", "top_tl", 18),
+       /* infra_ao_dapc is for device access permission control module */
+       GATE_INFRA_AO1_FLAGS(CLK_INFRA_AO_DEVICE_APC, "infra_ao_dapc",
+                            "top_axi", 20, CLK_IS_CRITICAL),
+       GATE_INFRA_AO1(CLK_INFRA_AO_ECC_66M_HCLK, "infra_ao_ecc_66m_hclk", "top_axi", 23),
+       GATE_INFRA_AO1(CLK_INFRA_AO_DEBUGSYS, "infra_ao_debugsys", "top_axi", 24),
+       GATE_INFRA_AO1(CLK_INFRA_AO_AUDIO, "infra_ao_audio", "top_axi", 25),
+       GATE_INFRA_AO1(CLK_INFRA_AO_PCIE_TL_32K, "infra_ao_pcie_tl_32k", "clk32k", 26),
+       GATE_INFRA_AO1(CLK_INFRA_AO_DBG_TRACE, "infra_ao_dbg_trace", "top_axi", 29),
+       GATE_INFRA_AO1(CLK_INFRA_AO_DRAMC_F26M, "infra_ao_dramc26", "clk26m", 31),
+       /* INFRA_AO2 */
+       GATE_INFRA_AO2(CLK_INFRA_AO_IRTX, "infra_ao_irtx", "top_axi", 0),
+       GATE_INFRA_AO2(CLK_INFRA_AO_DISP_PWM, "infra_ao_disp_pwm", "top_disp_pwm0", 2),
+       GATE_INFRA_AO2(CLK_INFRA_AO_CLDMA_BCLK, "infra_ao_cldmabclk", "top_axi", 3),
+       GATE_INFRA_AO2(CLK_INFRA_AO_AUDIO_26M_BCLK, "infra_ao_audio26m", "clk26m", 4),
+       GATE_INFRA_AO2(CLK_INFRA_AO_SPI1, "infra_ao_spi1", "top_spi", 6),
+       GATE_INFRA_AO2(CLK_INFRA_AO_SPI2, "infra_ao_spi2", "top_spi", 9),
+       GATE_INFRA_AO2(CLK_INFRA_AO_SPI3, "infra_ao_spi3", "top_spi", 10),
+       GATE_INFRA_AO2_FLAGS(CLK_INFRA_AO_FSSPM, "infra_ao_fsspm",
+                            "top_sspm", 15, CLK_IS_CRITICAL),
+       GATE_INFRA_AO2_FLAGS(CLK_INFRA_AO_SSPM_BUS_HCLK, "infra_ao_sspm_hclk",
+                            "top_axi", 17, CLK_IS_CRITICAL),
+       GATE_INFRA_AO2(CLK_INFRA_AO_APDMA_BCLK, "infra_ao_apdma_bclk", "top_axi", 18),
+       GATE_INFRA_AO2(CLK_INFRA_AO_SPI4, "infra_ao_spi4", "top_spi", 25),
+       GATE_INFRA_AO2(CLK_INFRA_AO_SPI5, "infra_ao_spi5", "top_spi", 26),
+       GATE_INFRA_AO2(CLK_INFRA_AO_CQ_DMA, "infra_ao_cq_dma", "top_axi", 27),
+       /* INFRA_AO3 */
+       GATE_INFRA_AO3(CLK_INFRA_AO_MSDC0_SELF, "infra_ao_msdc0sf", "top_msdc50_0", 0),
+       GATE_INFRA_AO3(CLK_INFRA_AO_MSDC1_SELF, "infra_ao_msdc1sf", "top_msdc50_0", 1),
+       GATE_INFRA_AO3(CLK_INFRA_AO_MSDC2_SELF, "infra_ao_msdc2sf", "top_msdc50_0", 2),
+       GATE_INFRA_AO3(CLK_INFRA_AO_I2S_DMA, "infra_ao_i2s_dma", "top_axi", 5),
+       GATE_INFRA_AO3(CLK_INFRA_AO_AP_MSDC0, "infra_ao_ap_msdc0", "top_msdc50_0", 7),
+       GATE_INFRA_AO3(CLK_INFRA_AO_MD_MSDC0, "infra_ao_md_msdc0", "top_msdc50_0", 8),
+       GATE_INFRA_AO3(CLK_INFRA_AO_MSDC30_2, "infra_ao_msdc30_2", "top_msdc30_2", 9),
+       GATE_INFRA_AO3(CLK_INFRA_AO_GCPU, "infra_ao_gcpu", "top_gcpu", 10),
+       GATE_INFRA_AO3(CLK_INFRA_AO_PCIE_PERI_26M, "infra_ao_pcie_peri_26m", "clk26m", 15),
+       GATE_INFRA_AO3(CLK_INFRA_AO_GCPU_66M_BCLK, "infra_ao_gcpu_66m_bclk", "top_axi", 16),
+       GATE_INFRA_AO3(CLK_INFRA_AO_GCPU_133M_BCLK, "infra_ao_gcpu_133m_bclk", "top_axi", 17),
+       GATE_INFRA_AO3(CLK_INFRA_AO_DISP_PWM1, "infra_ao_disp_pwm1", "top_disp_pwm1", 20),
+       GATE_INFRA_AO3(CLK_INFRA_AO_FBIST2FPC, "infra_ao_fbist2fpc", "top_msdc50_0", 24),
+       /* infra_ao_dapc_sync is for device access permission control module */
+       GATE_INFRA_AO3_FLAGS(CLK_INFRA_AO_DEVICE_APC_SYNC, "infra_ao_dapc_sync",
+                            "top_axi", 25, CLK_IS_CRITICAL),
+       GATE_INFRA_AO3(CLK_INFRA_AO_PCIE_P1_PERI_26M, "infra_ao_pcie_p1_peri_26m", "clk26m", 26),
+       /* INFRA_AO4 */
+       /* infra_ao_133m_mclk_set/infra_ao_66m_mclk_set are main clocks of peripheral */
+       GATE_INFRA_AO4_FLAGS(CLK_INFRA_AO_133M_MCLK_CK, "infra_ao_133m_mclk_set",
+                            "top_axi", 0, CLK_IS_CRITICAL),
+       GATE_INFRA_AO4_FLAGS(CLK_INFRA_AO_66M_MCLK_CK, "infra_ao_66m_mclk_set",
+                            "top_axi", 1, CLK_IS_CRITICAL),
+       GATE_INFRA_AO4(CLK_INFRA_AO_PCIE_PL_P_250M_P0, "infra_ao_pcie_pl_p_250m_p0",
+                      "pextp_pipe", 7),
+       GATE_INFRA_AO4(CLK_INFRA_AO_RG_AES_MSDCFDE_CK_0P,
+                      "infra_ao_aes_msdcfde_0p", "top_aes_msdcfde", 18),
+};
+
+static const struct mtk_clk_desc infra_ao_desc = {
+       .clks = infra_ao_clks,
+       .num_clks = ARRAY_SIZE(infra_ao_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_infra_ao[] = {
+       { .compatible = "mediatek,mt8188-infracfg-ao", .data = &infra_ao_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_infra_ao);
+
+static struct platform_driver clk_mt8188_infra_ao_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-infra_ao",
+               .of_match_table = of_match_clk_mt8188_infra_ao,
+       },
+};
+module_platform_driver(clk_mt8188_infra_ao_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-ipe.c b/drivers/clk/mediatek/clk-mt8188-ipe.c
new file mode 100644 (file)
index 0000000..c07afbd
--- /dev/null
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs ipe_cg_regs = {
+       .set_ofs = 0x4,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_IPE(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &ipe_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate ipe_clks[] = {
+       GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "top_ipe", 0),
+       GATE_IPE(CLK_IPE_FDVT, "ipe_fdvt", "top_ipe", 1),
+       GATE_IPE(CLK_IPE_ME, "ipe_me", "top_ipe", 2),
+       GATE_IPE(CLK_IPESYS_TOP, "ipesys_top", "top_ipe", 3),
+       GATE_IPE(CLK_IPE_SMI_LARB12, "ipe_smi_larb12", "top_ipe", 4),
+};
+
+static const struct mtk_clk_desc ipe_desc = {
+       .clks = ipe_clks,
+       .num_clks = ARRAY_SIZE(ipe_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_ipe[] = {
+       { .compatible = "mediatek,mt8188-ipesys", .data = &ipe_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_ipe);
+
+static struct platform_driver clk_mt8188_ipe_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-ipe",
+               .of_match_table = of_match_clk_mt8188_ipe,
+       },
+};
+
+module_platform_driver(clk_mt8188_ipe_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-mfg.c b/drivers/clk/mediatek/clk-mt8188-mfg.c
new file mode 100644 (file)
index 0000000..e5a6eaf
--- /dev/null
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs mfgcfg_cg_regs = {
+       .set_ofs = 0x4,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_MFG(_id, _name, _parent, _shift)                          \
+       GATE_MTK_FLAGS(_id, _name, _parent, &mfgcfg_cg_regs, _shift,    \
+                      &mtk_clk_gate_ops_setclr, CLK_SET_RATE_PARENT)
+
+static const struct mtk_gate mfgcfg_clks[] = {
+       GATE_MFG(CLK_MFGCFG_BG3D, "mfgcfg_bg3d", "mfg_ck_fast_ref", 0),
+};
+
+static const struct mtk_clk_desc mfgcfg_desc = {
+       .clks = mfgcfg_clks,
+       .num_clks = ARRAY_SIZE(mfgcfg_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_mfgcfg[] = {
+       { .compatible = "mediatek,mt8188-mfgcfg", .data = &mfgcfg_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_mfgcfg);
+
+static struct platform_driver clk_mt8188_mfgcfg_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-mfgcfg",
+               .of_match_table = of_match_clk_mt8188_mfgcfg,
+       },
+};
+
+module_platform_driver(clk_mt8188_mfgcfg_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-peri_ao.c b/drivers/clk/mediatek/clk-mt8188-peri_ao.c
new file mode 100644 (file)
index 0000000..b00e1ae
--- /dev/null
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs peri_ao_cg_regs = {
+       .set_ofs = 0x10,
+       .clr_ofs = 0x14,
+       .sta_ofs = 0x18,
+};
+
+#define GATE_PERI_AO(_id, _name, _parent, _shift)                      \
+       GATE_MTK(_id, _name, _parent, &peri_ao_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate peri_ao_clks[] = {
+       GATE_PERI_AO(CLK_PERI_AO_ETHERNET, "peri_ao_ethernet", "top_axi", 0),
+       GATE_PERI_AO(CLK_PERI_AO_ETHERNET_BUS, "peri_ao_ethernet_bus", "top_axi", 1),
+       GATE_PERI_AO(CLK_PERI_AO_FLASHIF_BUS, "peri_ao_flashif_bus", "top_axi", 3),
+       GATE_PERI_AO(CLK_PERI_AO_FLASHIF_26M, "peri_ao_flashif_26m", "clk26m", 4),
+       GATE_PERI_AO(CLK_PERI_AO_FLASHIFLASHCK, "peri_ao_flashiflashck", "top_spinor", 5),
+       GATE_PERI_AO(CLK_PERI_AO_SSUSB_2P_BUS, "peri_ao_ssusb_2p_bus", "top_usb_top_2p", 9),
+       GATE_PERI_AO(CLK_PERI_AO_SSUSB_2P_XHCI, "peri_ao_ssusb_2p_xhci", "top_ssusb_xhci_2p", 10),
+       GATE_PERI_AO(CLK_PERI_AO_SSUSB_3P_BUS, "peri_ao_ssusb_3p_bus", "top_usb_top_3p", 11),
+       GATE_PERI_AO(CLK_PERI_AO_SSUSB_3P_XHCI, "peri_ao_ssusb_3p_xhci", "top_ssusb_xhci_3p", 12),
+       GATE_PERI_AO(CLK_PERI_AO_SSUSB_BUS, "peri_ao_ssusb_bus", "top_usb_top", 13),
+       GATE_PERI_AO(CLK_PERI_AO_SSUSB_XHCI, "peri_ao_ssusb_xhci", "top_ssusb_xhci", 14),
+       GATE_PERI_AO(CLK_PERI_AO_ETHERNET_MAC, "peri_ao_ethernet_mac_clk", "top_snps_eth_250m", 16),
+       GATE_PERI_AO(CLK_PERI_AO_PCIE_P0_FMEM, "peri_ao_pcie_p0_fmem", "hd_466m_fmem_ck", 24),
+};
+
+static const struct mtk_clk_desc peri_ao_desc = {
+       .clks = peri_ao_clks,
+       .num_clks = ARRAY_SIZE(peri_ao_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_peri_ao[] = {
+       { .compatible = "mediatek,mt8188-pericfg-ao", .data = &peri_ao_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_peri_ao);
+
+static struct platform_driver clk_mt8188_peri_ao_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-peri_ao",
+               .of_match_table = of_match_clk_mt8188_peri_ao,
+       },
+};
+module_platform_driver(clk_mt8188_peri_ao_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-topckgen.c b/drivers/clk/mediatek/clk-mt8188-topckgen.c
new file mode 100644 (file)
index 0000000..c56ec42
--- /dev/null
@@ -0,0 +1,1350 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+#include "clk-mux.h"
+
+static DEFINE_SPINLOCK(mt8188_clk_lock);
+
+static const struct mtk_fixed_clk top_fixed_clks[] = {
+       FIXED_CLK(CLK_TOP_ULPOSC1, "ulposc_ck1", NULL, 260000000),
+       FIXED_CLK(CLK_TOP_MPHONE_SLAVE_BCK, "mphone_slave_bck", NULL, 49152000),
+       FIXED_CLK(CLK_TOP_PAD_FPC, "pad_fpc_ck", NULL, 50000000),
+       FIXED_CLK(CLK_TOP_466M_FMEM, "hd_466m_fmem_ck", NULL, 533000000),
+       FIXED_CLK(CLK_TOP_PEXTP_PIPE, "pextp_pipe", NULL, 250000000),
+       FIXED_CLK(CLK_TOP_DSI_PHY, "dsi_phy", NULL, 500000000),
+};
+
+static const struct mtk_fixed_factor top_divs[] = {
+       FACTOR(CLK_TOP_MAINPLL_D3, "mainpll_d3", "mainpll", 1, 3),
+       FACTOR(CLK_TOP_MAINPLL_D4, "mainpll_d4", "mainpll", 1, 4),
+       FACTOR(CLK_TOP_MAINPLL_D4_D2, "mainpll_d4_d2", "mainpll_d4", 1, 2),
+       FACTOR(CLK_TOP_MAINPLL_D4_D4, "mainpll_d4_d4", "mainpll_d4", 1, 4),
+       FACTOR(CLK_TOP_MAINPLL_D4_D8, "mainpll_d4_d8", "mainpll_d4", 1, 8),
+       FACTOR(CLK_TOP_MAINPLL_D5, "mainpll_d5", "mainpll", 1, 5),
+       FACTOR(CLK_TOP_MAINPLL_D5_D2, "mainpll_d5_d2", "mainpll_d5", 1, 2),
+       FACTOR(CLK_TOP_MAINPLL_D5_D4, "mainpll_d5_d4", "mainpll_d5", 1, 4),
+       FACTOR(CLK_TOP_MAINPLL_D5_D8, "mainpll_d5_d8", "mainpll_d5", 1, 8),
+       FACTOR(CLK_TOP_MAINPLL_D6, "mainpll_d6", "mainpll", 1, 6),
+       FACTOR(CLK_TOP_MAINPLL_D6_D2, "mainpll_d6_d2", "mainpll_d6", 1, 2),
+       FACTOR(CLK_TOP_MAINPLL_D6_D4, "mainpll_d6_d4", "mainpll_d6", 1, 4),
+       FACTOR(CLK_TOP_MAINPLL_D6_D8, "mainpll_d6_d8", "mainpll_d6", 1, 8),
+       FACTOR(CLK_TOP_MAINPLL_D7, "mainpll_d7", "mainpll", 1, 7),
+       FACTOR(CLK_TOP_MAINPLL_D7_D2, "mainpll_d7_d2", "mainpll_d7", 1, 2),
+       FACTOR(CLK_TOP_MAINPLL_D7_D4, "mainpll_d7_d4", "mainpll_d7", 1, 4),
+       FACTOR(CLK_TOP_MAINPLL_D7_D8, "mainpll_d7_d8", "mainpll_d7", 1, 8),
+       FACTOR(CLK_TOP_MAINPLL_D9, "mainpll_d9", "mainpll", 1, 9),
+       FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll", 1, 3),
+       FACTOR(CLK_TOP_UNIVPLL_D4, "univpll_d4", "univpll", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL_D4_D2, "univpll_d4_d2", "univpll_d4", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL_D4_D4, "univpll_d4_d4", "univpll_d4", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL_D4_D8, "univpll_d4_d8", "univpll_d4", 1, 8),
+       FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll", 1, 5),
+       FACTOR(CLK_TOP_UNIVPLL_D5_D2, "univpll_d5_d2", "univpll_d5", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL_D5_D4, "univpll_d5_d4", "univpll_d5", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL_D5_D8, "univpll_d5_d8", "univpll_d5", 1, 8),
+       FACTOR(CLK_TOP_UNIVPLL_D6, "univpll_d6", "univpll", 1, 6),
+       FACTOR(CLK_TOP_UNIVPLL_D6_D2, "univpll_d6_d2", "univpll_d6", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL_D6_D4, "univpll_d6_d4", "univpll_d6", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL_D6_D8, "univpll_d6_d8", "univpll_d6", 1, 8),
+       FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll", 1, 7),
+       FACTOR(CLK_TOP_UNIVPLL_192M, "univpll_192m", "univpll", 1, 13),
+       FACTOR(CLK_TOP_UNIVPLL_192M_D4, "univpll_192m_d4", "univpll_192m", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL_192M_D8, "univpll_192m_d8", "univpll_192m", 1, 8),
+       FACTOR(CLK_TOP_UNIVPLL_192M_D10, "univpll_192m_d10", "univpll_192m", 1, 10),
+       FACTOR(CLK_TOP_UNIVPLL_192M_D16, "univpll_192m_d16", "univpll_192m", 1, 16),
+       FACTOR(CLK_TOP_UNIVPLL_192M_D32, "univpll_192m_d32", "univpll_192m", 1, 32),
+       FACTOR(CLK_TOP_APLL1_D3, "apll1_d3", "apll1", 1, 3),
+       FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1", 1, 4),
+       FACTOR(CLK_TOP_APLL2_D3, "apll2_d3", "apll2", 1, 3),
+       FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2", 1, 4),
+       FACTOR(CLK_TOP_APLL3_D4, "apll3_d4", "apll3", 1, 4),
+       FACTOR(CLK_TOP_APLL4_D4, "apll4_d4", "apll4", 1, 4),
+       FACTOR(CLK_TOP_APLL5_D4, "apll5_d4", "apll5", 1, 4),
+       FACTOR(CLK_TOP_MMPLL_D4, "mmpll_d4", "mmpll", 1, 4),
+       FACTOR(CLK_TOP_MMPLL_D4_D2, "mmpll_d4_d2", "mmpll_d4", 1, 2),
+       FACTOR(CLK_TOP_MMPLL_D5, "mmpll_d5", "mmpll", 1, 5),
+       FACTOR(CLK_TOP_MMPLL_D5_D2, "mmpll_d5_d2", "mmpll_d5", 1, 2),
+       FACTOR(CLK_TOP_MMPLL_D5_D4, "mmpll_d5_d4", "mmpll_d5", 1, 4),
+       FACTOR(CLK_TOP_MMPLL_D6, "mmpll_d6", "mmpll", 1, 6),
+       FACTOR(CLK_TOP_MMPLL_D6_D2, "mmpll_d6_d2", "mmpll_d6", 1, 2),
+       FACTOR(CLK_TOP_MMPLL_D7, "mmpll_d7", "mmpll", 1, 7),
+       FACTOR(CLK_TOP_MMPLL_D9, "mmpll_d9", "mmpll", 1, 9),
+       FACTOR(CLK_TOP_TVDPLL1_D2, "tvdpll1_d2", "tvdpll1", 1, 2),
+       FACTOR(CLK_TOP_TVDPLL1_D4, "tvdpll1_d4", "tvdpll1", 1, 4),
+       FACTOR(CLK_TOP_TVDPLL1_D8, "tvdpll1_d8", "tvdpll1", 1, 8),
+       FACTOR(CLK_TOP_TVDPLL1_D16, "tvdpll1_d16", "tvdpll1", 1, 16),
+       FACTOR(CLK_TOP_TVDPLL2_D2, "tvdpll2_d2", "tvdpll2", 1, 2),
+       FACTOR(CLK_TOP_TVDPLL2_D4, "tvdpll2_d4", "tvdpll2", 1, 4),
+       FACTOR(CLK_TOP_TVDPLL2_D8, "tvdpll2_d8", "tvdpll2", 1, 8),
+       FACTOR(CLK_TOP_TVDPLL2_D16, "tvdpll2_d16", "tvdpll2", 1, 16),
+       FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll", 1, 2),
+       FACTOR(CLK_TOP_MSDCPLL_D16, "msdcpll_d16", "msdcpll", 1, 16),
+       FACTOR(CLK_TOP_ETHPLL_D2, "ethpll_d2", "ethpll", 1, 2),
+       FACTOR(CLK_TOP_ETHPLL_D4, "ethpll_d4", "ethpll", 1, 4),
+       FACTOR(CLK_TOP_ETHPLL_D8, "ethpll_d8", "ethpll", 1, 8),
+       FACTOR(CLK_TOP_ETHPLL_D10, "ethpll_d10", "ethpll", 1, 10),
+       FACTOR(CLK_TOP_ADSPPLL_D2, "adsppll_d2", "adsppll", 1, 2),
+       FACTOR(CLK_TOP_ADSPPLL_D4, "adsppll_d4", "adsppll", 1, 4),
+       FACTOR(CLK_TOP_ADSPPLL_D8, "adsppll_d8", "adsppll", 1, 8),
+       FACTOR(CLK_TOP_ULPOSC1_D2, "ulposc1_d2", "ulposc_ck1", 1, 2),
+       FACTOR(CLK_TOP_ULPOSC1_D4, "ulposc1_d4", "ulposc_ck1", 1, 4),
+       FACTOR(CLK_TOP_ULPOSC1_D8, "ulposc1_d8", "ulposc_ck1", 1, 8),
+       FACTOR(CLK_TOP_ULPOSC1_D7, "ulposc1_d7", "ulposc_ck1", 1, 7),
+       FACTOR(CLK_TOP_ULPOSC1_D10, "ulposc1_d10", "ulposc_ck1", 1, 10),
+       FACTOR(CLK_TOP_ULPOSC1_D16, "ulposc1_d16", "ulposc_ck1", 1, 16),
+};
+
+static const char * const axi_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d7_d2",
+       "mainpll_d4_d2",
+       "mainpll_d5_d2",
+       "mainpll_d6_d2",
+       "ulposc1_d4"
+};
+
+static const char * const spm_parents[] = {
+       "clk26m",
+       "ulposc1_d10",
+       "mainpll_d7_d4",
+       "clk32k"
+};
+
+static const char * const scp_parents[] = {
+       "clk26m",
+       "univpll_d4",
+       "mainpll_d6",
+       "univpll_d6",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "univpll_d3",
+       "mainpll_d3"
+};
+
+static const char * const bus_aximem_parents[] = {
+       "clk26m",
+       "mainpll_d7_d2",
+       "mainpll_d4_d2",
+       "mainpll_d5_d2",
+       "mainpll_d6"
+};
+
+static const char * const vpp_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d4",
+       "mmpll_d5",
+       "tvdpll1",
+       "tvdpll2",
+       "univpll_d4",
+       "mmpll_d4"
+};
+
+static const char * const ethdr_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d4",
+       "mmpll_d5_d4",
+       "tvdpll1",
+       "tvdpll2",
+       "univpll_d4",
+       "mmpll_d4"
+};
+
+static const char * const ipe_parents[] = {
+       "clk26m",
+       "imgpll",
+       "mainpll_d4",
+       "mmpll_d6",
+       "univpll_d6",
+       "mainpll_d6",
+       "mmpll_d4_d2",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "mainpll_d7"
+};
+
+static const char * const cam_parents[] = {
+       "clk26m",
+       "tvdpll1",
+       "mainpll_d4",
+       "mmpll_d4",
+       "univpll_d4",
+       "univpll_d5",
+       "univpll_d6",
+       "mmpll_d7",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "imgpll"
+};
+
+static const char * const ccu_parents[] = {
+       "clk26m",
+       "univpll_d6",
+       "mainpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d5",
+       "mainpll_d6",
+       "mmpll_d6",
+       "mmpll_d7",
+       "univpll_d4_d2",
+       "univpll_d7"
+};
+
+static const char * const ccu_ahb_parents[] = {
+       "clk26m",
+       "univpll_d6",
+       "mainpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d5",
+       "mainpll_d6",
+       "mmpll_d6",
+       "mmpll_d7",
+       "univpll_d4_d2",
+       "univpll_d7"
+};
+
+static const char * const img_parents[] = {
+       "clk26m",
+       "imgpll",
+       "univpll_d4",
+       "mainpll_d4",
+       "univpll_d5",
+       "mmpll_d6",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d6",
+       "mmpll_d4_d2",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "univpll_d5_d2"
+};
+
+static const char * const camtm_parents[] = {
+       "clk26m",
+       "univpll_d4_d4",
+       "univpll_d6_d2",
+       "univpll_d6_d4"
+};
+
+static const char * const dsp_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "univpll_d5",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp1_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d5",
+       "mmpll_d5",
+       "univpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp2_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d5",
+       "mmpll_d5",
+       "univpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp3_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d5",
+       "mmpll_d5",
+       "univpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp4_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp5_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp6_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp7_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "univpll_d5",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const mfg_core_tmp_parents[] = {
+       "clk26m",
+       "mainpll_d5_d2",
+       "univpll_d6",
+       "univpll_d7"
+};
+
+static const char * const camtg_parents[] = {
+       "clk26m",
+       "univpll_192m_d8",
+       "univpll_d6_d8",
+       "univpll_192m_d4",
+       "univpll_192m_d10",
+       "clk13m",
+       "univpll_192m_d16",
+       "univpll_192m_d32"
+};
+
+static const char * const camtg2_parents[] = {
+       "clk26m",
+       "univpll_192m_d8",
+       "univpll_d6_d8",
+       "univpll_192m_d4",
+       "univpll_192m_d10",
+       "clk13m",
+       "univpll_192m_d16",
+       "univpll_192m_d32"
+};
+
+static const char * const camtg3_parents[] = {
+       "clk26m",
+       "univpll_192m_d8",
+       "univpll_d6_d8",
+       "univpll_192m_d4",
+       "univpll_192m_d10",
+       "clk13m",
+       "univpll_192m_d16",
+       "univpll_192m_d32"
+};
+
+static const char * const uart_parents[] = {
+       "clk26m",
+       "univpll_d6_d8"
+};
+
+static const char * const spi_parents[] = {
+       "clk26m",
+       "mainpll_d5_d4",
+       "mainpll_d6_d4",
+       "univpll_d6_d4",
+       "univpll_d6_d2",
+       "mainpll_d6_d2",
+       "mainpll_d4_d4",
+       "univpll_d5_d4"
+};
+
+static const char * const msdc5hclk_parents[] = {
+       "clk26m",
+       "mainpll_d4_d2",
+       "mainpll_d6_d2"
+};
+
+static const char * const msdc50_0_parents[] = {
+       "clk26m",
+       "msdcpll",
+       "msdcpll_d2",
+       "univpll_d4_d4",
+       "mainpll_d6_d2",
+       "univpll_d4_d2"
+};
+
+static const char * const msdc30_1_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d6_d2",
+       "mainpll_d7_d2",
+       "msdcpll_d2"
+};
+
+static const char * const msdc30_2_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d6_d2",
+       "mainpll_d7_d2",
+       "msdcpll_d2"
+};
+
+static const char * const intdir_parents[] = {
+       "clk26m",
+       "univpll_d6",
+       "mainpll_d4",
+       "univpll_d4"
+};
+
+static const char * const aud_intbus_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d7_d4"
+};
+
+static const char * const audio_h_parents[] = {
+       "clk26m",
+       "univpll_d7",
+       "apll1",
+       "apll2"
+};
+
+static const char * const pwrap_ulposc_parents[] = {
+       "clk26m",
+       "ulposc1_d10",
+       "ulposc1_d7",
+       "ulposc1_d8",
+       "ulposc1_d16",
+       "mainpll_d4_d8",
+       "univpll_d5_d8",
+       "tvdpll1_d16"
+};
+
+static const char * const atb_parents[] = {
+       "clk26m",
+       "mainpll_d4_d2",
+       "mainpll_d5_d2"
+};
+
+static const char * const sspm_parents[] = {
+       "clk26m",
+       "mainpll_d7_d2",
+       "mainpll_d6_d2",
+       "mainpll_d5_d2",
+       "mainpll_d9",
+       "mainpll_d4_d2"
+};
+
+static const char * const dp_parents[] = {
+       "clk26m",
+       "tvdpll1_d2",
+       "tvdpll2_d2",
+       "tvdpll1_d4",
+       "tvdpll2_d4",
+       "tvdpll1_d8",
+       "tvdpll2_d8",
+       "tvdpll1_d16",
+       "tvdpll2_d16"
+};
+
+static const char * const edp_parents[] = {
+       "clk26m",
+       "tvdpll1_d2",
+       "tvdpll2_d2",
+       "tvdpll1_d4",
+       "tvdpll2_d4",
+       "tvdpll1_d8",
+       "tvdpll2_d8",
+       "tvdpll1_d16",
+       "tvdpll2_d16"
+};
+
+static const char * const dpi_parents[] = {
+       "clk26m",
+       "tvdpll1_d2",
+       "tvdpll2_d2",
+       "tvdpll1_d4",
+       "tvdpll2_d4",
+       "tvdpll1_d8",
+       "tvdpll2_d8",
+       "tvdpll1_d16",
+       "tvdpll2_d16"
+};
+
+static const char * const disp_pwm0_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "ulposc1_d2",
+       "ulposc1_d4",
+       "ulposc1_d16",
+       "ethpll_d4"
+};
+
+static const char * const disp_pwm1_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "ulposc1_d2",
+       "ulposc1_d4",
+       "ulposc1_d16"
+};
+
+static const char * const usb_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const ssusb_xhci_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const usb_2p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const ssusb_xhci_2p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const usb_3p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const ssusb_xhci_3p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const i2c_parents[] = {
+       "clk26m",
+       "mainpll_d4_d8",
+       "univpll_d5_d4"
+};
+
+static const char * const seninf_parents[] = {
+       "clk26m",
+       "univpll_d4_d4",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d7",
+       "univpll_d6",
+       "mmpll_d6",
+       "univpll_d5"
+};
+
+static const char * const seninf1_parents[] = {
+       "clk26m",
+       "univpll_d4_d4",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d7",
+       "univpll_d6",
+       "mmpll_d6",
+       "univpll_d5"
+};
+
+static const char * const gcpu_parents[] = {
+       "clk26m",
+       "mainpll_d6",
+       "univpll_d4_d2",
+       "mmpll_d5_d2",
+       "univpll_d5_d2"
+};
+
+static const char * const venc_parents[] = {
+       "clk26m",
+       "mmpll_d4_d2",
+       "mainpll_d6",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "univpll_d6",
+       "mmpll_d6",
+       "mainpll_d5_d2",
+       "mainpll_d6_d2",
+       "mmpll_d9",
+       "univpll_d4_d4",
+       "mainpll_d4",
+       "univpll_d4",
+       "univpll_d5",
+       "univpll_d5_d2",
+       "mainpll_d5"
+};
+
+static const char * const vdec_parents[] = {
+       "clk26m",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "univpll_d6",
+       "mainpll_d5",
+       "univpll_d5",
+       "mmpll_d6",
+       "mainpll_d4",
+       "tvdpll2",
+       "univpll_d4",
+       "imgpll",
+       "univpll_d6_d2",
+       "mmpll_d9"
+};
+
+static const char * const pwm_parents[] = {
+       "clk32k",
+       "clk26m",
+       "univpll_d4_d8",
+       "univpll_d6_d4"
+};
+
+static const char * const mcupm_parents[] = {
+       "clk26m",
+       "mainpll_d6_d2",
+       "mainpll_d7_d4"
+};
+
+static const char * const spmi_p_mst_parents[] = {
+       "clk26m",
+       "clk13m",
+       "ulposc1_d8",
+       "ulposc1_d10",
+       "ulposc1_d16",
+       "ulposc1_d7",
+       "clk32k",
+       "mainpll_d7_d8",
+       "mainpll_d6_d8",
+       "mainpll_d5_d8"
+};
+
+static const char * const spmi_m_mst_parents[] = {
+       "clk26m",
+       "clk13m",
+       "ulposc1_d8",
+       "ulposc1_d10",
+       "ulposc1_d16",
+       "ulposc1_d7",
+       "clk32k",
+       "mainpll_d7_d8",
+       "mainpll_d6_d8",
+       "mainpll_d5_d8"
+};
+
+static const char * const dvfsrc_parents[] = {
+       "clk26m",
+       "ulposc1_d10",
+       "univpll_d6_d8",
+       "msdcpll_d16"
+};
+
+static const char * const tl_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "mainpll_d4_d4"
+};
+
+static const char * const aes_msdcfde_parents[] = {
+       "clk26m",
+       "mainpll_d4_d2",
+       "mainpll_d6",
+       "mainpll_d4_d4",
+       "univpll_d4_d2",
+       "univpll_d6"
+};
+
+static const char * const dsi_occ_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2"
+};
+
+static const char * const wpe_vpp_parents[] = {
+       "clk26m",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "mainpll_d4_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "mainpll_d6",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d5",
+       "univpll_d5",
+       "mainpll_d4",
+       "tvdpll1",
+       "univpll_d4"
+};
+
+static const char * const hdcp_parents[] = {
+       "clk26m",
+       "univpll_d4_d8",
+       "mainpll_d5_d8",
+       "univpll_d6_d4"
+};
+
+static const char * const hdcp_24m_parents[] = {
+       "clk26m",
+       "univpll_192m_d4",
+       "univpll_192m_d8",
+       "univpll_d6_d8"
+};
+
+static const char * const hdmi_apb_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "msdcpll_d2"
+};
+
+static const char * const snps_eth_250m_parents[] = {
+       "clk26m",
+       "ethpll_d2"
+};
+
+static const char * const snps_eth_62p4m_ptp_parents[] = {
+       "apll2_d3",
+       "apll1_d3",
+       "clk26m",
+       "ethpll_d8"
+};
+
+static const char * const snps_eth_50m_rmii_parents[] = {
+       "clk26m",
+       "ethpll_d10"
+};
+
+static const char * const adsp_parents[] = {
+       "clk26m",
+       "clk13m",
+       "mainpll_d6",
+       "mainpll_d5_d2",
+       "univpll_d4_d4",
+       "univpll_d4",
+       "ulposc1_d2",
+       "ulposc1_ck1",
+       "adsppll",
+       "adsppll_d2",
+       "adsppll_d4",
+       "adsppll_d8"
+};
+
+static const char * const audio_local_bus_parents[] = {
+       "clk26m",
+       "clk13m",
+       "mainpll_d4_d4",
+       "mainpll_d7_d2",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2",
+       "mainpll_d7",
+       "mainpll_d4",
+       "univpll_d6",
+       "ulposc1_ck1",
+       "ulposc1_d4",
+       "ulposc1_d2"
+};
+
+static const char * const asm_h_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "univpll_d6_d2",
+       "mainpll_d5_d2"
+};
+
+static const char * const asm_l_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "univpll_d6_d2",
+       "mainpll_d5_d2"
+};
+
+static const char * const apll1_parents[] = {
+       "clk26m",
+       "apll1_d4"
+};
+
+static const char * const apll2_parents[] = {
+       "clk26m",
+       "apll2_d4"
+};
+
+static const char * const apll3_parents[] = {
+       "clk26m",
+       "apll3_d4"
+};
+
+static const char * const apll4_parents[] = {
+       "clk26m",
+       "apll4_d4"
+};
+
+static const char * const apll5_parents[] = {
+       "clk26m",
+       "apll5_d4"
+};
+
+static const char * const i2so1_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const i2so2_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const i2si1_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const i2si2_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const dptx_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const aud_iec_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const a1sys_hp_parents[] = {
+       "clk26m",
+       "apll1_d4"
+};
+
+static const char * const a2sys_parents[] = {
+       "clk26m",
+       "apll2_d4"
+};
+
+static const char * const a3sys_parents[] = {
+       "clk26m",
+       "apll3_d4",
+       "apll4_d4",
+       "apll5_d4"
+};
+
+static const char * const a4sys_parents[] = {
+       "clk26m",
+       "apll3_d4",
+       "apll4_d4",
+       "apll5_d4"
+};
+
+static const char * const ecc_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2",
+       "mainpll_d6",
+       "univpll_d6"
+};
+
+static const char * const spinor_parents[] = {
+       "clk26m",
+       "clk13m",
+       "mainpll_d7_d8",
+       "univpll_d6_d8"
+};
+
+static const char * const ulposc_parents[] = {
+       "ulposc_ck1",
+       "ethpll_d2",
+       "mainpll_d4_d2",
+       "ethpll_d10"
+};
+
+static const char * const srck_parents[] = {
+       "ulposc1_d10",
+       "clk26m"
+};
+
+static const char * const mfg_fast_ref_parents[] = {
+       "top_mfg_core_tmp",
+       "mfgpll"
+};
+
+static const struct mtk_mux top_mtk_muxes[] = {
+       /*
+        * CLK_CFG_0
+        * axi_sel and bus_aximem_sel are bus clocks, should not be closed by Linux.
+        * spm_sel and scp_sel are main clocks in always-on co-processor.
+        */
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_AXI, "top_axi", axi_parents,
+                                  0x020, 0x024, 0x028, 0, 4, 7, 0x04, 0, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SPM, "top_spm", spm_parents,
+                                  0x020, 0x024, 0x028, 8, 4, 15, 0x04, 1, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SCP, "top_scp", scp_parents,
+                                  0x020, 0x024, 0x028, 16, 4, 23, 0x04, 2, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_BUS_AXIMEM, "top_bus_aximem", bus_aximem_parents,
+                                  0x020, 0x024, 0x028, 24, 4, 31, 0x04, 3, CLK_IS_CRITICAL),
+       /* CLK_CFG_1 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_VPP, "top_vpp",
+                            vpp_parents, 0x02C, 0x030, 0x034, 0, 4, 7, 0x04, 4),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ETHDR, "top_ethdr",
+                            ethdr_parents, 0x02C, 0x030, 0x034, 8, 4, 15, 0x04, 5),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_IPE, "top_ipe",
+                            ipe_parents, 0x02C, 0x030, 0x034, 16, 4, 23, 0x04, 6),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAM, "top_cam",
+                            cam_parents, 0x02C, 0x030, 0x034, 24, 4, 31, 0x04, 7),
+       /* CLK_CFG_2 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CCU, "top_ccu",
+                            ccu_parents, 0x038, 0x03C, 0x040, 0, 4, 7, 0x04, 8),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CCU_AHB, "top_ccu_ahb",
+                            ccu_ahb_parents, 0x038, 0x03C, 0x040, 8, 4, 15, 0x04, 9),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_IMG, "top_img",
+                            img_parents, 0x038, 0x03C, 0x040, 16, 4, 23, 0x04, 10),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTM, "top_camtm",
+                            camtm_parents, 0x038, 0x03C, 0x040, 24, 4, 31, 0x04, 11),
+       /* CLK_CFG_3 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP, "top_dsp",
+                            dsp_parents, 0x044, 0x048, 0x04C, 0, 4, 7, 0x04, 12),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP1, "top_dsp1",
+                            dsp1_parents, 0x044, 0x048, 0x04C, 8, 4, 15, 0x04, 13),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP2, "top_dsp2",
+                            dsp2_parents, 0x044, 0x048, 0x04C, 16, 4, 23, 0x04, 14),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP3, "top_dsp3",
+                            dsp3_parents, 0x044, 0x048, 0x04C, 24, 4, 31, 0x04, 15),
+       /* CLK_CFG_4 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP4, "top_dsp4",
+                            dsp4_parents, 0x050, 0x054, 0x058, 0, 4, 7, 0x04, 16),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP5, "top_dsp5",
+                            dsp5_parents, 0x050, 0x054, 0x058, 8, 4, 15, 0x04, 17),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP6, "top_dsp6",
+                            dsp6_parents, 0x050, 0x054, 0x058, 16, 4, 23, 0x04, 18),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP7, "top_dsp7",
+                            dsp7_parents, 0x050, 0x054, 0x058, 24, 4, 31, 0x04, 19),
+       /* CLK_CFG_5 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MFG_CORE_TMP, "top_mfg_core_tmp",
+                            mfg_core_tmp_parents, 0x05C, 0x060, 0x064, 0, 4, 7, 0x04, 20),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG, "top_camtg",
+                            camtg_parents, 0x05C, 0x060, 0x064, 8, 4, 15, 0x04, 21),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG2, "top_camtg2",
+                            camtg2_parents, 0x05C, 0x060, 0x064, 16, 4, 23, 0x04, 22),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG3, "top_camtg3",
+                            camtg3_parents, 0x05C, 0x060, 0x064, 24, 4, 31, 0x04, 23),
+       /* CLK_CFG_6 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_UART, "top_uart",
+                            uart_parents, 0x068, 0x06C, 0x070, 0, 4, 7, 0x04, 24),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPI, "top_spi",
+                            spi_parents, 0x068, 0x06C, 0x070, 8, 4, 15, 0x04, 25),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0_HCLK, "top_msdc5hclk",
+                            msdc5hclk_parents, 0x068, 0x06C, 0x070, 16, 4, 23, 0x04, 26),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0, "top_msdc50_0",
+                            msdc50_0_parents, 0x068, 0x06C, 0x070, 24, 4, 31, 0x04, 27),
+       /* CLK_CFG_7 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_1, "top_msdc30_1",
+                            msdc30_1_parents, 0x074, 0x078, 0x07C, 0, 4, 7, 0x04, 28),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_2, "top_msdc30_2",
+                            msdc30_2_parents, 0x074, 0x078, 0x07C, 8, 4, 15, 0x04, 29),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_INTDIR, "top_intdir",
+                            intdir_parents, 0x074, 0x078, 0x07C, 16, 4, 23, 0x04, 30),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_INTBUS, "top_aud_intbus",
+                            aud_intbus_parents, 0x074, 0x078, 0x07C, 24, 4, 31, 0x04, 31),
+       /* CLK_CFG_8 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO_H, "top_audio_h",
+                            audio_h_parents, 0x080, 0x084, 0x088, 0, 4, 7, 0x08, 0),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_PWRAP_ULPOSC, "top_pwrap_ulposc",
+                            pwrap_ulposc_parents, 0x080, 0x084, 0x088, 8, 4, 15, 0x08, 1),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ATB, "top_atb",
+                            atb_parents, 0x080, 0x084, 0x088, 16, 4, 23, 0x08, 2),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSPM, "top_sspm",
+                            sspm_parents, 0x080, 0x084, 0x088, 24, 4, 31, 0x08, 3),
+       /* CLK_CFG_9 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DP, "top_dp",
+                            dp_parents, 0x08C, 0x090, 0x094, 0, 4, 7, 0x08, 4),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_EDP, "top_edp",
+                            edp_parents, 0x08C, 0x090, 0x094, 8, 4, 15, 0x08, 5),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DPI, "top_dpi",
+                            dpi_parents, 0x08C, 0x090, 0x094, 16, 4, 23, 0x08, 6),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DISP_PWM0, "top_disp_pwm0",
+                            disp_pwm0_parents, 0x08C, 0x090, 0x094, 24, 4, 31, 0x08, 7),
+       /* CLK_CFG_10 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DISP_PWM1, "top_disp_pwm1",
+                            disp_pwm1_parents, 0x098, 0x09C, 0x0A0, 0, 4, 7, 0x08, 8),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP, "top_usb_top",
+                            usb_parents, 0x098, 0x09C, 0x0A0, 8, 4, 15, 0x08, 9),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI, "top_ssusb_xhci",
+                            ssusb_xhci_parents, 0x098, 0x09C, 0x0A0, 16, 4, 23, 0x08, 10),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP_2P, "top_usb_top_2p",
+                            usb_2p_parents, 0x098, 0x09C, 0x0A0, 24, 4, 31, 0x08, 11),
+       /* CLK_CFG_11 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI_2P, "top_ssusb_xhci_2p",
+                            ssusb_xhci_2p_parents, 0x0A4, 0x0A8, 0x0AC, 0, 4, 7, 0x08, 12),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP_3P, "top_usb_top_3p",
+                            usb_3p_parents, 0x0A4, 0x0A8, 0x0AC, 8, 4, 15, 0x08, 13),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI_3P, "top_ssusb_xhci_3p",
+                            ssusb_xhci_3p_parents, 0x0A4, 0x0A8, 0x0AC, 16, 4, 23, 0x08, 14),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2C, "top_i2c",
+                            i2c_parents, 0x0A4, 0x0A8, 0x0AC, 24, 4, 31, 0x08, 15),
+       /* CLK_CFG_12 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF, "top_seninf",
+                            seninf_parents, 0x0B0, 0x0B4, 0x0B8, 0, 4, 7, 0x08, 16),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF1, "top_seninf1",
+                            seninf1_parents, 0x0B0, 0x0B4, 0x0B8, 8, 4, 15, 0x08, 17),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_GCPU, "top_gcpu",
+                            gcpu_parents, 0x0B0, 0x0B4, 0x0B8, 16, 4, 23, 0x08, 18),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_VENC, "top_venc",
+                            venc_parents, 0x0B0, 0x0B4, 0x0B8, 24, 4, 31, 0x08, 19),
+       /*
+        * CLK_CFG_13
+        * top_mcupm is main clock in co-processor, should not be handled by Linux.
+        */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_VDEC, "top_vdec",
+                            vdec_parents, 0x0BC, 0x0C0, 0x0C4, 0, 4, 7, 0x08, 20),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_PWM, "top_pwm",
+                            pwm_parents, 0x0BC, 0x0C0, 0x0C4, 8, 4, 15, 0x08, 21),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MCUPM, "top_mcupm", mcupm_parents,
+                                  0x0BC, 0x0C0, 0x0C4, 16, 4, 23, 0x08, 22, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPMI_P_MST, "top_spmi_p_mst",
+                            spmi_p_mst_parents, 0x0BC, 0x0C0, 0x0C4, 24, 4, 31, 0x08, 23),
+       /*
+        * CLK_CFG_14
+        * dvfsrc_sel is for internal DVFS usage, should not be handled by Linux.
+        */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPMI_M_MST, "top_spmi_m_mst",
+                            spmi_m_mst_parents, 0x0C8, 0x0CC, 0x0D0, 0, 4, 7, 0x08, 24),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_DVFSRC, "top_dvfsrc", dvfsrc_parents,
+                                  0x0C8, 0x0CC, 0x0D0, 8, 4, 15, 0x08, 25, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_TL, "top_tl",
+                            tl_parents, 0x0C8, 0x0CC, 0x0D0, 16, 4, 23, 0x08, 26),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AES_MSDCFDE, "top_aes_msdcfde",
+                            aes_msdcfde_parents, 0x0C8, 0x0CC, 0x0D0, 24, 4, 31, 0x08, 27),
+       /* CLK_CFG_15 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSI_OCC, "top_dsi_occ",
+                            dsi_occ_parents, 0x0D4, 0x0D8, 0x0DC, 0, 4, 7, 0x08, 28),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_WPE_VPP, "top_wpe_vpp",
+                            wpe_vpp_parents, 0x0D4, 0x0D8, 0x0DC, 8, 4, 15, 0x08, 29),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_HDCP, "top_hdcp",
+                            hdcp_parents, 0x0D4, 0x0D8, 0x0DC, 16, 4, 23, 0x08, 30),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_HDCP_24M, "top_hdcp_24m",
+                            hdcp_24m_parents, 0x0D4, 0x0D8, 0x0DC, 24, 4, 31, 0x08, 31),
+       /* CLK_CFG_16 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_HDMI_APB, "top_hdmi_apb",
+                            hdmi_apb_parents, 0x0E0, 0x0E4, 0x0E8, 0, 4, 7, 0x0C, 0),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_250M, "top_snps_eth_250m",
+                            snps_eth_250m_parents, 0x0E0, 0x0E4, 0x0E8, 8, 4, 15, 0x0C, 1),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_62P4M_PTP, "top_snps_eth_62p4m_ptp",
+                            snps_eth_62p4m_ptp_parents, 0x0E0, 0x0E4, 0x0E8, 16, 4, 23, 0x0C, 2),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_50M_RMII, "snps_eth_50m_rmii",
+                            snps_eth_50m_rmii_parents, 0x0E0, 0x0E4, 0x0E8, 24, 4, 31, 0x0C, 3),
+       /* CLK_CFG_17 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ADSP, "top_adsp",
+                            adsp_parents, 0x0EC, 0x0F0, 0x0F4, 0, 4, 7, 0x0C, 4),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO_LOCAL_BUS, "top_audio_local_bus",
+                            audio_local_bus_parents, 0x0EC, 0x0F0, 0x0F4, 8, 4, 15, 0x0C, 5),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ASM_H, "top_asm_h",
+                            asm_h_parents, 0x0EC, 0x0F0, 0x0F4, 16, 4, 23, 0x0C, 6),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ASM_L, "top_asm_l",
+                            asm_l_parents, 0x0EC, 0x0F0, 0x0F4, 24, 4, 31, 0x0C, 7),
+       /* CLK_CFG_18 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL1, "top_apll1",
+                            apll1_parents, 0x0F8, 0x0FC, 0x100, 0, 4, 7, 0x0C, 8),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL2, "top_apll2",
+                            apll2_parents, 0x0F8, 0x0FC, 0x100, 8, 4, 15, 0x0C, 9),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL3, "top_apll3",
+                            apll3_parents, 0x0F8, 0x0FC, 0x100, 16, 4, 23, 0x0C, 10),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL4, "top_apll4",
+                            apll4_parents, 0x0F8, 0x0FC, 0x100, 24, 4, 31, 0x0C, 11),
+       /* CLK_CFG_19 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL5, "top_apll5",
+                            apll5_parents, 0x0104, 0x0108, 0x010C, 0, 4, 7, 0x0C, 12),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SO1, "top_i2so1",
+                            i2so1_parents, 0x0104, 0x0108, 0x010C, 8, 4, 15, 0x0C, 13),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SO2, "top_i2so2",
+                            i2so2_parents, 0x0104, 0x0108, 0x010C, 16, 4, 23, 0x0C, 14),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SI1, "top_i2si1",
+                            i2si1_parents, 0x0104, 0x0108, 0x010C, 24, 4, 31, 0x0C, 15),
+       /* CLK_CFG_20 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SI2, "top_i2si2",
+                            i2si2_parents, 0x0110, 0x0114, 0x0118, 0, 4, 7, 0x0C, 16),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DPTX, "top_dptx",
+                            dptx_parents, 0x0110, 0x0114, 0x0118, 8, 4, 15, 0x0C, 17),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_IEC, "top_aud_iec",
+                            aud_iec_parents, 0x0110, 0x0114, 0x0118, 16, 4, 23, 0x0C, 18),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A1SYS_HP, "top_a1sys_hp",
+                            a1sys_hp_parents, 0x0110, 0x0114, 0x0118, 24, 4, 31, 0x0C, 19),
+       /* CLK_CFG_21 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A2SYS, "top_a2sys",
+                            a2sys_parents, 0x011C, 0x0120, 0x0124, 0, 4, 7, 0x0C, 20),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A3SYS, "top_a3sys",
+                            a3sys_parents, 0x011C, 0x0120, 0x0124, 8, 4, 15, 0x0C, 21),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A4SYS, "top_a4sys",
+                            a4sys_parents, 0x011C, 0x0120, 0x0124, 16, 4, 23, 0x0C, 22),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ECC, "top_ecc",
+                            ecc_parents, 0x011C, 0x0120, 0x0124, 24, 4, 31, 0x0C, 23),
+       /*
+        * CLK_CFG_22
+        * top_ulposc/top_srck are clock source of always on co-processor,
+        * should not be closed by Linux.
+        */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPINOR, "top_spinor",
+                            spinor_parents, 0x0128, 0x012C, 0x0130, 0, 4, 7, 0x0C, 24),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_ULPOSC, "top_ulposc", ulposc_parents,
+                                  0x0128, 0x012C, 0x0130, 8, 4, 15, 0x0C, 25, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SRCK, "top_srck", srck_parents,
+                                  0x0128, 0x012C, 0x0130, 16, 4, 23, 0x0C, 26, CLK_IS_CRITICAL),
+};
+
+static const struct mtk_composite top_adj_divs[] = {
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV0, "apll12_div0", "top_i2si1", 0x0320, 0, 0x0328, 8, 0),
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV1, "apll12_div1", "top_i2si2", 0x0320, 1, 0x0328, 8, 8),
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV2, "apll12_div2", "top_i2so1", 0x0320, 2, 0x0328, 8, 16),
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV3, "apll12_div3", "top_i2so2", 0x0320, 3, 0x0328, 8, 24),
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV4, "apll12_div4", "top_aud_iec", 0x0320, 4, 0x0334, 8, 0),
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV9, "apll12_div9", "top_dptx", 0x0320, 9, 0x0338, 8, 8),
+};
+static const struct mtk_gate_regs top0_cg_regs = {
+       .set_ofs = 0x238,
+       .clr_ofs = 0x238,
+       .sta_ofs = 0x238,
+};
+
+static const struct mtk_gate_regs top1_cg_regs = {
+       .set_ofs = 0x250,
+       .clr_ofs = 0x250,
+       .sta_ofs = 0x250,
+};
+
+#define GATE_TOP0(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+#define GATE_TOP1(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+static const struct mtk_gate top_clks[] = {
+       /* TOP0 */
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VPP0, "cfgreg_clock_vpp0", "top_vpp", 0),
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VPP1, "cfgreg_clock_vpp1", "top_vpp", 1),
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VDO0, "cfgreg_clock_vdo0", "top_vpp", 2),
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VDO1, "cfgreg_clock_vdo1", "top_vpp", 3),
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_ISP_AXI_GALS, "cfgreg_clock_isp_axi_gals", "top_vpp", 4),
+       GATE_TOP0(CLK_TOP_CFGREG_F26M_VPP0, "cfgreg_f26m_vpp0", "clk26m", 5),
+       GATE_TOP0(CLK_TOP_CFGREG_F26M_VPP1, "cfgreg_f26m_vpp1", "clk26m", 6),
+       GATE_TOP0(CLK_TOP_CFGREG_F26M_VDO0, "cfgreg_f26m_vdo0", "clk26m", 7),
+       GATE_TOP0(CLK_TOP_CFGREG_F26M_VDO1, "cfgreg_f26m_vdo1", "clk26m", 8),
+       GATE_TOP0(CLK_TOP_CFGREG_AUD_F26M_AUD, "cfgreg_aud_f26m_aud", "clk26m", 9),
+       GATE_TOP0(CLK_TOP_CFGREG_UNIPLL_SES, "cfgreg_unipll_ses", "univpll_d2", 15),
+       GATE_TOP0(CLK_TOP_CFGREG_F_PCIE_PHY_REF, "cfgreg_f_pcie_phy_ref", "clk26m", 18),
+       /* TOP1 */
+       GATE_TOP1(CLK_TOP_SSUSB_TOP_REF, "ssusb_ref", "clk26m", 0),
+       GATE_TOP1(CLK_TOP_SSUSB_PHY_REF, "ssusb_phy_ref", "clk26m", 1),
+       GATE_TOP1(CLK_TOP_SSUSB_TOP_P1_REF, "ssusb_p1_ref", "clk26m", 2),
+       GATE_TOP1(CLK_TOP_SSUSB_PHY_P1_REF, "ssusb_phy_p1_ref", "clk26m", 3),
+       GATE_TOP1(CLK_TOP_SSUSB_TOP_P2_REF, "ssusb_p2_ref", "clk26m", 4),
+       GATE_TOP1(CLK_TOP_SSUSB_PHY_P2_REF, "ssusb_phy_p2_ref", "clk26m", 5),
+       GATE_TOP1(CLK_TOP_SSUSB_TOP_P3_REF, "ssusb_p3_ref", "clk26m", 6),
+       GATE_TOP1(CLK_TOP_SSUSB_PHY_P3_REF, "ssusb_phy_p3_ref", "clk26m", 7),
+};
+
+static const struct of_device_id of_match_clk_mt8188_topck[] = {
+       { .compatible = "mediatek,mt8188-topckgen" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_topck);
+
+/* Register mux notifier for MFG mux */
+static int clk_mt8188_reg_mfg_mux_notifier(struct device *dev, struct clk *clk)
+{
+       struct mtk_mux_nb *mfg_mux_nb;
+
+       mfg_mux_nb = devm_kzalloc(dev, sizeof(*mfg_mux_nb), GFP_KERNEL);
+       if (!mfg_mux_nb)
+               return -ENOMEM;
+
+       mfg_mux_nb->ops = &clk_mux_ops;
+       mfg_mux_nb->bypass_index = 0; /* Bypass to TOP_MFG_CORE_TMP */
+
+       return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb);
+}
+
+static int clk_mt8188_topck_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *top_clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       struct clk_hw *hw;
+       int r;
+       void __iomem *base;
+
+       top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
+       if (!top_clk_data)
+               return -ENOMEM;
+
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(base)) {
+               r = PTR_ERR(base);
+               goto free_top_data;
+       }
+
+       r = mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
+                                       top_clk_data);
+       if (r)
+               goto free_top_data;
+
+       r = mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
+       if (r)
+               goto unregister_fixed_clks;
+
+       r = mtk_clk_register_muxes(&pdev->dev, top_mtk_muxes,
+                                  ARRAY_SIZE(top_mtk_muxes), node,
+                                  &mt8188_clk_lock, top_clk_data);
+       if (r)
+               goto unregister_factors;
+
+       hw = devm_clk_hw_register_mux(&pdev->dev, "mfg_ck_fast_ref", mfg_fast_ref_parents,
+                                     ARRAY_SIZE(mfg_fast_ref_parents), CLK_SET_RATE_PARENT,
+                                     (base + 0x250), 8, 1, 0, &mt8188_clk_lock);
+       if (IS_ERR(hw)) {
+               r = PTR_ERR(hw);
+               goto unregister_muxes;
+       }
+       top_clk_data->hws[CLK_TOP_MFG_CK_FAST_REF] = hw;
+
+       r = clk_mt8188_reg_mfg_mux_notifier(&pdev->dev,
+                                           top_clk_data->hws[CLK_TOP_MFG_CK_FAST_REF]->clk);
+       if (r)
+               goto unregister_muxes;
+
+       r = mtk_clk_register_composites(&pdev->dev, top_adj_divs,
+                                       ARRAY_SIZE(top_adj_divs), base,
+                                       &mt8188_clk_lock, top_clk_data);
+       if (r)
+               goto unregister_muxes;
+
+       r = mtk_clk_register_gates(&pdev->dev, node, top_clks,
+                                  ARRAY_SIZE(top_clks), top_clk_data);
+       if (r)
+               goto unregister_composite_divs;
+
+       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data);
+       if (r)
+               goto unregister_gates;
+
+       platform_set_drvdata(pdev, top_clk_data);
+
+       return r;
+
+unregister_gates:
+       mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data);
+unregister_composite_divs:
+       mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top_clk_data);
+unregister_muxes:
+       mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data);
+unregister_factors:
+       mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
+unregister_fixed_clks:
+       mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data);
+free_top_data:
+       mtk_free_clk_data(top_clk_data);
+       return r;
+}
+
+static int clk_mt8188_topck_remove(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *top_clk_data = platform_get_drvdata(pdev);
+       struct device_node *node = pdev->dev.of_node;
+
+       of_clk_del_provider(node);
+       mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data);
+       mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top_clk_data);
+       mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data);
+       mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
+       mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data);
+       mtk_free_clk_data(top_clk_data);
+
+       return 0;
+}
+
+static struct platform_driver clk_mt8188_topck_drv = {
+       .probe = clk_mt8188_topck_probe,
+       .remove = clk_mt8188_topck_remove,
+       .driver = {
+               .name = "clk-mt8188-topck",
+               .of_match_table = of_match_clk_mt8188_topck,
+       },
+};
+module_platform_driver(clk_mt8188_topck_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-vdec.c b/drivers/clk/mediatek/clk-mt8188-vdec.c
new file mode 100644 (file)
index 0000000..8c3d765
--- /dev/null
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vdec0_cg_regs = {
+       .set_ofs = 0x0,
+       .clr_ofs = 0x4,
+       .sta_ofs = 0x0,
+};
+
+static const struct mtk_gate_regs vdec1_cg_regs = {
+       .set_ofs = 0x200,
+       .clr_ofs = 0x204,
+       .sta_ofs = 0x200,
+};
+
+static const struct mtk_gate_regs vdec2_cg_regs = {
+       .set_ofs = 0x8,
+       .clr_ofs = 0xc,
+       .sta_ofs = 0x8,
+};
+
+#define GATE_VDEC0(_id, _name, _parent, _shift)                        \
+       GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+#define GATE_VDEC1(_id, _name, _parent, _shift)                        \
+       GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+#define GATE_VDEC2(_id, _name, _parent, _shift)                        \
+       GATE_MTK(_id, _name, _parent, &vdec2_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+static const struct mtk_gate vdec1_clks[] = {
+       /* VDEC1_0 */
+       GATE_VDEC0(CLK_VDEC1_SOC_VDEC, "vdec1_soc_vdec", "top_vdec", 0),
+       GATE_VDEC0(CLK_VDEC1_SOC_VDEC_ACTIVE, "vdec1_soc_vdec_active", "top_vdec", 4),
+       GATE_VDEC0(CLK_VDEC1_SOC_VDEC_ENG, "vdec1_soc_vdec_eng", "top_vdec", 8),
+       /* VDEC1_1 */
+       GATE_VDEC1(CLK_VDEC1_SOC_LAT, "vdec1_soc_lat", "top_vdec", 0),
+       GATE_VDEC1(CLK_VDEC1_SOC_LAT_ACTIVE, "vdec1_soc_lat_active", "top_vdec", 4),
+       GATE_VDEC1(CLK_VDEC1_SOC_LAT_ENG, "vdec1_soc_lat_eng", "top_vdec", 8),
+       /* VDEC1_2 */
+       GATE_VDEC2(CLK_VDEC1_SOC_LARB1, "vdec1_soc_larb1", "top_vdec", 0),
+};
+
+static const struct mtk_gate vdec2_clks[] = {
+       /* VDEC2_0 */
+       GATE_VDEC0(CLK_VDEC2_VDEC, "vdec2_vdec", "top_vdec", 0),
+       GATE_VDEC0(CLK_VDEC2_VDEC_ACTIVE, "vdec2_vdec_active", "top_vdec", 4),
+       GATE_VDEC0(CLK_VDEC2_VDEC_ENG, "vdec2_vdec_eng", "top_vdec", 8),
+       /* VDEC2_1 */
+       GATE_VDEC1(CLK_VDEC2_LAT, "vdec2_lat", "top_vdec", 0),
+       /* VDEC2_2 */
+       GATE_VDEC2(CLK_VDEC2_LARB1, "vdec2_larb1", "top_vdec", 0),
+};
+
+static const struct mtk_clk_desc vdec1_desc = {
+       .clks = vdec1_clks,
+       .num_clks = ARRAY_SIZE(vdec1_clks),
+};
+
+static const struct mtk_clk_desc vdec2_desc = {
+       .clks = vdec2_clks,
+       .num_clks = ARRAY_SIZE(vdec2_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_vdec[] = {
+       { .compatible = "mediatek,mt8188-vdecsys-soc", .data = &vdec1_desc },
+       { .compatible = "mediatek,mt8188-vdecsys", .data = &vdec2_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_vdec);
+
+static struct platform_driver clk_mt8188_vdec_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-vdec",
+               .of_match_table = of_match_clk_mt8188_vdec,
+       },
+};
+
+module_platform_driver(clk_mt8188_vdec_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-vdo0.c b/drivers/clk/mediatek/clk-mt8188-vdo0.c
new file mode 100644 (file)
index 0000000..d2be44c
--- /dev/null
@@ -0,0 +1,107 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vdo0_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vdo0_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+static const struct mtk_gate_regs vdo0_2_cg_regs = {
+       .set_ofs = 0x124,
+       .clr_ofs = 0x128,
+       .sta_ofs = 0x120,
+};
+
+#define GATE_VDO0_0(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo0_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO0_1(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo0_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO0_2(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo0_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO0_2_FLAGS(_id, _name, _parent, _shift, _flags)         \
+       GATE_MTK_FLAGS(_id, _name, _parent, &vdo0_2_cg_regs, _shift,    \
+       &mtk_clk_gate_ops_setclr, _flags)
+
+static const struct mtk_gate vdo0_clks[] = {
+       /* VDO0_0 */
+       GATE_VDO0_0(CLK_VDO0_DISP_OVL0, "vdo0_disp_ovl0", "top_vpp", 0),
+       GATE_VDO0_0(CLK_VDO0_FAKE_ENG0, "vdo0_fake_eng0", "top_vpp", 2),
+       GATE_VDO0_0(CLK_VDO0_DISP_CCORR0, "vdo0_disp_ccorr0", "top_vpp", 4),
+       GATE_VDO0_0(CLK_VDO0_DISP_MUTEX0, "vdo0_disp_mutex0", "top_vpp", 6),
+       GATE_VDO0_0(CLK_VDO0_DISP_GAMMA0, "vdo0_disp_gamma0", "top_vpp", 8),
+       GATE_VDO0_0(CLK_VDO0_DISP_DITHER0, "vdo0_disp_dither0", "top_vpp", 10),
+       GATE_VDO0_0(CLK_VDO0_DISP_WDMA0, "vdo0_disp_wdma0", "top_vpp", 17),
+       GATE_VDO0_0(CLK_VDO0_DISP_RDMA0, "vdo0_disp_rdma0", "top_vpp", 19),
+       GATE_VDO0_0(CLK_VDO0_DSI0, "vdo0_dsi0", "top_vpp", 21),
+       GATE_VDO0_0(CLK_VDO0_DSI1, "vdo0_dsi1", "top_vpp", 22),
+       GATE_VDO0_0(CLK_VDO0_DSC_WRAP0, "vdo0_dsc_wrap0", "top_vpp", 23),
+       GATE_VDO0_0(CLK_VDO0_VPP_MERGE0, "vdo0_vpp_merge0", "top_vpp", 24),
+       GATE_VDO0_0(CLK_VDO0_DP_INTF0, "vdo0_dp_intf0", "top_vpp", 25),
+       GATE_VDO0_0(CLK_VDO0_DISP_AAL0, "vdo0_disp_aal0", "top_vpp", 26),
+       GATE_VDO0_0(CLK_VDO0_INLINEROT0, "vdo0_inlinerot0", "top_vpp", 27),
+       GATE_VDO0_0(CLK_VDO0_APB_BUS, "vdo0_apb_bus", "top_vpp", 28),
+       GATE_VDO0_0(CLK_VDO0_DISP_COLOR0, "vdo0_disp_color0", "top_vpp", 29),
+       GATE_VDO0_0(CLK_VDO0_MDP_WROT0, "vdo0_mdp_wrot0", "top_vpp", 30),
+       GATE_VDO0_0(CLK_VDO0_DISP_RSZ0, "vdo0_disp_rsz0", "top_vpp", 31),
+       /* VDO0_1 */
+       GATE_VDO0_1(CLK_VDO0_DISP_POSTMASK0, "vdo0_disp_postmask0", "top_vpp", 0),
+       GATE_VDO0_1(CLK_VDO0_FAKE_ENG1, "vdo0_fake_eng1", "top_vpp", 1),
+       GATE_VDO0_1(CLK_VDO0_DL_ASYNC2, "vdo0_dl_async2", "top_vpp", 5),
+       GATE_VDO0_1(CLK_VDO0_DL_RELAY3, "vdo0_dl_relay3", "top_vpp", 6),
+       GATE_VDO0_1(CLK_VDO0_DL_RELAY4, "vdo0_dl_relay4", "top_vpp", 7),
+       GATE_VDO0_1(CLK_VDO0_SMI_GALS, "vdo0_smi_gals", "top_vpp", 10),
+       GATE_VDO0_1(CLK_VDO0_SMI_COMMON, "vdo0_smi_common", "top_vpp", 11),
+       GATE_VDO0_1(CLK_VDO0_SMI_EMI, "vdo0_smi_emi", "top_vpp", 12),
+       GATE_VDO0_1(CLK_VDO0_SMI_IOMMU, "vdo0_smi_iommu", "top_vpp", 13),
+       GATE_VDO0_1(CLK_VDO0_SMI_LARB, "vdo0_smi_larb", "top_vpp", 14),
+       GATE_VDO0_1(CLK_VDO0_SMI_RSI, "vdo0_smi_rsi", "top_vpp", 15),
+       /* VDO0_2 */
+       GATE_VDO0_2(CLK_VDO0_DSI0_DSI, "vdo0_dsi0_dsi", "top_dsi_occ", 0),
+       GATE_VDO0_2(CLK_VDO0_DSI1_DSI, "vdo0_dsi1_dsi", "top_dsi_occ", 8),
+       GATE_VDO0_2_FLAGS(CLK_VDO0_DP_INTF0_DP_INTF, "vdo0_dp_intf0_dp_intf",
+               "top_edp", 16, CLK_SET_RATE_PARENT),
+};
+
+static const struct mtk_clk_desc vdo0_desc = {
+       .clks = vdo0_clks,
+       .num_clks = ARRAY_SIZE(vdo0_clks),
+};
+
+static const struct platform_device_id clk_mt8188_vdo0_id_table[] = {
+       { .name = "clk-mt8188-vdo0", .driver_data = (kernel_ulong_t)&vdo0_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8188_vdo0_id_table);
+
+static struct platform_driver clk_mt8188_vdo0_drv = {
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
+       .driver = {
+               .name = "clk-mt8188-vdo0",
+       },
+       .id_table = clk_mt8188_vdo0_id_table,
+};
+module_platform_driver(clk_mt8188_vdo0_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-vdo1.c b/drivers/clk/mediatek/clk-mt8188-vdo1.c
new file mode 100644 (file)
index 0000000..2ef8cae
--- /dev/null
@@ -0,0 +1,154 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vdo1_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vdo1_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+static const struct mtk_gate_regs vdo1_2_cg_regs = {
+       .set_ofs = 0x124,
+       .clr_ofs = 0x128,
+       .sta_ofs = 0x120,
+};
+
+static const struct mtk_gate_regs vdo1_3_cg_regs = {
+       .set_ofs = 0x134,
+       .clr_ofs = 0x138,
+       .sta_ofs = 0x130,
+};
+
+static const struct mtk_gate_regs vdo1_4_cg_regs = {
+       .set_ofs = 0x144,
+       .clr_ofs = 0x148,
+       .sta_ofs = 0x140,
+};
+
+#define GATE_VDO1_0(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo1_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO1_1(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo1_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO1_2(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo1_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO1_3(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo1_3_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO1_3_FLAGS(_id, _name, _parent, _shift, _flags)         \
+       GATE_MTK_FLAGS(_id, _name, _parent, &vdo1_3_cg_regs, _shift,    \
+                      &mtk_clk_gate_ops_setclr, _flags)
+
+#define GATE_VDO1_4(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo1_4_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate vdo1_clks[] = {
+       /* VDO1_0 */
+       GATE_VDO1_0(CLK_VDO1_SMI_LARB2, "vdo1_smi_larb2", "top_vpp", 0),
+       GATE_VDO1_0(CLK_VDO1_SMI_LARB3, "vdo1_smi_larb3", "top_vpp", 1),
+       GATE_VDO1_0(CLK_VDO1_GALS, "vdo1_gals", "top_vpp", 2),
+       GATE_VDO1_0(CLK_VDO1_FAKE_ENG0, "vdo1_fake_eng0", "top_vpp", 3),
+       GATE_VDO1_0(CLK_VDO1_FAKE_ENG1, "vdo1_fake_eng1", "top_vpp", 4),
+       GATE_VDO1_0(CLK_VDO1_MDP_RDMA0, "vdo1_mdp_rdma0", "top_vpp", 5),
+       GATE_VDO1_0(CLK_VDO1_MDP_RDMA1, "vdo1_mdp_rdma1", "top_vpp", 6),
+       GATE_VDO1_0(CLK_VDO1_MDP_RDMA2, "vdo1_mdp_rdma2", "top_vpp", 7),
+       GATE_VDO1_0(CLK_VDO1_MDP_RDMA3, "vdo1_mdp_rdma3", "top_vpp", 8),
+       GATE_VDO1_0(CLK_VDO1_VPP_MERGE0, "vdo1_vpp_merge0", "top_vpp", 9),
+       GATE_VDO1_0(CLK_VDO1_VPP_MERGE1, "vdo1_vpp_merge1", "top_vpp", 10),
+       GATE_VDO1_0(CLK_VDO1_VPP_MERGE2, "vdo1_vpp_merge2", "top_vpp", 11),
+       /* VDO1_1 */
+       GATE_VDO1_1(CLK_VDO1_VPP_MERGE3, "vdo1_vpp_merge3", "top_vpp", 0),
+       GATE_VDO1_1(CLK_VDO1_VPP_MERGE4, "vdo1_vpp_merge4", "top_vpp", 1),
+       GATE_VDO1_1(CLK_VDO1_VPP2_TO_VDO1_DL_ASYNC, "vdo1_vpp2_to_vdo1_dl_async", "top_vpp", 2),
+       GATE_VDO1_1(CLK_VDO1_VPP3_TO_VDO1_DL_ASYNC, "vdo1_vpp3_to_vdo1_dl_async", "top_vpp", 3),
+       GATE_VDO1_1(CLK_VDO1_DISP_MUTEX, "vdo1_disp_mutex", "top_vpp", 4),
+       GATE_VDO1_1(CLK_VDO1_MDP_RDMA4, "vdo1_mdp_rdma4", "top_vpp", 5),
+       GATE_VDO1_1(CLK_VDO1_MDP_RDMA5, "vdo1_mdp_rdma5", "top_vpp", 6),
+       GATE_VDO1_1(CLK_VDO1_MDP_RDMA6, "vdo1_mdp_rdma6", "top_vpp", 7),
+       GATE_VDO1_1(CLK_VDO1_MDP_RDMA7, "vdo1_mdp_rdma7", "top_vpp", 8),
+       GATE_VDO1_1(CLK_VDO1_DP_INTF0_MMCK, "vdo1_dp_intf0_mmck", "top_vpp", 9),
+       GATE_VDO1_1(CLK_VDO1_DPI0_MM, "vdo1_dpi0_mm_ck", "top_vpp", 10),
+       GATE_VDO1_1(CLK_VDO1_DPI1_MM, "vdo1_dpi1_mm_ck", "top_vpp", 11),
+       GATE_VDO1_1(CLK_VDO1_MERGE0_DL_ASYNC, "vdo1_merge0_dl_async", "top_vpp", 13),
+       GATE_VDO1_1(CLK_VDO1_MERGE1_DL_ASYNC, "vdo1_merge1_dl_async", "top_vpp", 14),
+       GATE_VDO1_1(CLK_VDO1_MERGE2_DL_ASYNC, "vdo1_merge2_dl_async", "top_vpp", 15),
+       GATE_VDO1_1(CLK_VDO1_MERGE3_DL_ASYNC, "vdo1_merge3_dl_async", "top_vpp", 16),
+       GATE_VDO1_1(CLK_VDO1_MERGE4_DL_ASYNC, "vdo1_merge4_dl_async", "top_vpp", 17),
+       GATE_VDO1_1(CLK_VDO1_DSC_VDO1_DL_ASYNC, "vdo1_dsc_vdo1_dl_async", "top_vpp", 18),
+       GATE_VDO1_1(CLK_VDO1_MERGE_VDO1_DL_ASYNC, "vdo1_merge_vdo1_dl_async", "top_vpp", 19),
+       GATE_VDO1_1(CLK_VDO1_PADDING0, "vdo1_padding0", "top_vpp", 20),
+       GATE_VDO1_1(CLK_VDO1_PADDING1, "vdo1_padding1", "top_vpp", 21),
+       GATE_VDO1_1(CLK_VDO1_PADDING2, "vdo1_padding2", "top_vpp", 22),
+       GATE_VDO1_1(CLK_VDO1_PADDING3, "vdo1_padding3", "top_vpp", 23),
+       GATE_VDO1_1(CLK_VDO1_PADDING4, "vdo1_padding4", "top_vpp", 24),
+       GATE_VDO1_1(CLK_VDO1_PADDING5, "vdo1_padding5", "top_vpp", 25),
+       GATE_VDO1_1(CLK_VDO1_PADDING6, "vdo1_padding6", "top_vpp", 26),
+       GATE_VDO1_1(CLK_VDO1_PADDING7, "vdo1_padding7", "top_vpp", 27),
+       GATE_VDO1_1(CLK_VDO1_DISP_RSZ0, "vdo1_disp_rsz0", "top_vpp", 28),
+       GATE_VDO1_1(CLK_VDO1_DISP_RSZ1, "vdo1_disp_rsz1", "top_vpp", 29),
+       GATE_VDO1_1(CLK_VDO1_DISP_RSZ2, "vdo1_disp_rsz2", "top_vpp", 30),
+       GATE_VDO1_1(CLK_VDO1_DISP_RSZ3, "vdo1_disp_rsz3", "top_vpp", 31),
+       /* VDO1_2 */
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE0, "vdo1_hdr_vdo_fe0", "top_vpp", 0),
+       GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE0, "vdo1_hdr_gfx_fe0", "top_vpp", 1),
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_BE, "vdo1_hdr_vdo_be", "top_vpp", 2),
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE1, "vdo1_hdr_vdo_fe1", "top_vpp", 16),
+       GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE1, "vdo1_hdr_gfx_fe1", "top_vpp", 17),
+       GATE_VDO1_2(CLK_VDO1_DISP_MIXER, "vdo1_disp_mixer", "top_vpp", 18),
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE0_DL_ASYNC, "vdo1_hdr_vdo_fe0_dl_async", "top_vpp", 19),
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE1_DL_ASYNC, "vdo1_hdr_vdo_fe1_dl_async", "top_vpp", 20),
+       GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE0_DL_ASYNC, "vdo1_hdr_gfx_fe0_dl_async", "top_vpp", 21),
+       GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE1_DL_ASYNC, "vdo1_hdr_gfx_fe1_dl_async", "top_vpp", 22),
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_BE_DL_ASYNC, "vdo1_hdr_vdo_be_dl_async", "top_vpp", 23),
+       /* VDO1_3 */
+       GATE_VDO1_3(CLK_VDO1_DPI0, "vdo1_dpi0_ck", "top_vpp", 0),
+       GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPI0, "vdo1_disp_monitor_dpi0_ck", "top_vpp", 1),
+       GATE_VDO1_3(CLK_VDO1_DPI1, "vdo1_dpi1_ck", "top_vpp", 8),
+       GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPI1, "vdo1_disp_monitor_dpi1_ck", "top_vpp", 9),
+       GATE_VDO1_3_FLAGS(CLK_VDO1_DPINTF, "vdo1_dpintf", "top_dp", 16, CLK_SET_RATE_PARENT),
+       GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPINTF, "vdo1_disp_monitor_dpintf_ck", "top_vpp", 17),
+       /* VDO1_4 */
+       GATE_VDO1_4(CLK_VDO1_26M_SLOW, "vdo1_26m_slow_ck", "clk26m", 8),
+};
+
+static const struct mtk_clk_desc vdo1_desc = {
+       .clks = vdo1_clks,
+       .num_clks = ARRAY_SIZE(vdo1_clks),
+};
+
+static const struct platform_device_id clk_mt8188_vdo1_id_table[] = {
+       { .name = "clk-mt8188-vdo1", .driver_data = (kernel_ulong_t)&vdo1_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8188_vdo1_id_table);
+
+static struct platform_driver clk_mt8188_vdo1_drv = {
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
+       .driver = {
+               .name = "clk-mt8188-vdo1",
+       },
+       .id_table = clk_mt8188_vdo1_id_table,
+};
+module_platform_driver(clk_mt8188_vdo1_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-venc.c b/drivers/clk/mediatek/clk-mt8188-venc.c
new file mode 100644 (file)
index 0000000..245367f
--- /dev/null
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs venc1_cg_regs = {
+       .set_ofs = 0x4,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_VENC1(_id, _name, _parent, _shift)                        \
+       GATE_MTK(_id, _name, _parent, &venc1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+static const struct mtk_gate venc1_clks[] = {
+       GATE_VENC1(CLK_VENC1_LARB, "venc1_larb", "top_venc", 0),
+       GATE_VENC1(CLK_VENC1_VENC, "venc1_venc", "top_venc", 4),
+       GATE_VENC1(CLK_VENC1_JPGENC, "venc1_jpgenc", "top_venc", 8),
+       GATE_VENC1(CLK_VENC1_JPGDEC, "venc1_jpgdec", "top_venc", 12),
+       GATE_VENC1(CLK_VENC1_JPGDEC_C1, "venc1_jpgdec_c1", "top_venc", 16),
+       GATE_VENC1(CLK_VENC1_GALS, "venc1_gals", "top_venc", 28),
+       GATE_VENC1(CLK_VENC1_GALS_SRAM, "venc1_gals_sram", "top_venc", 31),
+};
+
+static const struct mtk_clk_desc venc1_desc = {
+       .clks = venc1_clks,
+       .num_clks = ARRAY_SIZE(venc1_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_venc1[] = {
+       { .compatible = "mediatek,mt8188-vencsys", .data = &venc1_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_venc1);
+
+static struct platform_driver clk_mt8188_venc1_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-venc1",
+               .of_match_table = of_match_clk_mt8188_venc1,
+       },
+};
+
+module_platform_driver(clk_mt8188_venc1_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-vpp0.c b/drivers/clk/mediatek/clk-mt8188-vpp0.c
new file mode 100644 (file)
index 0000000..07bdedf
--- /dev/null
@@ -0,0 +1,114 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vpp0_0_cg_regs = {
+       .set_ofs = 0x24,
+       .clr_ofs = 0x28,
+       .sta_ofs = 0x20,
+};
+
+static const struct mtk_gate_regs vpp0_1_cg_regs = {
+       .set_ofs = 0x30,
+       .clr_ofs = 0x34,
+       .sta_ofs = 0x2c,
+};
+
+static const struct mtk_gate_regs vpp0_2_cg_regs = {
+       .set_ofs = 0x3c,
+       .clr_ofs = 0x40,
+       .sta_ofs = 0x38,
+};
+
+#define GATE_VPP0_0(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vpp0_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VPP0_1(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vpp0_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VPP0_2(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vpp0_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate vpp0_clks[] = {
+       /* VPP0_0 */
+       GATE_VPP0_0(CLK_VPP0_MDP_FG, "vpp0_mdp_fg", "top_vpp", 1),
+       GATE_VPP0_0(CLK_VPP0_STITCH, "vpp0_stitch", "top_vpp", 2),
+       GATE_VPP0_0(CLK_VPP0_PADDING, "vpp0_padding", "top_vpp", 7),
+       GATE_VPP0_0(CLK_VPP0_MDP_TCC, "vpp0_mdp_tcc", "top_vpp", 8),
+       GATE_VPP0_0(CLK_VPP0_WARP0_ASYNC_TX, "vpp0_warp0_async_tx", "top_vpp", 10),
+       GATE_VPP0_0(CLK_VPP0_WARP1_ASYNC_TX, "vpp0_warp1_async_tx", "top_vpp", 11),
+       GATE_VPP0_0(CLK_VPP0_MUTEX, "vpp0_mutex", "top_vpp", 13),
+       GATE_VPP0_0(CLK_VPP02VPP1_RELAY, "vpp02vpp1_relay", "top_vpp", 14),
+       GATE_VPP0_0(CLK_VPP0_VPP12VPP0_ASYNC, "vpp0_vpp12vpp0_async", "top_vpp", 15),
+       GATE_VPP0_0(CLK_VPP0_MMSYSRAM_TOP, "vpp0_mmsysram_top", "top_vpp", 16),
+       GATE_VPP0_0(CLK_VPP0_MDP_AAL, "vpp0_mdp_aal", "top_vpp", 17),
+       GATE_VPP0_0(CLK_VPP0_MDP_RSZ, "vpp0_mdp_rsz", "top_vpp", 18),
+       /* VPP0_1 */
+       GATE_VPP0_1(CLK_VPP0_SMI_COMMON_MMSRAM, "vpp0_smi_common_mmsram", "top_vpp", 0),
+       GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB0_MMSRAM, "vpp0_gals_vdo0_larb0_mmsram", "top_vpp", 1),
+       GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB1_MMSRAM, "vpp0_gals_vdo0_larb1_mmsram", "top_vpp", 2),
+       GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_MMSRAM, "vpp0_gals_vencsys_mmsram", "top_vpp", 3),
+       GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_CORE1_MMSRAM,
+                   "vpp0_gals_vencsys_core1_mmsram", "top_vpp", 4),
+       GATE_VPP0_1(CLK_VPP0_GALS_INFRA_MMSRAM, "vpp0_gals_infra_mmsram", "top_vpp", 5),
+       GATE_VPP0_1(CLK_VPP0_GALS_CAMSYS_MMSRAM, "vpp0_gals_camsys_mmsram", "top_vpp", 6),
+       GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB5_MMSRAM, "vpp0_gals_vpp1_larb5_mmsram", "top_vpp", 7),
+       GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB6_MMSRAM, "vpp0_gals_vpp1_larb6_mmsram", "top_vpp", 8),
+       GATE_VPP0_1(CLK_VPP0_SMI_REORDER_MMSRAM, "vpp0_smi_reorder_mmsram", "top_vpp", 9),
+       GATE_VPP0_1(CLK_VPP0_SMI_IOMMU, "vpp0_smi_iommu", "top_vpp", 10),
+       GATE_VPP0_1(CLK_VPP0_GALS_IMGSYS_CAMSYS, "vpp0_gals_imgsys_camsys", "top_vpp", 11),
+       GATE_VPP0_1(CLK_VPP0_MDP_RDMA, "vpp0_mdp_rdma", "top_vpp", 12),
+       GATE_VPP0_1(CLK_VPP0_MDP_WROT, "vpp0_mdp_wrot", "top_vpp", 13),
+       GATE_VPP0_1(CLK_VPP0_GALS_EMI0_EMI1, "vpp0_gals_emi0_emi1", "top_vpp", 16),
+       GATE_VPP0_1(CLK_VPP0_SMI_SUB_COMMON_REORDER, "vpp0_smi_sub_common_reorder", "top_vpp", 17),
+       GATE_VPP0_1(CLK_VPP0_SMI_RSI, "vpp0_smi_rsi", "top_vpp", 18),
+       GATE_VPP0_1(CLK_VPP0_SMI_COMMON_LARB4, "vpp0_smi_common_larb4", "top_vpp", 19),
+       GATE_VPP0_1(CLK_VPP0_GALS_VDEC_VDEC_CORE1, "vpp0_gals_vdec_vdec_core1", "top_vpp", 20),
+       GATE_VPP0_1(CLK_VPP0_GALS_VPP1_WPESYS, "vpp0_gals_vpp1_wpesys", "top_vpp", 21),
+       GATE_VPP0_1(CLK_VPP0_GALS_VDO0_VDO1_VENCSYS_CORE1,
+                   "vpp0_gals_vdo0_vdo1_vencsys_core1", "top_vpp", 22),
+       GATE_VPP0_1(CLK_VPP0_FAKE_ENG, "vpp0_fake_eng", "top_vpp", 23),
+       GATE_VPP0_1(CLK_VPP0_MDP_HDR, "vpp0_mdp_hdr", "top_vpp", 24),
+       GATE_VPP0_1(CLK_VPP0_MDP_TDSHP, "vpp0_mdp_tdshp", "top_vpp", 25),
+       GATE_VPP0_1(CLK_VPP0_MDP_COLOR, "vpp0_mdp_color", "top_vpp", 26),
+       GATE_VPP0_1(CLK_VPP0_MDP_OVL, "vpp0_mdp_ovl", "top_vpp", 27),
+       GATE_VPP0_1(CLK_VPP0_DSIP_RDMA, "vpp0_dsip_rdma", "top_vpp", 28),
+       GATE_VPP0_1(CLK_VPP0_DISP_WDMA, "vpp0_disp_wdma", "top_vpp", 29),
+       GATE_VPP0_1(CLK_VPP0_MDP_HMS, "vpp0_mdp_hms", "top_vpp", 30),
+       /* VPP0_2 */
+       GATE_VPP0_2(CLK_VPP0_WARP0_RELAY, "vpp0_warp0_relay", "top_wpe_vpp", 0),
+       GATE_VPP0_2(CLK_VPP0_WARP0_ASYNC, "vpp0_warp0_async", "top_wpe_vpp", 1),
+       GATE_VPP0_2(CLK_VPP0_WARP1_RELAY, "vpp0_warp1_relay", "top_wpe_vpp", 2),
+       GATE_VPP0_2(CLK_VPP0_WARP1_ASYNC, "vpp0_warp1_async", "top_wpe_vpp", 3),
+};
+
+static const struct mtk_clk_desc vpp0_desc = {
+       .clks = vpp0_clks,
+       .num_clks = ARRAY_SIZE(vpp0_clks),
+};
+
+static const struct platform_device_id clk_mt8188_vpp0_id_table[] = {
+       { .name = "clk-mt8188-vpp0", .driver_data = (kernel_ulong_t)&vpp0_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8188_vpp0_id_table);
+
+static struct platform_driver clk_mt8188_vpp0_drv = {
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
+       .driver = {
+               .name = "clk-mt8188-vpp0",
+       },
+       .id_table = clk_mt8188_vpp0_id_table,
+};
+module_platform_driver(clk_mt8188_vpp0_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-vpp1.c b/drivers/clk/mediatek/clk-mt8188-vpp1.c
new file mode 100644 (file)
index 0000000..d4e66b2
--- /dev/null
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vpp1_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vpp1_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+#define GATE_VPP1_0(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vpp1_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VPP1_1(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vpp1_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate vpp1_clks[] = {
+       /* VPP1_0 */
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_OVL, "vpp1_svpp1_mdp_ovl", "top_vpp", 0),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TCC, "vpp1_svpp1_mdp_tcc", "top_vpp", 1),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_WROT, "vpp1_svpp1_mdp_wrot", "top_vpp", 2),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_VPP_PAD, "vpp1_svpp1_vpp_pad", "top_vpp", 3),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_WROT, "vpp1_svpp2_mdp_wrot", "top_vpp", 4),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_PAD, "vpp1_svpp2_vpp_pad", "top_vpp", 5),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_WROT, "vpp1_svpp3_mdp_wrot", "top_vpp", 6),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_PAD, "vpp1_svpp3_vpp_pad", "top_vpp", 7),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RDMA, "vpp1_svpp1_mdp_rdma", "top_vpp", 8),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_FG, "vpp1_svpp1_mdp_fg", "top_vpp", 9),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RDMA, "vpp1_svpp2_mdp_rdma", "top_vpp", 10),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_FG, "vpp1_svpp2_mdp_fg", "top_vpp", 11),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RDMA, "vpp1_svpp3_mdp_rdma", "top_vpp", 12),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_FG, "vpp1_svpp3_mdp_fg", "top_vpp", 13),
+       GATE_VPP1_0(CLK_VPP1_VPP_SPLIT, "vpp1_vpp_split", "top_vpp", 14),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_VDO0_DL_RELAY, "vpp1_svpp2_vdo0_dl_relay", "top_vpp", 15),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RSZ, "vpp1_svpp1_mdp_rsz", "top_vpp", 16),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TDSHP, "vpp1_svpp1_mdp_tdshp", "top_vpp", 17),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_COLOR, "vpp1_svpp1_mdp_color", "top_vpp", 18),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_VDO1_DL_RELAY, "vpp1_svpp3_vdo1_dl_relay", "top_vpp", 19),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RSZ, "vpp1_svpp2_mdp_rsz", "top_vpp", 20),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_MERGE, "vpp1_svpp2_vpp_merge", "top_vpp", 21),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_TDSHP, "vpp1_svpp2_mdp_tdshp", "top_vpp", 22),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_COLOR, "vpp1_svpp2_mdp_color", "top_vpp", 23),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RSZ, "vpp1_svpp3_mdp_rsz", "top_vpp", 24),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_MERGE, "vpp1_svpp3_vpp_merge", "top_vpp", 25),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_TDSHP, "vpp1_svpp3_mdp_tdshp", "top_vpp", 26),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_COLOR, "vpp1_svpp3_mdp_color", "top_vpp", 27),
+       GATE_VPP1_0(CLK_VPP1_GALS5, "vpp1_gals5", "top_vpp", 28),
+       GATE_VPP1_0(CLK_VPP1_GALS6, "vpp1_gals6", "top_vpp", 29),
+       GATE_VPP1_0(CLK_VPP1_LARB5, "vpp1_larb5", "top_vpp", 30),
+       GATE_VPP1_0(CLK_VPP1_LARB6, "vpp1_larb6", "top_vpp", 31),
+       /* VPP1_1 */
+       GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_HDR, "vpp1_svpp1_mdp_hdr", "top_vpp", 0),
+       GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_AAL, "vpp1_svpp1_mdp_aal", "top_vpp", 1),
+       GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_HDR, "vpp1_svpp2_mdp_hdr", "top_vpp", 2),
+       GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_AAL, "vpp1_svpp2_mdp_aal", "top_vpp", 3),
+       GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_HDR, "vpp1_svpp3_mdp_hdr", "top_vpp", 4),
+       GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_AAL, "vpp1_svpp3_mdp_aal", "top_vpp", 5),
+       GATE_VPP1_1(CLK_VPP1_DISP_MUTEX, "vpp1_disp_mutex", "top_vpp", 7),
+       GATE_VPP1_1(CLK_VPP1_SVPP2_VDO1_DL_RELAY, "vpp1_svpp2_vdo1_dl_relay", "top_vpp", 8),
+       GATE_VPP1_1(CLK_VPP1_SVPP3_VDO0_DL_RELAY, "vpp1_svpp3_vdo0_dl_relay", "top_vpp", 9),
+       GATE_VPP1_1(CLK_VPP1_VPP0_DL_ASYNC, "vpp1_vpp0_dl_async", "top_vpp", 10),
+       GATE_VPP1_1(CLK_VPP1_VPP0_DL1_RELAY, "vpp1_vpp0_dl1_relay", "top_vpp", 11),
+       GATE_VPP1_1(CLK_VPP1_LARB5_FAKE_ENG, "vpp1_larb5_fake_eng", "top_vpp", 12),
+       GATE_VPP1_1(CLK_VPP1_LARB6_FAKE_ENG, "vpp1_larb6_fake_eng", "top_vpp", 13),
+       GATE_VPP1_1(CLK_VPP1_HDMI_META, "vpp1_hdmi_meta", "top_vpp", 16),
+       GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_HDMI, "vpp1_vpp_split_hdmi", "top_vpp", 17),
+       GATE_VPP1_1(CLK_VPP1_DGI_IN, "vpp1_dgi_in", "top_vpp", 18),
+       GATE_VPP1_1(CLK_VPP1_DGI_OUT, "vpp1_dgi_out", "top_vpp", 19),
+       GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_DGI, "vpp1_vpp_split_dgi", "top_vpp", 20),
+       GATE_VPP1_1(CLK_VPP1_DL_CON_OCC, "vpp1_dl_con_occ", "top_vpp", 21),
+       GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "top_vpp", 26),
+};
+
+static const struct mtk_clk_desc vpp1_desc = {
+       .clks = vpp1_clks,
+       .num_clks = ARRAY_SIZE(vpp1_clks),
+};
+
+static const struct platform_device_id clk_mt8188_vpp1_id_table[] = {
+       { .name = "clk-mt8188-vpp1", .driver_data = (kernel_ulong_t)&vpp1_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8188_vpp1_id_table);
+
+static struct platform_driver clk_mt8188_vpp1_drv = {
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
+       .driver = {
+               .name = "clk-mt8188-vpp1",
+       },
+       .id_table = clk_mt8188_vpp1_id_table,
+};
+module_platform_driver(clk_mt8188_vpp1_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8188-wpe.c b/drivers/clk/mediatek/clk-mt8188-wpe.c
new file mode 100644 (file)
index 0000000..393ac38
--- /dev/null
@@ -0,0 +1,105 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs wpe_top_cg_regs = {
+       .set_ofs = 0x0,
+       .clr_ofs = 0x0,
+       .sta_ofs = 0x0,
+};
+
+static const struct mtk_gate_regs wpe_vpp0_0_cg_regs = {
+       .set_ofs = 0x58,
+       .clr_ofs = 0x58,
+       .sta_ofs = 0x58,
+};
+
+static const struct mtk_gate_regs wpe_vpp0_1_cg_regs = {
+       .set_ofs = 0x5c,
+       .clr_ofs = 0x5c,
+       .sta_ofs = 0x5c,
+};
+
+#define GATE_WPE_TOP(_id, _name, _parent, _shift)                      \
+       GATE_MTK(_id, _name, _parent, &wpe_top_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+#define GATE_WPE_VPP0_0(_id, _name, _parent, _shift)           \
+       GATE_MTK(_id, _name, _parent, &wpe_vpp0_0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+#define GATE_WPE_VPP0_1(_id, _name, _parent, _shift)           \
+       GATE_MTK(_id, _name, _parent, &wpe_vpp0_1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+static const struct mtk_gate wpe_top_clks[] = {
+       GATE_WPE_TOP(CLK_WPE_TOP_WPE_VPP0, "wpe_wpe_vpp0", "top_wpe_vpp", 16),
+       GATE_WPE_TOP(CLK_WPE_TOP_SMI_LARB7, "wpe_smi_larb7", "top_wpe_vpp", 18),
+       GATE_WPE_TOP(CLK_WPE_TOP_WPESYS_EVENT_TX, "wpe_wpesys_event_tx", "top_wpe_vpp", 20),
+       GATE_WPE_TOP(CLK_WPE_TOP_SMI_LARB7_PCLK_EN, "wpe_smi_larb7_p_en", "top_wpe_vpp", 24),
+};
+
+static const struct mtk_gate wpe_vpp0_clks[] = {
+       /* WPE_VPP00 */
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_VGEN, "wpe_vpp0_vgen", "top_img", 0),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_EXT, "wpe_vpp0_ext", "top_img", 1),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_VFC, "wpe_vpp0_vfc", "top_img", 2),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH0_TOP, "wpe_vpp0_cach0_top", "top_img", 3),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH0_DMA, "wpe_vpp0_cach0_dma", "top_img", 4),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH1_TOP, "wpe_vpp0_cach1_top", "top_img", 5),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH1_DMA, "wpe_vpp0_cach1_dma", "top_img", 6),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH2_TOP, "wpe_vpp0_cach2_top", "top_img", 7),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH2_DMA, "wpe_vpp0_cach2_dma", "top_img", 8),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH3_TOP, "wpe_vpp0_cach3_top", "top_img", 9),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH3_DMA, "wpe_vpp0_cach3_dma", "top_img", 10),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_PSP, "wpe_vpp0_psp", "top_img", 11),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_PSP2, "wpe_vpp0_psp2", "top_img", 12),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_SYNC, "wpe_vpp0_sync", "top_img", 13),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_C24, "wpe_vpp0_c24", "top_img", 14),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_MDP_CROP, "wpe_vpp0_mdp_crop", "top_img", 15),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_ISP_CROP, "wpe_vpp0_isp_crop", "top_img", 16),
+       GATE_WPE_VPP0_0(CLK_WPE_VPP0_TOP, "wpe_vpp0_top", "top_img", 17),
+       /* WPE_VPP0_1 */
+       GATE_WPE_VPP0_1(CLK_WPE_VPP0_VECI, "wpe_vpp0_veci", "top_img", 0),
+       GATE_WPE_VPP0_1(CLK_WPE_VPP0_VEC2I, "wpe_vpp0_vec2i", "top_img", 1),
+       GATE_WPE_VPP0_1(CLK_WPE_VPP0_VEC3I, "wpe_vpp0_vec3i", "top_img", 2),
+       GATE_WPE_VPP0_1(CLK_WPE_VPP0_WPEO, "wpe_vpp0_wpeo", "top_img", 3),
+       GATE_WPE_VPP0_1(CLK_WPE_VPP0_MSKO, "wpe_vpp0_msko", "top_img", 4),
+};
+
+static const struct mtk_clk_desc wpe_top_desc = {
+       .clks = wpe_top_clks,
+       .num_clks = ARRAY_SIZE(wpe_top_clks),
+};
+
+static const struct mtk_clk_desc wpe_vpp0_desc = {
+       .clks = wpe_vpp0_clks,
+       .num_clks = ARRAY_SIZE(wpe_vpp0_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_wpe[] = {
+       { .compatible = "mediatek,mt8188-wpesys", .data = &wpe_top_desc },
+       { .compatible = "mediatek,mt8188-wpesys-vpp0", .data = &wpe_vpp0_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_wpe);
+
+static struct platform_driver clk_mt8188_wpe_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-wpe",
+               .of_match_table = of_match_clk_mt8188_wpe,
+       },
+};
+
+module_platform_driver(clk_mt8188_wpe_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8192-apmixedsys.c b/drivers/clk/mediatek/clk-mt8192-apmixedsys.c
new file mode 100644 (file)
index 0000000..eafd342
--- /dev/null
@@ -0,0 +1,215 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ *               Chun-Jie Chen <chun-jie.chen@mediatek.com>
+ * Copyright (c) 2023 Collabora Ltd.
+ *               AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+ */
+
+#include <dt-bindings/clock/mt8192-clk.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include "clk-fhctl.h"
+#include "clk-gate.h"
+#include "clk-mtk.h"
+#include "clk-pll.h"
+#include "clk-pllfh.h"
+
+static const struct mtk_gate_regs apmixed_cg_regs = {
+       .set_ofs = 0x14,
+       .clr_ofs = 0x14,
+       .sta_ofs = 0x14,
+};
+
+#define GATE_APMIXED(_id, _name, _parent, _shift)      \
+       GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+static const struct mtk_gate apmixed_clks[] = {
+       GATE_APMIXED(CLK_APMIXED_MIPID26M, "mipid26m", "clk26m", 16),
+};
+
+#define MT8192_PLL_FMAX                (3800UL * MHZ)
+#define MT8192_PLL_FMIN                (1500UL * MHZ)
+#define MT8192_INTEGER_BITS    8
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags,              \
+                       _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift,    \
+                       _tuner_reg, _tuner_en_reg, _tuner_en_bit,       \
+                       _pcw_reg, _pcw_shift, _pcw_chg_reg,             \
+                       _en_reg, _pll_en_bit) {                         \
+               .id = _id,                                              \
+               .name = _name,                                          \
+               .reg = _reg,                                            \
+               .pwr_reg = _pwr_reg,                                    \
+               .en_mask = _en_mask,                                    \
+               .flags = _flags,                                        \
+               .rst_bar_mask = _rst_bar_mask,                          \
+               .fmax = MT8192_PLL_FMAX,                                \
+               .fmin = MT8192_PLL_FMIN,                                \
+               .pcwbits = _pcwbits,                                    \
+               .pcwibits = MT8192_INTEGER_BITS,                        \
+               .pd_reg = _pd_reg,                                      \
+               .pd_shift = _pd_shift,                                  \
+               .tuner_reg = _tuner_reg,                                \
+               .tuner_en_reg = _tuner_en_reg,                          \
+               .tuner_en_bit = _tuner_en_bit,                          \
+               .pcw_reg = _pcw_reg,                                    \
+               .pcw_shift = _pcw_shift,                                \
+               .pcw_chg_reg = _pcw_chg_reg,                            \
+               .en_reg = _en_reg,                                      \
+               .pll_en_bit = _pll_en_bit,                              \
+       }
+
+#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,            \
+                       _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift,    \
+                       _tuner_reg, _tuner_en_reg, _tuner_en_bit,       \
+                       _pcw_reg, _pcw_shift)                           \
+               PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags,       \
+                       _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift,    \
+                       _tuner_reg, _tuner_en_reg, _tuner_en_bit,       \
+                       _pcw_reg, _pcw_shift, 0, 0, 0)
+
+static const struct mtk_pll_data plls[] = {
+       PLL_B(CLK_APMIXED_MAINPLL, "mainpll", 0x0340, 0x034c, 0xff000000,
+             HAVE_RST_BAR, BIT(23), 22, 0x0344, 24, 0, 0, 0, 0x0344, 0),
+       PLL_B(CLK_APMIXED_UNIVPLL, "univpll", 0x0308, 0x0314, 0xff000000,
+             HAVE_RST_BAR, BIT(23), 22, 0x030c, 24, 0, 0, 0, 0x030c, 0),
+       PLL(CLK_APMIXED_USBPLL, "usbpll", 0x03c4, 0x03cc, 0x00000000,
+           0, 0, 22, 0x03c4, 24, 0, 0, 0, 0x03c4, 0, 0x03c4, 0x03cc, 2),
+       PLL_B(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0350, 0x035c, 0x00000000,
+             0, 0, 22, 0x0354, 24, 0, 0, 0, 0x0354, 0),
+       PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0360, 0x036c, 0xff000000,
+             HAVE_RST_BAR, BIT(23), 22, 0x0364, 24, 0, 0, 0, 0x0364, 0),
+       PLL_B(CLK_APMIXED_ADSPPLL, "adsppll", 0x0370, 0x037c, 0xff000000,
+             HAVE_RST_BAR, BIT(23), 22, 0x0374, 24, 0, 0, 0, 0x0374, 0),
+       PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0268, 0x0274, 0x00000000,
+             0, 0, 22, 0x026c, 24, 0, 0, 0, 0x026c, 0),
+       PLL_B(CLK_APMIXED_TVDPLL, "tvdpll", 0x0380, 0x038c, 0x00000000,
+             0, 0, 22, 0x0384, 24, 0, 0, 0, 0x0384, 0),
+       PLL_B(CLK_APMIXED_APLL1, "apll1", 0x0318, 0x0328, 0x00000000,
+             0, 0, 32, 0x031c, 24, 0x0040, 0x000c, 0, 0x0320, 0),
+       PLL_B(CLK_APMIXED_APLL2, "apll2", 0x032c, 0x033c, 0x00000000,
+             0, 0, 32, 0x0330, 24, 0, 0, 0, 0x0334, 0),
+};
+
+enum fh_pll_id {
+       FH_ARMPLL_LL,
+       FH_ARMPLL_BL0,
+       FH_ARMPLL_BL1,
+       FH_ARMPLL_BL2,
+       FH_ARMPLL_BL3,
+       FH_CCIPLL,
+       FH_MFGPLL,
+       FH_MEMPLL,
+       FH_MPLL,
+       FH_MMPLL,
+       FH_MAINPLL,
+       FH_MSDCPLL,
+       FH_ADSPPLL,
+       FH_APUPLL,
+       FH_TVDPLL,
+       FH_NR_FH,
+};
+
+#define FH(_pllid, _fhid, _offset) {                                   \
+               .data = {                                               \
+                       .pll_id = _pllid,                               \
+                       .fh_id = _fhid,                                 \
+                       .fh_ver = FHCTL_PLLFH_V2,                       \
+                       .fhx_offset = _offset,                          \
+                       .dds_mask = GENMASK(21, 0),                     \
+                       .slope0_value = 0x6003c97,                      \
+                       .slope1_value = 0x6003c97,                      \
+                       .sfstrx_en = BIT(2),                            \
+                       .frddsx_en = BIT(1),                            \
+                       .fhctlx_en = BIT(0),                            \
+                       .tgl_org = BIT(31),                             \
+                       .dvfs_tri = BIT(31),                            \
+                       .pcwchg = BIT(31),                              \
+                       .dt_val = 0x0,                                  \
+                       .df_val = 0x9,                                  \
+                       .updnlmt_shft = 16,                             \
+                       .msk_frddsx_dys = GENMASK(23, 20),              \
+                       .msk_frddsx_dts = GENMASK(19, 16),              \
+               },                                                      \
+       }
+
+static struct mtk_pllfh_data pllfhs[] = {
+       FH(CLK_APMIXED_MFGPLL, FH_MFGPLL, 0xb4),
+       FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0xf0),
+       FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x104),
+       FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x118),
+       FH(CLK_APMIXED_ADSPPLL, FH_ADSPPLL, 0x12c),
+       FH(CLK_APMIXED_TVDPLL, FH_TVDPLL, 0x154),
+};
+
+static const struct of_device_id of_match_clk_mt8192_apmixed[] = {
+       { .compatible = "mediatek,mt8192-apmixedsys" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_apmixed);
+
+static int clk_mt8192_apmixed_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       const u8 *fhctl_node = "mediatek,mt8192-fhctl";
+       int r;
+
+       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
+
+       r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
+                                   pllfhs, ARRAY_SIZE(pllfhs), clk_data);
+       if (r)
+               goto free_clk_data;
+
+       r = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks,
+                                  ARRAY_SIZE(apmixed_clks), clk_data);
+       if (r)
+               goto unregister_plls;
+
+       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (r)
+               goto unregister_gates;
+
+       return r;
+
+unregister_gates:
+       mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
+unregister_plls:
+       mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs,
+                                 ARRAY_SIZE(pllfhs), clk_data);
+free_clk_data:
+       mtk_free_clk_data(clk_data);
+       return r;
+}
+
+static int clk_mt8192_apmixed_remove(struct platform_device *pdev)
+{
+       struct device_node *node = pdev->dev.of_node;
+       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+       of_clk_del_provider(node);
+       mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
+       mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs,
+                                 ARRAY_SIZE(pllfhs), clk_data);
+       mtk_free_clk_data(clk_data);
+
+       return 0;
+}
+
+static struct platform_driver clk_mt8192_apmixed_drv = {
+       .driver = {
+               .name = "clk-mt8192-apmixed",
+               .of_match_table = of_match_clk_mt8192_apmixed,
+       },
+       .probe = clk_mt8192_apmixed_probe,
+       .remove = clk_mt8192_apmixed_remove,
+};
+module_platform_driver(clk_mt8192_apmixed_drv);
+MODULE_DESCRIPTION("MediaTek MT8192 apmixed clocks driver");
+MODULE_LICENSE("GPL");
index 29affb68e854bcebb9f14ee868712fbc751a8b43..ee251492d4f13a05d4404b54a390958831c6a354 100644 (file)
@@ -107,6 +107,7 @@ static const struct of_device_id of_match_clk_mt8192_aud[] = {
        { .compatible = "mediatek,mt8192-audsys", .data = &aud_desc },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_aud);
 
 static struct platform_driver clk_mt8192_aud_drv = {
        .probe = clk_mt8192_aud_probe,
@@ -116,5 +117,5 @@ static struct platform_driver clk_mt8192_aud_drv = {
                .of_match_table = of_match_clk_mt8192_aud,
        },
 };
-
-builtin_platform_driver(clk_mt8192_aud_drv);
+module_platform_driver(clk_mt8192_aud_drv);
+MODULE_LICENSE("GPL");
index 90b57d46eef74db8cc2c8c640a66f25fe1225903..7befd6ee8c799c1b1265edc8a0bde0e0e134a5b4 100644 (file)
@@ -95,6 +95,7 @@ static const struct of_device_id of_match_clk_mt8192_cam[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_cam);
 
 static struct platform_driver clk_mt8192_cam_drv = {
        .probe = mtk_clk_simple_probe,
@@ -104,5 +105,5 @@ static struct platform_driver clk_mt8192_cam_drv = {
                .of_match_table = of_match_clk_mt8192_cam,
        },
 };
-
-builtin_platform_driver(clk_mt8192_cam_drv);
+module_platform_driver(clk_mt8192_cam_drv);
+MODULE_LICENSE("GPL");
index da82d65a765015f3fa161b5ad1977d4a90d21767..a7505150a9d014124cdb5a6f133501421426b98b 100644 (file)
@@ -58,6 +58,7 @@ static const struct of_device_id of_match_clk_mt8192_img[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_img);
 
 static struct platform_driver clk_mt8192_img_drv = {
        .probe = mtk_clk_simple_probe,
@@ -67,5 +68,5 @@ static struct platform_driver clk_mt8192_img_drv = {
                .of_match_table = of_match_clk_mt8192_img,
        },
 };
-
-builtin_platform_driver(clk_mt8192_img_drv);
+module_platform_driver(clk_mt8192_img_drv);
+MODULE_LICENSE("GPL");
index ff8e20bb44bb0ed1dc8d6ea7bd368a47d1f528cb..cd5d00a7c54b32081978f31777884c75bd35e089 100644 (file)
@@ -107,6 +107,7 @@ static const struct of_device_id of_match_clk_mt8192_imp_iic_wrap[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_imp_iic_wrap);
 
 static struct platform_driver clk_mt8192_imp_iic_wrap_drv = {
        .probe = mtk_clk_simple_probe,
@@ -116,5 +117,5 @@ static struct platform_driver clk_mt8192_imp_iic_wrap_drv = {
                .of_match_table = of_match_clk_mt8192_imp_iic_wrap,
        },
 };
-
-builtin_platform_driver(clk_mt8192_imp_iic_wrap_drv);
+module_platform_driver(clk_mt8192_imp_iic_wrap_drv);
+MODULE_LICENSE("GPL");
index 0225abe4170a916a1d32270af3adb8de574505a7..dee671ae38e6d42d96fe4561d7d3d6cec7a3a39e 100644 (file)
@@ -45,6 +45,7 @@ static const struct of_device_id of_match_clk_mt8192_ipe[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_ipe);
 
 static struct platform_driver clk_mt8192_ipe_drv = {
        .probe = mtk_clk_simple_probe,
@@ -54,5 +55,5 @@ static struct platform_driver clk_mt8192_ipe_drv = {
                .of_match_table = of_match_clk_mt8192_ipe,
        },
 };
-
-builtin_platform_driver(clk_mt8192_ipe_drv);
+module_platform_driver(clk_mt8192_ipe_drv);
+MODULE_LICENSE("GPL");
index 4675788d78169a04db7981e0a387d7c49212a9de..f7b27264e378c5f8f48ea59e72b4220962f3ab64 100644 (file)
@@ -70,6 +70,7 @@ static const struct of_device_id of_match_clk_mt8192_mdp[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_mdp);
 
 static struct platform_driver clk_mt8192_mdp_drv = {
        .probe = mtk_clk_simple_probe,
@@ -79,5 +80,5 @@ static struct platform_driver clk_mt8192_mdp_drv = {
                .of_match_table = of_match_clk_mt8192_mdp,
        },
 };
-
-builtin_platform_driver(clk_mt8192_mdp_drv);
+module_platform_driver(clk_mt8192_mdp_drv);
+MODULE_LICENSE("GPL");
index ec5b44ffa458d797afd018660817592814bb879a..85f76a2bbac4553ffe944f38effdb91a85fd2f1e 100644 (file)
@@ -40,6 +40,7 @@ static const struct of_device_id of_match_clk_mt8192_mfg[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_mfg);
 
 static struct platform_driver clk_mt8192_mfg_drv = {
        .probe = mtk_clk_simple_probe,
@@ -49,5 +50,5 @@ static struct platform_driver clk_mt8192_mfg_drv = {
                .of_match_table = of_match_clk_mt8192_mfg,
        },
 };
-
-builtin_platform_driver(clk_mt8192_mfg_drv);
+module_platform_driver(clk_mt8192_mfg_drv);
+MODULE_LICENSE("GPL");
index e9eb4cf8349acff1ec4a5dfa1171c6c89efd09ad..47335d5177141c0186f64ee54a876f3816ff8e9f 100644 (file)
@@ -80,30 +80,24 @@ static const struct mtk_gate mm_clks[] = {
        GATE_MM2(CLK_MM_32KHZ, "mm_32khz", "clk32k", 25),
 };
 
-static int clk_mt8192_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       r = mtk_clk_register_gates(&pdev->dev, node, mm_clks,
-                              ARRAY_SIZE(mm_clks), clk_data);
-       if (r)
-               return r;
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mm_clks,
+       .num_clks = ARRAY_SIZE(mm_clks),
+};
 
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct platform_device_id clk_mt8192_mm_id_table[] = {
+       { .name = "clk-mt8192-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8192_mm_id_table);
 
 static struct platform_driver clk_mt8192_mm_drv = {
-       .probe = clk_mt8192_mm_probe,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt8192-mm",
        },
+       .id_table = clk_mt8192_mm_id_table,
 };
-
-builtin_platform_driver(clk_mt8192_mm_drv);
+module_platform_driver(clk_mt8192_mm_drv);
+MODULE_LICENSE("GPL");
index a72e1b73fce8649e92be9d473083f06aa907cb4b..60d65f96d39a13674c8717b7a0729f8df4066f0a 100644 (file)
@@ -52,6 +52,7 @@ static const struct of_device_id of_match_clk_mt8192_msdc[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_msdc);
 
 static struct platform_driver clk_mt8192_msdc_drv = {
        .probe = mtk_clk_simple_probe,
@@ -61,5 +62,5 @@ static struct platform_driver clk_mt8192_msdc_drv = {
                .of_match_table = of_match_clk_mt8192_msdc,
        },
 };
-
-builtin_platform_driver(clk_mt8192_msdc_drv);
+module_platform_driver(clk_mt8192_msdc_drv);
+MODULE_LICENSE("GPL");
index 18a8679108b860d2e85c9e47820245d54445ca26..6aad57797c3908ab76913aedaea0191388545a22 100644 (file)
@@ -38,6 +38,7 @@ static const struct of_device_id of_match_clk_mt8192_scp_adsp[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_scp_adsp);
 
 static struct platform_driver clk_mt8192_scp_adsp_drv = {
        .probe = mtk_clk_simple_probe,
@@ -47,5 +48,5 @@ static struct platform_driver clk_mt8192_scp_adsp_drv = {
                .of_match_table = of_match_clk_mt8192_scp_adsp,
        },
 };
-
-builtin_platform_driver(clk_mt8192_scp_adsp_drv);
+module_platform_driver(clk_mt8192_scp_adsp_drv);
+MODULE_LICENSE("GPL");
index e149962dbbf95fffbb7a2b4c46227967846f2b25..473afd58495c29bcdee7e59b09a188b00fdea217 100644 (file)
@@ -82,6 +82,7 @@ static const struct of_device_id of_match_clk_mt8192_vdec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_vdec);
 
 static struct platform_driver clk_mt8192_vdec_drv = {
        .probe = mtk_clk_simple_probe,
@@ -91,5 +92,5 @@ static struct platform_driver clk_mt8192_vdec_drv = {
                .of_match_table = of_match_clk_mt8192_vdec,
        },
 };
-
-builtin_platform_driver(clk_mt8192_vdec_drv);
+module_platform_driver(clk_mt8192_vdec_drv);
+MODULE_LICENSE("GPL");
index 80b8bb170996bbb65c58870c5dc9eacce577367c..57b1b16e23108a2feb41f4f025f2bdd4c4a9ffca 100644 (file)
@@ -41,6 +41,7 @@ static const struct of_device_id of_match_clk_mt8192_venc[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_venc);
 
 static struct platform_driver clk_mt8192_venc_drv = {
        .probe = mtk_clk_simple_probe,
@@ -50,5 +51,5 @@ static struct platform_driver clk_mt8192_venc_drv = {
                .of_match_table = of_match_clk_mt8192_venc,
        },
 };
-
-builtin_platform_driver(clk_mt8192_venc_drv);
+module_platform_driver(clk_mt8192_venc_drv);
+MODULE_LICENSE("GPL");
index 61299960d28adbb9996ada69494784b5afe8ebef..aa11291463f7578afa7c04d28c5fcaffa695820a 100644 (file)
@@ -15,7 +15,6 @@
 #include "clk-gate.h"
 #include "clk-mtk.h"
 #include "clk-mux.h"
-#include "clk-pll.h"
 
 #include <dt-bindings/clock/mt8192-clk.h>
 #include <dt-bindings/reset/mt8192-resets.h>
@@ -712,19 +711,6 @@ static struct mtk_composite top_muxes[] = {
        DIV_GATE(CLK_TOP_APLL12_DIV9, "apll12_div9", "apll_i2s9_m_sel", 0x320, 10, 0x338, 8, 16),
 };
 
-static const struct mtk_gate_regs apmixed_cg_regs = {
-       .set_ofs = 0x14,
-       .clr_ofs = 0x14,
-       .sta_ofs = 0x14,
-};
-
-#define GATE_APMIXED(_id, _name, _parent, _shift)      \
-       GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
-
-static const struct mtk_gate apmixed_clks[] = {
-       GATE_APMIXED(CLK_APMIXED_MIPID26M, "mipid26m", "clk26m", 16),
-};
-
 static const struct mtk_gate_regs infra0_cg_regs = {
        .set_ofs = 0x80,
        .clr_ofs = 0x84,
@@ -978,70 +964,6 @@ static const struct mtk_clk_rst_desc clk_rst_desc = {
        .rst_idx_map_nr = ARRAY_SIZE(infra_ao_idx_map),
 };
 
-#define MT8192_PLL_FMAX                (3800UL * MHZ)
-#define MT8192_PLL_FMIN                (1500UL * MHZ)
-#define MT8192_INTEGER_BITS    8
-
-#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags,              \
-                       _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift,    \
-                       _tuner_reg, _tuner_en_reg, _tuner_en_bit,       \
-                       _pcw_reg, _pcw_shift, _pcw_chg_reg,             \
-                       _en_reg, _pll_en_bit) {                         \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .reg = _reg,                                            \
-               .pwr_reg = _pwr_reg,                                    \
-               .en_mask = _en_mask,                                    \
-               .flags = _flags,                                        \
-               .rst_bar_mask = _rst_bar_mask,                          \
-               .fmax = MT8192_PLL_FMAX,                                \
-               .fmin = MT8192_PLL_FMIN,                                \
-               .pcwbits = _pcwbits,                                    \
-               .pcwibits = MT8192_INTEGER_BITS,                        \
-               .pd_reg = _pd_reg,                                      \
-               .pd_shift = _pd_shift,                                  \
-               .tuner_reg = _tuner_reg,                                \
-               .tuner_en_reg = _tuner_en_reg,                          \
-               .tuner_en_bit = _tuner_en_bit,                          \
-               .pcw_reg = _pcw_reg,                                    \
-               .pcw_shift = _pcw_shift,                                \
-               .pcw_chg_reg = _pcw_chg_reg,                            \
-               .en_reg = _en_reg,                                      \
-               .pll_en_bit = _pll_en_bit,                              \
-       }
-
-#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,            \
-                       _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift,    \
-                       _tuner_reg, _tuner_en_reg, _tuner_en_bit,       \
-                       _pcw_reg, _pcw_shift)                           \
-               PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags,       \
-                       _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift,    \
-                       _tuner_reg, _tuner_en_reg, _tuner_en_bit,       \
-                       _pcw_reg, _pcw_shift, 0, 0, 0)
-
-static const struct mtk_pll_data plls[] = {
-       PLL_B(CLK_APMIXED_MAINPLL, "mainpll", 0x0340, 0x034c, 0xff000000,
-             HAVE_RST_BAR, BIT(23), 22, 0x0344, 24, 0, 0, 0, 0x0344, 0),
-       PLL_B(CLK_APMIXED_UNIVPLL, "univpll", 0x0308, 0x0314, 0xff000000,
-             HAVE_RST_BAR, BIT(23), 22, 0x030c, 24, 0, 0, 0, 0x030c, 0),
-       PLL(CLK_APMIXED_USBPLL, "usbpll", 0x03c4, 0x03cc, 0x00000000,
-           0, 0, 22, 0x03c4, 24, 0, 0, 0, 0x03c4, 0, 0x03c4, 0x03cc, 2),
-       PLL_B(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0350, 0x035c, 0x00000000,
-             0, 0, 22, 0x0354, 24, 0, 0, 0, 0x0354, 0),
-       PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0360, 0x036c, 0xff000000,
-             HAVE_RST_BAR, BIT(23), 22, 0x0364, 24, 0, 0, 0, 0x0364, 0),
-       PLL_B(CLK_APMIXED_ADSPPLL, "adsppll", 0x0370, 0x037c, 0xff000000,
-             HAVE_RST_BAR, BIT(23), 22, 0x0374, 24, 0, 0, 0, 0x0374, 0),
-       PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0268, 0x0274, 0x00000000,
-             0, 0, 22, 0x026c, 24, 0, 0, 0, 0x026c, 0),
-       PLL_B(CLK_APMIXED_TVDPLL, "tvdpll", 0x0380, 0x038c, 0x00000000,
-             0, 0, 22, 0x0384, 24, 0, 0, 0, 0x0384, 0),
-       PLL_B(CLK_APMIXED_APLL1, "apll1", 0x0318, 0x0328, 0x00000000,
-             0, 0, 32, 0x031c, 24, 0x0040, 0x000c, 0, 0x0320, 0),
-       PLL_B(CLK_APMIXED_APLL2, "apll2", 0x032c, 0x033c, 0x00000000,
-             0, 0, 32, 0x0330, 24, 0, 0, 0, 0x0334, 0),
-};
-
 /* Register mux notifier for MFG mux */
 static int clk_mt8192_reg_mfg_mux_notifier(struct device *dev, struct clk *clk)
 {
@@ -1064,60 +986,6 @@ static int clk_mt8192_reg_mfg_mux_notifier(struct device *dev, struct clk *clk)
        return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb);
 }
 
-static int clk_mt8192_apmixed_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
-       r = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks,
-                                  ARRAY_SIZE(apmixed_clks), clk_data);
-       if (r)
-               goto free_clk_data;
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               goto unregister_gates;
-
-       return r;
-
-unregister_gates:
-       mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
-free_clk_data:
-       mtk_free_clk_data(clk_data);
-       return r;
-}
-
-static const struct of_device_id of_match_clk_mt8192[] = {
-       {
-               .compatible = "mediatek,mt8192-apmixedsys",
-               .data = clk_mt8192_apmixed_probe,
-       }, {
-               /* sentinel */
-       }
-};
-
-static int clk_mt8192_probe(struct platform_device *pdev)
-{
-       int (*clk_probe)(struct platform_device *pdev);
-       int r;
-
-       clk_probe = of_device_get_match_data(&pdev->dev);
-       if (!clk_probe)
-               return -EINVAL;
-
-       r = clk_probe(pdev);
-       if (r)
-               dev_err(&pdev->dev, "could not register clock provider: %s: %d\n", pdev->name, r);
-
-       return r;
-}
-
 static const struct mtk_clk_desc infra_desc = {
        .clks = infra_clks,
        .num_clks = ARRAY_SIZE(infra_clks),
@@ -1145,37 +1013,21 @@ static const struct mtk_clk_desc topck_desc = {
        .mfg_clk_idx = CLK_TOP_MFG_PLL_SEL,
 };
 
-static const struct of_device_id of_match_clk_mt8192_simple[] = {
+static const struct of_device_id of_match_clk_mt8192[] = {
        { .compatible = "mediatek,mt8192-infracfg", .data = &infra_desc },
        { .compatible = "mediatek,mt8192-pericfg", .data = &peri_desc },
        { .compatible = "mediatek,mt8192-topckgen", .data = &topck_desc },
        { /* sentinel */ }
 };
-
-static struct platform_driver clk_mt8192_simple_drv = {
-       .probe = mtk_clk_simple_probe,
-       .remove = mtk_clk_simple_remove,
-       .driver = {
-               .name = "clk-mt8192-simple",
-               .of_match_table = of_match_clk_mt8192_simple,
-       },
-};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8192);
 
 static struct platform_driver clk_mt8192_drv = {
-       .probe = clk_mt8192_probe,
        .driver = {
                .name = "clk-mt8192",
                .of_match_table = of_match_clk_mt8192,
        },
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
 };
-
-static int __init clk_mt8192_init(void)
-{
-       int ret = platform_driver_register(&clk_mt8192_drv);
-
-       if (ret)
-               return ret;
-       return platform_driver_register(&clk_mt8192_simple_drv);
-}
-
-arch_initcall(clk_mt8192_init);
+module_platform_driver(clk_mt8192_drv);
+MODULE_LICENSE("GPL");
index 1bc917f2667e485c4ce4b16092f9a9da83447bd3..8b9b5d8202869b6af3ebb40eb4dc67fffcc2634b 100644 (file)
@@ -3,9 +3,11 @@
 // Copyright (c) 2021 MediaTek Inc.
 // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com>
 
+#include "clk-fhctl.h"
 #include "clk-gate.h"
 #include "clk-mtk.h"
 #include "clk-pll.h"
+#include "clk-pllfh.h"
 
 #include <dt-bindings/clock/mt8195-clk.h>
 #include <linux/of_device.h>
@@ -105,22 +107,82 @@ static const struct mtk_pll_data plls[] = {
            0, 0, 22, 0x0158, 24, 0, 0, 0, 0x0158, 0, 0x0158, 0, 9),
 };
 
+enum fh_pll_id {
+       FH_ARMPLL_LL,
+       FH_ARMPLL_BL,
+       FH_MEMPLL,
+       FH_ADSPPLL,
+       FH_NNAPLL,
+       FH_CCIPLL,
+       FH_MFGPLL,
+       FH_TVDPLL2,
+       FH_MPLL,
+       FH_MMPLL,
+       FH_MAINPLL,
+       FH_MSDCPLL,
+       FH_IMGPLL,
+       FH_VDECPLL,
+       FH_TVDPLL1,
+       FH_NR_FH,
+};
+
+#define FH(_pllid, _fhid, _offset) {                                   \
+               .data = {                                               \
+                       .pll_id = _pllid,                               \
+                       .fh_id = _fhid,                                 \
+                       .fh_ver = FHCTL_PLLFH_V2,                       \
+                       .fhx_offset = _offset,                          \
+                       .dds_mask = GENMASK(21, 0),                     \
+                       .slope0_value = 0x6003c97,                      \
+                       .slope1_value = 0x6003c97,                      \
+                       .sfstrx_en = BIT(2),                            \
+                       .frddsx_en = BIT(1),                            \
+                       .fhctlx_en = BIT(0),                            \
+                       .tgl_org = BIT(31),                             \
+                       .dvfs_tri = BIT(31),                            \
+                       .pcwchg = BIT(31),                              \
+                       .dt_val = 0x0,                                  \
+                       .df_val = 0x9,                                  \
+                       .updnlmt_shft = 16,                             \
+                       .msk_frddsx_dys = GENMASK(23, 20),              \
+                       .msk_frddsx_dts = GENMASK(19, 16),              \
+               },                                                      \
+       }
+
+static struct mtk_pllfh_data pllfhs[] = {
+       FH(CLK_APMIXED_ADSPPLL, FH_ADSPPLL, 0x78),
+       FH(CLK_APMIXED_NNAPLL, FH_NNAPLL, 0x8c),
+       FH(CLK_APMIXED_MFGPLL, FH_MFGPLL, 0xb4),
+       FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL2, 0xc8),
+       FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0xf0),
+       FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x104),
+       FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x118),
+       FH(CLK_APMIXED_IMGPLL, FH_IMGPLL, 0x12c),
+       FH(CLK_APMIXED_VDECPLL, FH_VDECPLL, 0x140),
+       FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL1, 0x154),
+};
+
 static const struct of_device_id of_match_clk_mt8195_apmixed[] = {
        { .compatible = "mediatek,mt8195-apmixedsys", },
        {}
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_apmixed);
 
 static int clk_mt8195_apmixed_probe(struct platform_device *pdev)
 {
        struct clk_hw_onecell_data *clk_data;
        struct device_node *node = pdev->dev.of_node;
+       const u8 *fhctl_node = "mediatek,mt8195-fhctl";
        int r;
 
        clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
        if (!clk_data)
                return -ENOMEM;
 
-       r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
+
+       r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
+                                   pllfhs, ARRAY_SIZE(pllfhs), clk_data);
        if (r)
                goto free_apmixed_data;
 
@@ -140,7 +202,8 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev)
 unregister_gates:
        mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
 unregister_plls:
-       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+       mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs,
+                                 ARRAY_SIZE(pllfhs), clk_data);
 free_apmixed_data:
        mtk_free_clk_data(clk_data);
        return r;
@@ -153,7 +216,8 @@ static int clk_mt8195_apmixed_remove(struct platform_device *pdev)
 
        of_clk_del_provider(node);
        mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
-       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+       mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs,
+                                 ARRAY_SIZE(pllfhs), clk_data);
        mtk_free_clk_data(clk_data);
 
        return 0;
@@ -167,4 +231,5 @@ static struct platform_driver clk_mt8195_apmixed_drv = {
                .of_match_table = of_match_clk_mt8195_apmixed,
        },
 };
-builtin_platform_driver(clk_mt8195_apmixed_drv);
+module_platform_driver(clk_mt8195_apmixed_drv);
+MODULE_LICENSE("GPL");
index 0b52f6a009c4bbb735df8d6a776488463fb7fafe..de04c087c8c33d15e947d313eca82d7d0fcdbdba 100644 (file)
@@ -101,6 +101,7 @@ static const struct of_device_id of_match_clk_mt8195_apusys_pll[] = {
        { .compatible = "mediatek,mt8195-apusys_pll", },
        {}
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_apusys_pll);
 
 static struct platform_driver clk_mt8195_apusys_pll_drv = {
        .probe = clk_mt8195_apusys_pll_probe,
@@ -110,4 +111,5 @@ static struct platform_driver clk_mt8195_apusys_pll_drv = {
                .of_match_table = of_match_clk_mt8195_apusys_pll,
        },
 };
-builtin_platform_driver(clk_mt8195_apusys_pll_drv);
+module_platform_driver(clk_mt8195_apusys_pll_drv);
+MODULE_LICENSE("GPL");
index e4d00fe6e757b3240cd29ace4d2d3051bee74991..77e608be579aa138e5fab3db5ea682d56ad4f878 100644 (file)
@@ -131,6 +131,7 @@ static const struct of_device_id of_match_clk_mt8195_cam[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_cam);
 
 static struct platform_driver clk_mt8195_cam_drv = {
        .probe = mtk_clk_simple_probe,
@@ -140,4 +141,5 @@ static struct platform_driver clk_mt8195_cam_drv = {
                .of_match_table = of_match_clk_mt8195_cam,
        },
 };
-builtin_platform_driver(clk_mt8195_cam_drv);
+module_platform_driver(clk_mt8195_cam_drv);
+MODULE_LICENSE("GPL");
index 4e326b6301ba1e121d39f132551e33a883749ad1..bdc2e6f3e9ce3cb012a8fa9300da11d8e550fec2 100644 (file)
@@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8195_ccu[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_ccu);
 
 static struct platform_driver clk_mt8195_ccu_drv = {
        .probe = mtk_clk_simple_probe,
@@ -48,4 +49,5 @@ static struct platform_driver clk_mt8195_ccu_drv = {
                .of_match_table = of_match_clk_mt8195_ccu,
        },
 };
-builtin_platform_driver(clk_mt8195_ccu_drv);
+module_platform_driver(clk_mt8195_ccu_drv);
+MODULE_LICENSE("GPL");
index 12f5c436d07548b7902a326ea3a09d615ec2a951..d853e0e63d87a8a32ff8404069ca05984ebc9c1b 100644 (file)
@@ -85,6 +85,7 @@ static const struct of_device_id of_match_clk_mt8195_img[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_img);
 
 static struct platform_driver clk_mt8195_img_drv = {
        .probe = mtk_clk_simple_probe,
@@ -94,4 +95,5 @@ static struct platform_driver clk_mt8195_img_drv = {
                .of_match_table = of_match_clk_mt8195_img,
        },
 };
-builtin_platform_driver(clk_mt8195_img_drv);
+module_platform_driver(clk_mt8195_img_drv);
+MODULE_LICENSE("GPL");
index fbc809d050727fa0ed2853991f1c502622a719ba..1d808876f5c54fb89e87d1c80bce6d13b0298104 100644 (file)
@@ -55,6 +55,7 @@ static const struct of_device_id of_match_clk_mt8195_imp_iic_wrap[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_imp_iic_wrap);
 
 static struct platform_driver clk_mt8195_imp_iic_wrap_drv = {
        .probe = mtk_clk_simple_probe,
@@ -64,4 +65,5 @@ static struct platform_driver clk_mt8195_imp_iic_wrap_drv = {
                .of_match_table = of_match_clk_mt8195_imp_iic_wrap,
        },
 };
-builtin_platform_driver(clk_mt8195_imp_iic_wrap_drv);
+module_platform_driver(clk_mt8195_imp_iic_wrap_drv);
+MODULE_LICENSE("GPL");
index fcd410461d3bb4419046dff5a24c8e10da26d7af..f3ee4390707dd7c2fd07341d9099569e95211944 100644 (file)
@@ -229,6 +229,7 @@ static const struct of_device_id of_match_clk_mt8195_infra_ao[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_infra_ao);
 
 static struct platform_driver clk_mt8195_infra_ao_drv = {
        .probe = mtk_clk_simple_probe,
@@ -238,4 +239,5 @@ static struct platform_driver clk_mt8195_infra_ao_drv = {
                .of_match_table = of_match_clk_mt8195_infra_ao,
        },
 };
-builtin_platform_driver(clk_mt8195_infra_ao_drv);
+module_platform_driver(clk_mt8195_infra_ao_drv);
+MODULE_LICENSE("GPL");
index b0d745cf77523a24b23865bb90aec7f31c58a05a..4c47f65212753b51b2240646ffd62c5c0332602c 100644 (file)
@@ -40,6 +40,7 @@ static const struct of_device_id of_match_clk_mt8195_ipe[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_ipe);
 
 static struct platform_driver clk_mt8195_ipe_drv = {
        .probe = mtk_clk_simple_probe,
@@ -49,4 +50,5 @@ static struct platform_driver clk_mt8195_ipe_drv = {
                .of_match_table = of_match_clk_mt8195_ipe,
        },
 };
-builtin_platform_driver(clk_mt8195_ipe_drv);
+module_platform_driver(clk_mt8195_ipe_drv);
+MODULE_LICENSE("GPL");
index c94cb71bd9b94c163580468ce7843ed9e9627831..038acf0b1167ab73529d8e1301aeb37169bec6ed 100644 (file)
@@ -38,6 +38,7 @@ static const struct of_device_id of_match_clk_mt8195_mfg[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_mfg);
 
 static struct platform_driver clk_mt8195_mfg_drv = {
        .probe = mtk_clk_simple_probe,
@@ -47,4 +48,5 @@ static struct platform_driver clk_mt8195_mfg_drv = {
                .of_match_table = of_match_clk_mt8195_mfg,
        },
 };
-builtin_platform_driver(clk_mt8195_mfg_drv);
+module_platform_driver(clk_mt8195_mfg_drv);
+MODULE_LICENSE("GPL");
index 2f6b3bb657dbbcc0e11229147c3678f16a5eef5b..0de162593c0153cbee2a23e4f5b63906b28838e4 100644 (file)
@@ -51,6 +51,7 @@ static const struct of_device_id of_match_clk_mt8195_peri_ao[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_peri_ao);
 
 static struct platform_driver clk_mt8195_peri_ao_drv = {
        .probe = mtk_clk_simple_probe,
@@ -60,4 +61,5 @@ static struct platform_driver clk_mt8195_peri_ao_drv = {
                .of_match_table = of_match_clk_mt8195_peri_ao,
        },
 };
-builtin_platform_driver(clk_mt8195_peri_ao_drv);
+module_platform_driver(clk_mt8195_peri_ao_drv);
+MODULE_LICENSE("GPL");
index e16c383f631b55506972ade7dd14b4055502b1a3..d0d3e3b097803a698b1284c619f5fdec4021a094 100644 (file)
@@ -36,6 +36,7 @@ static const struct of_device_id of_match_clk_mt8195_scp_adsp[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_scp_adsp);
 
 static struct platform_driver clk_mt8195_scp_adsp_drv = {
        .probe = mtk_clk_simple_probe,
@@ -45,4 +46,5 @@ static struct platform_driver clk_mt8195_scp_adsp_drv = {
                .of_match_table = of_match_clk_mt8195_scp_adsp,
        },
 };
-builtin_platform_driver(clk_mt8195_scp_adsp_drv);
+module_platform_driver(clk_mt8195_scp_adsp_drv);
+MODULE_LICENSE("GPL");
index cf520f85de73c7dfacd89a8347a54570f89df9b3..3c2174c3e742f390526a367921144d5ed9684e25 100644 (file)
@@ -1219,6 +1219,7 @@ static const struct of_device_id of_match_clk_mt8195_topck[] = {
        { .compatible = "mediatek,mt8195-topckgen", },
        {}
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_topck);
 
 /* Register mux notifier for MFG mux */
 static int clk_mt8195_reg_mfg_mux_notifier(struct device *dev, struct clk *clk)
@@ -1340,4 +1341,5 @@ static struct platform_driver clk_mt8195_topck_drv = {
                .of_match_table = of_match_clk_mt8195_topck,
        },
 };
-builtin_platform_driver(clk_mt8195_topck_drv);
+module_platform_driver(clk_mt8195_topck_drv);
+MODULE_LICENSE("GPL");
index a1446b66638505eb39f5c4a8559248f59df84fe8..2bcbceb10326bb2a27f3128f0193ace2db3d4c86 100644 (file)
@@ -93,6 +93,7 @@ static const struct of_device_id of_match_clk_mt8195_vdec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_vdec);
 
 static struct platform_driver clk_mt8195_vdec_drv = {
        .probe = mtk_clk_simple_probe,
@@ -102,4 +103,5 @@ static struct platform_driver clk_mt8195_vdec_drv = {
                .of_match_table = of_match_clk_mt8195_vdec,
        },
 };
-builtin_platform_driver(clk_mt8195_vdec_drv);
+module_platform_driver(clk_mt8195_vdec_drv);
+MODULE_LICENSE("GPL");
index 839b730688acbc6d086ee54c40a330f26ef97a28..509780750e43c31dc5922bce5afa7fad2d491f47 100644 (file)
@@ -93,55 +93,24 @@ static const struct mtk_gate vdo0_clks[] = {
                          "top_edp", 16, CLK_SET_RATE_PARENT),
 };
 
-static int clk_mt8195_vdo0_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_VDO0_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       r = mtk_clk_register_gates(&pdev->dev, node, vdo0_clks,
-                                  ARRAY_SIZE(vdo0_clks), clk_data);
-       if (r)
-               goto free_vdo0_data;
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               goto unregister_gates;
-
-       platform_set_drvdata(pdev, clk_data);
-
-       return r;
-
-unregister_gates:
-       mtk_clk_unregister_gates(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data);
-free_vdo0_data:
-       mtk_free_clk_data(clk_data);
-       return r;
-}
-
-static int clk_mt8195_vdo0_remove(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-
-       of_clk_del_provider(node);
-       mtk_clk_unregister_gates(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data);
-       mtk_free_clk_data(clk_data);
+static const struct mtk_clk_desc vdo0_desc = {
+       .clks = vdo0_clks,
+       .num_clks = ARRAY_SIZE(vdo0_clks),
+};
 
-       return 0;
-}
+static const struct platform_device_id clk_mt8195_vdo0_id_table[] = {
+       { .name = "clk-mt8195-vdo0", .driver_data = (kernel_ulong_t)&vdo0_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8195_vdo0_id_table);
 
 static struct platform_driver clk_mt8195_vdo0_drv = {
-       .probe = clk_mt8195_vdo0_probe,
-       .remove = clk_mt8195_vdo0_remove,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt8195-vdo0",
        },
+       .id_table = clk_mt8195_vdo0_id_table,
 };
-builtin_platform_driver(clk_mt8195_vdo0_drv);
+module_platform_driver(clk_mt8195_vdo0_drv);
+MODULE_LICENSE("GPL");
index 7df695b2892588dfa94ff647823083fa67254a72..0a5214a1ed256f4c5cb979cd96b6c263647378e2 100644 (file)
@@ -120,55 +120,24 @@ static const struct mtk_gate vdo1_clks[] = {
        GATE_VDO1_4(CLK_VDO1_DPI1_HDMI, "vdo1_dpi1_hdmi", "hdmi_txpll", 0),
 };
 
-static int clk_mt8195_vdo1_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_VDO1_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       r = mtk_clk_register_gates(&pdev->dev, node, vdo1_clks,
-                                  ARRAY_SIZE(vdo1_clks), clk_data);
-       if (r)
-               goto free_vdo1_data;
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               goto unregister_gates;
-
-       platform_set_drvdata(pdev, clk_data);
-
-       return r;
-
-unregister_gates:
-       mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data);
-free_vdo1_data:
-       mtk_free_clk_data(clk_data);
-       return r;
-}
-
-static int clk_mt8195_vdo1_remove(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-
-       of_clk_del_provider(node);
-       mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data);
-       mtk_free_clk_data(clk_data);
-
-       return 0;
-}
+static const struct mtk_clk_desc vdo1_desc = {
+       .clks = vdo1_clks,
+       .num_clks = ARRAY_SIZE(vdo1_clks),
+};
+
+static const struct platform_device_id clk_mt8195_vdo1_id_table[] = {
+       { .name = "clk-mt8195-vdo1", .driver_data = (kernel_ulong_t)&vdo1_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8195_vdo1_id_table);
 
 static struct platform_driver clk_mt8195_vdo1_drv = {
-       .probe = clk_mt8195_vdo1_probe,
-       .remove = clk_mt8195_vdo1_remove,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt8195-vdo1",
        },
+       .id_table = clk_mt8195_vdo1_id_table,
 };
-builtin_platform_driver(clk_mt8195_vdo1_drv);
+module_platform_driver(clk_mt8195_vdo1_drv);
+MODULE_LICENSE("GPL");
index 622f57804f961628f5d672e52b2590b8168e2d7f..0991a69687650ef513ca7d3c720e06b4463cc61f 100644 (file)
@@ -58,6 +58,7 @@ static const struct of_device_id of_match_clk_mt8195_venc[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_venc);
 
 static struct platform_driver clk_mt8195_venc_drv = {
        .probe = mtk_clk_simple_probe,
@@ -67,4 +68,5 @@ static struct platform_driver clk_mt8195_venc_drv = {
                .of_match_table = of_match_clk_mt8195_venc,
        },
 };
-builtin_platform_driver(clk_mt8195_venc_drv);
+module_platform_driver(clk_mt8195_venc_drv);
+MODULE_LICENSE("GPL");
index e19664af09b6c0900a17d5e851848bc6972a8aae..1a98fb9a25e8a3274a87448ae09990aa2525175a 100644 (file)
@@ -86,54 +86,24 @@ static const struct mtk_gate vpp0_clks[] = {
        GATE_VPP0_2(CLK_VPP0_WARP1_MDP_DL_ASYNC, "vpp0_warp1_mdp_dl_async", "top_wpe_vpp", 3),
 };
 
-static int clk_mt8195_vpp0_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_VPP0_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       r = mtk_clk_register_gates(dev, node, vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
-       if (r)
-               goto free_vpp0_data;
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               goto unregister_gates;
-
-       platform_set_drvdata(pdev, clk_data);
-
-       return r;
-
-unregister_gates:
-       mtk_clk_unregister_gates(vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
-free_vpp0_data:
-       mtk_free_clk_data(clk_data);
-       return r;
-}
-
-static int clk_mt8195_vpp0_remove(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-
-       of_clk_del_provider(node);
-       mtk_clk_unregister_gates(vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
-       mtk_free_clk_data(clk_data);
+static const struct mtk_clk_desc vpp0_desc = {
+       .clks = vpp0_clks,
+       .num_clks = ARRAY_SIZE(vpp0_clks),
+};
 
-       return 0;
-}
+static const struct platform_device_id clk_mt8195_vpp0_id_table[] = {
+       { .name = "clk-mt8195-vpp0", .driver_data = (kernel_ulong_t)&vpp0_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8195_vpp0_id_table);
 
 static struct platform_driver clk_mt8195_vpp0_drv = {
-       .probe = clk_mt8195_vpp0_probe,
-       .remove = clk_mt8195_vpp0_remove,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt8195-vpp0",
        },
+       .id_table = clk_mt8195_vpp0_id_table,
 };
-builtin_platform_driver(clk_mt8195_vpp0_drv);
+module_platform_driver(clk_mt8195_vpp0_drv);
+MODULE_LICENSE("GPL");
index e6c458fc153103319bbfcc499aa416a0caaf4af6..c2d5b582f53a6d29b27ee9b99f88fa7cdfb0e505 100644 (file)
@@ -84,54 +84,24 @@ static const struct mtk_gate vpp1_clks[] = {
        GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "clk26m", 26),
 };
 
-static int clk_mt8195_vpp1_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_VPP1_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       r = mtk_clk_register_gates(dev, node, vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
-       if (r)
-               goto free_vpp1_data;
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               goto unregister_gates;
-
-       platform_set_drvdata(pdev, clk_data);
-
-       return r;
-
-unregister_gates:
-       mtk_clk_unregister_gates(vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
-free_vpp1_data:
-       mtk_free_clk_data(clk_data);
-       return r;
-}
-
-static int clk_mt8195_vpp1_remove(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-
-       of_clk_del_provider(node);
-       mtk_clk_unregister_gates(vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
-       mtk_free_clk_data(clk_data);
+static const struct mtk_clk_desc vpp1_desc = {
+       .clks = vpp1_clks,
+       .num_clks = ARRAY_SIZE(vpp1_clks),
+};
 
-       return 0;
-}
+static const struct platform_device_id clk_mt8195_vpp1_id_table[] = {
+       { .name = "clk-mt8195-vpp1", .driver_data = (kernel_ulong_t)&vpp1_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8195_vpp1_id_table);
 
 static struct platform_driver clk_mt8195_vpp1_drv = {
-       .probe = clk_mt8195_vpp1_probe,
-       .remove = clk_mt8195_vpp1_remove,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt8195-vpp1",
        },
+       .id_table = clk_mt8195_vpp1_id_table,
 };
-builtin_platform_driver(clk_mt8195_vpp1_drv);
+module_platform_driver(clk_mt8195_vpp1_drv);
+MODULE_LICENSE("GPL");
index b483fab10e187625059c923248bb1cd097eb24f1..289896cb2f6ceb0d7c49ce0c3eb17bdf81a48c86 100644 (file)
@@ -132,6 +132,7 @@ static const struct of_device_id of_match_clk_mt8195_wpe[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_wpe);
 
 static struct platform_driver clk_mt8195_wpe_drv = {
        .probe = mtk_clk_simple_probe,
@@ -141,4 +142,5 @@ static struct platform_driver clk_mt8195_wpe_drv = {
                .of_match_table = of_match_clk_mt8195_wpe,
        },
 };
-builtin_platform_driver(clk_mt8195_wpe_drv);
+module_platform_driver(clk_mt8195_wpe_drv);
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8365-apmixedsys.c b/drivers/clk/mediatek/clk-mt8365-apmixedsys.c
new file mode 100644 (file)
index 0000000..9b0bc5d
--- /dev/null
@@ -0,0 +1,166 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Copyright (c) 2023 Collabora Ltd.
+ */
+
+#include <dt-bindings/clock/mediatek,mt8365-clk.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "clk-pll.h"
+#include "clk-mtk.h"
+
+#define MT8365_PLL_FMAX                (3800UL * MHZ)
+#define MT8365_PLL_FMIN                (1500UL * MHZ)
+#define CON0_MT8365_RST_BAR    BIT(23)
+
+#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,  \
+               _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg,          \
+               _tuner_en_bit,  _pcw_reg, _pcw_shift, _div_table,       \
+               _rst_bar_mask, _pcw_chg_reg) {                          \
+               .id = _id,                                              \
+               .name = _name,                                          \
+               .reg = _reg,                                            \
+               .pwr_reg = _pwr_reg,                                    \
+               .en_mask = _en_mask,                                    \
+               .flags = _flags,                                        \
+               .rst_bar_mask = _rst_bar_mask,                          \
+               .fmax = MT8365_PLL_FMAX,                                \
+               .fmin = MT8365_PLL_FMIN,                                \
+               .pcwbits = _pcwbits,                                    \
+               .pcwibits = 8,                                          \
+               .pd_reg = _pd_reg,                                      \
+               .pd_shift = _pd_shift,                                  \
+               .tuner_reg = _tuner_reg,                                \
+               .tuner_en_reg = _tuner_en_reg,                          \
+               .tuner_en_bit = _tuner_en_bit,                          \
+               .pcw_reg = _pcw_reg,                                    \
+               .pcw_shift = _pcw_shift,                                \
+               .pcw_chg_reg = _pcw_chg_reg,                            \
+               .div_table = _div_table,                                \
+       }
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,    \
+                       _pd_reg, _pd_shift, _tuner_reg,                 \
+                       _tuner_en_reg, _tuner_en_bit, _pcw_reg,         \
+                       _pcw_shift, _rst_bar_mask, _pcw_chg_reg)        \
+               PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,     \
+                       _pcwbits, _pd_reg, _pd_shift,                   \
+                       _tuner_reg, _tuner_en_reg, _tuner_en_bit,       \
+                       _pcw_reg, _pcw_shift, NULL, _rst_bar_mask,      \
+                       _pcw_chg_reg)                                   \
+
+static const struct mtk_pll_div_table armpll_div_table[] = {
+       { .div = 0, .freq = MT8365_PLL_FMAX },
+       { .div = 1, .freq = 1500 * MHZ },
+       { .div = 2, .freq = 750 * MHZ },
+       { .div = 3, .freq = 375 * MHZ },
+       { .div = 4, .freq = 182500000 },
+       { } /* sentinel */
+};
+
+static const struct mtk_pll_div_table mfgpll_div_table[] = {
+       { .div = 0, .freq = MT8365_PLL_FMAX },
+       { .div = 1, .freq = 1600 * MHZ },
+       { .div = 2, .freq = 800 * MHZ },
+       { .div = 3, .freq = 400 * MHZ },
+       { .div = 4, .freq = 200 * MHZ },
+       { } /* sentinel */
+};
+
+static const struct mtk_pll_div_table dsppll_div_table[] = {
+       { .div = 0, .freq = MT8365_PLL_FMAX },
+       { .div = 1, .freq = 1600 * MHZ },
+       { .div = 2, .freq = 600 * MHZ },
+       { .div = 3, .freq = 400 * MHZ },
+       { .div = 4, .freq = 200 * MHZ },
+       { } /* sentinel */
+};
+
+static const struct mtk_pll_data plls[] = {
+       PLL_B(CLK_APMIXED_ARMPLL, "armpll", 0x030C, 0x0318, 0x00000001, PLL_AO,
+             22, 0x0310, 24, 0, 0, 0, 0x0310, 0, armpll_div_table, 0, 0),
+       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0228, 0x0234, 0xFF000001,
+           HAVE_RST_BAR, 22, 0x022C, 24, 0, 0, 0, 0x022C, 0, CON0_MT8365_RST_BAR, 0),
+       PLL(CLK_APMIXED_UNIVPLL, "univpll2", 0x0208, 0x0214, 0xFF000001,
+           HAVE_RST_BAR, 22, 0x020C, 24, 0, 0, 0, 0x020C, 0, CON0_MT8365_RST_BAR, 0),
+       PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0218, 0x0224, 0x00000001, 0, 22,
+             0x021C, 24, 0, 0, 0, 0x021C, 0, mfgpll_div_table, 0, 0),
+       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0350, 0x035C, 0x00000001, 0, 22,
+           0x0354, 24, 0, 0, 0, 0x0354, 0, 0, 0),
+       PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0330, 0x033C, 0x00000001, 0, 22,
+           0x0334, 24, 0, 0, 0, 0x0334, 0, 0, 0),
+       PLL(CLK_APMIXED_APLL1, "apll1", 0x031C, 0x032C, 0x00000001, 0, 32,
+           0x0320, 24, 0x0040, 0x000C, 0, 0x0324, 0, 0, 0x0320),
+       PLL(CLK_APMIXED_APLL2, "apll2", 0x0360, 0x0370, 0x00000001, 0, 32,
+           0x0364, 24, 0x004C, 0x000C, 5, 0x0368, 0, 0, 0x0364),
+       PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0374, 0x0380, 0x00000001, 0, 22,
+           0x0378, 24, 0, 0, 0, 0x0378, 0, 0, 0),
+       PLL_B(CLK_APMIXED_DSPPLL, "dsppll", 0x0390, 0x039C, 0x00000001, 0, 22,
+             0x0394, 24, 0, 0, 0, 0x0394, 0, dsppll_div_table, 0, 0),
+       PLL(CLK_APMIXED_APUPLL, "apupll", 0x03A0, 0x03AC, 0x00000001, 0, 22,
+           0x03A4, 24, 0, 0, 0, 0x03A4, 0, 0, 0),
+};
+
+static int clk_mt8365_apmixed_probe(struct platform_device *pdev)
+{
+       void __iomem *base;
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       struct device *dev = &pdev->dev;
+       struct clk_hw *hw;
+       int ret;
+
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       clk_data = mtk_devm_alloc_clk_data(dev, CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       hw = devm_clk_hw_register_gate(dev, "univ_en", "univpll2", 0,
+                                      base + 0x204, 0, 0, NULL);
+       if (IS_ERR(hw))
+               return PTR_ERR(hw);
+       clk_data->hws[CLK_APMIXED_UNIV_EN] = hw;
+
+       hw = devm_clk_hw_register_gate(dev, "usb20_en", "univ_en", 0,
+                                      base + 0x204, 1, 0, NULL);
+       if (IS_ERR(hw))
+               return PTR_ERR(hw);
+       clk_data->hws[CLK_APMIXED_USB20_EN] = hw;
+
+       ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       if (ret)
+               return ret;
+
+       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (ret)
+               goto unregister_plls;
+
+       return 0;
+
+unregister_plls:
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+
+       return ret;
+}
+
+static const struct of_device_id of_match_clk_mt8365_apmixed[] = {
+       { .compatible = "mediatek,mt8365-apmixedsys" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_apmixed);
+
+static struct platform_driver clk_mt8365_apmixed_drv = {
+       .probe = clk_mt8365_apmixed_probe,
+       .driver = {
+               .name = "clk-mt8365-apmixed",
+               .of_match_table = of_match_clk_mt8365_apmixed,
+       },
+};
+builtin_platform_driver(clk_mt8365_apmixed_drv)
+MODULE_LICENSE("GPL");
index 91ffe89d9721f6b17e34836314224a11183bec29..74f7fb22c87f3b9ef1798e6ef1abbb345533f7d3 100644 (file)
@@ -42,6 +42,7 @@ static const struct of_device_id of_match_clk_mt8365_apu[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_apu);
 
 static struct platform_driver clk_mt8365_apu_drv = {
        .probe = mtk_clk_simple_probe,
@@ -51,5 +52,5 @@ static struct platform_driver clk_mt8365_apu_drv = {
                .of_match_table = of_match_clk_mt8365_apu,
        },
 };
-builtin_platform_driver(clk_mt8365_apu_drv);
+module_platform_driver(clk_mt8365_apu_drv);
 MODULE_LICENSE("GPL");
index 31d5b5cd6de1b174b0f5c3a67f6c7e0204bd7c31..61516e19acd11e9ba96ac21a82cc8266a0cf55fb 100644 (file)
@@ -44,6 +44,7 @@ static const struct of_device_id of_match_clk_mt8365_cam[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_cam);
 
 static struct platform_driver clk_mt8365_cam_drv = {
        .probe = mtk_clk_simple_probe,
@@ -53,5 +54,5 @@ static struct platform_driver clk_mt8365_cam_drv = {
                .of_match_table = of_match_clk_mt8365_cam,
        },
 };
-builtin_platform_driver(clk_mt8365_cam_drv);
+module_platform_driver(clk_mt8365_cam_drv);
 MODULE_LICENSE("GPL");
index 587b49128b035a40be2dead0ad0073bbc6919c34..4c836c69db4fe2cd85b131292c26ff347f662232 100644 (file)
@@ -50,6 +50,7 @@ static const struct of_device_id of_match_clk_mt8365_mfg[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_mfg);
 
 static struct platform_driver clk_mt8365_mfg_drv = {
        .probe = mtk_clk_simple_probe,
@@ -59,5 +60,5 @@ static struct platform_driver clk_mt8365_mfg_drv = {
                .of_match_table = of_match_clk_mt8365_mfg,
        },
 };
-builtin_platform_driver(clk_mt8365_mfg_drv);
+module_platform_driver(clk_mt8365_mfg_drv);
 MODULE_LICENSE("GPL");
index 22c75a03a6452dc4c991dc34ba0b98d906524fbb..44427120846f01b06cb578f010e1ce512c4d95da 100644 (file)
@@ -72,40 +72,24 @@ static const struct mtk_gate mm_clks[] = {
        GATE_MM1(CLK_MM_LVDSTX_CTS, "mm_flvdstx_cts", "lvdstx_dig_cts", 3),
 };
 
-static int clk_mt8365_mm_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->parent->of_node;
-       struct clk_hw_onecell_data *clk_data;
-       int ret;
-
-       clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
-
-       ret = mtk_clk_register_gates(dev, node, mm_clks,
-                                    ARRAY_SIZE(mm_clks), clk_data);
-       if (ret)
-               goto err_free_clk_data;
-
-       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (ret)
-               goto err_unregister_gates;
-
-       return 0;
-
-err_unregister_gates:
-       mtk_clk_unregister_gates(mm_clks, ARRAY_SIZE(mm_clks), clk_data);
-
-err_free_clk_data:
-       mtk_free_clk_data(clk_data);
+static const struct mtk_clk_desc mm_desc = {
+       .clks = mm_clks,
+       .num_clks = ARRAY_SIZE(mm_clks),
+};
 
-       return ret;
-}
+static const struct platform_device_id clk_mt8365_mm_id_table[] = {
+       { .name = "clk-mt8365-mm", .driver_data = (kernel_ulong_t)&mm_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, clk_mt8365_mm_id_table);
 
 static struct platform_driver clk_mt8365_mm_drv = {
-       .probe = clk_mt8365_mm_probe,
+       .probe = mtk_clk_pdev_probe,
+       .remove = mtk_clk_pdev_remove,
        .driver = {
                .name = "clk-mt8365-mm",
        },
+       .id_table = clk_mt8365_mm_id_table,
 };
-builtin_platform_driver(clk_mt8365_mm_drv);
+module_platform_driver(clk_mt8365_mm_drv);
 MODULE_LICENSE("GPL");
index cdc678e8941ca654eb6929b71440843570435b04..b51571e9da00607909c4946085ab2ddca27ed15a 100644 (file)
@@ -50,6 +50,7 @@ static const struct of_device_id of_match_clk_mt8365_vdec[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_vdec);
 
 static struct platform_driver clk_mt8365_vdec_drv = {
        .probe = mtk_clk_simple_probe,
@@ -59,5 +60,5 @@ static struct platform_driver clk_mt8365_vdec_drv = {
                .of_match_table = of_match_clk_mt8365_vdec,
        },
 };
-builtin_platform_driver(clk_mt8365_vdec_drv);
+module_platform_driver(clk_mt8365_vdec_drv);
 MODULE_LICENSE("GPL");
index 0e080c22119dc63b2fb54630d7772c5ff127f805..572344645c86645202a89c489e4f7620bee7e26d 100644 (file)
@@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8365_venc[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_venc);
 
 static struct platform_driver clk_mt8365_venc_drv = {
        .probe = mtk_clk_simple_probe,
@@ -48,5 +49,5 @@ static struct platform_driver clk_mt8365_venc_drv = {
                .of_match_table = of_match_clk_mt8365_venc,
        },
 };
-builtin_platform_driver(clk_mt8365_venc_drv);
+module_platform_driver(clk_mt8365_venc_drv);
 MODULE_LICENSE("GPL");
index c9faa07ec0a6403bc3b365dc2c07705fefc68406..6b4e193f648d81e3181abaef3fc80a7929ce8c14 100644 (file)
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2022 MediaTek Inc.
+ * Copyright (C) 2023 Collabora Ltd.
+ *                    AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
  */
 
 #include <dt-bindings/clock/mediatek,mt8365-clk.h>
@@ -17,7 +19,6 @@
 #include "clk-gate.h"
 #include "clk-mtk.h"
 #include "clk-mux.h"
-#include "clk-pll.h"
 
 static DEFINE_SPINLOCK(mt8365_clk_lock);
 
@@ -383,31 +384,23 @@ static const char * const mbist_diag_parents[] = {
        "univpll2_d8"
 };
 
-static const char * const apll_i2s0_parents[] = {
+static const char * const apll_i2s_parents[] = {
        "aud_1_sel",
        "aud_2_sel"
 };
 
-static struct mtk_composite top_misc_mux_gates[] = {
+static struct mtk_composite top_misc_muxes[] = {
        /* CLK_CFG_11 */
        MUX_GATE(CLK_TOP_MBIST_DIAG_SEL, "mbist_diag_sel", mbist_diag_parents,
                 0x0ec, 0, 2, 7),
-};
-
-struct mt8365_clk_audio_mux {
-       int id;
-       const char *name;
-       u8 shift;
-};
-
-static struct mt8365_clk_audio_mux top_misc_muxes[] = {
-       { CLK_TOP_APLL_I2S0_SEL, "apll_i2s0_sel", 11},
-       { CLK_TOP_APLL_I2S1_SEL, "apll_i2s1_sel", 12},
-       { CLK_TOP_APLL_I2S2_SEL, "apll_i2s2_sel", 13},
-       { CLK_TOP_APLL_I2S3_SEL, "apll_i2s3_sel", 14},
-       { CLK_TOP_APLL_TDMOUT_SEL, "apll_tdmout_sel", 15},
-       { CLK_TOP_APLL_TDMIN_SEL, "apll_tdmin_sel", 16},
-       { CLK_TOP_APLL_SPDIF_SEL, "apll_spdif_sel", 17},
+       /* Audio MUX */
+       MUX(CLK_TOP_APLL_I2S0_SEL, "apll_i2s0_sel", apll_i2s_parents, 0x0320, 11, 1),
+       MUX(CLK_TOP_APLL_I2S1_SEL, "apll_i2s1_sel", apll_i2s_parents, 0x0320, 12, 1),
+       MUX(CLK_TOP_APLL_I2S2_SEL, "apll_i2s2_sel", apll_i2s_parents, 0x0320, 13, 1),
+       MUX(CLK_TOP_APLL_I2S3_SEL, "apll_i2s3_sel", apll_i2s_parents, 0x0320, 14, 1),
+       MUX(CLK_TOP_APLL_TDMOUT_SEL, "apll_tdmout_sel", apll_i2s_parents, 0x0320, 15, 1),
+       MUX(CLK_TOP_APLL_TDMIN_SEL, "apll_tdmin_sel", apll_i2s_parents, 0x0320, 16, 1),
+       MUX(CLK_TOP_APLL_SPDIF_SEL, "apll_spdif_sel", apll_i2s_parents, 0x0320, 17, 1),
 };
 
 #define CLK_CFG_UPDATE 0x004
@@ -570,35 +563,56 @@ static const struct mtk_clk_divider top_adj_divs[] = {
                  0x32c, 0, 8, CLK_DIVIDER_ROUND_CLOSEST),
 };
 
-struct mtk_simple_gate {
-       int id;
-       const char *name;
-       const char *parent;
-       u32 reg;
-       u8 shift;
-       unsigned long gate_flags;
-};
-
-static const struct mtk_simple_gate top_clk_gates[] = {
-       { CLK_TOP_CONN_32K, "conn_32k", "clk32k", 0x0, 10, CLK_GATE_SET_TO_DISABLE },
-       { CLK_TOP_CONN_26M, "conn_26m", "clk26m", 0x0, 11, CLK_GATE_SET_TO_DISABLE },
-       { CLK_TOP_DSP_32K, "dsp_32k", "clk32k", 0x0, 16, CLK_GATE_SET_TO_DISABLE },
-       { CLK_TOP_DSP_26M, "dsp_26m", "clk26m", 0x0, 17, CLK_GATE_SET_TO_DISABLE },
-       { CLK_TOP_USB20_48M_EN, "usb20_48m_en", "usb20_192m_d4", 0x104, 8, 0 },
-       { CLK_TOP_UNIVPLL_48M_EN, "univpll_48m_en", "usb20_192m_d4", 0x104, 9, 0 },
-       { CLK_TOP_LVDSTX_CLKDIG_EN, "lvdstx_dig_en", "lvdstx_dig_cts", 0x104, 20, 0 },
-       { CLK_TOP_VPLL_DPIX_EN, "vpll_dpix_en", "vpll_dpix", 0x104, 21, 0 },
-       { CLK_TOP_SSUSB_TOP_CK_EN, "ssusb_top_ck_en", NULL, 0x104, 22, 0 },
-       { CLK_TOP_SSUSB_PHY_CK_EN, "ssusb_phy_ck_en", NULL, 0x104, 23, 0 },
-       { CLK_TOP_AUD_I2S0_M, "aud_i2s0_m_ck", "apll12_ck_div0", 0x320, 0, 0 },
-       { CLK_TOP_AUD_I2S1_M, "aud_i2s1_m_ck", "apll12_ck_div1", 0x320, 1, 0 },
-       { CLK_TOP_AUD_I2S2_M, "aud_i2s2_m_ck", "apll12_ck_div2", 0x320, 2, 0 },
-       { CLK_TOP_AUD_I2S3_M, "aud_i2s3_m_ck", "apll12_ck_div3", 0x320, 3, 0 },
-       { CLK_TOP_AUD_TDMOUT_M, "aud_tdmout_m_ck", "apll12_ck_div4", 0x320, 4, 0 },
-       { CLK_TOP_AUD_TDMOUT_B, "aud_tdmout_b_ck", "apll12_ck_div4b", 0x320, 5, 0 },
-       { CLK_TOP_AUD_TDMIN_M, "aud_tdmin_m_ck", "apll12_ck_div5", 0x320, 6, 0 },
-       { CLK_TOP_AUD_TDMIN_B, "aud_tdmin_b_ck", "apll12_ck_div5b", 0x320, 7, 0 },
-       { CLK_TOP_AUD_SPDIF_M, "aud_spdif_m_ck", "apll12_ck_div6", 0x320, 8, 0 },
+static const struct mtk_gate_regs top0_cg_regs = {
+       .set_ofs = 0,
+       .clr_ofs = 0,
+       .sta_ofs = 0,
+};
+
+static const struct mtk_gate_regs top1_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x104,
+       .sta_ofs = 0x104,
+};
+
+static const struct mtk_gate_regs top2_cg_regs = {
+       .set_ofs = 0x320,
+       .clr_ofs = 0x320,
+       .sta_ofs = 0x320,
+};
+
+#define GATE_TOP0(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &top0_cg_regs,            \
+                _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+#define GATE_TOP1(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &top1_cg_regs,            \
+                _shift, &mtk_clk_gate_ops_no_setclr)
+
+#define GATE_TOP2(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &top2_cg_regs,            \
+                _shift, &mtk_clk_gate_ops_no_setclr)
+
+static const struct mtk_gate top_clk_gates[] = {
+       GATE_TOP0(CLK_TOP_CONN_32K, "conn_32k", "clk32k", 10),
+       GATE_TOP0(CLK_TOP_CONN_26M, "conn_26m", "clk26m", 11),
+       GATE_TOP0(CLK_TOP_DSP_32K, "dsp_32k", "clk32k", 16),
+       GATE_TOP0(CLK_TOP_DSP_26M, "dsp_26m", "clk26m", 17),
+       GATE_TOP1(CLK_TOP_USB20_48M_EN, "usb20_48m_en", "usb20_192m_d4", 8),
+       GATE_TOP1(CLK_TOP_UNIVPLL_48M_EN, "univpll_48m_en", "usb20_192m_d4", 9),
+       GATE_TOP1(CLK_TOP_LVDSTX_CLKDIG_EN, "lvdstx_dig_en", "lvdstx_dig_cts", 20),
+       GATE_TOP1(CLK_TOP_VPLL_DPIX_EN, "vpll_dpix_en", "vpll_dpix", 21),
+       GATE_TOP1(CLK_TOP_SSUSB_TOP_CK_EN, "ssusb_top_ck_en", NULL, 22),
+       GATE_TOP1(CLK_TOP_SSUSB_PHY_CK_EN, "ssusb_phy_ck_en", NULL, 23),
+       GATE_TOP2(CLK_TOP_AUD_I2S0_M, "aud_i2s0_m_ck", "apll12_ck_div0", 0),
+       GATE_TOP2(CLK_TOP_AUD_I2S1_M, "aud_i2s1_m_ck", "apll12_ck_div1", 1),
+       GATE_TOP2(CLK_TOP_AUD_I2S2_M, "aud_i2s2_m_ck", "apll12_ck_div2", 2),
+       GATE_TOP2(CLK_TOP_AUD_I2S3_M, "aud_i2s3_m_ck", "apll12_ck_div3", 3),
+       GATE_TOP2(CLK_TOP_AUD_TDMOUT_M, "aud_tdmout_m_ck", "apll12_ck_div4", 4),
+       GATE_TOP2(CLK_TOP_AUD_TDMOUT_B, "aud_tdmout_b_ck", "apll12_ck_div4b", 5),
+       GATE_TOP2(CLK_TOP_AUD_TDMIN_M, "aud_tdmin_m_ck", "apll12_ck_div5", 6),
+       GATE_TOP2(CLK_TOP_AUD_TDMIN_B, "aud_tdmin_b_ck", "apll12_ck_div5b", 7),
+       GATE_TOP2(CLK_TOP_AUD_SPDIF_M, "aud_spdif_m_ck", "apll12_ck_div6", 8),
 };
 
 static const struct mtk_gate_regs ifr2_cg_regs = {
@@ -631,50 +645,24 @@ static const struct mtk_gate_regs ifr6_cg_regs = {
        .sta_ofs = 0xd8,
 };
 
-#define GATE_IFR2(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ifr2_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_IFR3(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ifr3_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_IFR4(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ifr4_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_IFR5(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ifr5_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_IFR6(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &ifr6_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
+#define GATE_IFRX(_id, _name, _parent, _shift, _regs)  \
+       GATE_MTK(_id, _name, _parent, _regs, _shift,    \
+                &mtk_clk_gate_ops_setclr)
+
+#define GATE_IFR2(_id, _name, _parent, _shift)         \
+       GATE_IFRX(_id, _name, _parent, _shift, &ifr2_cg_regs)
+
+#define GATE_IFR3(_id, _name, _parent, _shift)         \
+       GATE_IFRX(_id, _name, _parent, _shift, &ifr3_cg_regs)
+
+#define GATE_IFR4(_id, _name, _parent, _shift)         \
+       GATE_IFRX(_id, _name, _parent, _shift, &ifr4_cg_regs)
+
+#define GATE_IFR5(_id, _name, _parent, _shift)         \
+       GATE_IFRX(_id, _name, _parent, _shift, &ifr5_cg_regs)
+
+#define GATE_IFR6(_id, _name, _parent, _shift)         \
+       GATE_IFRX(_id, _name, _parent, _shift, &ifr6_cg_regs)
 
 static const struct mtk_gate ifr_clks[] = {
        /* IFR2 */
@@ -753,405 +741,65 @@ static const struct mtk_gate ifr_clks[] = {
        GATE_IFR6(CLK_IFR_SSUSB_XHCI, "ifr_ssusb_xhci", "ssusb_xhci_sel", 11),
 };
 
-static const struct mtk_simple_gate peri_clks[] = {
-       { CLK_PERIAXI, "periaxi", "axi_sel", 0x20c, 31, 0 },
-};
-
-#define MT8365_PLL_FMAX                (3800UL * MHZ)
-#define MT8365_PLL_FMIN                (1500UL * MHZ)
-#define CON0_MT8365_RST_BAR    BIT(23)
-
-#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,  \
-               _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg,          \
-               _tuner_en_bit,  _pcw_reg, _pcw_shift, _div_table,       \
-               _rst_bar_mask, _pcw_chg_reg) {                          \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .reg = _reg,                                            \
-               .pwr_reg = _pwr_reg,                                    \
-               .en_mask = _en_mask,                                    \
-               .flags = _flags,                                        \
-               .rst_bar_mask = _rst_bar_mask,                          \
-               .fmax = MT8365_PLL_FMAX,                                \
-               .fmin = MT8365_PLL_FMIN,                                \
-               .pcwbits = _pcwbits,                                    \
-               .pcwibits = 8,                                          \
-               .pd_reg = _pd_reg,                                      \
-               .pd_shift = _pd_shift,                                  \
-               .tuner_reg = _tuner_reg,                                \
-               .tuner_en_reg = _tuner_en_reg,                          \
-               .tuner_en_bit = _tuner_en_bit,                          \
-               .pcw_reg = _pcw_reg,                                    \
-               .pcw_shift = _pcw_shift,                                \
-               .pcw_chg_reg = _pcw_chg_reg,                            \
-               .div_table = _div_table,                                \
-       }
-
-#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,    \
-                       _pd_reg, _pd_shift, _tuner_reg,                 \
-                       _tuner_en_reg, _tuner_en_bit, _pcw_reg,         \
-                       _pcw_shift, _rst_bar_mask, _pcw_chg_reg)        \
-               PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,     \
-                       _pcwbits, _pd_reg, _pd_shift,                   \
-                       _tuner_reg, _tuner_en_reg, _tuner_en_bit,       \
-                       _pcw_reg, _pcw_shift, NULL, _rst_bar_mask,      \
-                       _pcw_chg_reg)                                   \
-
-static const struct mtk_pll_div_table armpll_div_table[] = {
-       { .div = 0, .freq = MT8365_PLL_FMAX },
-       { .div = 1, .freq = 1500 * MHZ },
-       { .div = 2, .freq = 750 * MHZ },
-       { .div = 3, .freq = 375 * MHZ },
-       { .div = 4, .freq = 182500000 },
-       { } /* sentinel */
-};
-
-static const struct mtk_pll_div_table mfgpll_div_table[] = {
-       { .div = 0, .freq = MT8365_PLL_FMAX },
-       { .div = 1, .freq = 1600 * MHZ },
-       { .div = 2, .freq = 800 * MHZ },
-       { .div = 3, .freq = 400 * MHZ },
-       { .div = 4, .freq = 200 * MHZ },
-       { } /* sentinel */
-};
-
-static const struct mtk_pll_div_table dsppll_div_table[] = {
-       { .div = 0, .freq = MT8365_PLL_FMAX },
-       { .div = 1, .freq = 1600 * MHZ },
-       { .div = 2, .freq = 600 * MHZ },
-       { .div = 3, .freq = 400 * MHZ },
-       { .div = 4, .freq = 200 * MHZ },
-       { } /* sentinel */
-};
-
-static const struct mtk_pll_data plls[] = {
-       PLL_B(CLK_APMIXED_ARMPLL, "armpll", 0x030C, 0x0318, 0x00000001, PLL_AO,
-             22, 0x0310, 24, 0, 0, 0, 0x0310, 0, armpll_div_table, 0, 0),
-       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0228, 0x0234, 0xFF000001,
-           HAVE_RST_BAR, 22, 0x022C, 24, 0, 0, 0, 0x022C, 0,
-           CON0_MT8365_RST_BAR, 0),
-       PLL(CLK_APMIXED_UNIVPLL, "univpll2", 0x0208, 0x0214, 0xFF000001,
-           HAVE_RST_BAR, 22, 0x020C, 24, 0, 0, 0, 0x020C, 0,
-           CON0_MT8365_RST_BAR, 0),
-       PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0218, 0x0224, 0x00000001, 0, 22,
-             0x021C, 24, 0, 0, 0, 0x021C, 0, mfgpll_div_table, 0, 0),
-       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0350, 0x035C, 0x00000001, 0, 22,
-           0x0354, 24, 0, 0, 0, 0x0354, 0, 0, 0),
-       PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0330, 0x033C, 0x00000001, 0, 22,
-           0x0334, 24, 0, 0, 0, 0x0334, 0, 0, 0),
-       PLL(CLK_APMIXED_APLL1, "apll1", 0x031C, 0x032C, 0x00000001, 0, 32,
-           0x0320, 24, 0x0040, 0x000C, 0, 0x0324, 0, 0, 0x0320),
-       PLL(CLK_APMIXED_APLL2, "apll2", 0x0360, 0x0370, 0x00000001, 0, 32,
-           0x0364, 24, 0x004C, 0x000C, 5, 0x0368, 0, 0, 0x0364),
-       PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0374, 0x0380, 0x00000001, 0, 22,
-           0x0378, 24, 0, 0, 0, 0x0378, 0, 0, 0),
-       PLL_B(CLK_APMIXED_DSPPLL, "dsppll", 0x0390, 0x039C, 0x00000001, 0, 22,
-             0x0394, 24, 0, 0, 0, 0x0394, 0, dsppll_div_table, 0, 0),
-       PLL(CLK_APMIXED_APUPLL, "apupll", 0x03A0, 0x03AC, 0x00000001, 0, 22,
-           0x03A4, 24, 0, 0, 0, 0x03A4, 0, 0, 0),
-};
-
-static int clk_mt8365_apmixed_probe(struct platform_device *pdev)
-{
-       void __iomem *base;
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-       struct device *dev = &pdev->dev;
-       struct clk_hw *hw;
-       int ret;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       clk_data = mtk_devm_alloc_clk_data(dev, CLK_APMIXED_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       hw = devm_clk_hw_register_gate(dev, "univ_en", "univpll2", 0,
-                                      base + 0x204, 0, 0, NULL);
-       if (IS_ERR(hw))
-               return PTR_ERR(hw);
-       clk_data->hws[CLK_APMIXED_UNIV_EN] = hw;
-
-       hw = devm_clk_hw_register_gate(dev, "usb20_en", "univ_en", 0,
-                                      base + 0x204, 1, 0, NULL);
-       if (IS_ERR(hw))
-               return PTR_ERR(hw);
-       clk_data->hws[CLK_APMIXED_USB20_EN] = hw;
-
-       ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
-       if (ret)
-               return ret;
-
-       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (ret)
-               goto unregister_plls;
-
-       return 0;
-
-unregister_plls:
-       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
-
-       return ret;
-}
-
-static int
-clk_mt8365_register_mtk_simple_gates(struct device *dev, void __iomem *base,
-                                    struct clk_hw_onecell_data *clk_data,
-                                    const struct mtk_simple_gate *gates,
-                                    unsigned int num_gates)
-{
-       unsigned int i;
-
-       for (i = 0; i != num_gates; ++i) {
-               const struct mtk_simple_gate *gate = &gates[i];
-               struct clk_hw *hw;
-
-               hw = devm_clk_hw_register_gate(dev, gate->name, gate->parent, 0,
-                                              base + gate->reg, gate->shift,
-                                              gate->gate_flags, NULL);
-               if (IS_ERR(hw))
-                       return PTR_ERR(hw);
-
-               clk_data->hws[gate->id] = hw;
-       }
-
-       return 0;
-}
-
-static int clk_mt8365_top_probe(struct platform_device *pdev)
-{
-       void __iomem *base;
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-       struct device *dev = &pdev->dev;
-       int ret;
-       int i;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       ret = mtk_clk_register_fixed_clks(top_fixed_clks,
-                                         ARRAY_SIZE(top_fixed_clks), clk_data);
-       if (ret)
-               goto free_clk_data;
-
-       ret = mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs),
-                                      clk_data);
-       if (ret)
-               goto unregister_fixed_clks;
-
-       ret = mtk_clk_register_muxes(&pdev->dev, top_muxes,
-                                    ARRAY_SIZE(top_muxes), node,
-                                    &mt8365_clk_lock, clk_data);
-       if (ret)
-               goto unregister_factors;
-
-       ret = mtk_clk_register_composites(&pdev->dev, top_misc_mux_gates,
-                                         ARRAY_SIZE(top_misc_mux_gates), base,
-                                         &mt8365_clk_lock, clk_data);
-       if (ret)
-               goto unregister_muxes;
-
-       for (i = 0; i != ARRAY_SIZE(top_misc_muxes); ++i) {
-               struct mt8365_clk_audio_mux *mux = &top_misc_muxes[i];
-               struct clk_hw *hw;
-
-               hw = devm_clk_hw_register_mux(dev, mux->name, apll_i2s0_parents,
-                                             ARRAY_SIZE(apll_i2s0_parents),
-                                             CLK_SET_RATE_PARENT, base + 0x320,
-                                             mux->shift, 1, 0, NULL);
-               if (IS_ERR(hw)) {
-                       ret = PTR_ERR(hw);
-                       goto unregister_composites;
-               }
-
-               clk_data->hws[mux->id] = hw;
-       }
-
-       ret = mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs),
-                                       base, &mt8365_clk_lock, clk_data);
-       if (ret)
-               goto unregister_composites;
-
-       ret = clk_mt8365_register_mtk_simple_gates(dev, base, clk_data,
-                                                  top_clk_gates,
-                                                  ARRAY_SIZE(top_clk_gates));
-       if (ret)
-               goto unregister_dividers;
-
-       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (ret)
-               goto unregister_dividers;
-
-       return 0;
-unregister_dividers:
-       mtk_clk_unregister_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs),
-                                   clk_data);
-unregister_composites:
-       mtk_clk_unregister_composites(top_misc_mux_gates,
-                                     ARRAY_SIZE(top_misc_mux_gates), clk_data);
-unregister_muxes:
-       mtk_clk_unregister_muxes(top_muxes, ARRAY_SIZE(top_muxes), clk_data);
-unregister_factors:
-       mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
-unregister_fixed_clks:
-       mtk_clk_unregister_fixed_clks(top_fixed_clks,
-                                     ARRAY_SIZE(top_fixed_clks), clk_data);
-free_clk_data:
-       mtk_free_clk_data(clk_data);
-
-       return ret;
-}
-
-static int clk_mt8365_infra_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-       int ret;
-
-       clk_data = mtk_alloc_clk_data(CLK_IFR_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       ret = mtk_clk_register_gates(&pdev->dev, node, ifr_clks,
-                                    ARRAY_SIZE(ifr_clks), clk_data);
-       if (ret)
-               goto free_clk_data;
-
-       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (ret)
-               goto unregister_gates;
-
-       return 0;
-
-unregister_gates:
-       mtk_clk_unregister_gates(ifr_clks, ARRAY_SIZE(ifr_clks), clk_data);
-free_clk_data:
-       mtk_free_clk_data(clk_data);
-
-       return ret;
-}
-
-static int clk_mt8365_peri_probe(struct platform_device *pdev)
-{
-       void __iomem *base;
-       struct clk_hw_onecell_data *clk_data;
-       struct device *dev = &pdev->dev;
-       struct device_node *node = dev->of_node;
-       int ret;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       clk_data = mtk_devm_alloc_clk_data(dev, CLK_PERI_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
-
-       ret = clk_mt8365_register_mtk_simple_gates(dev, base, clk_data,
-                                                  peri_clks,
-                                                  ARRAY_SIZE(peri_clks));
-       if (ret)
-               return ret;
-
-       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-
-       return ret;
-}
-
-static int clk_mt8365_mcu_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-       void __iomem *base;
-       int ret;
-
-       base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       clk_data = mtk_alloc_clk_data(CLK_MCU_NR_CLK);
-       if (!clk_data)
-               return -ENOMEM;
+static const struct mtk_gate_regs peri_cg_regs = {
+       .set_ofs = 0x20c,
+       .clr_ofs = 0x20c,
+       .sta_ofs = 0x20c,
+};
 
-       ret = mtk_clk_register_composites(&pdev->dev, mcu_muxes,
-                                         ARRAY_SIZE(mcu_muxes), base,
-                                         &mt8365_clk_lock, clk_data);
-       if (ret)
-               goto free_clk_data;
+static const struct mtk_gate peri_clks[] = {
+       GATE_MTK(CLK_PERIAXI, "periaxi", "axi_sel", &peri_cg_regs, 31,
+                &mtk_clk_gate_ops_no_setclr),
+};
 
-       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (ret)
-               goto unregister_composites;
+static const struct mtk_clk_desc topck_desc = {
+       .clks = top_clk_gates,
+       .num_clks = ARRAY_SIZE(top_clk_gates),
+       .fixed_clks = top_fixed_clks,
+       .num_fixed_clks = ARRAY_SIZE(top_fixed_clks),
+       .factor_clks = top_divs,
+       .num_factor_clks = ARRAY_SIZE(top_divs),
+       .mux_clks = top_muxes,
+       .num_mux_clks = ARRAY_SIZE(top_muxes),
+       .composite_clks = top_misc_muxes,
+       .num_composite_clks = ARRAY_SIZE(top_misc_muxes),
+       .divider_clks = top_adj_divs,
+       .num_divider_clks = ARRAY_SIZE(top_adj_divs),
+       .clk_lock = &mt8365_clk_lock,
+};
 
-       return 0;
+static const struct mtk_clk_desc infra_desc = {
+       .clks = ifr_clks,
+       .num_clks = ARRAY_SIZE(ifr_clks),
+};
 
-unregister_composites:
-       mtk_clk_unregister_composites(mcu_muxes, ARRAY_SIZE(mcu_muxes),
-                                     clk_data);
-free_clk_data:
-       mtk_free_clk_data(clk_data);
+static const struct mtk_clk_desc peri_desc = {
+       .clks = peri_clks,
+       .num_clks = ARRAY_SIZE(peri_clks),
+};
 
-       return ret;
-}
+static const struct mtk_clk_desc mcu_desc = {
+       .composite_clks = mcu_muxes,
+       .num_composite_clks = ARRAY_SIZE(mcu_muxes),
+       .clk_lock = &mt8365_clk_lock,
+};
 
 static const struct of_device_id of_match_clk_mt8365[] = {
-       {
-               .compatible = "mediatek,mt8365-apmixedsys",
-               .data = clk_mt8365_apmixed_probe,
-       }, {
-               .compatible = "mediatek,mt8365-topckgen",
-               .data = clk_mt8365_top_probe,
-       }, {
-               .compatible = "mediatek,mt8365-infracfg",
-               .data = clk_mt8365_infra_probe,
-       }, {
-               .compatible = "mediatek,mt8365-pericfg",
-               .data = clk_mt8365_peri_probe,
-       }, {
-               .compatible = "mediatek,mt8365-mcucfg",
-               .data = clk_mt8365_mcu_probe,
-       }, {
-               /* sentinel */
-       }
-};
-
-static int clk_mt8365_probe(struct platform_device *pdev)
-{
-       int (*clk_probe)(struct platform_device *pdev);
-       int ret;
-
-       clk_probe = of_device_get_match_data(&pdev->dev);
-       if (!clk_probe)
-               return -EINVAL;
-
-       ret = clk_probe(pdev);
-       if (ret)
-               dev_err(&pdev->dev,
-                       "%s: could not register clock provider: %d\n",
-                       pdev->name, ret);
-
-       return ret;
-}
+       { .compatible = "mediatek,mt8365-topckgen", .data = &topck_desc },
+       { .compatible = "mediatek,mt8365-infracfg", .data = &infra_desc },
+       { .compatible = "mediatek,mt8365-pericfg", .data = &peri_desc },
+       { .compatible = "mediatek,mt8365-mcucfg", .data = &mcu_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8365);
 
 static struct platform_driver clk_mt8365_drv = {
-       .probe = clk_mt8365_probe,
        .driver = {
                .name = "clk-mt8365",
                .of_match_table = of_match_clk_mt8365,
        },
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
 };
-
-static int __init clk_mt8365_init(void)
-{
-       return platform_driver_register(&clk_mt8365_drv);
-}
-arch_initcall(clk_mt8365_init);
+module_platform_driver(clk_mt8365_drv);
 MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/clk-mt8516-apmixedsys.c b/drivers/clk/mediatek/clk-mt8516-apmixedsys.c
new file mode 100644 (file)
index 0000000..edd9174
--- /dev/null
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2019 MediaTek Inc.
+ *               James Liao <jamesjj.liao@mediatek.com>
+ *               Fabien Parent <fparent@baylibre.com>
+ *
+ * Copyright (c) 2023 Collabora, Ltd.
+ *               AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+ */
+
+#include <dt-bindings/clock/mt8516-clk.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "clk-mtk.h"
+#include "clk-pll.h"
+
+#define MT8516_PLL_FMAX                (1502UL * MHZ)
+
+#define CON0_MT8516_RST_BAR    BIT(27)
+
+#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,  \
+                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
+                       _pcw_shift, _div_table) {                       \
+               .id = _id,                                              \
+               .name = _name,                                          \
+               .reg = _reg,                                            \
+               .pwr_reg = _pwr_reg,                                    \
+               .en_mask = _en_mask,                                    \
+               .flags = _flags,                                        \
+               .rst_bar_mask = CON0_MT8516_RST_BAR,                    \
+               .fmax = MT8516_PLL_FMAX,                                \
+               .pcwbits = _pcwbits,                                    \
+               .pd_reg = _pd_reg,                                      \
+               .pd_shift = _pd_shift,                                  \
+               .tuner_reg = _tuner_reg,                                \
+               .pcw_reg = _pcw_reg,                                    \
+               .pcw_shift = _pcw_shift,                                \
+               .div_table = _div_table,                                \
+       }
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,    \
+                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
+                       _pcw_shift)                                     \
+               PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \
+                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \
+                       NULL)
+
+static const struct mtk_pll_div_table mmpll_div_table[] = {
+       { .div = 0, .freq = MT8516_PLL_FMAX },
+       { .div = 1, .freq = 1000000000 },
+       { .div = 2, .freq = 604500000 },
+       { .div = 3, .freq = 253500000 },
+       { .div = 4, .freq = 126750000 },
+       { } /* sentinel */
+};
+
+static const struct mtk_pll_data plls[] = {
+       PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0,
+           21, 0x0104, 24, 0, 0x0104, 0),
+       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0,
+           HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0),
+       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x30000000,
+           HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0),
+       PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0,
+             21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table),
+       PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0,
+           31, 0x0180, 1, 0x0194, 0x0184, 0),
+       PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0,
+           31, 0x01A0, 1, 0x01B4, 0x01A4, 0),
+};
+
+static int clk_mt8516_apmixed_probe(struct platform_device *pdev)
+{
+       void __iomem *base;
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       struct device *dev = &pdev->dev;
+       int ret;
+
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       clk_data = mtk_devm_alloc_clk_data(dev, CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       if (ret)
+               return ret;
+
+       ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (ret)
+               goto unregister_plls;
+
+       return 0;
+
+unregister_plls:
+       mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+
+       return ret;
+}
+
+static const struct of_device_id of_match_clk_mt8516_apmixed[] = {
+       { .compatible = "mediatek,mt8516-apmixedsys" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8516_apmixed);
+
+static struct platform_driver clk_mt8516_apmixed_drv = {
+       .probe = clk_mt8516_apmixed_probe,
+       .driver = {
+               .name = "clk-mt8516-apmixed",
+               .of_match_table = of_match_clk_mt8516_apmixed,
+       },
+};
+builtin_platform_driver(clk_mt8516_apmixed_drv)
+
+MODULE_DESCRIPTION("MediaTek MT8516 apmixedsys clocks driver");
+MODULE_LICENSE("GPL");
index 00f356fe7c7a6085d9603d92280ee5821d9c9835..48340fc7430db3d0309555f5247f24d22f9ef785 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright (c) 2019 MediaTek Inc.
  * Author: James Liao <jamesjj.liao@mediatek.com>
  *         Fabien Parent <fparent@baylibre.com>
+ * Copyright (c) 2023 Collabora Ltd.
  */
 
 #include <linux/clk-provider.h>
@@ -22,16 +23,10 @@ static const struct mtk_gate_regs aud_cg_regs = {
        .sta_ofs = 0x0,
 };
 
-#define GATE_AUD(_id, _name, _parent, _shift) {        \
-               .id = _id,                      \
-               .name = _name,                  \
-               .parent_name = _parent,         \
-               .regs = &aud_cg_regs,           \
-               .shift = _shift,                \
-               .ops = &mtk_clk_gate_ops_no_setclr,             \
-       }
+#define GATE_AUD(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &aud_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
 
-static const struct mtk_gate aud_clks[] __initconst = {
+static const struct mtk_gate aud_clks[] = {
        GATE_AUD(CLK_AUD_AFE, "aud_afe", "clk26m_ck", 2),
        GATE_AUD(CLK_AUD_I2S, "aud_i2s", "i2s_infra_bck", 6),
        GATE_AUD(CLK_AUD_22M, "aud_22m", "rg_aud_engen1", 8),
@@ -47,19 +42,26 @@ static const struct mtk_gate aud_clks[] __initconst = {
        GATE_AUD(CLK_AUD_TML, "aud_tml", "aud_afe", 27),
 };
 
-static void __init mtk_audsys_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-
-       clk_data = mtk_alloc_clk_data(CLK_AUD_NR_CLK);
+static const struct mtk_clk_desc aud_desc = {
+       .clks = aud_clks,
+       .num_clks = ARRAY_SIZE(aud_clks),
+};
 
-       mtk_clk_register_gates(NULL, node, aud_clks, ARRAY_SIZE(aud_clks), clk_data);
+static const struct of_device_id of_match_clk_mt8516_aud[] = {
+       { .compatible = "mediatek,mt8516-audsys", .data = &aud_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8516_aud);
 
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
+static struct platform_driver clk_mt8516_aud_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8516-aud",
+               .of_match_table = of_match_clk_mt8516_aud,
+       },
+};
+module_platform_driver(clk_mt8516_aud_drv);
 
-}
-CLK_OF_DECLARE(mtk_audsys, "mediatek,mt8516-audsys", mtk_audsys_init);
+MODULE_DESCRIPTION("MediaTek MT8516 audiosys clocks driver");
+MODULE_LICENSE("GPL");
index 2c0cae7b3bcfefd112db9a938d2d990fd5c9e4aa..21eb052b0a539c060401bc1990435d0ede8073cc 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright (c) 2019 MediaTek Inc.
  * Author: James Liao <jamesjj.liao@mediatek.com>
  *         Fabien Parent <fparent@baylibre.com>
+ * Copyright (c) 2023 Collabora Ltd.
  */
 
 #include <linux/delay.h>
 #include <linux/of_address.h>
 #include <linux/slab.h>
 #include <linux/mfd/syscon.h>
+#include <linux/platform_device.h>
 
 #include "clk-gate.h"
 #include "clk-mtk.h"
-#include "clk-pll.h"
 
 #include <dt-bindings/clock/mt8516-clk.h>
 
@@ -525,59 +526,23 @@ static const struct mtk_gate_regs top5_cg_regs = {
        .sta_ofs = 0x44,
 };
 
-#define GATE_TOP1(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top1_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_TOP2(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top2_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_TOP2_I(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top2_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
-
-#define GATE_TOP3(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top3_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr,        \
-       }
-
-#define GATE_TOP4_I(_id, _name, _parent, _shift) {     \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top4_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_setclr_inv,    \
-       }
-
-#define GATE_TOP5(_id, _name, _parent, _shift) {       \
-               .id = _id,                              \
-               .name = _name,                          \
-               .parent_name = _parent,                 \
-               .regs = &top5_cg_regs,                  \
-               .shift = _shift,                        \
-               .ops = &mtk_clk_gate_ops_no_setclr,     \
-       }
+#define GATE_TOP1(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_TOP2(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_TOP2_I(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &top2_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+#define GATE_TOP3(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top3_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_TOP4_I(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &top4_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+#define GATE_TOP5(_id, _name, _parent, _shift)                         \
+       GATE_MTK(_id, _name, _parent, &top5_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
 
 static const struct mtk_gate top_clks[] __initconst = {
        /* TOP1 */
@@ -675,139 +640,42 @@ static const struct mtk_gate top_clks[] __initconst = {
        GATE_TOP5(CLK_TOP_APLL12_DIV6, "apll12_div6", "apll12_ck_div6", 8),
 };
 
-static void __init mtk_topckgen_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-       void __iomem *base;
-
-       base = of_iomap(node, 0);
-       if (!base) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return;
-       }
-
-       clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
+static const struct mtk_clk_desc topck_desc = {
+       .clks = top_clks,
+       .num_clks = ARRAY_SIZE(top_clks),
+       .fixed_clks = fixed_clks,
+       .num_fixed_clks = ARRAY_SIZE(fixed_clks),
+       .factor_clks = top_divs,
+       .num_factor_clks = ARRAY_SIZE(top_divs),
+       .composite_clks = top_muxes,
+       .num_composite_clks = ARRAY_SIZE(top_muxes),
+       .divider_clks = top_adj_divs,
+       .num_divider_clks = ARRAY_SIZE(top_adj_divs),
+       .clk_lock = &mt8516_clk_lock,
+};
 
-       mtk_clk_register_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks),
-                                   clk_data);
-       mtk_clk_register_gates(NULL, node, top_clks, ARRAY_SIZE(top_clks), clk_data);
+static const struct mtk_clk_desc infra_desc = {
+       .composite_clks = ifr_muxes,
+       .num_composite_clks = ARRAY_SIZE(ifr_muxes),
+       .clk_lock = &mt8516_clk_lock,
+};
 
-       mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
-       mtk_clk_register_composites(NULL, top_muxes,
-                                   ARRAY_SIZE(top_muxes), base,
-                                   &mt8516_clk_lock, clk_data);
-       mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs),
-                               base, &mt8516_clk_lock, clk_data);
+static const struct of_device_id of_match_clk_mt8516[] = {
+       { .compatible = "mediatek,mt8516-topckgen", .data = &topck_desc },
+       { .compatible = "mediatek,mt8516-infracfg", .data = &infra_desc },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_match_clk_mt8516);
 
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
-}
-CLK_OF_DECLARE(mtk_topckgen, "mediatek,mt8516-topckgen", mtk_topckgen_init);
-
-static void __init mtk_infracfg_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       int r;
-       void __iomem *base;
-
-       base = of_iomap(node, 0);
-       if (!base) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return;
-       }
-
-       clk_data = mtk_alloc_clk_data(CLK_IFR_NR_CLK);
-
-       mtk_clk_register_composites(NULL, ifr_muxes,
-                                   ARRAY_SIZE(ifr_muxes), base,
-                                   &mt8516_clk_lock, clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
-}
-CLK_OF_DECLARE(mtk_infracfg, "mediatek,mt8516-infracfg", mtk_infracfg_init);
-
-#define MT8516_PLL_FMAX                (1502UL * MHZ)
-
-#define CON0_MT8516_RST_BAR    BIT(27)
-
-#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,  \
-                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
-                       _pcw_shift, _div_table) {                       \
-               .id = _id,                                              \
-               .name = _name,                                          \
-               .reg = _reg,                                            \
-               .pwr_reg = _pwr_reg,                                    \
-               .en_mask = _en_mask,                                    \
-               .flags = _flags,                                        \
-               .rst_bar_mask = CON0_MT8516_RST_BAR,                    \
-               .fmax = MT8516_PLL_FMAX,                                \
-               .pcwbits = _pcwbits,                                    \
-               .pd_reg = _pd_reg,                                      \
-               .pd_shift = _pd_shift,                                  \
-               .tuner_reg = _tuner_reg,                                \
-               .pcw_reg = _pcw_reg,                                    \
-               .pcw_shift = _pcw_shift,                                \
-               .div_table = _div_table,                                \
-       }
-
-#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,    \
-                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg,       \
-                       _pcw_shift)                                     \
-               PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \
-                       _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \
-                       NULL)
-
-static const struct mtk_pll_div_table mmpll_div_table[] = {
-       { .div = 0, .freq = MT8516_PLL_FMAX },
-       { .div = 1, .freq = 1000000000 },
-       { .div = 2, .freq = 604500000 },
-       { .div = 3, .freq = 253500000 },
-       { .div = 4, .freq = 126750000 },
-       { } /* sentinel */
-};
-
-static const struct mtk_pll_data plls[] = {
-       PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0,
-               21, 0x0104, 24, 0, 0x0104, 0),
-       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0,
-               HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0),
-       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x30000000,
-               HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0),
-       PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0,
-               21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table),
-       PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0,
-               31, 0x0180, 1, 0x0194, 0x0184, 0),
-       PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0,
-               31, 0x01A0, 1, 0x01B4, 0x01A4, 0),
-};
-
-static void __init mtk_apmixedsys_init(struct device_node *node)
-{
-       struct clk_hw_onecell_data *clk_data;
-       void __iomem *base;
-       int r;
-
-       base = of_iomap(node, 0);
-       if (!base) {
-               pr_err("%s(): ioremap failed\n", __func__);
-               return;
-       }
-
-       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
-
-       mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
-
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-       if (r)
-               pr_err("%s(): could not register clock provider: %d\n",
-                       __func__, r);
+static struct platform_driver clk_mt8516_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8516",
+               .of_match_table = of_match_clk_mt8516,
+       },
+};
+module_platform_driver(clk_mt8516_drv);
 
-}
-CLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8516-apmixedsys",
-               mtk_apmixedsys_init);
+MODULE_DESCRIPTION("MediaTek MT8516 clocks driver");
+MODULE_LICENSE("GPL");
index 14e8b64a32a3c300d5a99ed8d9459c74e84e1510..fd2214c3242f2b2c372d088337fbdeef18220de8 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
@@ -394,7 +393,8 @@ void mtk_clk_unregister_composites(const struct mtk_composite *mcs, int num,
 }
 EXPORT_SYMBOL_GPL(mtk_clk_unregister_composites);
 
-int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num,
+int mtk_clk_register_dividers(struct device *dev,
+                             const struct mtk_clk_divider *mcds, int num,
                              void __iomem *base, spinlock_t *lock,
                              struct clk_hw_onecell_data *clk_data)
 {
@@ -413,7 +413,7 @@ int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num,
                        continue;
                }
 
-               hw = clk_hw_register_divider(NULL, mcd->name, mcd->parent_name,
+               hw = clk_hw_register_divider(dev, mcd->name, mcd->parent_name,
                        mcd->flags, base +  mcd->div_reg, mcd->div_shift,
                        mcd->div_width, mcd->clk_divider_flags, lock);
 
@@ -463,17 +463,25 @@ void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num,
 }
 EXPORT_SYMBOL_GPL(mtk_clk_unregister_dividers);
 
-int mtk_clk_simple_probe(struct platform_device *pdev)
+static int __mtk_clk_simple_probe(struct platform_device *pdev,
+                                 struct device_node *node)
 {
+       const struct platform_device_id *id;
        const struct mtk_clk_desc *mcd;
        struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
        void __iomem *base;
        int num_clks, r;
 
-       mcd = of_device_get_match_data(&pdev->dev);
-       if (!mcd)
-               return -EINVAL;
+       mcd = device_get_match_data(&pdev->dev);
+       if (!mcd) {
+               /* Clock driver wasn't registered from devicetree */
+               id = platform_get_device_id(pdev);
+               if (id)
+                       mcd = (const struct mtk_clk_desc *)id->driver_data;
+
+               if (!mcd)
+                       return -EINVAL;
+       }
 
        /* Composite clocks needs us to pass iomem pointer */
        if (mcd->composite_clks) {
@@ -489,7 +497,7 @@ int mtk_clk_simple_probe(struct platform_device *pdev)
        /* Calculate how many clk_hw_onecell_data entries to allocate */
        num_clks = mcd->num_clks + mcd->num_composite_clks;
        num_clks += mcd->num_fixed_clks + mcd->num_factor_clks;
-       num_clks += mcd->num_mux_clks;
+       num_clks += mcd->num_mux_clks + mcd->num_divider_clks;
 
        clk_data = mtk_alloc_clk_data(num_clks);
        if (!clk_data)
@@ -527,11 +535,20 @@ int mtk_clk_simple_probe(struct platform_device *pdev)
                        goto unregister_muxes;
        }
 
+       if (mcd->divider_clks) {
+               r = mtk_clk_register_dividers(&pdev->dev,
+                                             mcd->divider_clks,
+                                             mcd->num_divider_clks,
+                                             base, mcd->clk_lock, clk_data);
+               if (r)
+                       goto unregister_composites;
+       }
+
        if (mcd->clks) {
                r = mtk_clk_register_gates(&pdev->dev, node, mcd->clks,
                                           mcd->num_clks, clk_data);
                if (r)
-                       goto unregister_composites;
+                       goto unregister_dividers;
        }
 
        if (mcd->clk_notifier_func) {
@@ -560,6 +577,10 @@ int mtk_clk_simple_probe(struct platform_device *pdev)
 unregister_clks:
        if (mcd->clks)
                mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data);
+unregister_dividers:
+       if (mcd->divider_clks)
+               mtk_clk_unregister_dividers(mcd->divider_clks,
+                                           mcd->num_divider_clks, clk_data);
 unregister_composites:
        if (mcd->composite_clks)
                mtk_clk_unregister_composites(mcd->composite_clks,
@@ -582,17 +603,19 @@ free_data:
                iounmap(base);
        return r;
 }
-EXPORT_SYMBOL_GPL(mtk_clk_simple_probe);
 
-int mtk_clk_simple_remove(struct platform_device *pdev)
+static int __mtk_clk_simple_remove(struct platform_device *pdev,
+                                  struct device_node *node)
 {
-       const struct mtk_clk_desc *mcd = of_device_get_match_data(&pdev->dev);
        struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-       struct device_node *node = pdev->dev.of_node;
+       const struct mtk_clk_desc *mcd = device_get_match_data(&pdev->dev);
 
        of_clk_del_provider(node);
        if (mcd->clks)
                mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data);
+       if (mcd->divider_clks)
+               mtk_clk_unregister_dividers(mcd->divider_clks,
+                                           mcd->num_divider_clks, clk_data);
        if (mcd->composite_clks)
                mtk_clk_unregister_composites(mcd->composite_clks,
                                              mcd->num_composite_clks, clk_data);
@@ -609,6 +632,37 @@ int mtk_clk_simple_remove(struct platform_device *pdev)
 
        return 0;
 }
+
+int mtk_clk_pdev_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+
+       return __mtk_clk_simple_probe(pdev, node);
+}
+EXPORT_SYMBOL_GPL(mtk_clk_pdev_probe);
+
+int mtk_clk_simple_probe(struct platform_device *pdev)
+{
+       struct device_node *node = pdev->dev.of_node;
+
+       return __mtk_clk_simple_probe(pdev, node);
+}
+EXPORT_SYMBOL_GPL(mtk_clk_simple_probe);
+
+int mtk_clk_pdev_remove(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+
+       return __mtk_clk_simple_remove(pdev, node);
+}
+EXPORT_SYMBOL_GPL(mtk_clk_pdev_remove);
+
+int mtk_clk_simple_remove(struct platform_device *pdev)
+{
+       return __mtk_clk_simple_remove(pdev, pdev->dev.of_node);
+}
 EXPORT_SYMBOL_GPL(mtk_clk_simple_remove);
 
 MODULE_LICENSE("GPL");
index 41f4fa3b0c212338e2d0ec7faa4efaa46d728fa8..b7a751861fcee32b45dba3c5dedd6507ed0aeb13 100644 (file)
@@ -202,7 +202,8 @@ struct mtk_clk_divider {
                .div_width = _width,                            \
 }
 
-int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num,
+int mtk_clk_register_dividers(struct device *dev,
+                             const struct mtk_clk_divider *mcds, int num,
                              void __iomem *base, spinlock_t *lock,
                              struct clk_hw_onecell_data *clk_data);
 void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num,
@@ -222,6 +223,8 @@ struct mtk_clk_desc {
        size_t num_clks;
        const struct mtk_composite *composite_clks;
        size_t num_composite_clks;
+       const struct mtk_clk_divider *divider_clks;
+       size_t num_divider_clks;
        const struct mtk_fixed_clk *fixed_clks;
        size_t num_fixed_clks;
        const struct mtk_fixed_factor *factor_clks;
@@ -236,6 +239,8 @@ struct mtk_clk_desc {
        unsigned int mfg_clk_idx;
 };
 
+int mtk_clk_pdev_probe(struct platform_device *pdev);
+int mtk_clk_pdev_remove(struct platform_device *pdev);
 int mtk_clk_simple_probe(struct platform_device *pdev);
 int mtk_clk_simple_remove(struct platform_device *pdev);
 
index f48780bec5077ae27aad22bd59a654e94734bdcb..3a2b3f90be25d5925a19890c82823784791dd70a 100644 (file)
@@ -75,13 +75,13 @@ void fhctl_parse_dt(const u8 *compatible_node, struct mtk_pllfh_data *pllfhs,
        base = of_iomap(node, 0);
        if (!base) {
                pr_err("%s(): ioremap failed\n", __func__);
-               return;
+               goto out_node_put;
        }
 
        num_clocks = of_clk_get_parent_count(node);
        if (!num_clocks) {
                pr_err("%s(): failed to get clocks property\n", __func__);
-               return;
+               goto err;
        }
 
        for (i = 0; i < num_clocks; i++) {
@@ -102,16 +102,26 @@ void fhctl_parse_dt(const u8 *compatible_node, struct mtk_pllfh_data *pllfhs,
                pllfh->state.ssc_rate = ssc_rate;
                pllfh->state.base = base;
        }
+
+out_node_put:
+       of_node_put(node);
+       return;
+err:
+       iounmap(base);
+       goto out_node_put;
 }
+EXPORT_SYMBOL_GPL(fhctl_parse_dt);
 
-static void pllfh_init(struct mtk_fh *fh, struct mtk_pllfh_data *pllfh_data)
+static int pllfh_init(struct mtk_fh *fh, struct mtk_pllfh_data *pllfh_data)
 {
        struct fh_pll_regs *regs = &fh->regs;
        const struct fhctl_offset *offset;
        void __iomem *base = pllfh_data->state.base;
        void __iomem *fhx_base = base + pllfh_data->data.fhx_offset;
 
-       offset = fhctl_get_offset_table();
+       offset = fhctl_get_offset_table(pllfh_data->data.fh_ver);
+       if (IS_ERR(offset))
+               return PTR_ERR(offset);
 
        regs->reg_hp_en = base + offset->offset_hp_en;
        regs->reg_clk_con = base + offset->offset_clk_con;
@@ -129,6 +139,8 @@ static void pllfh_init(struct mtk_fh *fh, struct mtk_pllfh_data *pllfh_data)
        fh->lock = &pllfh_lock;
 
        fh->ops = fhctl_get_ops();
+
+       return 0;
 }
 
 static bool fhctl_is_supported_and_enabled(const struct mtk_pllfh_data *pllfh)
@@ -142,20 +154,29 @@ mtk_clk_register_pllfh(const struct mtk_pll_data *pll_data,
 {
        struct clk_hw *hw;
        struct mtk_fh *fh;
+       int ret;
 
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
        if (!fh)
                return ERR_PTR(-ENOMEM);
 
-       pllfh_init(fh, pllfh_data);
+       ret = pllfh_init(fh, pllfh_data);
+       if (ret) {
+               hw = ERR_PTR(ret);
+               goto out;
+       }
 
        hw = mtk_clk_register_pll_ops(&fh->clk_pll, pll_data, base,
                                      &mtk_pllfh_ops);
 
+       if (IS_ERR(hw))
+               goto out;
+
+       fhctl_hw_init(fh);
+
+out:
        if (IS_ERR(hw))
                kfree(fh);
-       else
-               fhctl_hw_init(fh);
 
        return hw;
 }
@@ -234,6 +255,7 @@ err:
 
        return PTR_ERR(hw);
 }
+EXPORT_SYMBOL_GPL(mtk_clk_register_pllfhs);
 
 void mtk_clk_unregister_pllfhs(const struct mtk_pll_data *plls, int num_plls,
                               struct mtk_pllfh_data *pllfhs, int num_fhs,
@@ -273,3 +295,4 @@ void mtk_clk_unregister_pllfhs(const struct mtk_pll_data *plls, int num_plls,
 
        iounmap(base);
 }
+EXPORT_SYMBOL_GPL(mtk_clk_unregister_pllfhs);
index c0a6e1537034f8d3827d894288cf399109d39f87..5f419c2ec01f988ede4e40289c6e5d5f8070ad14 100644 (file)
@@ -18,6 +18,7 @@ struct fh_pll_state {
 struct fh_pll_data {
        int pll_id;
        int fh_id;
+       int fh_ver;
        u32 fhx_offset;
        u32 dds_mask;
        u32 slope0_value;
index 4f0a19db7ed749a43d08a12a46da70b80a82410d..cc5d7dee59f06fc1e387f427e7e686408b0d3611 100644 (file)
@@ -374,14 +374,13 @@ static void mpfs_reset_unregister_adev(void *_adev)
        struct auxiliary_device *adev = _adev;
 
        auxiliary_device_delete(adev);
+       auxiliary_device_uninit(adev);
 }
 
 static void mpfs_reset_adev_release(struct device *dev)
 {
        struct auxiliary_device *adev = to_auxiliary_dev(dev);
 
-       auxiliary_device_uninit(adev);
-
        kfree(adev);
 }
 
index 7aa7f4a9564fde8617f9e2fd5819219dfadbc20d..6fb1aa9487b59c6bed4ff9ad8da8deb2eb298fba 100644 (file)
@@ -384,12 +384,10 @@ disable_pm_runtime:
        return ret;
 }
 
-static int mmp2_audio_clk_remove(struct platform_device *pdev)
+static void mmp2_audio_clk_remove(struct platform_device *pdev)
 {
        pm_clk_destroy(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
-
-       return 0;
 }
 
 #ifdef CONFIG_PM
@@ -436,7 +434,7 @@ static struct platform_driver mmp2_audio_clk_driver = {
                .pm = &mmp2_audio_clk_pm_ops,
        },
        .probe = mmp2_audio_clk_probe,
-       .remove = mmp2_audio_clk_remove,
+       .remove_new = mmp2_audio_clk_remove,
 };
 module_platform_driver(mmp2_audio_clk_driver);
 
index e3777ca659120d52d035b55325a8abf17f1b1e8c..3ae6078f6ff76bff3096ab60b44969d9fd74f6c7 100644 (file)
@@ -781,7 +781,7 @@ static int armada_3700_periph_clock_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int armada_3700_periph_clock_remove(struct platform_device *pdev)
+static void armada_3700_periph_clock_remove(struct platform_device *pdev)
 {
        struct clk_periph_driver_data *data = platform_get_drvdata(pdev);
        struct clk_hw_onecell_data *hw_data = data->hw_data;
@@ -791,13 +791,11 @@ static int armada_3700_periph_clock_remove(struct platform_device *pdev)
 
        for (i = 0; i < hw_data->num; i++)
                clk_hw_unregister(hw_data->hws[i]);
-
-       return 0;
 }
 
 static struct platform_driver armada_3700_periph_clock_driver = {
        .probe = armada_3700_periph_clock_probe,
-       .remove = armada_3700_periph_clock_remove,
+       .remove_new = armada_3700_periph_clock_remove,
        .driver         = {
                .name   = "marvell-armada-3700-periph-clock",
                .of_match_table = armada_3700_periph_clock_of_match,
index fc403ad735adeff8a07a21fe0fa00f567521848f..eccc1aeefbafff5bb58330667fecd909e84d0590 100644 (file)
@@ -126,7 +126,7 @@ static int armada_3700_tbg_clock_probe(struct platform_device *pdev)
        return of_clk_add_hw_provider(np, of_clk_hw_onecell_get, hw_tbg_data);
 }
 
-static int armada_3700_tbg_clock_remove(struct platform_device *pdev)
+static void armada_3700_tbg_clock_remove(struct platform_device *pdev)
 {
        int i;
        struct clk_hw_onecell_data *hw_tbg_data = platform_get_drvdata(pdev);
@@ -134,8 +134,6 @@ static int armada_3700_tbg_clock_remove(struct platform_device *pdev)
        of_clk_del_provider(pdev->dev.of_node);
        for (i = 0; i < hw_tbg_data->num; i++)
                clk_hw_unregister_fixed_factor(hw_tbg_data->hws[i]);
-
-       return 0;
 }
 
 static const struct of_device_id armada_3700_tbg_clock_of_match[] = {
@@ -145,7 +143,7 @@ static const struct of_device_id armada_3700_tbg_clock_of_match[] = {
 
 static struct platform_driver armada_3700_tbg_clock_driver = {
        .probe = armada_3700_tbg_clock_probe,
-       .remove = armada_3700_tbg_clock_remove,
+       .remove_new = armada_3700_tbg_clock_remove,
        .driver         = {
                .name   = "marvell-armada-3700-tbg-clock",
                .of_match_table = armada_3700_tbg_clock_of_match,
index 41271351cf1f4f1349599323a732f565c7b50a2a..0e2e7d00ae113c35b3e5aa967f9766f8107b0dc4 100644 (file)
@@ -65,11 +65,9 @@ static int armada_3700_xtal_clock_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int armada_3700_xtal_clock_remove(struct platform_device *pdev)
+static void armada_3700_xtal_clock_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-
-       return 0;
 }
 
 static const struct of_device_id armada_3700_xtal_clock_of_match[] = {
@@ -79,7 +77,7 @@ static const struct of_device_id armada_3700_xtal_clock_of_match[] = {
 
 static struct platform_driver armada_3700_xtal_clock_driver = {
        .probe = armada_3700_xtal_clock_probe,
-       .remove = armada_3700_xtal_clock_remove,
+       .remove_new = armada_3700_xtal_clock_remove,
        .driver         = {
                .name   = "marvell-armada-3700-xtal-clock",
                .of_match_table = armada_3700_xtal_clock_of_match,
index 0f59c84229a8b8ce37ccf8868be05c868e7dd2b4..7e90e94c4b68821b91f455bf1cf6c34905914e67 100644 (file)
@@ -76,6 +76,7 @@ static const struct cpg_core_clk r8a77970_core_clks[] __initconst = {
        DEF_FIXED(".pll1_div4", CLK_PLL1_DIV4,  CLK_PLL1_DIV2,  2, 1),
 
        /* Core Clock Outputs */
+       DEF_FIXED("z2",         R8A77970_CLK_Z2,    CLK_PLL1_DIV4,  1, 1),
        DEF_FIXED("ztr",        R8A77970_CLK_ZTR,   CLK_PLL1_DIV2,  6, 1),
        DEF_FIXED("ztrd2",      R8A77970_CLK_ZTRD2, CLK_PLL1_DIV2, 12, 1),
        DEF_FIXED("zt",         R8A77970_CLK_ZT,    CLK_PLL1_DIV2,  4, 1),
index 06f925aff407b1c1ac7ae1c4f62d55159f4edd83..aaa685ec35df06efcae8d2c77a2dca695c92c14f 100644 (file)
@@ -72,6 +72,7 @@ static const struct cpg_core_clk r8a77980_core_clks[] __initconst = {
        DEF_RATE(".oco",        CLK_OCO,           32768),
 
        /* Core Clock Outputs */
+       DEF_FIXED("z2",         R8A77980_CLK_Z2,    CLK_PLL2,       4, 1),
        DEF_FIXED("ztr",        R8A77980_CLK_ZTR,   CLK_PLL1_DIV2,  6, 1),
        DEF_FIXED("ztrd2",      R8A77980_CLK_ZTRD2, CLK_PLL1_DIV2, 12, 1),
        DEF_FIXED("zt",         R8A77980_CLK_ZT,    CLK_PLL1_DIV2,  4, 1),
@@ -150,11 +151,27 @@ static const struct mssr_mod_clk r8a77980_mod_clks[] __initconst = {
        DEF_MOD("imp-ocv3",              529,   R8A77980_CLK_S1D1),
        DEF_MOD("imp-ocv2",              531,   R8A77980_CLK_S1D1),
        DEF_MOD("fcpvd0",                603,   R8A77980_CLK_S3D1),
+       DEF_MOD("vin15",                 604,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin14",                 605,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin13",                 608,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin12",                 612,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin11",                 618,   R8A77980_CLK_S2D1),
        DEF_MOD("vspd0",                 623,   R8A77980_CLK_S3D1),
+       DEF_MOD("vin10",                 625,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin9",                  627,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin8",                  628,   R8A77980_CLK_S2D1),
        DEF_MOD("csi41",                 715,   R8A77980_CLK_CSI0),
        DEF_MOD("csi40",                 716,   R8A77980_CLK_CSI0),
        DEF_MOD("du0",                   724,   R8A77980_CLK_S2D1),
        DEF_MOD("lvds",                  727,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin7",                  804,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin6",                  805,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin5",                  806,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin4",                  807,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin3",                  808,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin2",                  809,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin1",                  810,   R8A77980_CLK_S2D1),
+       DEF_MOD("vin0",                  811,   R8A77980_CLK_S2D1),
        DEF_MOD("etheravb",              812,   R8A77980_CLK_S3D2),
        DEF_MOD("gether",                813,   R8A77980_CLK_S3D2),
        DEF_MOD("imp3",                  824,   R8A77980_CLK_S1D1),
@@ -173,6 +190,7 @@ static const struct mssr_mod_clk r8a77980_mod_clks[] __initconst = {
        DEF_MOD("gpio0",                 912,   R8A77980_CLK_CP),
        DEF_MOD("can-fd",                914,   R8A77980_CLK_S3D2),
        DEF_MOD("rpc-if",                917,   R8A77980_CLK_RPCD2),
+       DEF_MOD("i2c5",                  919,   R8A77980_CLK_S0D6),
        DEF_MOD("i2c4",                  927,   R8A77980_CLK_S0D6),
        DEF_MOD("i2c3",                  928,   R8A77980_CLK_S0D6),
        DEF_MOD("i2c2",                  929,   R8A77980_CLK_S3D2),
index 24ba9093a72f7341ab79c27182732cbf60ad1f9c..3a73f6f911dd5160f1ee6116b522b24f0f6d1875 100644 (file)
@@ -167,7 +167,7 @@ static const struct mssr_mod_clk r8a77995_mod_clks[] __initconst = {
        DEF_MOD("du0",                   724,   R8A77995_CLK_S1D1),
        DEF_MOD("lvds",                  727,   R8A77995_CLK_S2D1),
        DEF_MOD("mlp",                   802,   R8A77995_CLK_S2D1),
-       DEF_MOD("vin4",                  807,   R8A77995_CLK_S1D2),
+       DEF_MOD("vin4",                  807,   R8A77995_CLK_S3D1),
        DEF_MOD("etheravb",              812,   R8A77995_CLK_S3D2),
        DEF_MOD("imr0",                  823,   R8A77995_CLK_S1D2),
        DEF_MOD("gpio6",                 906,   R8A77995_CLK_S3D4),
index 7fca11204f74a50f9470b9d56424244eb7e2a31d..7cc580d67362610a977f112a12f948ebf6223b1d 100644 (file)
@@ -146,6 +146,7 @@ static const struct cpg_core_clk r8a779g0_core_clks[] __initconst = {
        DEF_FIXED("vcbus",      R8A779G0_CLK_VCBUS,     CLK_VC,         1, 1),
        DEF_FIXED("vcbusd2",    R8A779G0_CLK_VCBUSD2,   CLK_VC,         2, 1),
        DEF_DIV6P1("canfd",     R8A779G0_CLK_CANFD,     CLK_PLL5_DIV4,  0x878),
+       DEF_DIV6P1("csi",       R8A779G0_CLK_CSI,       CLK_PLL5_DIV4,  0x880),
        DEF_FIXED("dsiref",     R8A779G0_CLK_DSIREF,    CLK_PLL5_DIV4,  48, 1),
        DEF_DIV6P1("dsiext",    R8A779G0_CLK_DSIEXT,    CLK_PLL5_DIV4,  0x884),
 
@@ -165,6 +166,8 @@ static const struct mssr_mod_clk r8a779g0_mod_clks[] __initconst = {
        DEF_MOD("avb1",         212,    R8A779G0_CLK_S0D4_HSC),
        DEF_MOD("avb2",         213,    R8A779G0_CLK_S0D4_HSC),
        DEF_MOD("canfd0",       328,    R8A779G0_CLK_SASYNCPERD2),
+       DEF_MOD("csi40",        331,    R8A779G0_CLK_CSI),
+       DEF_MOD("csi41",        400,    R8A779G0_CLK_CSI),
        DEF_MOD("dis0",         411,    R8A779G0_CLK_VIOBUSD2),
        DEF_MOD("dsitxlink0",   415,    R8A779G0_CLK_VIOBUSD2),
        DEF_MOD("dsitxlink1",   416,    R8A779G0_CLK_VIOBUSD2),
@@ -181,6 +184,8 @@ static const struct mssr_mod_clk r8a779g0_mod_clks[] __initconst = {
        DEF_MOD("i2c4",         522,    R8A779G0_CLK_S0D6_PER),
        DEF_MOD("i2c5",         523,    R8A779G0_CLK_S0D6_PER),
        DEF_MOD("irqc",         611,    R8A779G0_CLK_CL16M),
+       DEF_MOD("ispcs0",       612,    R8A779G0_CLK_S0D2_VIO),
+       DEF_MOD("ispcs1",       613,    R8A779G0_CLK_S0D2_VIO),
        DEF_MOD("msi0",         618,    R8A779G0_CLK_MSO),
        DEF_MOD("msi1",         619,    R8A779G0_CLK_MSO),
        DEF_MOD("msi2",         620,    R8A779G0_CLK_MSO),
@@ -202,6 +207,22 @@ static const struct mssr_mod_clk r8a779g0_mod_clks[] __initconst = {
        DEF_MOD("tmu3",         716,    R8A779G0_CLK_SASYNCPERD2),
        DEF_MOD("tmu4",         717,    R8A779G0_CLK_SASYNCPERD2),
        DEF_MOD("tpu0",         718,    R8A779G0_CLK_SASYNCPERD4),
+       DEF_MOD("vin00",        730,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin01",        731,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin02",        800,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin03",        801,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin04",        802,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin05",        803,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin06",        804,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin07",        805,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin10",        806,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin11",        807,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin12",        808,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin13",        809,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin14",        810,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin15",        811,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin16",        812,    R8A779G0_CLK_S0D4_VIO),
+       DEF_MOD("vin17",        813,    R8A779G0_CLK_S0D4_VIO),
        DEF_MOD("vspd0",        830,    R8A779G0_CLK_VIOBUSD2),
        DEF_MOD("vspd1",        831,    R8A779G0_CLK_VIOBUSD2),
        DEF_MOD("wdt1:wdt0",    907,    R8A779G0_CLK_R),
@@ -213,6 +234,9 @@ static const struct mssr_mod_clk r8a779g0_mod_clks[] __initconst = {
        DEF_MOD("pfc1",         916,    R8A779G0_CLK_CL16M),
        DEF_MOD("pfc2",         917,    R8A779G0_CLK_CL16M),
        DEF_MOD("pfc3",         918,    R8A779G0_CLK_CL16M),
+       DEF_MOD("tsc",          919,    R8A779G0_CLK_CL16M),
+       DEF_MOD("ssiu",         2926,   R8A779G0_CLK_S0D6_PER),
+       DEF_MOD("ssi",          2927,   R8A779G0_CLK_S0D6_PER),
 };
 
 /*
index 087146f2ee068713208cb23efe16cc0f2ff9658c..40828616f723ea3e7515278ce45c4f2f72823ad8 100644 (file)
 #define R9A06G032_SYSCTRL_USB_H2MODE  (1<<1)
 #define R9A06G032_SYSCTRL_DMAMUX 0xA0
 
+/**
+ * struct regbit - describe one bit in a register
+ * @reg: offset of register relative to base address,
+ *          expressed in units of 32-bit words (not bytes),
+ * @bit: which bit (0 to 31) in the register
+ *
+ * This structure is used to compactly encode the location
+ * of a single bit in a register. Five bits are needed to
+ * encode the bit number. With uint16_t data type, this
+ * leaves 11 bits to encode a register offset up to 2047.
+ *
+ * Since registers are aligned on 32-bit boundaries, the
+ * offset will be specified in 32-bit words rather than bytes.
+ * This allows encoding an offset up to 0x1FFC (8188) bytes.
+ *
+ * Helper macro RB() takes care of converting the register
+ * offset from bytes to 32-bit words.
+ */
+struct regbit {
+       u16 bit:5;
+       u16 reg:11;
+};
+
+#define RB(_reg, _bit) ((struct regbit) { \
+       .reg = (_reg) / 4, \
+       .bit = (_bit) \
+})
+
+/**
+ * struct r9a06g032_gate - clock-related control bits
+ * @gate:   clock enable/disable
+ * @reset:  clock module reset (active low)
+ * @ready:  enables NoC forwarding of read/write requests to device,
+ *          (eg. device is ready to handle read/write requests)
+ * @midle:  request to idle the NoC interconnect
+ *
+ * Each of these fields describes a single bit in a register,
+ * which controls some aspect of clock gating. The @gate field
+ * is mandatory, this one enables/disables the clock. The
+ * other fields are optional, with zero indicating "not used".
+ *
+ * In most cases there is a @reset bit which needs to be
+ * de-asserted to bring the module out of reset.
+ *
+ * Modules may also need to signal when they are @ready to
+ * handle requests (read/writes) from the NoC interconnect.
+ *
+ * Similarly, the @midle bit is used to idle the master.
+ */
 struct r9a06g032_gate {
-       u16 gate, reset, ready, midle,
-               scon, mirack, mistat;
+       struct regbit gate, reset, ready, midle;
+       /* Unused fields omitted to save space */
+       /* struct regbit scon, mirack, mistat */;
+};
+
+enum gate_type {
+       K_GATE = 0,     /* gate which enable/disable */
+       K_FFC,          /* fixed factor clock */
+       K_DIV,          /* divisor */
+       K_BITSEL,       /* special for UARTs */
+       K_DUALGATE      /* special for UARTs */
 };
 
-/* This is used to describe a clock for instantiation */
+/**
+ * struct r9a06g032_clkdesc - describe a single clock
+ * @name:      string describing this clock
+ * @managed:   boolean indicating if this clock should be
+ *             started/stopped as part of power management
+ * @type:      see enum @gate_type
+ * @index:     the ID of this clock element
+ * @source:    the ID+1 of the parent clock element.
+ *             Root clock uses ID of ~0 (PARENT_ID);
+ * @gate:      clock enable/disable
+ * @div_min:   smallest permitted clock divider
+ * @div_max:   largest permitted clock divider
+ * @reg:       clock divider register offset, in 32-bit words
+ * @div_table: optional list of fixed clock divider values;
+ *             must be in ascending order, zero for unused
+ * @div:       divisor for fixed-factor clock
+ * @mul:       multiplier for fixed-factor clock
+ * @group:     UART group, 0=UART0/1/2, 1=UART3/4/5/6/7
+ * @sel:       select either g1/r1 or g2/r2 as clock source
+ * @g1:        1st source gate (clock enable/disable)
+ * @r1:        1st source reset (module reset)
+ * @g2:        2nd source gate (clock enable/disable)
+ * @r2:        2nd source reset (module reset)
+ *
+ * Describes a single element in the clock tree hierarchy.
+ * As there are quite a large number of clock elements, this
+ * structure is packed tightly to conserve space.
+ */
 struct r9a06g032_clkdesc {
        const char *name;
-       uint32_t managed: 1;
-       uint32_t type: 3;
-       uint32_t index: 8;
-       uint32_t source : 8; /* source index + 1 (0 == none) */
-       /* these are used to populate the bitsel struct */
+       uint32_t managed:1;
+       enum gate_type type:3;
+       uint32_t index:8;
+       uint32_t source:8; /* source index + 1 (0 == none) */
        union {
+               /* type = K_GATE */
                struct r9a06g032_gate gate;
-               /* for dividers */
+               /* type = K_DIV  */
                struct {
-                       unsigned int div_min : 10, div_max : 10, reg: 10;
+                       unsigned int div_min:10, div_max:10, reg:10;
                        u16 div_table[4];
                };
-               /* For fixed-factor ones */
+               /* type = K_FFC */
                struct {
                        u16 div, mul;
                };
-               /* for dual gate */
+               /* type = K_DUALGATE */
                struct {
-                       uint16_t group : 1;
-                       u16 sel, g1, r1, g2, r2;
+                       uint16_t group:1;
+                       struct regbit sel, g1, r1, g2, r2;
                } dual;
        };
 };
 
-#define I_GATE(_clk, _rst, _rdy, _midle, _scon, _mirack, _mistat) \
-       { .gate = _clk, .reset = _rst, \
-               .ready = _rdy, .midle = _midle, \
-               .scon = _scon, .mirack = _mirack, .mistat = _mistat }
-#define D_GATE(_idx, _n, _src, ...) \
-       { .type = K_GATE, .index = R9A06G032_##_idx, \
-               .source = 1 + R9A06G032_##_src, .name = _n, \
-               .gate = I_GATE(__VA_ARGS__) }
-#define D_MODULE(_idx, _n, _src, ...) \
-       { .type = K_GATE, .index = R9A06G032_##_idx, \
-               .source = 1 + R9A06G032_##_src, .name = _n, \
-               .managed = 1, .gate = I_GATE(__VA_ARGS__) }
-#define D_ROOT(_idx, _n, _mul, _div) \
-       { .type = K_FFC, .index = R9A06G032_##_idx, .name = _n, \
-               .div = _div, .mul = _mul }
-#define D_FFC(_idx, _n, _src, _div) \
-       { .type = K_FFC, .index = R9A06G032_##_idx, \
-               .source = 1 + R9A06G032_##_src, .name = _n, \
-               .div = _div, .mul = 1}
-#define D_DIV(_idx, _n, _src, _reg, _min, _max, ...) \
-       { .type = K_DIV, .index = R9A06G032_##_idx, \
-               .source = 1 + R9A06G032_##_src, .name = _n, \
-               .reg = _reg, .div_min = _min, .div_max = _max, \
-               .div_table = { __VA_ARGS__ } }
-#define D_UGATE(_idx, _n, _src, _g, _g1, _r1, _g2, _r2) \
-       { .type = K_DUALGATE, .index = R9A06G032_##_idx, \
-               .source = 1 + R9A06G032_##_src, .name = _n, \
-               .dual = { .group = _g, \
-                       .g1 = _g1, .r1 = _r1, .g2 = _g2, .r2 = _r2 }, }
-
-enum { K_GATE = 0, K_FFC, K_DIV, K_BITSEL, K_DUALGATE };
+/*
+ * The last three arguments are not currently used,
+ * but are kept in the r9a06g032_clocks table below.
+ */
+#define I_GATE(_clk, _rst, _rdy, _midle, _scon, _mirack, _mistat) { \
+       .gate = _clk, \
+       .reset = _rst, \
+       .ready = _rdy, \
+       .midle = _midle, \
+       /* .scon = _scon, */ \
+       /* .mirack = _mirack, */ \
+       /* .mistat = _mistat */ \
+}
+#define D_GATE(_idx, _n, _src, ...) { \
+       .type = K_GATE, \
+       .index = R9A06G032_##_idx, \
+       .source = 1 + R9A06G032_##_src, \
+       .name = _n, \
+       .gate = I_GATE(__VA_ARGS__) \
+}
+#define D_MODULE(_idx, _n, _src, ...) { \
+       .type = K_GATE, \
+       .index = R9A06G032_##_idx, \
+       .source = 1 + R9A06G032_##_src, \
+       .name = _n, \
+       .managed = 1, \
+       .gate = I_GATE(__VA_ARGS__) \
+}
+#define D_ROOT(_idx, _n, _mul, _div) { \
+       .type = K_FFC, \
+       .index = R9A06G032_##_idx, \
+       .name = _n, \
+       .div = _div, \
+       .mul = _mul \
+}
+#define D_FFC(_idx, _n, _src, _div) { \
+       .type = K_FFC, \
+       .index = R9A06G032_##_idx, \
+       .source = 1 + R9A06G032_##_src, \
+       .name = _n, \
+       .div = _div, \
+       .mul = 1 \
+}
+#define D_DIV(_idx, _n, _src, _reg, _min, _max, ...) { \
+       .type = K_DIV, \
+       .index = R9A06G032_##_idx, \
+       .source = 1 + R9A06G032_##_src, \
+       .name = _n, \
+       .reg = _reg, \
+       .div_min = _min, \
+       .div_max = _max, \
+       .div_table = { __VA_ARGS__ } \
+}
+#define D_UGATE(_idx, _n, _src, _g, _g1, _r1, _g2, _r2) { \
+       .type = K_DUALGATE, \
+       .index = R9A06G032_##_idx, \
+       .source = 1 + R9A06G032_##_src, \
+       .name = _n, \
+       .dual = { \
+               .group = _g, \
+               .g1 = _g1, \
+               .r1 = _r1, \
+               .g2 = _g2, \
+               .r2 = _r2 \
+       }, \
+}
 
 /* Internal clock IDs */
 #define R9A06G032_CLKOUT               0
@@ -160,58 +280,160 @@ static const struct r9a06g032_clkdesc r9a06g032_clocks[] = {
        D_DIV(DIV_SDIO1, "div_sdio1", CLKOUT, 75, 20, 128),
        D_DIV(DIV_SWITCH, "div_switch", CLKOUT, 37, 5, 40),
        D_DIV(DIV_UART, "div_uart", CLKOUT, 79, 12, 128),
-       D_GATE(CLK_25_PG4, "clk_25_pg4", CLKOUT_D40, 0x749, 0x74a, 0x74b, 0, 0xae3, 0, 0),
-       D_GATE(CLK_25_PG5, "clk_25_pg5", CLKOUT_D40, 0x74c, 0x74d, 0x74e, 0, 0xae4, 0, 0),
-       D_GATE(CLK_25_PG6, "clk_25_pg6", CLKOUT_D40, 0x74f, 0x750, 0x751, 0, 0xae5, 0, 0),
-       D_GATE(CLK_25_PG7, "clk_25_pg7", CLKOUT_D40, 0x752, 0x753, 0x754, 0, 0xae6, 0, 0),
-       D_GATE(CLK_25_PG8, "clk_25_pg8", CLKOUT_D40, 0x755, 0x756, 0x757, 0, 0xae7, 0, 0),
-       D_GATE(CLK_ADC, "clk_adc", DIV_ADC, 0x1ea, 0x1eb, 0, 0, 0, 0, 0),
-       D_GATE(CLK_ECAT100, "clk_ecat100", CLKOUT_D10, 0x405, 0, 0, 0, 0, 0, 0),
-       D_GATE(CLK_HSR100, "clk_hsr100", CLKOUT_D10, 0x483, 0, 0, 0, 0, 0, 0),
-       D_GATE(CLK_I2C0, "clk_i2c0", DIV_I2C, 0x1e6, 0x1e7, 0, 0, 0, 0, 0),
-       D_GATE(CLK_I2C1, "clk_i2c1", DIV_I2C, 0x1e8, 0x1e9, 0, 0, 0, 0, 0),
-       D_GATE(CLK_MII_REF, "clk_mii_ref", CLKOUT_D40, 0x342, 0, 0, 0, 0, 0, 0),
-       D_GATE(CLK_NAND, "clk_nand", DIV_NAND, 0x284, 0x285, 0, 0, 0, 0, 0),
-       D_GATE(CLK_NOUSBP2_PG6, "clk_nousbp2_pg6", DIV_P2_PG, 0x774, 0x775, 0, 0, 0, 0, 0),
-       D_GATE(CLK_P1_PG2, "clk_p1_pg2", DIV_P1_PG, 0x862, 0x863, 0, 0, 0, 0, 0),
-       D_GATE(CLK_P1_PG3, "clk_p1_pg3", DIV_P1_PG, 0x864, 0x865, 0, 0, 0, 0, 0),
-       D_GATE(CLK_P1_PG4, "clk_p1_pg4", DIV_P1_PG, 0x866, 0x867, 0, 0, 0, 0, 0),
-       D_GATE(CLK_P4_PG3, "clk_p4_pg3", DIV_P4_PG, 0x824, 0x825, 0, 0, 0, 0, 0),
-       D_GATE(CLK_P4_PG4, "clk_p4_pg4", DIV_P4_PG, 0x826, 0x827, 0, 0, 0, 0, 0),
-       D_GATE(CLK_P6_PG1, "clk_p6_pg1", DIV_P6_PG, 0x8a0, 0x8a1, 0x8a2, 0, 0xb60, 0, 0),
-       D_GATE(CLK_P6_PG2, "clk_p6_pg2", DIV_P6_PG, 0x8a3, 0x8a4, 0x8a5, 0, 0xb61, 0, 0),
-       D_GATE(CLK_P6_PG3, "clk_p6_pg3", DIV_P6_PG, 0x8a6, 0x8a7, 0x8a8, 0, 0xb62, 0, 0),
-       D_GATE(CLK_P6_PG4, "clk_p6_pg4", DIV_P6_PG, 0x8a9, 0x8aa, 0x8ab, 0, 0xb63, 0, 0),
-       D_MODULE(CLK_PCI_USB, "clk_pci_usb", CLKOUT_D40, 0xe6, 0, 0, 0, 0, 0, 0),
-       D_GATE(CLK_QSPI0, "clk_qspi0", DIV_QSPI0, 0x2a4, 0x2a5, 0, 0, 0, 0, 0),
-       D_GATE(CLK_QSPI1, "clk_qspi1", DIV_QSPI1, 0x484, 0x485, 0, 0, 0, 0, 0),
-       D_GATE(CLK_RGMII_REF, "clk_rgmii_ref", CLKOUT_D8, 0x340, 0, 0, 0, 0, 0, 0),
-       D_GATE(CLK_RMII_REF, "clk_rmii_ref", CLKOUT_D20, 0x341, 0, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SDIO0, "clk_sdio0", DIV_SDIO0, 0x64, 0, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SDIO1, "clk_sdio1", DIV_SDIO1, 0x644, 0, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SERCOS100, "clk_sercos100", CLKOUT_D10, 0x425, 0, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SLCD, "clk_slcd", DIV_P1_PG, 0x860, 0x861, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SPI0, "clk_spi0", DIV_P3_PG, 0x7e0, 0x7e1, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SPI1, "clk_spi1", DIV_P3_PG, 0x7e2, 0x7e3, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SPI2, "clk_spi2", DIV_P3_PG, 0x7e4, 0x7e5, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SPI3, "clk_spi3", DIV_P3_PG, 0x7e6, 0x7e7, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SPI4, "clk_spi4", DIV_P4_PG, 0x820, 0x821, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SPI5, "clk_spi5", DIV_P4_PG, 0x822, 0x823, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SWITCH, "clk_switch", DIV_SWITCH, 0x982, 0x983, 0, 0, 0, 0, 0),
+       D_GATE(CLK_25_PG4, "clk_25_pg4", CLKOUT_D40, RB(0xe8, 9),
+              RB(0xe8, 10), RB(0xe8, 11), RB(0x00, 0),
+              RB(0x15c, 3), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_25_PG5, "clk_25_pg5", CLKOUT_D40, RB(0xe8, 12),
+              RB(0xe8, 13), RB(0xe8, 14), RB(0x00, 0),
+              RB(0x15c, 4), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_25_PG6, "clk_25_pg6", CLKOUT_D40, RB(0xe8, 15),
+              RB(0xe8, 16), RB(0xe8, 17), RB(0x00, 0),
+              RB(0x15c, 5), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_25_PG7, "clk_25_pg7", CLKOUT_D40, RB(0xe8, 18),
+              RB(0xe8, 19), RB(0xe8, 20), RB(0x00, 0),
+              RB(0x15c, 6), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_25_PG8, "clk_25_pg8", CLKOUT_D40, RB(0xe8, 21),
+              RB(0xe8, 22), RB(0xe8, 23), RB(0x00, 0),
+              RB(0x15c, 7), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_ADC, "clk_adc", DIV_ADC, RB(0x3c, 10),
+              RB(0x3c, 11), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_ECAT100, "clk_ecat100", CLKOUT_D10, RB(0x80, 5),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_HSR100, "clk_hsr100", CLKOUT_D10, RB(0x90, 3),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_I2C0, "clk_i2c0", DIV_I2C, RB(0x3c, 6),
+              RB(0x3c, 7), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_I2C1, "clk_i2c1", DIV_I2C, RB(0x3c, 8),
+              RB(0x3c, 9), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_MII_REF, "clk_mii_ref", CLKOUT_D40, RB(0x68, 2),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_NAND, "clk_nand", DIV_NAND, RB(0x50, 4),
+              RB(0x50, 5), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_NOUSBP2_PG6, "clk_nousbp2_pg6", DIV_P2_PG, RB(0xec, 20),
+              RB(0xec, 21), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_P1_PG2, "clk_p1_pg2", DIV_P1_PG, RB(0x10c, 2),
+              RB(0x10c, 3), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_P1_PG3, "clk_p1_pg3", DIV_P1_PG, RB(0x10c, 4),
+              RB(0x10c, 5), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_P1_PG4, "clk_p1_pg4", DIV_P1_PG, RB(0x10c, 6),
+              RB(0x10c, 7), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_P4_PG3, "clk_p4_pg3", DIV_P4_PG, RB(0x104, 4),
+              RB(0x104, 5), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_P4_PG4, "clk_p4_pg4", DIV_P4_PG, RB(0x104, 6),
+              RB(0x104, 7), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_P6_PG1, "clk_p6_pg1", DIV_P6_PG, RB(0x114, 0),
+              RB(0x114, 1), RB(0x114, 2), RB(0x00, 0),
+              RB(0x16c, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_P6_PG2, "clk_p6_pg2", DIV_P6_PG, RB(0x114, 3),
+              RB(0x114, 4), RB(0x114, 5), RB(0x00, 0),
+              RB(0x16c, 1), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_P6_PG3, "clk_p6_pg3", DIV_P6_PG, RB(0x114, 6),
+              RB(0x114, 7), RB(0x114, 8), RB(0x00, 0),
+              RB(0x16c, 2), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_P6_PG4, "clk_p6_pg4", DIV_P6_PG, RB(0x114, 9),
+              RB(0x114, 10), RB(0x114, 11), RB(0x00, 0),
+              RB(0x16c, 3), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(CLK_PCI_USB, "clk_pci_usb", CLKOUT_D40, RB(0x1c, 6),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_QSPI0, "clk_qspi0", DIV_QSPI0, RB(0x54, 4),
+              RB(0x54, 5), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_QSPI1, "clk_qspi1", DIV_QSPI1, RB(0x90, 4),
+              RB(0x90, 5), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_RGMII_REF, "clk_rgmii_ref", CLKOUT_D8, RB(0x68, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_RMII_REF, "clk_rmii_ref", CLKOUT_D20, RB(0x68, 1),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SDIO0, "clk_sdio0", DIV_SDIO0, RB(0x0c, 4),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SDIO1, "clk_sdio1", DIV_SDIO1, RB(0xc8, 4),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SERCOS100, "clk_sercos100", CLKOUT_D10, RB(0x84, 5),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SLCD, "clk_slcd", DIV_P1_PG, RB(0x10c, 0),
+              RB(0x10c, 1), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SPI0, "clk_spi0", DIV_P3_PG, RB(0xfc, 0),
+              RB(0xfc, 1), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SPI1, "clk_spi1", DIV_P3_PG, RB(0xfc, 2),
+              RB(0xfc, 3), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SPI2, "clk_spi2", DIV_P3_PG, RB(0xfc, 4),
+              RB(0xfc, 5), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SPI3, "clk_spi3", DIV_P3_PG, RB(0xfc, 6),
+              RB(0xfc, 7), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SPI4, "clk_spi4", DIV_P4_PG, RB(0x104, 0),
+              RB(0x104, 1), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SPI5, "clk_spi5", DIV_P4_PG, RB(0x104, 2),
+              RB(0x104, 3), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SWITCH, "clk_switch", DIV_SWITCH, RB(0x130, 2),
+              RB(0x130, 3), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
        D_DIV(DIV_MOTOR, "div_motor", CLKOUT_D5, 84, 2, 8),
-       D_MODULE(HCLK_ECAT125, "hclk_ecat125", CLKOUT_D8, 0x400, 0x401, 0, 0x402, 0, 0x440, 0x441),
-       D_MODULE(HCLK_PINCONFIG, "hclk_pinconfig", CLKOUT_D40, 0x740, 0x741, 0x742, 0, 0xae0, 0, 0),
-       D_MODULE(HCLK_SERCOS, "hclk_sercos", CLKOUT_D10, 0x420, 0x422, 0, 0x421, 0, 0x460, 0x461),
-       D_MODULE(HCLK_SGPIO2, "hclk_sgpio2", DIV_P5_PG, 0x8c3, 0x8c4, 0x8c5, 0, 0xb41, 0, 0),
-       D_MODULE(HCLK_SGPIO3, "hclk_sgpio3", DIV_P5_PG, 0x8c6, 0x8c7, 0x8c8, 0, 0xb42, 0, 0),
-       D_MODULE(HCLK_SGPIO4, "hclk_sgpio4", DIV_P5_PG, 0x8c9, 0x8ca, 0x8cb, 0, 0xb43, 0, 0),
-       D_MODULE(HCLK_TIMER0, "hclk_timer0", CLKOUT_D40, 0x743, 0x744, 0x745, 0, 0xae1, 0, 0),
-       D_MODULE(HCLK_TIMER1, "hclk_timer1", CLKOUT_D40, 0x746, 0x747, 0x748, 0, 0xae2, 0, 0),
-       D_MODULE(HCLK_USBF, "hclk_usbf", CLKOUT_D8, 0xe3, 0, 0, 0xe4, 0, 0x102, 0x103),
-       D_MODULE(HCLK_USBH, "hclk_usbh", CLKOUT_D8, 0xe0, 0xe1, 0, 0xe2, 0, 0x100, 0x101),
-       D_MODULE(HCLK_USBPM, "hclk_usbpm", CLKOUT_D8, 0xe5, 0, 0, 0, 0, 0, 0),
-       D_GATE(CLK_48_PG_F, "clk_48_pg_f", CLK_48, 0x78c, 0x78d, 0, 0x78e, 0, 0xb04, 0xb05),
-       D_GATE(CLK_48_PG4, "clk_48_pg4", CLK_48, 0x789, 0x78a, 0x78b, 0, 0xb03, 0, 0),
+       D_MODULE(HCLK_ECAT125, "hclk_ecat125", CLKOUT_D8, RB(0x80, 0),
+                RB(0x80, 1), RB(0x00, 0), RB(0x80, 2),
+                RB(0x00, 0), RB(0x88, 0), RB(0x88, 1)),
+       D_MODULE(HCLK_PINCONFIG, "hclk_pinconfig", CLKOUT_D40, RB(0xe8, 0),
+                RB(0xe8, 1), RB(0xe8, 2), RB(0x00, 0),
+                RB(0x15c, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SERCOS, "hclk_sercos", CLKOUT_D10, RB(0x84, 0),
+                RB(0x84, 2), RB(0x00, 0), RB(0x84, 1),
+                RB(0x00, 0), RB(0x8c, 0), RB(0x8c, 1)),
+       D_MODULE(HCLK_SGPIO2, "hclk_sgpio2", DIV_P5_PG, RB(0x118, 3),
+                RB(0x118, 4), RB(0x118, 5), RB(0x00, 0),
+                RB(0x168, 1), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SGPIO3, "hclk_sgpio3", DIV_P5_PG, RB(0x118, 6),
+                RB(0x118, 7), RB(0x118, 8), RB(0x00, 0),
+                RB(0x168, 2), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SGPIO4, "hclk_sgpio4", DIV_P5_PG, RB(0x118, 9),
+                RB(0x118, 10), RB(0x118, 11), RB(0x00, 0),
+                RB(0x168, 3), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_TIMER0, "hclk_timer0", CLKOUT_D40, RB(0xe8, 3),
+                RB(0xe8, 4), RB(0xe8, 5), RB(0x00, 0),
+                RB(0x15c, 1), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_TIMER1, "hclk_timer1", CLKOUT_D40, RB(0xe8, 6),
+                RB(0xe8, 7), RB(0xe8, 8), RB(0x00, 0),
+                RB(0x15c, 2), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_USBF, "hclk_usbf", CLKOUT_D8, RB(0x1c, 3),
+                RB(0x00, 0), RB(0x00, 0), RB(0x1c, 4),
+                RB(0x00, 0), RB(0x20, 2), RB(0x20, 3)),
+       D_MODULE(HCLK_USBH, "hclk_usbh", CLKOUT_D8, RB(0x1c, 0),
+                RB(0x1c, 1), RB(0x00, 0), RB(0x1c, 2),
+                RB(0x00, 0), RB(0x20, 0), RB(0x20, 1)),
+       D_MODULE(HCLK_USBPM, "hclk_usbpm", CLKOUT_D8, RB(0x1c, 5),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_48_PG_F, "clk_48_pg_f", CLK_48, RB(0xf0, 12),
+              RB(0xf0, 13), RB(0x00, 0), RB(0xf0, 14),
+              RB(0x00, 0), RB(0x160, 4), RB(0x160, 5)),
+       D_GATE(CLK_48_PG4, "clk_48_pg4", CLK_48, RB(0xf0, 9),
+              RB(0xf0, 10), RB(0xf0, 11), RB(0x00, 0),
+              RB(0x160, 3), RB(0x00, 0), RB(0x00, 0)),
        D_FFC(CLK_DDRPHY_PLLCLK_D4, "clk_ddrphy_pllclk_d4", CLK_DDRPHY_PLLCLK, 4),
        D_FFC(CLK_ECAT100_D4, "clk_ecat100_d4", CLK_ECAT100, 4),
        D_FFC(CLK_HSR100_D2, "clk_hsr100_d2", CLK_HSR100, 2),
@@ -219,67 +441,187 @@ static const struct r9a06g032_clkdesc r9a06g032_clocks[] = {
        D_FFC(CLK_REF_SYNC_D8, "clk_ref_sync_d8", CLK_REF_SYNC, 8),
        D_FFC(CLK_SERCOS100_D2, "clk_sercos100_d2", CLK_SERCOS100, 2),
        D_DIV(DIV_CA7, "div_ca7", CLK_REF_SYNC, 57, 1, 4, 1, 2, 4),
-       D_MODULE(HCLK_CAN0, "hclk_can0", CLK_48, 0x783, 0x784, 0x785, 0, 0xb01, 0, 0),
-       D_MODULE(HCLK_CAN1, "hclk_can1", CLK_48, 0x786, 0x787, 0x788, 0, 0xb02, 0, 0),
-       D_MODULE(HCLK_DELTASIGMA, "hclk_deltasigma", DIV_MOTOR, 0x1ef, 0x1f0, 0x1f1, 0, 0, 0, 0),
-       D_MODULE(HCLK_PWMPTO, "hclk_pwmpto", DIV_MOTOR, 0x1ec, 0x1ed, 0x1ee, 0, 0, 0, 0),
-       D_MODULE(HCLK_RSV, "hclk_rsv", CLK_48, 0x780, 0x781, 0x782, 0, 0xb00, 0, 0),
-       D_MODULE(HCLK_SGPIO0, "hclk_sgpio0", DIV_MOTOR, 0x1e0, 0x1e1, 0x1e2, 0, 0, 0, 0),
-       D_MODULE(HCLK_SGPIO1, "hclk_sgpio1", DIV_MOTOR, 0x1e3, 0x1e4, 0x1e5, 0, 0, 0, 0),
+       D_MODULE(HCLK_CAN0, "hclk_can0", CLK_48, RB(0xf0, 3),
+                RB(0xf0, 4), RB(0xf0, 5), RB(0x00, 0),
+                RB(0x160, 1), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_CAN1, "hclk_can1", CLK_48, RB(0xf0, 6),
+                RB(0xf0, 7), RB(0xf0, 8), RB(0x00, 0),
+                RB(0x160, 2), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_DELTASIGMA, "hclk_deltasigma", DIV_MOTOR, RB(0x3c, 15),
+                RB(0x3c, 16), RB(0x3c, 17), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_PWMPTO, "hclk_pwmpto", DIV_MOTOR, RB(0x3c, 12),
+                RB(0x3c, 13), RB(0x3c, 14), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_RSV, "hclk_rsv", CLK_48, RB(0xf0, 0),
+                RB(0xf0, 1), RB(0xf0, 2), RB(0x00, 0),
+                RB(0x160, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SGPIO0, "hclk_sgpio0", DIV_MOTOR, RB(0x3c, 0),
+                RB(0x3c, 1), RB(0x3c, 2), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SGPIO1, "hclk_sgpio1", DIV_MOTOR, RB(0x3c, 3),
+                RB(0x3c, 4), RB(0x3c, 5), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
        D_DIV(RTOS_MDC, "rtos_mdc", CLK_REF_SYNC, 100, 80, 640, 80, 160, 320, 640),
-       D_GATE(CLK_CM3, "clk_cm3", CLK_REF_SYNC_D4, 0xba0, 0xba1, 0, 0xba2, 0, 0xbc0, 0xbc1),
-       D_GATE(CLK_DDRC, "clk_ddrc", CLK_DDRPHY_PLLCLK_D4, 0x323, 0x324, 0, 0, 0, 0, 0),
-       D_GATE(CLK_ECAT25, "clk_ecat25", CLK_ECAT100_D4, 0x403, 0x404, 0, 0, 0, 0, 0),
-       D_GATE(CLK_HSR50, "clk_hsr50", CLK_HSR100_D2, 0x484, 0x485, 0, 0, 0, 0, 0),
-       D_GATE(CLK_HW_RTOS, "clk_hw_rtos", CLK_REF_SYNC_D4, 0xc60, 0xc61, 0, 0, 0, 0, 0),
-       D_GATE(CLK_SERCOS50, "clk_sercos50", CLK_SERCOS100_D2, 0x424, 0x423, 0, 0, 0, 0, 0),
-       D_MODULE(HCLK_ADC, "hclk_adc", CLK_REF_SYNC_D8, 0x1af, 0x1b0, 0x1b1, 0, 0, 0, 0),
-       D_MODULE(HCLK_CM3, "hclk_cm3", CLK_REF_SYNC_D4, 0xc20, 0xc21, 0xc22, 0, 0, 0, 0),
-       D_MODULE(HCLK_CRYPTO_EIP150, "hclk_crypto_eip150", CLK_REF_SYNC_D4, 0x123, 0x124, 0x125, 0, 0x142, 0, 0),
-       D_MODULE(HCLK_CRYPTO_EIP93, "hclk_crypto_eip93", CLK_REF_SYNC_D4, 0x120, 0x121, 0, 0x122, 0, 0x140, 0x141),
-       D_MODULE(HCLK_DDRC, "hclk_ddrc", CLK_REF_SYNC_D4, 0x320, 0x322, 0, 0x321, 0, 0x3a0, 0x3a1),
-       D_MODULE(HCLK_DMA0, "hclk_dma0", CLK_REF_SYNC_D4, 0x260, 0x261, 0x262, 0x263, 0x2c0, 0x2c1, 0x2c2),
-       D_MODULE(HCLK_DMA1, "hclk_dma1", CLK_REF_SYNC_D4, 0x264, 0x265, 0x266, 0x267, 0x2c3, 0x2c4, 0x2c5),
-       D_MODULE(HCLK_GMAC0, "hclk_gmac0", CLK_REF_SYNC_D4, 0x360, 0x361, 0x362, 0x363, 0x3c0, 0x3c1, 0x3c2),
-       D_MODULE(HCLK_GMAC1, "hclk_gmac1", CLK_REF_SYNC_D4, 0x380, 0x381, 0x382, 0x383, 0x3e0, 0x3e1, 0x3e2),
-       D_MODULE(HCLK_GPIO0, "hclk_gpio0", CLK_REF_SYNC_D4, 0x212, 0x213, 0x214, 0, 0, 0, 0),
-       D_MODULE(HCLK_GPIO1, "hclk_gpio1", CLK_REF_SYNC_D4, 0x215, 0x216, 0x217, 0, 0, 0, 0),
-       D_MODULE(HCLK_GPIO2, "hclk_gpio2", CLK_REF_SYNC_D4, 0x229, 0x22a, 0x22b, 0, 0, 0, 0),
-       D_MODULE(HCLK_HSR, "hclk_hsr", CLK_HSR100_D2, 0x480, 0x482, 0, 0x481, 0, 0x4c0, 0x4c1),
-       D_MODULE(HCLK_I2C0, "hclk_i2c0", CLK_REF_SYNC_D8, 0x1a9, 0x1aa, 0x1ab, 0, 0, 0, 0),
-       D_MODULE(HCLK_I2C1, "hclk_i2c1", CLK_REF_SYNC_D8, 0x1ac, 0x1ad, 0x1ae, 0, 0, 0, 0),
-       D_MODULE(HCLK_LCD, "hclk_lcd", CLK_REF_SYNC_D4, 0x7a0, 0x7a1, 0x7a2, 0, 0xb20, 0, 0),
-       D_MODULE(HCLK_MSEBI_M, "hclk_msebi_m", CLK_REF_SYNC_D4, 0x164, 0x165, 0x166, 0, 0x183, 0, 0),
-       D_MODULE(HCLK_MSEBI_S, "hclk_msebi_s", CLK_REF_SYNC_D4, 0x160, 0x161, 0x162, 0x163, 0x180, 0x181, 0x182),
-       D_MODULE(HCLK_NAND, "hclk_nand", CLK_REF_SYNC_D4, 0x280, 0x281, 0x282, 0x283, 0x2e0, 0x2e1, 0x2e2),
-       D_MODULE(HCLK_PG_I, "hclk_pg_i", CLK_REF_SYNC_D4, 0x7ac, 0x7ad, 0, 0x7ae, 0, 0xb24, 0xb25),
-       D_MODULE(HCLK_PG19, "hclk_pg19", CLK_REF_SYNC_D4, 0x22c, 0x22d, 0x22e, 0, 0, 0, 0),
-       D_MODULE(HCLK_PG20, "hclk_pg20", CLK_REF_SYNC_D4, 0x22f, 0x230, 0x231, 0, 0, 0, 0),
-       D_MODULE(HCLK_PG3, "hclk_pg3", CLK_REF_SYNC_D4, 0x7a6, 0x7a7, 0x7a8, 0, 0xb22, 0, 0),
-       D_MODULE(HCLK_PG4, "hclk_pg4", CLK_REF_SYNC_D4, 0x7a9, 0x7aa, 0x7ab, 0, 0xb23, 0, 0),
-       D_MODULE(HCLK_QSPI0, "hclk_qspi0", CLK_REF_SYNC_D4, 0x2a0, 0x2a1, 0x2a2, 0x2a3, 0x300, 0x301, 0x302),
-       D_MODULE(HCLK_QSPI1, "hclk_qspi1", CLK_REF_SYNC_D4, 0x480, 0x481, 0x482, 0x483, 0x4c0, 0x4c1, 0x4c2),
-       D_MODULE(HCLK_ROM, "hclk_rom", CLK_REF_SYNC_D4, 0xaa0, 0xaa1, 0xaa2, 0, 0xb80, 0, 0),
-       D_MODULE(HCLK_RTC, "hclk_rtc", CLK_REF_SYNC_D8, 0xa00, 0xa03, 0, 0xa02, 0, 0, 0),
-       D_MODULE(HCLK_SDIO0, "hclk_sdio0", CLK_REF_SYNC_D4, 0x60, 0x61, 0x62, 0x63, 0x80, 0x81, 0x82),
-       D_MODULE(HCLK_SDIO1, "hclk_sdio1", CLK_REF_SYNC_D4, 0x640, 0x641, 0x642, 0x643, 0x660, 0x661, 0x662),
-       D_MODULE(HCLK_SEMAP, "hclk_semap", CLK_REF_SYNC_D4, 0x7a3, 0x7a4, 0x7a5, 0, 0xb21, 0, 0),
-       D_MODULE(HCLK_SPI0, "hclk_spi0", CLK_REF_SYNC_D4, 0x200, 0x201, 0x202, 0, 0, 0, 0),
-       D_MODULE(HCLK_SPI1, "hclk_spi1", CLK_REF_SYNC_D4, 0x203, 0x204, 0x205, 0, 0, 0, 0),
-       D_MODULE(HCLK_SPI2, "hclk_spi2", CLK_REF_SYNC_D4, 0x206, 0x207, 0x208, 0, 0, 0, 0),
-       D_MODULE(HCLK_SPI3, "hclk_spi3", CLK_REF_SYNC_D4, 0x209, 0x20a, 0x20b, 0, 0, 0, 0),
-       D_MODULE(HCLK_SPI4, "hclk_spi4", CLK_REF_SYNC_D4, 0x20c, 0x20d, 0x20e, 0, 0, 0, 0),
-       D_MODULE(HCLK_SPI5, "hclk_spi5", CLK_REF_SYNC_D4, 0x20f, 0x210, 0x211, 0, 0, 0, 0),
-       D_MODULE(HCLK_SWITCH, "hclk_switch", CLK_REF_SYNC_D4, 0x980, 0, 0x981, 0, 0, 0, 0),
-       D_MODULE(HCLK_SWITCH_RG, "hclk_switch_rg", CLK_REF_SYNC_D4, 0xc40, 0xc41, 0xc42, 0, 0, 0, 0),
-       D_MODULE(HCLK_UART0, "hclk_uart0", CLK_REF_SYNC_D8, 0x1a0, 0x1a1, 0x1a2, 0, 0, 0, 0),
-       D_MODULE(HCLK_UART1, "hclk_uart1", CLK_REF_SYNC_D8, 0x1a3, 0x1a4, 0x1a5, 0, 0, 0, 0),
-       D_MODULE(HCLK_UART2, "hclk_uart2", CLK_REF_SYNC_D8, 0x1a6, 0x1a7, 0x1a8, 0, 0, 0, 0),
-       D_MODULE(HCLK_UART3, "hclk_uart3", CLK_REF_SYNC_D4, 0x218, 0x219, 0x21a, 0, 0, 0, 0),
-       D_MODULE(HCLK_UART4, "hclk_uart4", CLK_REF_SYNC_D4, 0x21b, 0x21c, 0x21d, 0, 0, 0, 0),
-       D_MODULE(HCLK_UART5, "hclk_uart5", CLK_REF_SYNC_D4, 0x220, 0x221, 0x222, 0, 0, 0, 0),
-       D_MODULE(HCLK_UART6, "hclk_uart6", CLK_REF_SYNC_D4, 0x223, 0x224, 0x225, 0, 0, 0, 0),
-       D_MODULE(HCLK_UART7, "hclk_uart7", CLK_REF_SYNC_D4, 0x226, 0x227, 0x228, 0, 0, 0, 0),
+       D_GATE(CLK_CM3, "clk_cm3", CLK_REF_SYNC_D4, RB(0x174, 0),
+              RB(0x174, 1), RB(0x00, 0), RB(0x174, 2),
+              RB(0x00, 0), RB(0x178, 0), RB(0x178, 1)),
+       D_GATE(CLK_DDRC, "clk_ddrc", CLK_DDRPHY_PLLCLK_D4, RB(0x64, 3),
+              RB(0x64, 4), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_ECAT25, "clk_ecat25", CLK_ECAT100_D4, RB(0x80, 3),
+              RB(0x80, 4), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_HSR50, "clk_hsr50", CLK_HSR100_D2, RB(0x90, 4),
+              RB(0x90, 5), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_HW_RTOS, "clk_hw_rtos", CLK_REF_SYNC_D4, RB(0x18c, 0),
+              RB(0x18c, 1), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_GATE(CLK_SERCOS50, "clk_sercos50", CLK_SERCOS100_D2, RB(0x84, 4),
+              RB(0x84, 3), RB(0x00, 0), RB(0x00, 0),
+              RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_ADC, "hclk_adc", CLK_REF_SYNC_D8, RB(0x34, 15),
+                RB(0x34, 16), RB(0x34, 17), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_CM3, "hclk_cm3", CLK_REF_SYNC_D4, RB(0x184, 0),
+                RB(0x184, 1), RB(0x184, 2), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_CRYPTO_EIP150, "hclk_crypto_eip150", CLK_REF_SYNC_D4, RB(0x24, 3),
+                RB(0x24, 4), RB(0x24, 5), RB(0x00, 0),
+                RB(0x28, 2), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_CRYPTO_EIP93, "hclk_crypto_eip93", CLK_REF_SYNC_D4, RB(0x24, 0),
+                RB(0x24, 1), RB(0x00, 0), RB(0x24, 2),
+                RB(0x00, 0), RB(0x28, 0), RB(0x28, 1)),
+       D_MODULE(HCLK_DDRC, "hclk_ddrc", CLK_REF_SYNC_D4, RB(0x64, 0),
+                RB(0x64, 2), RB(0x00, 0), RB(0x64, 1),
+                RB(0x00, 0), RB(0x74, 0), RB(0x74, 1)),
+       D_MODULE(HCLK_DMA0, "hclk_dma0", CLK_REF_SYNC_D4, RB(0x4c, 0),
+                RB(0x4c, 1), RB(0x4c, 2), RB(0x4c, 3),
+                RB(0x58, 0), RB(0x58, 1), RB(0x58, 2)),
+       D_MODULE(HCLK_DMA1, "hclk_dma1", CLK_REF_SYNC_D4, RB(0x4c, 4),
+                RB(0x4c, 5), RB(0x4c, 6), RB(0x4c, 7),
+                RB(0x58, 3), RB(0x58, 4), RB(0x58, 5)),
+       D_MODULE(HCLK_GMAC0, "hclk_gmac0", CLK_REF_SYNC_D4, RB(0x6c, 0),
+                RB(0x6c, 1), RB(0x6c, 2), RB(0x6c, 3),
+                RB(0x78, 0), RB(0x78, 1), RB(0x78, 2)),
+       D_MODULE(HCLK_GMAC1, "hclk_gmac1", CLK_REF_SYNC_D4, RB(0x70, 0),
+                RB(0x70, 1), RB(0x70, 2), RB(0x70, 3),
+                RB(0x7c, 0), RB(0x7c, 1), RB(0x7c, 2)),
+       D_MODULE(HCLK_GPIO0, "hclk_gpio0", CLK_REF_SYNC_D4, RB(0x40, 18),
+                RB(0x40, 19), RB(0x40, 20), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_GPIO1, "hclk_gpio1", CLK_REF_SYNC_D4, RB(0x40, 21),
+                RB(0x40, 22), RB(0x40, 23), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_GPIO2, "hclk_gpio2", CLK_REF_SYNC_D4, RB(0x44, 9),
+                RB(0x44, 10), RB(0x44, 11), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_HSR, "hclk_hsr", CLK_HSR100_D2, RB(0x90, 0),
+                RB(0x90, 2), RB(0x00, 0), RB(0x90, 1),
+                RB(0x00, 0), RB(0x98, 0), RB(0x98, 1)),
+       D_MODULE(HCLK_I2C0, "hclk_i2c0", CLK_REF_SYNC_D8, RB(0x34, 9),
+                RB(0x34, 10), RB(0x34, 11), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_I2C1, "hclk_i2c1", CLK_REF_SYNC_D8, RB(0x34, 12),
+                RB(0x34, 13), RB(0x34, 14), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_LCD, "hclk_lcd", CLK_REF_SYNC_D4, RB(0xf4, 0),
+                RB(0xf4, 1), RB(0xf4, 2), RB(0x00, 0),
+                RB(0x164, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_MSEBI_M, "hclk_msebi_m", CLK_REF_SYNC_D4, RB(0x2c, 4),
+                RB(0x2c, 5), RB(0x2c, 6), RB(0x00, 0),
+                RB(0x30, 3), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_MSEBI_S, "hclk_msebi_s", CLK_REF_SYNC_D4, RB(0x2c, 0),
+                RB(0x2c, 1), RB(0x2c, 2), RB(0x2c, 3),
+                RB(0x30, 0), RB(0x30, 1), RB(0x30, 2)),
+       D_MODULE(HCLK_NAND, "hclk_nand", CLK_REF_SYNC_D4, RB(0x50, 0),
+                RB(0x50, 1), RB(0x50, 2), RB(0x50, 3),
+                RB(0x5c, 0), RB(0x5c, 1), RB(0x5c, 2)),
+       D_MODULE(HCLK_PG_I, "hclk_pg_i", CLK_REF_SYNC_D4, RB(0xf4, 12),
+                RB(0xf4, 13), RB(0x00, 0), RB(0xf4, 14),
+                RB(0x00, 0), RB(0x164, 4), RB(0x164, 5)),
+       D_MODULE(HCLK_PG19, "hclk_pg19", CLK_REF_SYNC_D4, RB(0x44, 12),
+                RB(0x44, 13), RB(0x44, 14), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_PG20, "hclk_pg20", CLK_REF_SYNC_D4, RB(0x44, 15),
+                RB(0x44, 16), RB(0x44, 17), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_PG3, "hclk_pg3", CLK_REF_SYNC_D4, RB(0xf4, 6),
+                RB(0xf4, 7), RB(0xf4, 8), RB(0x00, 0),
+                RB(0x164, 2), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_PG4, "hclk_pg4", CLK_REF_SYNC_D4, RB(0xf4, 9),
+                RB(0xf4, 10), RB(0xf4, 11), RB(0x00, 0),
+                RB(0x164, 3), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_QSPI0, "hclk_qspi0", CLK_REF_SYNC_D4, RB(0x54, 0),
+                RB(0x54, 1), RB(0x54, 2), RB(0x54, 3),
+                RB(0x60, 0), RB(0x60, 1), RB(0x60, 2)),
+       D_MODULE(HCLK_QSPI1, "hclk_qspi1", CLK_REF_SYNC_D4, RB(0x90, 0),
+                RB(0x90, 1), RB(0x90, 2), RB(0x90, 3),
+                RB(0x98, 0), RB(0x98, 1), RB(0x98, 2)),
+       D_MODULE(HCLK_ROM, "hclk_rom", CLK_REF_SYNC_D4, RB(0x154, 0),
+                RB(0x154, 1), RB(0x154, 2), RB(0x00, 0),
+                RB(0x170, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_RTC, "hclk_rtc", CLK_REF_SYNC_D8, RB(0x140, 0),
+                RB(0x140, 3), RB(0x00, 0), RB(0x140, 2),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SDIO0, "hclk_sdio0", CLK_REF_SYNC_D4, RB(0x0c, 0),
+                RB(0x0c, 1), RB(0x0c, 2), RB(0x0c, 3),
+                RB(0x10, 0), RB(0x10, 1), RB(0x10, 2)),
+       D_MODULE(HCLK_SDIO1, "hclk_sdio1", CLK_REF_SYNC_D4, RB(0xc8, 0),
+                RB(0xc8, 1), RB(0xc8, 2), RB(0xc8, 3),
+                RB(0xcc, 0), RB(0xcc, 1), RB(0xcc, 2)),
+       D_MODULE(HCLK_SEMAP, "hclk_semap", CLK_REF_SYNC_D4, RB(0xf4, 3),
+                RB(0xf4, 4), RB(0xf4, 5), RB(0x00, 0),
+                RB(0x164, 1), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SPI0, "hclk_spi0", CLK_REF_SYNC_D4, RB(0x40, 0),
+                RB(0x40, 1), RB(0x40, 2), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SPI1, "hclk_spi1", CLK_REF_SYNC_D4, RB(0x40, 3),
+                RB(0x40, 4), RB(0x40, 5), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SPI2, "hclk_spi2", CLK_REF_SYNC_D4, RB(0x40, 6),
+                RB(0x40, 7), RB(0x40, 8), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SPI3, "hclk_spi3", CLK_REF_SYNC_D4, RB(0x40, 9),
+                RB(0x40, 10), RB(0x40, 11), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SPI4, "hclk_spi4", CLK_REF_SYNC_D4, RB(0x40, 12),
+                RB(0x40, 13), RB(0x40, 14), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SPI5, "hclk_spi5", CLK_REF_SYNC_D4, RB(0x40, 15),
+                RB(0x40, 16), RB(0x40, 17), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SWITCH, "hclk_switch", CLK_REF_SYNC_D4, RB(0x130, 0),
+                RB(0x00, 0), RB(0x130, 1), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_SWITCH_RG, "hclk_switch_rg", CLK_REF_SYNC_D4, RB(0x188, 0),
+                RB(0x188, 1), RB(0x188, 2), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_UART0, "hclk_uart0", CLK_REF_SYNC_D8, RB(0x34, 0),
+                RB(0x34, 1), RB(0x34, 2), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_UART1, "hclk_uart1", CLK_REF_SYNC_D8, RB(0x34, 3),
+                RB(0x34, 4), RB(0x34, 5), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_UART2, "hclk_uart2", CLK_REF_SYNC_D8, RB(0x34, 6),
+                RB(0x34, 7), RB(0x34, 8), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_UART3, "hclk_uart3", CLK_REF_SYNC_D4, RB(0x40, 24),
+                RB(0x40, 25), RB(0x40, 26), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_UART4, "hclk_uart4", CLK_REF_SYNC_D4, RB(0x40, 27),
+                RB(0x40, 28), RB(0x40, 29), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_UART5, "hclk_uart5", CLK_REF_SYNC_D4, RB(0x44, 0),
+                RB(0x44, 1), RB(0x44, 2), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_UART6, "hclk_uart6", CLK_REF_SYNC_D4, RB(0x44, 3),
+                RB(0x44, 4), RB(0x44, 5), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
+       D_MODULE(HCLK_UART7, "hclk_uart7", CLK_REF_SYNC_D4, RB(0x44, 6),
+                RB(0x44, 7), RB(0x44, 8), RB(0x00, 0),
+                RB(0x00, 0), RB(0x00, 0), RB(0x00, 0)),
        /*
         * These are not hardware clocks, but are needed to handle the special
         * case where we have a 'selector bit' that doesn't just change the
@@ -291,7 +633,7 @@ static const struct r9a06g032_clkdesc r9a06g032_clocks[] = {
                .type = K_BITSEL,
                .source = 1 + R9A06G032_DIV_UART,
                /* R9A06G032_SYSCTRL_REG_PWRCTRL_PG0_0 */
-               .dual.sel = ((0x34 / 4) << 5) | 30,
+               .dual.sel = RB(0x34, 30),
                .dual.group = 0,
        },
        {
@@ -300,17 +642,25 @@ static const struct r9a06g032_clkdesc r9a06g032_clocks[] = {
                .type = K_BITSEL,
                .source = 1 + R9A06G032_DIV_P2_PG,
                /* R9A06G032_SYSCTRL_REG_PWRCTRL_PG1_PR2 */
-               .dual.sel = ((0xec / 4) << 5) | 24,
+               .dual.sel = RB(0xec, 24),
                .dual.group = 1,
        },
-       D_UGATE(CLK_UART0, "clk_uart0", UART_GROUP_012, 0, 0x1b2, 0x1b3, 0x1b4, 0x1b5),
-       D_UGATE(CLK_UART1, "clk_uart1", UART_GROUP_012, 0, 0x1b6, 0x1b7, 0x1b8, 0x1b9),
-       D_UGATE(CLK_UART2, "clk_uart2", UART_GROUP_012, 0, 0x1ba, 0x1bb, 0x1bc, 0x1bd),
-       D_UGATE(CLK_UART3, "clk_uart3", UART_GROUP_34567, 1, 0x760, 0x761, 0x762, 0x763),
-       D_UGATE(CLK_UART4, "clk_uart4", UART_GROUP_34567, 1, 0x764, 0x765, 0x766, 0x767),
-       D_UGATE(CLK_UART5, "clk_uart5", UART_GROUP_34567, 1, 0x768, 0x769, 0x76a, 0x76b),
-       D_UGATE(CLK_UART6, "clk_uart6", UART_GROUP_34567, 1, 0x76c, 0x76d, 0x76e, 0x76f),
-       D_UGATE(CLK_UART7, "clk_uart7", UART_GROUP_34567, 1, 0x770, 0x771, 0x772, 0x773),
+       D_UGATE(CLK_UART0, "clk_uart0", UART_GROUP_012, 0,
+               RB(0x34, 18), RB(0x34, 19), RB(0x34, 20), RB(0x34, 21)),
+       D_UGATE(CLK_UART1, "clk_uart1", UART_GROUP_012, 0,
+               RB(0x34, 22), RB(0x34, 23), RB(0x34, 24), RB(0x34, 25)),
+       D_UGATE(CLK_UART2, "clk_uart2", UART_GROUP_012, 0,
+               RB(0x34, 26), RB(0x34, 27), RB(0x34, 28), RB(0x34, 29)),
+       D_UGATE(CLK_UART3, "clk_uart3", UART_GROUP_34567, 1,
+               RB(0xec, 0), RB(0xec, 1), RB(0xec, 2), RB(0xec, 3)),
+       D_UGATE(CLK_UART4, "clk_uart4", UART_GROUP_34567, 1,
+               RB(0xec, 4), RB(0xec, 5), RB(0xec, 6), RB(0xec, 7)),
+       D_UGATE(CLK_UART5, "clk_uart5", UART_GROUP_34567, 1,
+               RB(0xec, 8), RB(0xec, 9), RB(0xec, 10), RB(0xec, 11)),
+       D_UGATE(CLK_UART6, "clk_uart6", UART_GROUP_34567, 1,
+               RB(0xec, 12), RB(0xec, 13), RB(0xec, 14), RB(0xec, 15)),
+       D_UGATE(CLK_UART7, "clk_uart7", UART_GROUP_34567, 1,
+               RB(0xec, 16), RB(0xec, 17), RB(0xec, 18), RB(0xec, 19)),
 };
 
 struct r9a06g032_priv {
@@ -343,26 +693,26 @@ int r9a06g032_sysctrl_set_dmamux(u32 mask, u32 val)
 }
 EXPORT_SYMBOL_GPL(r9a06g032_sysctrl_set_dmamux);
 
-/* register/bit pairs are encoded as an uint16_t */
-static void
-clk_rdesc_set(struct r9a06g032_priv *clocks,
-             u16 one, unsigned int on)
+static void clk_rdesc_set(struct r9a06g032_priv *clocks,
+                         struct regbit rb, unsigned int on)
 {
-       u32 __iomem *reg = clocks->reg + (4 * (one >> 5));
-       u32 val = readl(reg);
+       u32 __iomem *reg = clocks->reg + (rb.reg * 4);
+       u32 val;
 
-       val = (val & ~(1U << (one & 0x1f))) | ((!!on) << (one & 0x1f));
+       if (!rb.reg && !rb.bit)
+               return;
+
+       val = readl(reg);
+       val = (val & ~BIT(rb.bit)) | ((!!on) << rb.bit);
        writel(val, reg);
 }
 
-static int
-clk_rdesc_get(struct r9a06g032_priv *clocks,
-             uint16_t one)
+static int clk_rdesc_get(struct r9a06g032_priv *clocks, struct regbit rb)
 {
-       u32 __iomem *reg = clocks->reg + (4 * (one >> 5));
+       u32 __iomem *reg = clocks->reg + (rb.reg * 4);
        u32 val = readl(reg);
 
-       return !!(val & (1U << (one & 0x1f)));
+       return !!(val & BIT(rb.bit));
 }
 
 /*
@@ -464,13 +814,12 @@ r9a06g032_clk_gate_set(struct r9a06g032_priv *clocks,
 {
        unsigned long flags;
 
-       WARN_ON(!g->gate);
+       WARN_ON(!g->gate.reg && !g->gate.bit);
 
        spin_lock_irqsave(&clocks->lock, flags);
        clk_rdesc_set(clocks, g->gate, on);
        /* De-assert reset */
-       if (g->reset)
-               clk_rdesc_set(clocks, g->reset, 1);
+       clk_rdesc_set(clocks, g->reset, 1);
        spin_unlock_irqrestore(&clocks->lock, flags);
 
        /* Hardware manual recommends 5us delay after enabling clock & reset */
@@ -480,15 +829,12 @@ r9a06g032_clk_gate_set(struct r9a06g032_priv *clocks,
         * associated SLVRDY bit in the System Controller that needs to be set
         * so that the FlexWAY bus fabric passes on the read/write requests.
         */
-       if (g->ready || g->midle) {
-               spin_lock_irqsave(&clocks->lock, flags);
-               if (g->ready)
-                       clk_rdesc_set(clocks, g->ready, on);
-               /* Clear 'Master Idle Request' bit */
-               if (g->midle)
-                       clk_rdesc_set(clocks, g->midle, !on);
-               spin_unlock_irqrestore(&clocks->lock, flags);
-       }
+       spin_lock_irqsave(&clocks->lock, flags);
+       clk_rdesc_set(clocks, g->ready, on);
+       /* Clear 'Master Idle Request' bit */
+       clk_rdesc_set(clocks, g->midle, !on);
+       spin_unlock_irqrestore(&clocks->lock, flags);
+
        /* Note: We don't wait for FlexWAY Socket Connection signal */
 }
 
@@ -512,7 +858,7 @@ static int r9a06g032_clk_gate_is_enabled(struct clk_hw *hw)
        struct r9a06g032_clk_gate *g = to_r9a06g032_gate(hw);
 
        /* if clock is in reset, the gate might be on, and still not 'be' on */
-       if (g->gate.reset && !clk_rdesc_get(g->clocks, g->gate.reset))
+       if (g->gate.reset.reg && !clk_rdesc_get(g->clocks, g->gate.reset))
                return 0;
 
        return clk_rdesc_get(g->clocks, g->gate.gate);
@@ -751,7 +1097,7 @@ struct r9a06g032_clk_bitsel {
        struct clk_hw   hw;
        struct r9a06g032_priv *clocks;
        u16 index;
-       u16 selector;           /* selector register + bit */
+       struct regbit selector;         /* selector register + bit */
 };
 
 #define to_clk_bitselect(_hw) \
@@ -820,7 +1166,7 @@ struct r9a06g032_clk_dualgate {
        struct clk_hw   hw;
        struct r9a06g032_priv *clocks;
        u16 index;
-       u16 selector;           /* selector register + bit */
+       struct regbit selector;         /* selector register + bit */
        struct r9a06g032_gate gate[2];
 };
 
@@ -873,7 +1219,7 @@ static struct clk *
 r9a06g032_register_dualgate(struct r9a06g032_priv *clocks,
                            const char *parent_name,
                            const struct r9a06g032_clkdesc *desc,
-                           uint16_t sel)
+                           struct regbit sel)
 {
        struct r9a06g032_clk_dualgate *g;
        struct clk *clk;
@@ -951,7 +1297,7 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
        struct clk **clks;
        struct clk *mclk;
        unsigned int i;
-       u16 uart_group_sel[2];
+       struct regbit uart_group_sel[2];
        int error;
 
        clocks = devm_kzalloc(dev, sizeof(*clocks), GFP_KERNEL);
index 684d8937965e066abc512739182616ed9324f008..17c110978e33abc5b20c6c3d841c1b529b63541b 100644 (file)
@@ -125,15 +125,13 @@ static int rcar_usb2_clock_sel_resume(struct device *dev)
        return 0;
 }
 
-static int rcar_usb2_clock_sel_remove(struct platform_device *pdev)
+static void rcar_usb2_clock_sel_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
 
        of_clk_del_provider(dev->of_node);
        pm_runtime_put(dev);
        pm_runtime_disable(dev);
-
-       return 0;
 }
 
 static int rcar_usb2_clock_sel_probe(struct platform_device *pdev)
@@ -215,7 +213,7 @@ static struct platform_driver rcar_usb2_clock_sel_driver = {
                .pm     = &rcar_usb2_clock_sel_pm_ops,
        },
        .probe          = rcar_usb2_clock_sel_probe,
-       .remove         = rcar_usb2_clock_sel_remove,
+       .remove_new     = rcar_usb2_clock_sel_remove,
 };
 builtin_platform_driver(rcar_usb2_clock_sel_driver);
 
index b9f210437ddf30ff7411eb5456357f4a4333a993..9927bc0dde9762a32ff81d8d8aba0278499c3198 100644 (file)
@@ -61,7 +61,7 @@ static const u16 mstpsr_for_gen4[] = {
        0x2E00, 0x2E04, 0x2E08, 0x2E0C, 0x2E10, 0x2E14, 0x2E18, 0x2E1C,
        0x2E20, 0x2E24, 0x2E28, 0x2E2C, 0x2E30, 0x2E34, 0x2E38, 0x2E3C,
        0x2E40, 0x2E44, 0x2E48, 0x2E4C, 0x2E50, 0x2E54, 0x2E58, 0x2E5C,
-       0x2E60, 0x2E64, 0x2E68, 0x2E6C,
+       0x2E60, 0x2E64, 0x2E68, 0x2E6C, 0x2E70, 0x2E74,
 };
 
 /*
@@ -77,7 +77,7 @@ static const u16 mstpcr_for_gen4[] = {
        0x2D00, 0x2D04, 0x2D08, 0x2D0C, 0x2D10, 0x2D14, 0x2D18, 0x2D1C,
        0x2D20, 0x2D24, 0x2D28, 0x2D2C, 0x2D30, 0x2D34, 0x2D38, 0x2D3C,
        0x2D40, 0x2D44, 0x2D48, 0x2D4C, 0x2D50, 0x2D54, 0x2D58, 0x2D5C,
-       0x2D60, 0x2D64, 0x2D68, 0x2D6C,
+       0x2D60, 0x2D64, 0x2D68, 0x2D6C, 0x2D70, 0x2D74,
 };
 
 /*
@@ -103,7 +103,7 @@ static const u16 srcr_for_gen4[] = {
        0x2C00, 0x2C04, 0x2C08, 0x2C0C, 0x2C10, 0x2C14, 0x2C18, 0x2C1C,
        0x2C20, 0x2C24, 0x2C28, 0x2C2C, 0x2C30, 0x2C34, 0x2C38, 0x2C3C,
        0x2C40, 0x2C44, 0x2C48, 0x2C4C, 0x2C50, 0x2C54, 0x2C58, 0x2C5C,
-       0x2C60, 0x2C64, 0x2C68, 0x2C6C,
+       0x2C60, 0x2C64, 0x2C68, 0x2C6C, 0x2C70, 0x2C74,
 };
 
 /*
@@ -119,7 +119,7 @@ static const u16 srstclr_for_gen4[] = {
        0x2C80, 0x2C84, 0x2C88, 0x2C8C, 0x2C90, 0x2C94, 0x2C98, 0x2C9C,
        0x2CA0, 0x2CA4, 0x2CA8, 0x2CAC, 0x2CB0, 0x2CB4, 0x2CB8, 0x2CBC,
        0x2CC0, 0x2CC4, 0x2CC8, 0x2CCC, 0x2CD0, 0x2CD4, 0x2CD8, 0x2CDC,
-       0x2CE0, 0x2CE4, 0x2CE8, 0x2CEC,
+       0x2CE0, 0x2CE4, 0x2CE8, 0x2CEC, 0x2CF0, 0x2CF4,
 };
 
 /**
index 306910a3a0d38451d3bcf9b54063236ec11e1dba..9ebd6c451b3dbf81698627a12310e64cfb6cc445 100644 (file)
@@ -1263,7 +1263,7 @@ static struct rockchip_clk_branch rk3399_clk_branches[] __initdata = {
                        RK3399_CLKSEL_CON(56), 6, 2, MFLAGS,
                        RK3399_CLKGATE_CON(10), 7, GFLAGS),
 
-       COMPOSITE_NOGATE(SCLK_CIF_OUT, "clk_cifout", mux_clk_cif_p, 0,
+       COMPOSITE_NOGATE(SCLK_CIF_OUT, "clk_cifout", mux_clk_cif_p, CLK_SET_RATE_PARENT,
                         RK3399_CLKSEL_CON(56), 5, 1, MFLAGS, 0, 5, DFLAGS),
 
        /* gic */
index b7ce3fbd6fa6a4b331f0345e75e0f595ea9178a7..6994165e03957c89000addbf1479f18ebbbe26fc 100644 (file)
 #include "clk.h"
 
 /*
- * GATE with additional linked clock. Downstream enables the linked clock
- * (via runtime PM) whenever the gate is enabled. The downstream implementation
- * does this via separate clock nodes for each of the linked gate clocks,
- * which leaks parts of the clock tree into DT. It is unclear why this is
- * actually needed and things work without it for simple use cases. Thus
- * the linked clock is ignored for now.
+ * Recent Rockchip SoCs have a new hardware block called Native Interface
+ * Unit (NIU), which gates clocks to devices behind them. These effectively
+ * need two parent clocks.
+ *
+ * Downstream enables the linked clock via runtime PM whenever the gate is
+ * enabled. This implementation uses separate clock nodes for each of the
+ * linked gate clocks, which leaks parts of the clock tree into DT.
+ *
+ * The GATE_LINK macro instead takes the second parent via 'linkname', but
+ * ignores the information. Once the clock framework is ready to handle it, the
+ * information should be passed on here. But since these clocks are required to
+ * access multiple relevant IP blocks, such as PCIe or USB, we mark all linked
+ * clocks critical until a better solution is available. This will waste some
+ * power, but avoids leaking implementation details into DT or hanging the
+ * system.
  */
 #define GATE_LINK(_id, cname, pname, linkname, f, o, b, gf) \
        GATE(_id, cname, pname, f, o, b, gf)
+#define RK3588_LINKED_CLK              CLK_IS_CRITICAL
 
 
 #define RK3588_GRF_SOC_STATUS0         0x600
@@ -1446,7 +1456,7 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
        COMPOSITE_NODIV(HCLK_NVM_ROOT,  "hclk_nvm_root", mux_200m_100m_50m_24m_p, 0,
                        RK3588_CLKSEL_CON(77), 0, 2, MFLAGS,
                        RK3588_CLKGATE_CON(31), 0, GFLAGS),
-       COMPOSITE(ACLK_NVM_ROOT, "aclk_nvm_root", gpll_cpll_p, 0,
+       COMPOSITE(ACLK_NVM_ROOT, "aclk_nvm_root", gpll_cpll_p, RK3588_LINKED_CLK,
                        RK3588_CLKSEL_CON(77), 7, 1, MFLAGS, 2, 5, DFLAGS,
                        RK3588_CLKGATE_CON(31), 1, GFLAGS),
        GATE(ACLK_EMMC, "aclk_emmc", "aclk_nvm_root", 0,
@@ -1675,13 +1685,13 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
                        RK3588_CLKGATE_CON(42), 9, GFLAGS),
 
        /* vdpu */
-       COMPOSITE(ACLK_VDPU_ROOT, "aclk_vdpu_root", gpll_cpll_aupll_p, 0,
+       COMPOSITE(ACLK_VDPU_ROOT, "aclk_vdpu_root", gpll_cpll_aupll_p, RK3588_LINKED_CLK,
                        RK3588_CLKSEL_CON(98), 5, 2, MFLAGS, 0, 5, DFLAGS,
                        RK3588_CLKGATE_CON(44), 0, GFLAGS),
        COMPOSITE_NODIV(ACLK_VDPU_LOW_ROOT, "aclk_vdpu_low_root", mux_400m_200m_100m_24m_p, 0,
                        RK3588_CLKSEL_CON(98), 7, 2, MFLAGS,
                        RK3588_CLKGATE_CON(44), 1, GFLAGS),
-       COMPOSITE_NODIV(HCLK_VDPU_ROOT, "hclk_vdpu_root", mux_200m_100m_50m_24m_p, 0,
+       COMPOSITE_NODIV(HCLK_VDPU_ROOT, "hclk_vdpu_root", mux_200m_100m_50m_24m_p, RK3588_LINKED_CLK,
                        RK3588_CLKSEL_CON(98), 9, 2, MFLAGS,
                        RK3588_CLKGATE_CON(44), 2, GFLAGS),
        COMPOSITE(ACLK_JPEG_DECODER_ROOT, "aclk_jpeg_decoder_root", gpll_cpll_aupll_spll_p, 0,
@@ -1732,9 +1742,9 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
        COMPOSITE(ACLK_RKVENC0_ROOT, "aclk_rkvenc0_root", gpll_cpll_npll_p, 0,
                        RK3588_CLKSEL_CON(102), 7, 2, MFLAGS, 2, 5, DFLAGS,
                        RK3588_CLKGATE_CON(47), 1, GFLAGS),
-       GATE(HCLK_RKVENC0, "hclk_rkvenc0", "hclk_rkvenc0_root", 0,
+       GATE(HCLK_RKVENC0, "hclk_rkvenc0", "hclk_rkvenc0_root", RK3588_LINKED_CLK,
                        RK3588_CLKGATE_CON(47), 4, GFLAGS),
-       GATE(ACLK_RKVENC0, "aclk_rkvenc0", "aclk_rkvenc0_root", 0,
+       GATE(ACLK_RKVENC0, "aclk_rkvenc0", "aclk_rkvenc0_root", RK3588_LINKED_CLK,
                        RK3588_CLKGATE_CON(47), 5, GFLAGS),
        COMPOSITE(CLK_RKVENC0_CORE, "clk_rkvenc0_core", gpll_cpll_aupll_npll_p, 0,
                        RK3588_CLKSEL_CON(102), 14, 2, MFLAGS, 9, 5, DFLAGS,
@@ -1744,10 +1754,10 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
                        RK3588_CLKGATE_CON(48), 6, GFLAGS),
 
        /* vi */
-       COMPOSITE(ACLK_VI_ROOT, "aclk_vi_root", gpll_cpll_npll_aupll_spll_p, 0,
+       COMPOSITE(ACLK_VI_ROOT, "aclk_vi_root", gpll_cpll_npll_aupll_spll_p, RK3588_LINKED_CLK,
                        RK3588_CLKSEL_CON(106), 5, 3, MFLAGS, 0, 5, DFLAGS,
                        RK3588_CLKGATE_CON(49), 0, GFLAGS),
-       COMPOSITE_NODIV(HCLK_VI_ROOT, "hclk_vi_root", mux_200m_100m_50m_24m_p, 0,
+       COMPOSITE_NODIV(HCLK_VI_ROOT, "hclk_vi_root", mux_200m_100m_50m_24m_p, RK3588_LINKED_CLK,
                        RK3588_CLKSEL_CON(106), 8, 2, MFLAGS,
                        RK3588_CLKGATE_CON(49), 1, GFLAGS),
        COMPOSITE_NODIV(PCLK_VI_ROOT, "pclk_vi_root", mux_100m_50m_24m_p, 0,
@@ -1919,10 +1929,10 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
        COMPOSITE(ACLK_VOP_ROOT, "aclk_vop_root", gpll_cpll_dmyaupll_npll_spll_p, 0,
                        RK3588_CLKSEL_CON(110), 5, 3, MFLAGS, 0, 5, DFLAGS,
                        RK3588_CLKGATE_CON(52), 0, GFLAGS),
-       COMPOSITE_NODIV(ACLK_VOP_LOW_ROOT, "aclk_vop_low_root", mux_400m_200m_100m_24m_p, 0,
+       COMPOSITE_NODIV(ACLK_VOP_LOW_ROOT, "aclk_vop_low_root", mux_400m_200m_100m_24m_p, RK3588_LINKED_CLK,
                        RK3588_CLKSEL_CON(110), 8, 2, MFLAGS,
                        RK3588_CLKGATE_CON(52), 1, GFLAGS),
-       COMPOSITE_NODIV(HCLK_VOP_ROOT, "hclk_vop_root", mux_200m_100m_50m_24m_p, 0,
+       COMPOSITE_NODIV(HCLK_VOP_ROOT, "hclk_vop_root", mux_200m_100m_50m_24m_p, RK3588_LINKED_CLK,
                        RK3588_CLKSEL_CON(110), 10, 2, MFLAGS,
                        RK3588_CLKGATE_CON(52), 2, GFLAGS),
        COMPOSITE_NODIV(PCLK_VOP_ROOT, "pclk_vop_root", mux_100m_50m_24m_p, 0,
@@ -2425,7 +2435,7 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
 
        GATE_LINK(ACLK_ISP1_PRE, "aclk_isp1_pre", "aclk_isp1_root", "aclk_vi_root", 0, RK3588_CLKGATE_CON(26), 6, GFLAGS),
        GATE_LINK(HCLK_ISP1_PRE, "hclk_isp1_pre", "hclk_isp1_root", "hclk_vi_root", 0, RK3588_CLKGATE_CON(26), 8, GFLAGS),
-       GATE_LINK(HCLK_NVM, "hclk_nvm", "hclk_nvm_root", "aclk_nvm_root", 0, RK3588_CLKGATE_CON(31), 2, GFLAGS),
+       GATE_LINK(HCLK_NVM, "hclk_nvm", "hclk_nvm_root", "aclk_nvm_root", RK3588_LINKED_CLK, RK3588_CLKGATE_CON(31), 2, GFLAGS),
        GATE_LINK(ACLK_USB, "aclk_usb", "aclk_usb_root", "aclk_vo1usb_top_root", 0, RK3588_CLKGATE_CON(42), 2, GFLAGS),
        GATE_LINK(HCLK_USB, "hclk_usb", "hclk_usb_root", "hclk_vo1usb_top_root", 0, RK3588_CLKGATE_CON(42), 3, GFLAGS),
        GATE_LINK(ACLK_JPEG_DECODER_PRE, "aclk_jpeg_decoder_pre", "aclk_jpeg_decoder_root", "aclk_vdpu_root", 0, RK3588_CLKGATE_CON(44), 7, GFLAGS),
index a8646794575a31353d5a5c3b07fef5c3e30a82e2..4059d9365ae642e3e967138e67b9e664c15b6851 100644 (file)
@@ -244,10 +244,8 @@ static struct clk *rockchip_clk_register_frac_branch(
        div->reg = base + muxdiv_offset;
        div->mshift = 16;
        div->mwidth = 16;
-       div->mmask = GENMASK(div->mwidth - 1, 0) << div->mshift;
        div->nshift = 0;
        div->nwidth = 16;
-       div->nmask = GENMASK(div->nwidth - 1, 0) << div->nshift;
        div->lock = lock;
        div->approximation = rockchip_fractional_approximation;
        div_ops = &clk_fractional_divider_ops;
index b921b9a1134aaeda864491a8569d082fca920779..7d8937caf22acc08966e363a086c04f12353785c 100644 (file)
@@ -10,6 +10,9 @@
  */
 #include <linux/clk.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/slab.h>
 
 #include "clk-exynos-arm64.h"
 
 #define GATE_OFF_START         0x2000
 #define GATE_OFF_END           0x2fff
 
+struct exynos_arm64_cmu_data {
+       struct samsung_clk_reg_dump *clk_save;
+       unsigned int nr_clk_save;
+       const struct samsung_clk_reg_dump *clk_suspend;
+       unsigned int nr_clk_suspend;
+
+       struct clk *clk;
+       struct clk **pclks;
+       int nr_pclks;
+
+       struct samsung_clk_provider *ctx;
+};
+
 /**
  * exynos_arm64_init_clocks - Set clocks initial configuration
  * @np:                        CMU device tree node with "reg" property (CMU addr)
@@ -56,6 +72,83 @@ static void __init exynos_arm64_init_clocks(struct device_node *np,
        iounmap(reg_base);
 }
 
+/**
+ * exynos_arm64_enable_bus_clk - Enable parent clock of specified CMU
+ *
+ * @dev:       Device object; may be NULL if this function is not being
+ *             called from platform driver probe function
+ * @np:                CMU device tree node
+ * @cmu:       CMU data
+ *
+ * Keep CMU parent clock running (needed for CMU registers access).
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+static int __init exynos_arm64_enable_bus_clk(struct device *dev,
+               struct device_node *np, const struct samsung_cmu_info *cmu)
+{
+       struct clk *parent_clk;
+
+       if (!cmu->clk_name)
+               return 0;
+
+       if (dev) {
+               struct exynos_arm64_cmu_data *data;
+
+               parent_clk = clk_get(dev, cmu->clk_name);
+               data = dev_get_drvdata(dev);
+               if (data)
+                       data->clk = parent_clk;
+       } else {
+               parent_clk = of_clk_get_by_name(np, cmu->clk_name);
+       }
+
+       if (IS_ERR(parent_clk))
+               return PTR_ERR(parent_clk);
+
+       return clk_prepare_enable(parent_clk);
+}
+
+static int __init exynos_arm64_cmu_prepare_pm(struct device *dev,
+               const struct samsung_cmu_info *cmu)
+{
+       struct exynos_arm64_cmu_data *data = dev_get_drvdata(dev);
+       int i;
+
+       data->clk_save = samsung_clk_alloc_reg_dump(cmu->clk_regs,
+                                                   cmu->nr_clk_regs);
+       if (!data->clk_save)
+               return -ENOMEM;
+
+       data->nr_clk_save = cmu->nr_clk_regs;
+       data->clk_suspend = cmu->suspend_regs;
+       data->nr_clk_suspend = cmu->nr_suspend_regs;
+       data->nr_pclks = of_clk_get_parent_count(dev->of_node);
+       if (!data->nr_pclks)
+               return 0;
+
+       data->pclks = devm_kcalloc(dev, sizeof(struct clk *), data->nr_pclks,
+                                  GFP_KERNEL);
+       if (!data->pclks) {
+               kfree(data->clk_save);
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < data->nr_pclks; i++) {
+               struct clk *clk = of_clk_get(dev->of_node, i);
+
+               if (IS_ERR(clk)) {
+                       kfree(data->clk_save);
+                       while (--i >= 0)
+                               clk_put(data->pclks[i]);
+                       return PTR_ERR(clk);
+               }
+               data->pclks[i] = clk;
+       }
+
+       return 0;
+}
+
 /**
  * exynos_arm64_register_cmu - Register specified Exynos CMU domain
  * @dev:       Device object; may be NULL if this function is not being
@@ -72,23 +165,127 @@ static void __init exynos_arm64_init_clocks(struct device_node *np,
 void __init exynos_arm64_register_cmu(struct device *dev,
                struct device_node *np, const struct samsung_cmu_info *cmu)
 {
-       /* Keep CMU parent clock running (needed for CMU registers access) */
-       if (cmu->clk_name) {
-               struct clk *parent_clk;
-
-               if (dev)
-                       parent_clk = clk_get(dev, cmu->clk_name);
-               else
-                       parent_clk = of_clk_get_by_name(np, cmu->clk_name);
-
-               if (IS_ERR(parent_clk)) {
-                       pr_err("%s: could not find bus clock %s; err = %ld\n",
-                              __func__, cmu->clk_name, PTR_ERR(parent_clk));
-               } else {
-                       clk_prepare_enable(parent_clk);
-               }
-       }
+       int err;
+
+       /*
+        * Try to boot even if the parent clock enablement fails, as it might be
+        * already enabled by bootloader.
+        */
+       err = exynos_arm64_enable_bus_clk(dev, np, cmu);
+       if (err)
+               pr_err("%s: could not enable bus clock %s; err = %d\n",
+                      __func__, cmu->clk_name, err);
 
        exynos_arm64_init_clocks(np, cmu->clk_regs, cmu->nr_clk_regs);
        samsung_cmu_register_one(np, cmu);
 }
+
+/**
+ * exynos_arm64_register_cmu_pm - Register Exynos CMU domain with PM support
+ *
+ * @pdev:      Platform device object
+ * @set_manual:        If true, set gate clocks to manual mode
+ *
+ * It's a version of exynos_arm64_register_cmu() with PM support. Should be
+ * called from probe function of platform driver.
+ *
+ * Return: 0 on success, or negative error code on error.
+ */
+int __init exynos_arm64_register_cmu_pm(struct platform_device *pdev,
+                                       bool set_manual)
+{
+       const struct samsung_cmu_info *cmu;
+       struct device *dev = &pdev->dev;
+       struct device_node *np = dev->of_node;
+       struct exynos_arm64_cmu_data *data;
+       void __iomem *reg_base;
+       int ret;
+
+       cmu = of_device_get_match_data(dev);
+
+       data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+       if (!data)
+               return -ENOMEM;
+
+       platform_set_drvdata(pdev, data);
+
+       ret = exynos_arm64_cmu_prepare_pm(dev, cmu);
+       if (ret)
+               return ret;
+
+       /*
+        * Try to boot even if the parent clock enablement fails, as it might be
+        * already enabled by bootloader.
+        */
+       ret = exynos_arm64_enable_bus_clk(dev, NULL, cmu);
+       if (ret)
+               dev_err(dev, "%s: could not enable bus clock %s; err = %d\n",
+                      __func__, cmu->clk_name, ret);
+
+       if (set_manual)
+               exynos_arm64_init_clocks(np, cmu->clk_regs, cmu->nr_clk_regs);
+
+       reg_base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(reg_base))
+               return PTR_ERR(reg_base);
+
+       data->ctx = samsung_clk_init(dev, reg_base, cmu->nr_clk_ids);
+
+       /*
+        * Enable runtime PM here to allow the clock core using runtime PM
+        * for the registered clocks. Additionally, we increase the runtime
+        * PM usage count before registering the clocks, to prevent the
+        * clock core from runtime suspending the device.
+        */
+       pm_runtime_get_noresume(dev);
+       pm_runtime_set_active(dev);
+       pm_runtime_enable(dev);
+
+       samsung_cmu_register_clocks(data->ctx, cmu);
+       samsung_clk_of_add_provider(dev->of_node, data->ctx);
+       pm_runtime_put_sync(dev);
+
+       return 0;
+}
+
+int exynos_arm64_cmu_suspend(struct device *dev)
+{
+       struct exynos_arm64_cmu_data *data = dev_get_drvdata(dev);
+       int i;
+
+       samsung_clk_save(data->ctx->reg_base, data->clk_save,
+                        data->nr_clk_save);
+
+       for (i = 0; i < data->nr_pclks; i++)
+               clk_prepare_enable(data->pclks[i]);
+
+       /* For suspend some registers have to be set to certain values */
+       samsung_clk_restore(data->ctx->reg_base, data->clk_suspend,
+                           data->nr_clk_suspend);
+
+       for (i = 0; i < data->nr_pclks; i++)
+               clk_disable_unprepare(data->pclks[i]);
+
+       clk_disable_unprepare(data->clk);
+
+       return 0;
+}
+
+int exynos_arm64_cmu_resume(struct device *dev)
+{
+       struct exynos_arm64_cmu_data *data = dev_get_drvdata(dev);
+       int i;
+
+       clk_prepare_enable(data->clk);
+
+       for (i = 0; i < data->nr_pclks; i++)
+               clk_prepare_enable(data->pclks[i]);
+
+       samsung_clk_restore(data->ctx->reg_base, data->clk_save,
+                           data->nr_clk_save);
+
+       for (i = 0; i < data->nr_pclks; i++)
+               clk_disable_unprepare(data->pclks[i]);
+
+       return 0;
+}
index 0dd174693935dc095f8589c333180e0dccaa12c1..969979e714bc63a5e5e85181d04e52659f3274af 100644 (file)
@@ -16,5 +16,8 @@
 
 void exynos_arm64_register_cmu(struct device *dev,
                struct device_node *np, const struct samsung_cmu_info *cmu);
+int exynos_arm64_register_cmu_pm(struct platform_device *pdev, bool set_manual);
+int exynos_arm64_cmu_suspend(struct device *dev);
+int exynos_arm64_cmu_resume(struct device *dev);
 
 #endif /* __CLK_EXYNOS_ARM64_H */
index 9cc127a162ad6a9330ff21e3756ee8ee20dbb5b8..7626dff41f6faec912146a9b8978564583073fb0 100644 (file)
@@ -268,7 +268,7 @@ unregister:
        return ret;
 }
 
-static int exynos_audss_clk_remove(struct platform_device *pdev)
+static void exynos_audss_clk_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
 
@@ -277,8 +277,6 @@ static int exynos_audss_clk_remove(struct platform_device *pdev)
 
        if (!IS_ERR(epll))
                clk_disable_unprepare(epll);
-
-       return 0;
 }
 
 static const struct dev_pm_ops exynos_audss_clk_pm_ops = {
@@ -295,7 +293,7 @@ static struct platform_driver exynos_audss_clk_driver = {
                .pm = &exynos_audss_clk_pm_ops,
        },
        .probe = exynos_audss_clk_probe,
-       .remove = exynos_audss_clk_remove,
+       .remove_new = exynos_audss_clk_remove,
 };
 
 module_platform_driver(exynos_audss_clk_driver);
index e6d6cbf8c4e61e5d7d1c7edc653d27a0a995ed78..0cff1c94c35e67ae72f329dc24c86e04a6cb9d91 100644 (file)
@@ -196,15 +196,13 @@ clks_put:
        return ret;
 }
 
-static int exynos_clkout_remove(struct platform_device *pdev)
+static void exynos_clkout_remove(struct platform_device *pdev)
 {
        struct exynos_clkout *clkout = platform_get_drvdata(pdev);
 
        of_clk_del_provider(clkout->np);
        clk_hw_unregister(clkout->data.hws[0]);
        iounmap(clkout->reg);
-
-       return 0;
 }
 
 static int __maybe_unused exynos_clkout_suspend(struct device *dev)
@@ -235,7 +233,7 @@ static struct platform_driver exynos_clkout_driver = {
                .pm = &exynos_clkout_pm_ops,
        },
        .probe = exynos_clkout_probe,
-       .remove = exynos_clkout_remove,
+       .remove_new = exynos_clkout_remove,
 };
 module_platform_driver(exynos_clkout_driver);
 
index 22009cb53428a09005456fcbde4fa4ca4ae06943..d7dbb38583471e86d5c1eeb3723196d1356addbf 100644 (file)
@@ -1251,7 +1251,7 @@ static void __init exynos4_clk_init(struct device_node *np,
        if (!reg_base)
                panic("%s: failed to map registers\n", __func__);
 
-       ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
+       ctx = samsung_clk_init(NULL, reg_base, CLK_NR_CLKS);
        hws = ctx->clk_data.hws;
 
        samsung_clk_of_register_fixed_ext(ctx, exynos4_fixed_rate_ext_clks,
@@ -1276,7 +1276,7 @@ static void __init exynos4_clk_init(struct device_node *np,
                                                        exynos4210_vpll_rates;
 
                samsung_clk_register_pll(ctx, exynos4210_plls,
-                                       ARRAY_SIZE(exynos4210_plls), reg_base);
+                                       ARRAY_SIZE(exynos4210_plls));
        } else {
                if (clk_hw_get_rate(hws[CLK_FIN_PLL]) == 24000000) {
                        exynos4x12_plls[apll].rate_table =
@@ -1288,7 +1288,7 @@ static void __init exynos4_clk_init(struct device_node *np,
                }
 
                samsung_clk_register_pll(ctx, exynos4x12_plls,
-                                       ARRAY_SIZE(exynos4x12_plls), reg_base);
+                                       ARRAY_SIZE(exynos4x12_plls));
        }
 
        samsung_clk_register_fixed_rate(ctx, exynos4_fixed_rate_clks,
index 471a6fb8267059f8ff88821a51b214618ddab031..1470c15e95da3851c7f8e16272a392d81d053660 100644 (file)
@@ -121,8 +121,7 @@ static int __init exynos4x12_isp_clk_probe(struct platform_device *pdev)
        if (!exynos4x12_save_isp)
                return -ENOMEM;
 
-       ctx = samsung_clk_init(np, reg_base, CLK_NR_ISP_CLKS);
-       ctx->dev = dev;
+       ctx = samsung_clk_init(dev, reg_base, CLK_NR_ISP_CLKS);
 
        platform_set_drvdata(pdev, ctx);
 
index 113df773ee4490db0155e6219c303fba1e947d7c..92fb09922f2800d7e14d2c3d51d242a56e2200ba 100644 (file)
@@ -797,7 +797,7 @@ static void __init exynos5250_clk_init(struct device_node *np)
                panic("%s: unable to determine soc\n", __func__);
        }
 
-       ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
+       ctx = samsung_clk_init(NULL, reg_base, CLK_NR_CLKS);
        hws = ctx->clk_data.hws;
 
        samsung_clk_of_register_fixed_ext(ctx, exynos5250_fixed_rate_ext_clks,
@@ -815,8 +815,7 @@ static void __init exynos5250_clk_init(struct device_node *np)
                exynos5250_plls[vpll].rate_table =  vpll_24mhz_tbl;
 
        samsung_clk_register_pll(ctx, exynos5250_plls,
-                       ARRAY_SIZE(exynos5250_plls),
-                       reg_base);
+                       ARRAY_SIZE(exynos5250_plls));
        samsung_clk_register_fixed_rate(ctx, exynos5250_fixed_rate_clks,
                        ARRAY_SIZE(exynos5250_fixed_rate_clks));
        samsung_clk_register_fixed_factor(ctx, exynos5250_fixed_factor_clks,
index caad74dee2971b02bfc98d598f1480f6a20cd557..1e0cbf762408b169e8b79da94c34c7ad792e45cd 100644 (file)
@@ -1587,7 +1587,7 @@ static void __init exynos5x_clk_init(struct device_node *np,
 
        exynos5x_soc = soc;
 
-       ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
+       ctx = samsung_clk_init(NULL, reg_base, CLK_NR_CLKS);
        hws = ctx->clk_data.hws;
 
        samsung_clk_of_register_fixed_ext(ctx, exynos5x_fixed_rate_ext_clks,
@@ -1606,8 +1606,7 @@ static void __init exynos5x_clk_init(struct device_node *np,
        else
                exynos5x_plls[bpll].rate_table = exynos5422_bpll_rate_table;
 
-       samsung_clk_register_pll(ctx, exynos5x_plls, ARRAY_SIZE(exynos5x_plls),
-                                       reg_base);
+       samsung_clk_register_pll(ctx, exynos5x_plls, ARRAY_SIZE(exynos5x_plls));
        samsung_clk_register_fixed_rate(ctx, exynos5x_fixed_rate_clks,
                        ARRAY_SIZE(exynos5x_fixed_rate_clks));
        samsung_clk_register_fixed_factor(ctx, exynos5x_fixed_factor_clks,
index f9daae20f393de765fa8e2b30e3891fea530ddbf..ed43233649aeb5e83b6f087de68d656f23882b76 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/clk-provider.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
@@ -19,6 +18,7 @@
 
 #include "clk.h"
 #include "clk-cpu.h"
+#include "clk-exynos-arm64.h"
 #include "clk-pll.h"
 
 /*
@@ -5478,160 +5478,9 @@ static const struct samsung_cmu_info imem_cmu_info __initconst = {
        .clk_name               = "aclk_imem_200",
 };
 
-struct exynos5433_cmu_data {
-       struct samsung_clk_reg_dump *clk_save;
-       unsigned int nr_clk_save;
-       const struct samsung_clk_reg_dump *clk_suspend;
-       unsigned int nr_clk_suspend;
-
-       struct clk *clk;
-       struct clk **pclks;
-       int nr_pclks;
-
-       /* must be the last entry */
-       struct samsung_clk_provider ctx;
-};
-
-static int __maybe_unused exynos5433_cmu_suspend(struct device *dev)
-{
-       struct exynos5433_cmu_data *data = dev_get_drvdata(dev);
-       int i;
-
-       samsung_clk_save(data->ctx.reg_base, data->clk_save,
-                        data->nr_clk_save);
-
-       for (i = 0; i < data->nr_pclks; i++)
-               clk_prepare_enable(data->pclks[i]);
-
-       /* for suspend some registers have to be set to certain values */
-       samsung_clk_restore(data->ctx.reg_base, data->clk_suspend,
-                           data->nr_clk_suspend);
-
-       for (i = 0; i < data->nr_pclks; i++)
-               clk_disable_unprepare(data->pclks[i]);
-
-       clk_disable_unprepare(data->clk);
-
-       return 0;
-}
-
-static int __maybe_unused exynos5433_cmu_resume(struct device *dev)
-{
-       struct exynos5433_cmu_data *data = dev_get_drvdata(dev);
-       int i;
-
-       clk_prepare_enable(data->clk);
-
-       for (i = 0; i < data->nr_pclks; i++)
-               clk_prepare_enable(data->pclks[i]);
-
-       samsung_clk_restore(data->ctx.reg_base, data->clk_save,
-                           data->nr_clk_save);
-
-       for (i = 0; i < data->nr_pclks; i++)
-               clk_disable_unprepare(data->pclks[i]);
-
-       return 0;
-}
-
 static int __init exynos5433_cmu_probe(struct platform_device *pdev)
 {
-       const struct samsung_cmu_info *info;
-       struct exynos5433_cmu_data *data;
-       struct samsung_clk_provider *ctx;
-       struct device *dev = &pdev->dev;
-       void __iomem *reg_base;
-       int i;
-
-       info = of_device_get_match_data(dev);
-
-       data = devm_kzalloc(dev,
-                           struct_size(data, ctx.clk_data.hws, info->nr_clk_ids),
-                           GFP_KERNEL);
-       if (!data)
-               return -ENOMEM;
-       ctx = &data->ctx;
-
-       reg_base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(reg_base))
-               return PTR_ERR(reg_base);
-
-       for (i = 0; i < info->nr_clk_ids; ++i)
-               ctx->clk_data.hws[i] = ERR_PTR(-ENOENT);
-
-       ctx->clk_data.num = info->nr_clk_ids;
-       ctx->reg_base = reg_base;
-       ctx->dev = dev;
-       spin_lock_init(&ctx->lock);
-
-       data->clk_save = samsung_clk_alloc_reg_dump(info->clk_regs,
-                                                   info->nr_clk_regs);
-       if (!data->clk_save)
-               return -ENOMEM;
-       data->nr_clk_save = info->nr_clk_regs;
-       data->clk_suspend = info->suspend_regs;
-       data->nr_clk_suspend = info->nr_suspend_regs;
-       data->nr_pclks = of_clk_get_parent_count(dev->of_node);
-
-       if (data->nr_pclks > 0) {
-               data->pclks = devm_kcalloc(dev, sizeof(struct clk *),
-                                          data->nr_pclks, GFP_KERNEL);
-               if (!data->pclks) {
-                       kfree(data->clk_save);
-                       return -ENOMEM;
-               }
-               for (i = 0; i < data->nr_pclks; i++) {
-                       struct clk *clk = of_clk_get(dev->of_node, i);
-
-                       if (IS_ERR(clk)) {
-                               kfree(data->clk_save);
-                               while (--i >= 0)
-                                       clk_put(data->pclks[i]);
-                               return PTR_ERR(clk);
-                       }
-                       data->pclks[i] = clk;
-               }
-       }
-
-       if (info->clk_name)
-               data->clk = clk_get(dev, info->clk_name);
-       clk_prepare_enable(data->clk);
-
-       platform_set_drvdata(pdev, data);
-
-       /*
-        * Enable runtime PM here to allow the clock core using runtime PM
-        * for the registered clocks. Additionally, we increase the runtime
-        * PM usage count before registering the clocks, to prevent the
-        * clock core from runtime suspending the device.
-        */
-       pm_runtime_get_noresume(dev);
-       pm_runtime_set_active(dev);
-       pm_runtime_enable(dev);
-
-       if (info->pll_clks)
-               samsung_clk_register_pll(ctx, info->pll_clks, info->nr_pll_clks,
-                                        reg_base);
-       if (info->mux_clks)
-               samsung_clk_register_mux(ctx, info->mux_clks,
-                                        info->nr_mux_clks);
-       if (info->div_clks)
-               samsung_clk_register_div(ctx, info->div_clks,
-                                        info->nr_div_clks);
-       if (info->gate_clks)
-               samsung_clk_register_gate(ctx, info->gate_clks,
-                                         info->nr_gate_clks);
-       if (info->fixed_clks)
-               samsung_clk_register_fixed_rate(ctx, info->fixed_clks,
-                                               info->nr_fixed_clks);
-       if (info->fixed_factor_clks)
-               samsung_clk_register_fixed_factor(ctx, info->fixed_factor_clks,
-                                                 info->nr_fixed_factor_clks);
-
-       samsung_clk_of_add_provider(dev->of_node, ctx);
-       pm_runtime_put_sync(dev);
-
-       return 0;
+       return exynos_arm64_register_cmu_pm(pdev, false);
 }
 
 static const struct of_device_id exynos5433_cmu_of_match[] = {
@@ -5679,7 +5528,7 @@ static const struct of_device_id exynos5433_cmu_of_match[] = {
 };
 
 static const struct dev_pm_ops exynos5433_cmu_pm_ops = {
-       SET_RUNTIME_PM_OPS(exynos5433_cmu_suspend, exynos5433_cmu_resume,
+       SET_RUNTIME_PM_OPS(exynos_arm64_cmu_suspend, exynos_arm64_cmu_resume,
                           NULL)
        SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
                                     pm_runtime_force_resume)
index 541761e96aeb677d2abebfd86ef079ead45b15d1..98b23af7324d94efd77f2694c1176cd0b1fddcb4 100644 (file)
@@ -36,6 +36,7 @@
 #define CLK_CON_MUX_MUX_CLKCMU_CORE_MMC_EMBD   0x101c
 #define CLK_CON_MUX_MUX_CLKCMU_CORE_SSS                0x1020
 #define CLK_CON_MUX_MUX_CLKCMU_DPU             0x1034
+#define CLK_CON_MUX_MUX_CLKCMU_G3D_SWITCH      0x1038
 #define CLK_CON_MUX_MUX_CLKCMU_HSI_BUS         0x103c
 #define CLK_CON_MUX_MUX_CLKCMU_HSI_MMC_CARD    0x1040
 #define CLK_CON_MUX_MUX_CLKCMU_HSI_USB20DRD    0x1044
@@ -57,6 +58,7 @@
 #define CLK_CON_DIV_CLKCMU_CORE_MMC_EMBD       0x1828
 #define CLK_CON_DIV_CLKCMU_CORE_SSS            0x182c
 #define CLK_CON_DIV_CLKCMU_DPU                 0x1840
+#define CLK_CON_DIV_CLKCMU_G3D_SWITCH          0x1844
 #define CLK_CON_DIV_CLKCMU_HSI_BUS             0x1848
 #define CLK_CON_DIV_CLKCMU_HSI_MMC_CARD                0x184c
 #define CLK_CON_DIV_CLKCMU_HSI_USB20DRD                0x1850
@@ -84,6 +86,7 @@
 #define CLK_CON_GAT_GATE_CLKCMU_CORE_MMC_EMBD  0x2024
 #define CLK_CON_GAT_GATE_CLKCMU_CORE_SSS       0x2028
 #define CLK_CON_GAT_GATE_CLKCMU_DPU            0x203c
+#define CLK_CON_GAT_GATE_CLKCMU_G3D_SWITCH     0x2040
 #define CLK_CON_GAT_GATE_CLKCMU_HSI_BUS                0x2044
 #define CLK_CON_GAT_GATE_CLKCMU_HSI_MMC_CARD   0x2048
 #define CLK_CON_GAT_GATE_CLKCMU_HSI_USB20DRD   0x204c
@@ -116,6 +119,7 @@ static const unsigned long top_clk_regs[] __initconst = {
        CLK_CON_MUX_MUX_CLKCMU_CORE_MMC_EMBD,
        CLK_CON_MUX_MUX_CLKCMU_CORE_SSS,
        CLK_CON_MUX_MUX_CLKCMU_DPU,
+       CLK_CON_MUX_MUX_CLKCMU_G3D_SWITCH,
        CLK_CON_MUX_MUX_CLKCMU_HSI_BUS,
        CLK_CON_MUX_MUX_CLKCMU_HSI_MMC_CARD,
        CLK_CON_MUX_MUX_CLKCMU_HSI_USB20DRD,
@@ -137,6 +141,7 @@ static const unsigned long top_clk_regs[] __initconst = {
        CLK_CON_DIV_CLKCMU_CORE_MMC_EMBD,
        CLK_CON_DIV_CLKCMU_CORE_SSS,
        CLK_CON_DIV_CLKCMU_DPU,
+       CLK_CON_DIV_CLKCMU_G3D_SWITCH,
        CLK_CON_DIV_CLKCMU_HSI_BUS,
        CLK_CON_DIV_CLKCMU_HSI_MMC_CARD,
        CLK_CON_DIV_CLKCMU_HSI_USB20DRD,
@@ -164,6 +169,7 @@ static const unsigned long top_clk_regs[] __initconst = {
        CLK_CON_GAT_GATE_CLKCMU_CORE_MMC_EMBD,
        CLK_CON_GAT_GATE_CLKCMU_CORE_SSS,
        CLK_CON_GAT_GATE_CLKCMU_DPU,
+       CLK_CON_GAT_GATE_CLKCMU_G3D_SWITCH,
        CLK_CON_GAT_GATE_CLKCMU_HSI_BUS,
        CLK_CON_GAT_GATE_CLKCMU_HSI_MMC_CARD,
        CLK_CON_GAT_GATE_CLKCMU_HSI_USB20DRD,
@@ -216,6 +222,9 @@ PNAME(mout_core_mmc_embd_p) = { "oscclk", "dout_shared0_div2",
                                    "oscclk", "oscclk" };
 PNAME(mout_core_sss_p)         = { "dout_shared0_div3", "dout_shared1_div3",
                                    "dout_shared0_div4", "dout_shared1_div4" };
+/* List of parent clocks for Muxes in CMU_TOP: for CMU_G3D */
+PNAME(mout_g3d_switch_p)       = { "dout_shared0_div2", "dout_shared1_div2",
+                                   "dout_shared0_div3", "dout_shared1_div3" };
 /* List of parent clocks for Muxes in CMU_TOP: for CMU_HSI */
 PNAME(mout_hsi_bus_p)          = { "dout_shared0_div2", "dout_shared1_div2" };
 PNAME(mout_hsi_mmc_card_p)     = { "oscclk", "dout_shared0_div2",
@@ -283,6 +292,10 @@ static const struct samsung_mux_clock top_mux_clks[] __initconst = {
        MUX(CLK_MOUT_DPU, "mout_dpu", mout_dpu_p,
            CLK_CON_MUX_MUX_CLKCMU_DPU, 0, 2),
 
+       /* G3D */
+       MUX(CLK_MOUT_G3D_SWITCH, "mout_g3d_switch", mout_g3d_switch_p,
+           CLK_CON_MUX_MUX_CLKCMU_G3D_SWITCH, 0, 2),
+
        /* HSI */
        MUX(CLK_MOUT_HSI_BUS, "mout_hsi_bus", mout_hsi_bus_p,
            CLK_CON_MUX_MUX_CLKCMU_HSI_BUS, 0, 1),
@@ -357,6 +370,10 @@ static const struct samsung_div_clock top_div_clks[] __initconst = {
        DIV(CLK_DOUT_DPU, "dout_dpu", "gout_dpu",
            CLK_CON_DIV_CLKCMU_DPU, 0, 4),
 
+       /* G3D */
+       DIV(CLK_DOUT_G3D_SWITCH, "dout_g3d_switch", "gout_g3d_switch",
+           CLK_CON_DIV_CLKCMU_G3D_SWITCH, 0, 3),
+
        /* HSI */
        DIV(CLK_DOUT_HSI_BUS, "dout_hsi_bus", "gout_hsi_bus",
            CLK_CON_DIV_CLKCMU_HSI_BUS, 0, 4),
@@ -417,6 +434,10 @@ static const struct samsung_gate_clock top_gate_clks[] __initconst = {
        GATE(CLK_GOUT_DPU, "gout_dpu", "mout_dpu",
             CLK_CON_GAT_GATE_CLKCMU_DPU, 21, 0, 0),
 
+       /* G3D */
+       GATE(CLK_GOUT_G3D_SWITCH, "gout_g3d_switch", "mout_g3d_switch",
+            CLK_CON_GAT_GATE_CLKCMU_G3D_SWITCH, 21, 0, 0),
+
        /* HSI */
        GATE(CLK_GOUT_HSI_BUS, "gout_hsi_bus", "mout_hsi_bus",
             CLK_CON_GAT_GATE_CLKCMU_HSI_BUS, 21, 0, 0),
@@ -591,7 +612,7 @@ static const struct samsung_gate_clock apm_gate_clks[] __initconst = {
             CLK_CON_GAT_GOUT_APM_APBIF_GPIO_ALIVE_PCLK, 21, CLK_IGNORE_UNUSED,
             0),
        GATE(CLK_GOUT_PMU_ALIVE_PCLK, "gout_pmu_alive_pclk", "dout_apm_bus",
-            CLK_CON_GAT_GOUT_APM_APBIF_PMU_ALIVE_PCLK, 21, 0, 0),
+            CLK_CON_GAT_GOUT_APM_APBIF_PMU_ALIVE_PCLK, 21, CLK_IS_CRITICAL, 0),
        GATE(CLK_GOUT_SYSREG_APM_PCLK, "gout_sysreg_apm_pclk", "dout_apm_bus",
             CLK_CON_GAT_GOUT_APM_SYSREG_APM_PCLK, 21, 0, 0),
 };
@@ -653,6 +674,7 @@ static const struct samsung_cmu_info apm_cmu_info __initconst = {
 #define CLK_CON_GAT_GOUT_AUD_ABOX_BCLK_UAIF4   0x2014
 #define CLK_CON_GAT_GOUT_AUD_ABOX_BCLK_UAIF5   0x2018
 #define CLK_CON_GAT_GOUT_AUD_ABOX_BCLK_UAIF6   0x201c
+#define CLK_CON_GAT_CLK_AUD_CMU_AUD_PCLK       0x2020
 #define CLK_CON_GAT_GOUT_AUD_ABOX_ACLK         0x2048
 #define CLK_CON_GAT_GOUT_AUD_ABOX_BCLK_SPDY    0x204c
 #define CLK_CON_GAT_GOUT_AUD_ABOX_CCLK_ASB     0x2050
@@ -708,6 +730,7 @@ static const unsigned long aud_clk_regs[] __initconst = {
        CLK_CON_GAT_GOUT_AUD_ABOX_BCLK_UAIF4,
        CLK_CON_GAT_GOUT_AUD_ABOX_BCLK_UAIF5,
        CLK_CON_GAT_GOUT_AUD_ABOX_BCLK_UAIF6,
+       CLK_CON_GAT_CLK_AUD_CMU_AUD_PCLK,
        CLK_CON_GAT_GOUT_AUD_ABOX_ACLK,
        CLK_CON_GAT_GOUT_AUD_ABOX_BCLK_SPDY,
        CLK_CON_GAT_GOUT_AUD_ABOX_CCLK_ASB,
@@ -827,6 +850,9 @@ static const struct samsung_div_clock aud_div_clks[] __initconst = {
 };
 
 static const struct samsung_gate_clock aud_gate_clks[] __initconst = {
+       GATE(CLK_GOUT_AUD_CMU_AUD_PCLK, "gout_aud_cmu_aud_pclk",
+            "dout_aud_busd",
+            CLK_CON_GAT_CLK_AUD_CMU_AUD_PCLK, 21, CLK_IGNORE_UNUSED, 0),
        GATE(CLK_GOUT_AUD_CA32_CCLK, "gout_aud_ca32_cclk", "mout_aud_cpu_hch",
             CLK_CON_GAT_GOUT_AUD_ABOX_CCLK_CA32, 21, 0, 0),
        GATE(CLK_GOUT_AUD_ASB_CCLK, "gout_aud_asb_cclk", "dout_aud_cpu_aclk",
@@ -992,6 +1018,102 @@ static const struct samsung_cmu_info cmgp_cmu_info __initconst = {
        .clk_name               = "gout_clkcmu_cmgp_bus",
 };
 
+/* ---- CMU_G3D ------------------------------------------------------------- */
+
+/* Register Offset definitions for CMU_G3D (0x11400000) */
+#define PLL_LOCKTIME_PLL_G3D                   0x0000
+#define PLL_CON0_PLL_G3D                       0x0100
+#define PLL_CON3_PLL_G3D                       0x010c
+#define PLL_CON0_MUX_CLKCMU_G3D_SWITCH_USER    0x0600
+#define CLK_CON_MUX_MUX_CLK_G3D_BUSD           0x1000
+#define CLK_CON_DIV_DIV_CLK_G3D_BUSP           0x1804
+#define CLK_CON_GAT_CLK_G3D_CMU_G3D_PCLK       0x2000
+#define CLK_CON_GAT_CLK_G3D_GPU_CLK            0x2004
+#define CLK_CON_GAT_GOUT_G3D_TZPC_PCLK         0x200c
+#define CLK_CON_GAT_GOUT_G3D_GRAY2BIN_CLK      0x2010
+#define CLK_CON_GAT_GOUT_G3D_BUSD_CLK          0x2024
+#define CLK_CON_GAT_GOUT_G3D_BUSP_CLK          0x2028
+#define CLK_CON_GAT_GOUT_G3D_SYSREG_PCLK       0x202c
+
+static const unsigned long g3d_clk_regs[] __initconst = {
+       PLL_LOCKTIME_PLL_G3D,
+       PLL_CON0_PLL_G3D,
+       PLL_CON3_PLL_G3D,
+       PLL_CON0_MUX_CLKCMU_G3D_SWITCH_USER,
+       CLK_CON_MUX_MUX_CLK_G3D_BUSD,
+       CLK_CON_DIV_DIV_CLK_G3D_BUSP,
+       CLK_CON_GAT_CLK_G3D_CMU_G3D_PCLK,
+       CLK_CON_GAT_CLK_G3D_GPU_CLK,
+       CLK_CON_GAT_GOUT_G3D_TZPC_PCLK,
+       CLK_CON_GAT_GOUT_G3D_GRAY2BIN_CLK,
+       CLK_CON_GAT_GOUT_G3D_BUSD_CLK,
+       CLK_CON_GAT_GOUT_G3D_BUSP_CLK,
+       CLK_CON_GAT_GOUT_G3D_SYSREG_PCLK,
+};
+
+/* List of parent clocks for Muxes in CMU_G3D */
+PNAME(mout_g3d_pll_p)          = { "oscclk", "fout_g3d_pll" };
+PNAME(mout_g3d_switch_user_p)  = { "oscclk", "dout_g3d_switch" };
+PNAME(mout_g3d_busd_p)         = { "mout_g3d_pll", "mout_g3d_switch_user" };
+
+/*
+ * Do not provide PLL table to PLL_G3D, as MANUAL_PLL_CTRL bit is not set
+ * for that PLL by default, so set_rate operation would fail.
+ */
+static const struct samsung_pll_clock g3d_pll_clks[] __initconst = {
+       PLL(pll_0818x, CLK_FOUT_G3D_PLL, "fout_g3d_pll", "oscclk",
+           PLL_LOCKTIME_PLL_G3D, PLL_CON3_PLL_G3D, NULL),
+};
+
+static const struct samsung_mux_clock g3d_mux_clks[] __initconst = {
+       MUX(CLK_MOUT_G3D_PLL, "mout_g3d_pll", mout_g3d_pll_p,
+           PLL_CON0_PLL_G3D, 4, 1),
+       MUX(CLK_MOUT_G3D_SWITCH_USER, "mout_g3d_switch_user",
+           mout_g3d_switch_user_p,
+           PLL_CON0_MUX_CLKCMU_G3D_SWITCH_USER, 4, 1),
+       MUX(CLK_MOUT_G3D_BUSD, "mout_g3d_busd", mout_g3d_busd_p,
+           CLK_CON_MUX_MUX_CLK_G3D_BUSD, 0, 1),
+};
+
+static const struct samsung_div_clock g3d_div_clks[] __initconst = {
+       DIV(CLK_DOUT_G3D_BUSP, "dout_g3d_busp", "mout_g3d_busd",
+           CLK_CON_DIV_DIV_CLK_G3D_BUSP, 0, 3),
+};
+
+static const struct samsung_gate_clock g3d_gate_clks[] __initconst = {
+       GATE(CLK_GOUT_G3D_CMU_G3D_PCLK, "gout_g3d_cmu_g3d_pclk",
+            "dout_g3d_busp",
+            CLK_CON_GAT_CLK_G3D_CMU_G3D_PCLK, 21, CLK_IGNORE_UNUSED, 0),
+       GATE(CLK_GOUT_G3D_GPU_CLK, "gout_g3d_gpu_clk", "mout_g3d_busd",
+            CLK_CON_GAT_CLK_G3D_GPU_CLK, 21, 0, 0),
+       GATE(CLK_GOUT_G3D_TZPC_PCLK, "gout_g3d_tzpc_pclk", "dout_g3d_busp",
+            CLK_CON_GAT_GOUT_G3D_TZPC_PCLK, 21, 0, 0),
+       GATE(CLK_GOUT_G3D_GRAY2BIN_CLK, "gout_g3d_gray2bin_clk",
+            "mout_g3d_busd",
+            CLK_CON_GAT_GOUT_G3D_GRAY2BIN_CLK, 21, 0, 0),
+       GATE(CLK_GOUT_G3D_BUSD_CLK, "gout_g3d_busd_clk", "mout_g3d_busd",
+            CLK_CON_GAT_GOUT_G3D_BUSD_CLK, 21, 0, 0),
+       GATE(CLK_GOUT_G3D_BUSP_CLK, "gout_g3d_busp_clk", "dout_g3d_busp",
+            CLK_CON_GAT_GOUT_G3D_BUSP_CLK, 21, 0, 0),
+       GATE(CLK_GOUT_G3D_SYSREG_PCLK, "gout_g3d_sysreg_pclk", "dout_g3d_busp",
+            CLK_CON_GAT_GOUT_G3D_SYSREG_PCLK, 21, 0, 0),
+};
+
+static const struct samsung_cmu_info g3d_cmu_info __initconst = {
+       .pll_clks               = g3d_pll_clks,
+       .nr_pll_clks            = ARRAY_SIZE(g3d_pll_clks),
+       .mux_clks               = g3d_mux_clks,
+       .nr_mux_clks            = ARRAY_SIZE(g3d_mux_clks),
+       .div_clks               = g3d_div_clks,
+       .nr_div_clks            = ARRAY_SIZE(g3d_div_clks),
+       .gate_clks              = g3d_gate_clks,
+       .nr_gate_clks           = ARRAY_SIZE(g3d_gate_clks),
+       .nr_clk_ids             = G3D_NR_CLK,
+       .clk_regs               = g3d_clk_regs,
+       .nr_clk_regs            = ARRAY_SIZE(g3d_clk_regs),
+       .clk_name               = "dout_g3d_switch",
+};
+
 /* ---- CMU_HSI ------------------------------------------------------------- */
 
 /* Register Offset definitions for CMU_HSI (0x13400000) */
@@ -999,12 +1121,15 @@ static const struct samsung_cmu_info cmgp_cmu_info __initconst = {
 #define PLL_CON0_MUX_CLKCMU_HSI_MMC_CARD_USER                  0x0610
 #define PLL_CON0_MUX_CLKCMU_HSI_USB20DRD_USER                  0x0620
 #define CLK_CON_MUX_MUX_CLK_HSI_RTC                            0x1000
+#define CLK_CON_GAT_CLK_HSI_CMU_HSI_PCLK                       0x2000
 #define CLK_CON_GAT_HSI_USB20DRD_TOP_I_RTC_CLK__ALV            0x2008
 #define CLK_CON_GAT_HSI_USB20DRD_TOP_I_REF_CLK_50              0x200c
 #define CLK_CON_GAT_HSI_USB20DRD_TOP_I_PHY_REFCLK_26           0x2010
 #define CLK_CON_GAT_GOUT_HSI_GPIO_HSI_PCLK                     0x2018
 #define CLK_CON_GAT_GOUT_HSI_MMC_CARD_I_ACLK                   0x2024
 #define CLK_CON_GAT_GOUT_HSI_MMC_CARD_SDCLKIN                  0x2028
+#define CLK_CON_GAT_GOUT_HSI_PPMU_ACLK                         0x202c
+#define CLK_CON_GAT_GOUT_HSI_PPMU_PCLK                         0x2030
 #define CLK_CON_GAT_GOUT_HSI_SYSREG_HSI_PCLK                   0x2038
 #define CLK_CON_GAT_GOUT_HSI_USB20DRD_TOP_ACLK_PHYCTRL_20      0x203c
 #define CLK_CON_GAT_GOUT_HSI_USB20DRD_TOP_BUS_CLK_EARLY                0x2040
@@ -1014,12 +1139,15 @@ static const unsigned long hsi_clk_regs[] __initconst = {
        PLL_CON0_MUX_CLKCMU_HSI_MMC_CARD_USER,
        PLL_CON0_MUX_CLKCMU_HSI_USB20DRD_USER,
        CLK_CON_MUX_MUX_CLK_HSI_RTC,
+       CLK_CON_GAT_CLK_HSI_CMU_HSI_PCLK,
        CLK_CON_GAT_HSI_USB20DRD_TOP_I_RTC_CLK__ALV,
        CLK_CON_GAT_HSI_USB20DRD_TOP_I_REF_CLK_50,
        CLK_CON_GAT_HSI_USB20DRD_TOP_I_PHY_REFCLK_26,
        CLK_CON_GAT_GOUT_HSI_GPIO_HSI_PCLK,
        CLK_CON_GAT_GOUT_HSI_MMC_CARD_I_ACLK,
        CLK_CON_GAT_GOUT_HSI_MMC_CARD_SDCLKIN,
+       CLK_CON_GAT_GOUT_HSI_PPMU_ACLK,
+       CLK_CON_GAT_GOUT_HSI_PPMU_PCLK,
        CLK_CON_GAT_GOUT_HSI_SYSREG_HSI_PCLK,
        CLK_CON_GAT_GOUT_HSI_USB20DRD_TOP_ACLK_PHYCTRL_20,
        CLK_CON_GAT_GOUT_HSI_USB20DRD_TOP_BUS_CLK_EARLY,
@@ -1045,6 +1173,10 @@ static const struct samsung_mux_clock hsi_mux_clks[] __initconst = {
 };
 
 static const struct samsung_gate_clock hsi_gate_clks[] __initconst = {
+       /* TODO: Should be enabled in corresponding driver */
+       GATE(CLK_GOUT_HSI_CMU_HSI_PCLK, "gout_hsi_cmu_hsi_pclk",
+            "mout_hsi_bus_user",
+            CLK_CON_GAT_CLK_HSI_CMU_HSI_PCLK, 21, CLK_IGNORE_UNUSED, 0),
        GATE(CLK_GOUT_USB_RTC_CLK, "gout_usb_rtc", "mout_hsi_rtc",
             CLK_CON_GAT_HSI_USB20DRD_TOP_I_RTC_CLK__ALV, 21, 0, 0),
        GATE(CLK_GOUT_USB_REF_CLK, "gout_usb_ref", "mout_hsi_usb20drd_user",
@@ -1059,6 +1191,10 @@ static const struct samsung_gate_clock hsi_gate_clks[] __initconst = {
        GATE(CLK_GOUT_MMC_CARD_SDCLKIN, "gout_mmc_card_sdclkin",
             "mout_hsi_mmc_card_user",
             CLK_CON_GAT_GOUT_HSI_MMC_CARD_SDCLKIN, 21, CLK_SET_RATE_PARENT, 0),
+       GATE(CLK_GOUT_HSI_PPMU_ACLK, "gout_hsi_ppmu_aclk", "mout_hsi_bus_user",
+            CLK_CON_GAT_GOUT_HSI_PPMU_ACLK, 21, 0, 0),
+       GATE(CLK_GOUT_HSI_PPMU_PCLK, "gout_hsi_ppmu_pclk", "mout_hsi_bus_user",
+            CLK_CON_GAT_GOUT_HSI_PPMU_PCLK, 21, 0, 0),
        GATE(CLK_GOUT_SYSREG_HSI_PCLK, "gout_sysreg_hsi_pclk",
             "mout_hsi_bus_user",
             CLK_CON_GAT_GOUT_HSI_SYSREG_HSI_PCLK, 21, 0, 0),
@@ -1700,6 +1836,9 @@ static const struct of_device_id exynos850_cmu_of_match[] = {
        }, {
                .compatible = "samsung,exynos850-cmu-cmgp",
                .data = &cmgp_cmu_info,
+       }, {
+               .compatible = "samsung,exynos850-cmu-g3d",
+               .data = &g3d_cmu_info,
        }, {
                .compatible = "samsung,exynos850-cmu-hsi",
                .data = &hsi_cmu_info,
index df7812371d709c6d09706ef59ef462d69e9a27b0..74934c6182cea93ac6d183554646295b82da7c52 100644 (file)
@@ -1259,8 +1259,7 @@ static const struct clk_ops samsung_pll2650xx_clk_min_ops = {
 };
 
 static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
-                               const struct samsung_pll_clock *pll_clk,
-                               void __iomem *base)
+                               const struct samsung_pll_clock *pll_clk)
 {
        struct samsung_clk_pll *pll;
        struct clk_init_data init;
@@ -1315,6 +1314,7 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
                        init.ops = &samsung_pll35xx_clk_ops;
                break;
        case pll_1417x:
+       case pll_0818x:
        case pll_0822x:
                pll->enable_offs = PLL0822X_ENABLE_SHIFT;
                pll->lock_offs = PLL0822X_LOCK_STAT_SHIFT;
@@ -1395,8 +1395,8 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
 
        pll->hw.init = &init;
        pll->type = pll_clk->type;
-       pll->lock_reg = base + pll_clk->lock_offset;
-       pll->con_reg = base + pll_clk->con_offset;
+       pll->lock_reg = ctx->reg_base + pll_clk->lock_offset;
+       pll->con_reg = ctx->reg_base + pll_clk->con_offset;
 
        ret = clk_hw_register(ctx->dev, &pll->hw);
        if (ret) {
@@ -1412,10 +1412,10 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
 
 void __init samsung_clk_register_pll(struct samsung_clk_provider *ctx,
                        const struct samsung_pll_clock *pll_list,
-                       unsigned int nr_pll, void __iomem *base)
+                       unsigned int nr_pll)
 {
        int cnt;
 
        for (cnt = 0; cnt < nr_pll; cnt++)
-               _samsung_clk_register_pll(ctx, &pll_list[cnt], base);
+               _samsung_clk_register_pll(ctx, &pll_list[cnt]);
 }
index 5d5a58d40e7e98a2e56e17b7f5f5cc9f51912aec..0725d485c6eecd692bce2261600da035746098ab 100644 (file)
@@ -34,6 +34,7 @@ enum samsung_pll_type {
        pll_1451x,
        pll_1452x,
        pll_1460x,
+       pll_0818x,
        pll_0822x,
        pll_0831x,
        pll_142xx,
index d6b432a26d6391d240c1d646e29af1fd5e5e601d..d27a1f73f077e31ff7a42d8dbdade6ab1f373fb1 100644 (file)
@@ -405,7 +405,7 @@ void __init s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f,
                        panic("%s: failed to map registers\n", __func__);
        }
 
-       ctx = samsung_clk_init(np, reg_base, NR_CLKS);
+       ctx = samsung_clk_init(NULL, reg_base, NR_CLKS);
        hws = ctx->clk_data.hws;
 
        /* Register external clocks. */
@@ -414,7 +414,7 @@ void __init s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f,
 
        /* Register PLLs. */
        samsung_clk_register_pll(ctx, s3c64xx_pll_clks,
-                               ARRAY_SIZE(s3c64xx_pll_clks), reg_base);
+                               ARRAY_SIZE(s3c64xx_pll_clks));
 
        /* Register common internal clocks. */
        samsung_clk_register_fixed_rate(ctx, s3c64xx_fixed_rate_clks,
index 4425186bdcab56512423575c61f7b02283a391a8..cd85342e4ddbe28538d9f30e88c490089adc5e2c 100644 (file)
@@ -743,7 +743,7 @@ static void __init __s5pv210_clk_init(struct device_node *np,
        struct samsung_clk_provider *ctx;
        struct clk_hw **hws;
 
-       ctx = samsung_clk_init(np, reg_base, NR_CLKS);
+       ctx = samsung_clk_init(NULL, reg_base, NR_CLKS);
        hws = ctx->clk_data.hws;
 
        samsung_clk_register_mux(ctx, early_mux_clks,
@@ -753,7 +753,7 @@ static void __init __s5pv210_clk_init(struct device_node *np,
                samsung_clk_register_fixed_rate(ctx, s5p6442_frate_clks,
                        ARRAY_SIZE(s5p6442_frate_clks));
                samsung_clk_register_pll(ctx, s5p6442_pll_clks,
-                       ARRAY_SIZE(s5p6442_pll_clks), reg_base);
+                       ARRAY_SIZE(s5p6442_pll_clks));
                samsung_clk_register_mux(ctx, s5p6442_mux_clks,
                                ARRAY_SIZE(s5p6442_mux_clks));
                samsung_clk_register_div(ctx, s5p6442_div_clks,
@@ -764,7 +764,7 @@ static void __init __s5pv210_clk_init(struct device_node *np,
                samsung_clk_register_fixed_rate(ctx, s5pv210_frate_clks,
                        ARRAY_SIZE(s5pv210_frate_clks));
                samsung_clk_register_pll(ctx, s5pv210_pll_clks,
-                       ARRAY_SIZE(s5pv210_pll_clks), reg_base);
+                       ARRAY_SIZE(s5pv210_pll_clks));
                samsung_clk_register_mux(ctx, s5pv210_mux_clks,
                                ARRAY_SIZE(s5pv210_mux_clks));
                samsung_clk_register_div(ctx, s5pv210_div_clks,
index bca4731b14ea59e9f1e5eb4cf118d9fcb49aaf63..b6701905f25461934d60173e43756d96ab44ea47 100644 (file)
@@ -53,8 +53,18 @@ struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump(
        return rd;
 }
 
-/* setup the essentials required to support clock lookup using ccf */
-struct samsung_clk_provider *__init samsung_clk_init(struct device_node *np,
+/**
+ * samsung_clk_init() - Create and initialize a clock provider object
+ * @dev:       CMU device to enable runtime PM, or NULL if RPM is not needed
+ * @base:      Start address (mapped) of CMU registers
+ * @nr_clks:   Total clock count to allocate in clock provider object
+ *
+ * Setup the essentials required to support clock lookup using Common Clock
+ * Framework.
+ *
+ * Return: Allocated and initialized clock provider object.
+ */
+struct samsung_clk_provider * __init samsung_clk_init(struct device *dev,
                        void __iomem *base, unsigned long nr_clks)
 {
        struct samsung_clk_provider *ctx;
@@ -67,6 +77,7 @@ struct samsung_clk_provider *__init samsung_clk_init(struct device_node *np,
        for (i = 0; i < nr_clks; ++i)
                ctx->clk_data.hws[i] = ERR_PTR(-ENOENT);
 
+       ctx->dev = dev;
        ctx->reg_base = base;
        ctx->clk_data.num = nr_clks;
        spin_lock_init(&ctx->lock);
@@ -324,6 +335,33 @@ void samsung_clk_extended_sleep_init(void __iomem *reg_base,
 }
 #endif
 
+/**
+ * samsung_cmu_register_clocks() - Register all clocks provided in CMU object
+ * @ctx: Clock provider object
+ * @cmu: CMU object with clocks to register
+ */
+void __init samsung_cmu_register_clocks(struct samsung_clk_provider *ctx,
+                                       const struct samsung_cmu_info *cmu)
+{
+       if (cmu->pll_clks)
+               samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks);
+       if (cmu->mux_clks)
+               samsung_clk_register_mux(ctx, cmu->mux_clks, cmu->nr_mux_clks);
+       if (cmu->div_clks)
+               samsung_clk_register_div(ctx, cmu->div_clks, cmu->nr_div_clks);
+       if (cmu->gate_clks)
+               samsung_clk_register_gate(ctx, cmu->gate_clks,
+                                         cmu->nr_gate_clks);
+       if (cmu->fixed_clks)
+               samsung_clk_register_fixed_rate(ctx, cmu->fixed_clks,
+                                               cmu->nr_fixed_clks);
+       if (cmu->fixed_factor_clks)
+               samsung_clk_register_fixed_factor(ctx, cmu->fixed_factor_clks,
+                                                 cmu->nr_fixed_factor_clks);
+       if (cmu->cpu_clks)
+               samsung_clk_register_cpu(ctx, cmu->cpu_clks, cmu->nr_cpu_clks);
+}
+
 /*
  * Common function which registers plls, muxes, dividers and gates
  * for each CMU. It also add CMU register list to register cache.
@@ -341,31 +379,13 @@ struct samsung_clk_provider * __init samsung_cmu_register_one(
                return NULL;
        }
 
-       ctx = samsung_clk_init(np, reg_base, cmu->nr_clk_ids);
+       ctx = samsung_clk_init(NULL, reg_base, cmu->nr_clk_ids);
+       samsung_cmu_register_clocks(ctx, cmu);
 
-       if (cmu->pll_clks)
-               samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks,
-                       reg_base);
-       if (cmu->mux_clks)
-               samsung_clk_register_mux(ctx, cmu->mux_clks,
-                       cmu->nr_mux_clks);
-       if (cmu->div_clks)
-               samsung_clk_register_div(ctx, cmu->div_clks, cmu->nr_div_clks);
-       if (cmu->gate_clks)
-               samsung_clk_register_gate(ctx, cmu->gate_clks,
-                       cmu->nr_gate_clks);
-       if (cmu->fixed_clks)
-               samsung_clk_register_fixed_rate(ctx, cmu->fixed_clks,
-                       cmu->nr_fixed_clks);
-       if (cmu->fixed_factor_clks)
-               samsung_clk_register_fixed_factor(ctx, cmu->fixed_factor_clks,
-                       cmu->nr_fixed_factor_clks);
        if (cmu->clk_regs)
                samsung_clk_extended_sleep_init(reg_base,
                        cmu->clk_regs, cmu->nr_clk_regs,
                        cmu->suspend_regs, cmu->nr_suspend_regs);
-       if (cmu->cpu_clks)
-               samsung_clk_register_cpu(ctx, cmu->cpu_clks, cmu->nr_cpu_clks);
 
        samsung_clk_of_add_provider(np, ctx);
 
index b46e83a2581f4e5b07ee34f08753d48fdfa64a6d..ab9c3d7a25b3d6514afda12a1cf722d44daf4df4 100644 (file)
@@ -16,6 +16,7 @@
 /**
  * struct samsung_clk_provider: information about clock provider
  * @reg_base: virtual address for the register base.
+ * @dev: clock provider device needed for runtime PM.
  * @lock: maintains exclusion between callbacks for a given clock-provider.
  * @clk_data: holds clock related data like clk_hw* and number of clocks.
  */
@@ -337,9 +338,8 @@ struct samsung_cmu_info {
        const char *clk_name;
 };
 
-struct samsung_clk_provider * samsung_clk_init(
-                       struct device_node *np, void __iomem *base,
-                       unsigned long nr_clks);
+struct samsung_clk_provider *samsung_clk_init(struct device *dev,
+                       void __iomem *base, unsigned long nr_clks);
 void samsung_clk_of_add_provider(struct device_node *np,
                        struct samsung_clk_provider *ctx);
 void samsung_clk_of_register_fixed_ext(
@@ -373,10 +373,12 @@ void samsung_clk_register_gate(struct samsung_clk_provider *ctx,
                        unsigned int nr_clk);
 void samsung_clk_register_pll(struct samsung_clk_provider *ctx,
                        const struct samsung_pll_clock *pll_list,
-                       unsigned int nr_clk, void __iomem *base);
+                       unsigned int nr_clk);
 void samsung_clk_register_cpu(struct samsung_clk_provider *ctx,
                const struct samsung_cpu_clock *list, unsigned int nr_clk);
 
+void samsung_cmu_register_clocks(struct samsung_clk_provider *ctx,
+                                const struct samsung_cmu_info *cmu);
 struct samsung_clk_provider *samsung_cmu_register_one(
                        struct device_node *,
                        const struct samsung_cmu_info *);
index b7fde0aadfcbb0359a4f0334307f99f388c64a85..2322f634a910e9da09f3e4082d0c7c497158ea03 100644 (file)
@@ -2,8 +2,8 @@
 
 menuconfig CLK_SIFIVE
        bool "SiFive SoC driver support"
-       depends on SOC_SIFIVE || COMPILE_TEST
-       default SOC_SIFIVE
+       depends on ARCH_SIFIVE || COMPILE_TEST
+       default ARCH_SIFIVE
        help
          SoC drivers for SiFive Linux-capable SoCs.
 
@@ -11,7 +11,7 @@ if CLK_SIFIVE
 
 config CLK_SIFIVE_PRCI
        bool "PRCI driver for SiFive SoCs"
-       default SOC_SIFIVE
+       default ARCH_SIFIVE
        select RESET_CONTROLLER
        select RESET_SIMPLE
        select CLK_ANALOGBITS_WRPLL_CLN28HPC
index 7cdf2f07c79bf7a59b4221c6ea48135cb90b09d0..06f129c160bcfba5c64be0f10353359fac54cd95 100644 (file)
@@ -40,7 +40,7 @@ static struct clk_ops gateclk_ops = {
 };
 
 static void __init __socfpga_gate_init(struct device_node *node,
-       const struct clk_ops *ops)
+                                      const struct clk_ops *ops)
 {
        u32 clk_gate[2];
        u32 div_reg[3];
@@ -94,13 +94,25 @@ static void __init __socfpga_gate_init(struct device_node *node,
        socfpga_clk->hw.hw.init = &init;
        hw_clk = &socfpga_clk->hw.hw;
 
-       if (clk_hw_register(NULL, hw_clk)) {
-               kfree(socfpga_clk);
-               return;
+       rc = clk_hw_register(NULL, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock:%s\n", clk_name);
+               goto err_clk_hw_register;
        }
-       rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
-       if (WARN_ON(rc))
-               return;
+
+       rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock provider for node:%s\n",
+                      clk_name);
+               goto err_of_clk_add_hw_provider;
+       }
+
+       return;
+
+err_of_clk_add_hw_provider:
+       clk_hw_unregister(hw_clk);
+err_clk_hw_register:
+       kfree(socfpga_clk);
 }
 
 void __init socfpga_a10_gate_init(struct device_node *node)
index 0c18c55edf8cebc40751b65c68536c309e2a7f93..32ccda960f280c3b421c65802c753521e2419386 100644 (file)
@@ -126,17 +126,14 @@ void __init socfpga_gate_init(struct device_node *node)
        struct clk_init_data init;
        struct clk_ops *ops;
        int rc;
-       int err;
 
        socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
        if (WARN_ON(!socfpga_clk))
                return;
 
        ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL);
-       if (WARN_ON(!ops)) {
-               kfree(socfpga_clk);
-               return;
-       }
+       if (WARN_ON(!ops))
+               goto err_kmemdup;
 
        rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2);
        if (rc)
@@ -182,13 +179,25 @@ void __init socfpga_gate_init(struct device_node *node)
 
        hw_clk = &socfpga_clk->hw.hw;
 
-       err = clk_hw_register(NULL, hw_clk);
-       if (err) {
-               kfree(ops);
-               kfree(socfpga_clk);
-               return;
+       rc = clk_hw_register(NULL, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock:%s\n", clk_name);
+               goto err_clk_hw_register;
        }
-       rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
-       if (WARN_ON(rc))
-               return;
+
+       rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock provider for node:%s\n",
+                      clk_name);
+               goto err_of_clk_add_hw_provider;
+       }
+
+       return;
+
+err_of_clk_add_hw_provider:
+       clk_hw_unregister(hw_clk);
+err_clk_hw_register:
+       kfree(ops);
+err_kmemdup:
+       kfree(socfpga_clk);
 }
index b9cdde4b8441e4730d59f13df23243233a6953f9..64cc70b970b729e705b76e08822fdaaa0f982fed 100644 (file)
@@ -57,8 +57,8 @@ static const struct clk_ops periclk_ops = {
        .get_parent = clk_periclk_get_parent,
 };
 
-static __init void __socfpga_periph_init(struct device_node *node,
-       const struct clk_ops *ops)
+static void __init __socfpga_periph_init(struct device_node *node,
+                                        const struct clk_ops *ops)
 {
        u32 reg;
        struct clk_hw *hw_clk;
@@ -106,21 +106,25 @@ static __init void __socfpga_periph_init(struct device_node *node,
 
        hw_clk = &periph_clk->hw.hw;
 
-       if (clk_hw_register(NULL, hw_clk)) {
-               kfree(periph_clk);
-               return;
+       rc = clk_hw_register(NULL, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock:%s\n", clk_name);
+               goto err_clk_hw_register;
        }
-       rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
-       if (rc < 0) {
+
+       rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
+       if (rc) {
                pr_err("Could not register clock provider for node:%s\n",
                       clk_name);
-               goto err_clk;
+               goto err_of_clk_add_hw_provider;
        }
 
        return;
 
-err_clk:
+err_of_clk_add_hw_provider:
        clk_hw_unregister(hw_clk);
+err_clk_hw_register:
+       kfree(periph_clk);
 }
 
 void __init socfpga_a10_periph_init(struct device_node *node)
index 43707e2d724840dfaabc0473d25f9c1c3843b32f..6a4075147b9c13e66371b6cdebf031c07deea7c6 100644 (file)
@@ -47,8 +47,8 @@ static const struct clk_ops periclk_ops = {
        .get_parent = clk_periclk_get_parent,
 };
 
-static __init void __socfpga_periph_init(struct device_node *node,
-       const struct clk_ops *ops)
+static void __init __socfpga_periph_init(struct device_node *node,
+                                        const struct clk_ops *ops)
 {
        u32 reg;
        struct clk_hw *hw_clk;
@@ -96,11 +96,25 @@ static __init void __socfpga_periph_init(struct device_node *node,
        periph_clk->hw.hw.init = &init;
        hw_clk = &periph_clk->hw.hw;
 
-       if (clk_hw_register(NULL, hw_clk)) {
-               kfree(periph_clk);
-               return;
+       rc = clk_hw_register(NULL, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock:%s\n", clk_name);
+               goto err_clk_hw_register;
+       }
+
+       rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock provider for node:%s\n",
+                      clk_name);
+               goto err_of_clk_add_hw_provider;
        }
-       rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
+
+       return;
+
+err_of_clk_add_hw_provider:
+       clk_hw_unregister(hw_clk);
+err_clk_hw_register:
+       kfree(periph_clk);
 }
 
 void __init socfpga_periph_init(struct device_node *node)
index bee0f7da5b6eece8ce973339aee5d721e7555fc2..b028f25c658aabd5d87c9d1755d9a5ef6971a077 100644 (file)
@@ -63,8 +63,8 @@ static const struct clk_ops clk_pll_ops = {
        .get_parent = clk_pll_get_parent,
 };
 
-static struct clk_hw * __init __socfpga_pll_init(struct device_node *node,
-       const struct clk_ops *ops)
+static void __init __socfpga_pll_init(struct device_node *node,
+                                     const struct clk_ops *ops)
 {
        u32 reg;
        struct clk_hw *hw_clk;
@@ -73,13 +73,14 @@ static struct clk_hw * __init __socfpga_pll_init(struct device_node *node,
        const char *parent_name[SOCFGPA_MAX_PARENTS];
        struct clk_init_data init;
        struct device_node *clkmgr_np;
+       int rc;
        int i = 0;
 
        of_property_read_u32(node, "reg", &reg);
 
        pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL);
        if (WARN_ON(!pll_clk))
-               return NULL;
+               return;
 
        clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr");
        clk_mgr_a10_base_addr = of_iomap(clkmgr_np, 0);
@@ -103,12 +104,25 @@ static struct clk_hw * __init __socfpga_pll_init(struct device_node *node,
        pll_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
        hw_clk = &pll_clk->hw.hw;
 
-       if (clk_hw_register(NULL, hw_clk)) {
-               kfree(pll_clk);
-               return NULL;
+       rc = clk_hw_register(NULL, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock:%s\n", clk_name);
+               goto err_clk_hw_register;
        }
-       of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
-       return hw_clk;
+
+       rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock provider for node:%s\n",
+                      clk_name);
+               goto err_of_clk_add_hw_provider;
+       }
+
+       return;
+
+err_of_clk_add_hw_provider:
+       clk_hw_unregister(hw_clk);
+err_clk_hw_register:
+       kfree(pll_clk);
 }
 
 void __init socfpga_a10_pll_init(struct device_node *node)
index 127cc849c5eeaf44bb897356f97db4187d79ed6f..9dcc1b2d2cc0b9d0b515e97368bfbc4f47718cc3 100644 (file)
@@ -70,8 +70,8 @@ static const struct clk_ops clk_pll_ops = {
        .get_parent = clk_pll_get_parent,
 };
 
-static __init struct clk_hw *__socfpga_pll_init(struct device_node *node,
-       const struct clk_ops *ops)
+static void __init __socfpga_pll_init(struct device_node *node,
+                                     const struct clk_ops *ops)
 {
        u32 reg;
        struct clk_hw *hw_clk;
@@ -80,13 +80,13 @@ static __init struct clk_hw *__socfpga_pll_init(struct device_node *node,
        const char *parent_name[SOCFPGA_MAX_PARENTS];
        struct clk_init_data init;
        struct device_node *clkmgr_np;
-       int err;
+       int rc;
 
        of_property_read_u32(node, "reg", &reg);
 
        pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL);
        if (WARN_ON(!pll_clk))
-               return NULL;
+               return;
 
        clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr");
        clk_mgr_base_addr = of_iomap(clkmgr_np, 0);
@@ -108,13 +108,25 @@ static __init struct clk_hw *__socfpga_pll_init(struct device_node *node,
 
        hw_clk = &pll_clk->hw.hw;
 
-       err = clk_hw_register(NULL, hw_clk);
-       if (err) {
-               kfree(pll_clk);
-               return ERR_PTR(err);
+       rc = clk_hw_register(NULL, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock:%s\n", clk_name);
+               goto err_clk_hw_register;
        }
-       of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
-       return hw_clk;
+
+       rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
+       if (rc) {
+               pr_err("Could not register clock provider for node:%s\n",
+                      clk_name);
+               goto err_of_clk_add_hw_provider;
+       }
+
+       return;
+
+err_of_clk_add_hw_provider:
+       clk_hw_unregister(hw_clk);
+err_clk_hw_register:
+       kfree(pll_clk);
 }
 
 void __init socfpga_pll_init(struct device_node *node)
index ce81e4087a8fce2e8d2239e6d706de7f33b24c7d..1a3795a61f81d35c6ab92d2c8f0101eddafedde2 100644 (file)
@@ -44,7 +44,7 @@ int sprd_clk_regmap_init(struct platform_device *pdev,
        struct device_node *node = dev->of_node, *np;
        struct regmap *regmap;
 
-       if (of_find_property(node, "sprd,syscon", NULL)) {
+       if (of_property_present(node, "sprd,syscon")) {
                regmap = syscon_regmap_lookup_by_phandle(node, "sprd,syscon");
                if (IS_ERR(regmap)) {
                        pr_err("%s: failed to get syscon regmap\n", __func__);
index 003bd2d56ce7eaa47f28a92eda7b49e86d3c96d9..71c1148ee5f66fc4d5b63cd803fe2f1135051068 100644 (file)
@@ -1,9 +1,13 @@
 # SPDX-License-Identifier: GPL-2.0
 
+config CLK_STARFIVE_JH71X0
+       bool
+
 config CLK_STARFIVE_JH7100
        bool "StarFive JH7100 clock support"
-       depends on SOC_STARFIVE || COMPILE_TEST
-       default SOC_STARFIVE
+       depends on ARCH_STARFIVE || COMPILE_TEST
+       select CLK_STARFIVE_JH71X0
+       default ARCH_STARFIVE
        help
          Say yes here to support the clock controller on the StarFive JH7100
          SoC.
@@ -11,7 +15,30 @@ config CLK_STARFIVE_JH7100
 config CLK_STARFIVE_JH7100_AUDIO
        tristate "StarFive JH7100 audio clock support"
        depends on CLK_STARFIVE_JH7100
-       default m if SOC_STARFIVE
+       select CLK_STARFIVE_JH71X0
+       default m if ARCH_STARFIVE
        help
          Say Y or M here to support the audio clocks on the StarFive JH7100
          SoC.
+
+config CLK_STARFIVE_JH7110_SYS
+       bool "StarFive JH7110 system clock support"
+       depends on ARCH_STARFIVE || COMPILE_TEST
+       select AUXILIARY_BUS
+       select CLK_STARFIVE_JH71X0
+       select RESET_STARFIVE_JH7110
+       default ARCH_STARFIVE
+       help
+         Say yes here to support the system clock controller on the
+         StarFive JH7110 SoC.
+
+config CLK_STARFIVE_JH7110_AON
+       tristate "StarFive JH7110 always-on clock support"
+       depends on CLK_STARFIVE_JH7110_SYS
+       select AUXILIARY_BUS
+       select CLK_STARFIVE_JH71X0
+       select RESET_STARFIVE_JH7110
+       default m if ARCH_STARFIVE
+       help
+         Say yes here to support the always-on clock controller on the
+         StarFive JH7110 SoC.
index 0fa8ecb9ec1c6116b383886715043299b1431eea..f3df7d957b1e5c66e24d53245703e33dbe6d81a3 100644 (file)
@@ -1,4 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
-# StarFive Clock
+obj-$(CONFIG_CLK_STARFIVE_JH71X0)      += clk-starfive-jh71x0.o
+
 obj-$(CONFIG_CLK_STARFIVE_JH7100)      += clk-starfive-jh7100.o
 obj-$(CONFIG_CLK_STARFIVE_JH7100_AUDIO)        += clk-starfive-jh7100-audio.o
+
+obj-$(CONFIG_CLK_STARFIVE_JH7110_SYS)  += clk-starfive-jh7110-sys.o
+obj-$(CONFIG_CLK_STARFIVE_JH7110_AON)  += clk-starfive-jh7110-aon.o
index 8473a65e219be732f8f2c6e9d67149ed2f4d03ae..02aefb7264f8f3164870fffdb1ab4b737fba8ba3 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <dt-bindings/clock/starfive-jh7100-audio.h>
 
-#include "clk-starfive-jh7100.h"
+#include "clk-starfive-jh71x0.h"
 
 /* external clocks */
 #define JH7100_AUDCLK_AUDIO_SRC                        (JH7100_AUDCLK_END + 0)
 #define JH7100_AUDCLK_I2SDAC_LRCLK_IOPAD       (JH7100_AUDCLK_END + 6)
 #define JH7100_AUDCLK_VAD_INTMEM                (JH7100_AUDCLK_END + 7)
 
-static const struct jh7100_clk_data jh7100_audclk_data[] = {
-       JH7100__GMD(JH7100_AUDCLK_ADC_MCLK, "adc_mclk", 0, 15, 2,
+static const struct jh71x0_clk_data jh7100_audclk_data[] = {
+       JH71X0__GMD(JH7100_AUDCLK_ADC_MCLK, "adc_mclk", 0, 15, 2,
                    JH7100_AUDCLK_AUDIO_SRC,
                    JH7100_AUDCLK_AUDIO_12288),
-       JH7100__GMD(JH7100_AUDCLK_I2S1_MCLK, "i2s1_mclk", 0, 15, 2,
+       JH71X0__GMD(JH7100_AUDCLK_I2S1_MCLK, "i2s1_mclk", 0, 15, 2,
                    JH7100_AUDCLK_AUDIO_SRC,
                    JH7100_AUDCLK_AUDIO_12288),
-       JH7100_GATE(JH7100_AUDCLK_I2SADC_APB, "i2sadc_apb", 0, JH7100_AUDCLK_APB0_BUS),
-       JH7100_MDIV(JH7100_AUDCLK_I2SADC_BCLK, "i2sadc_bclk", 31, 2,
+       JH71X0_GATE(JH7100_AUDCLK_I2SADC_APB, "i2sadc_apb", 0, JH7100_AUDCLK_APB0_BUS),
+       JH71X0_MDIV(JH7100_AUDCLK_I2SADC_BCLK, "i2sadc_bclk", 31, 2,
                    JH7100_AUDCLK_ADC_MCLK,
                    JH7100_AUDCLK_I2SADC_BCLK_IOPAD),
-       JH7100__INV(JH7100_AUDCLK_I2SADC_BCLK_N, "i2sadc_bclk_n", JH7100_AUDCLK_I2SADC_BCLK),
-       JH7100_MDIV(JH7100_AUDCLK_I2SADC_LRCLK, "i2sadc_lrclk", 63, 3,
+       JH71X0__INV(JH7100_AUDCLK_I2SADC_BCLK_N, "i2sadc_bclk_n", JH7100_AUDCLK_I2SADC_BCLK),
+       JH71X0_MDIV(JH7100_AUDCLK_I2SADC_LRCLK, "i2sadc_lrclk", 63, 3,
                    JH7100_AUDCLK_I2SADC_BCLK_N,
                    JH7100_AUDCLK_I2SADC_LRCLK_IOPAD,
                    JH7100_AUDCLK_I2SADC_BCLK),
-       JH7100_GATE(JH7100_AUDCLK_PDM_APB, "pdm_apb", 0, JH7100_AUDCLK_APB0_BUS),
-       JH7100__GMD(JH7100_AUDCLK_PDM_MCLK, "pdm_mclk", 0, 15, 2,
+       JH71X0_GATE(JH7100_AUDCLK_PDM_APB, "pdm_apb", 0, JH7100_AUDCLK_APB0_BUS),
+       JH71X0__GMD(JH7100_AUDCLK_PDM_MCLK, "pdm_mclk", 0, 15, 2,
                    JH7100_AUDCLK_AUDIO_SRC,
                    JH7100_AUDCLK_AUDIO_12288),
-       JH7100_GATE(JH7100_AUDCLK_I2SVAD_APB, "i2svad_apb", 0, JH7100_AUDCLK_APB0_BUS),
-       JH7100__GMD(JH7100_AUDCLK_SPDIF, "spdif", 0, 15, 2,
+       JH71X0_GATE(JH7100_AUDCLK_I2SVAD_APB, "i2svad_apb", 0, JH7100_AUDCLK_APB0_BUS),
+       JH71X0__GMD(JH7100_AUDCLK_SPDIF, "spdif", 0, 15, 2,
                    JH7100_AUDCLK_AUDIO_SRC,
                    JH7100_AUDCLK_AUDIO_12288),
-       JH7100_GATE(JH7100_AUDCLK_SPDIF_APB, "spdif_apb", 0, JH7100_AUDCLK_APB0_BUS),
-       JH7100_GATE(JH7100_AUDCLK_PWMDAC_APB, "pwmdac_apb", 0, JH7100_AUDCLK_APB0_BUS),
-       JH7100__GMD(JH7100_AUDCLK_DAC_MCLK, "dac_mclk", 0, 15, 2,
+       JH71X0_GATE(JH7100_AUDCLK_SPDIF_APB, "spdif_apb", 0, JH7100_AUDCLK_APB0_BUS),
+       JH71X0_GATE(JH7100_AUDCLK_PWMDAC_APB, "pwmdac_apb", 0, JH7100_AUDCLK_APB0_BUS),
+       JH71X0__GMD(JH7100_AUDCLK_DAC_MCLK, "dac_mclk", 0, 15, 2,
                    JH7100_AUDCLK_AUDIO_SRC,
                    JH7100_AUDCLK_AUDIO_12288),
-       JH7100_GATE(JH7100_AUDCLK_I2SDAC_APB, "i2sdac_apb", 0, JH7100_AUDCLK_APB0_BUS),
-       JH7100_MDIV(JH7100_AUDCLK_I2SDAC_BCLK, "i2sdac_bclk", 31, 2,
+       JH71X0_GATE(JH7100_AUDCLK_I2SDAC_APB, "i2sdac_apb", 0, JH7100_AUDCLK_APB0_BUS),
+       JH71X0_MDIV(JH7100_AUDCLK_I2SDAC_BCLK, "i2sdac_bclk", 31, 2,
                    JH7100_AUDCLK_DAC_MCLK,
                    JH7100_AUDCLK_I2SDAC_BCLK_IOPAD),
-       JH7100__INV(JH7100_AUDCLK_I2SDAC_BCLK_N, "i2sdac_bclk_n", JH7100_AUDCLK_I2SDAC_BCLK),
-       JH7100_MDIV(JH7100_AUDCLK_I2SDAC_LRCLK, "i2sdac_lrclk", 31, 2,
+       JH71X0__INV(JH7100_AUDCLK_I2SDAC_BCLK_N, "i2sdac_bclk_n", JH7100_AUDCLK_I2SDAC_BCLK),
+       JH71X0_MDIV(JH7100_AUDCLK_I2SDAC_LRCLK, "i2sdac_lrclk", 31, 2,
                    JH7100_AUDCLK_I2S1_MCLK,
                    JH7100_AUDCLK_I2SDAC_BCLK_IOPAD),
-       JH7100_GATE(JH7100_AUDCLK_I2S1_APB, "i2s1_apb", 0, JH7100_AUDCLK_APB0_BUS),
-       JH7100_MDIV(JH7100_AUDCLK_I2S1_BCLK, "i2s1_bclk", 31, 2,
+       JH71X0_GATE(JH7100_AUDCLK_I2S1_APB, "i2s1_apb", 0, JH7100_AUDCLK_APB0_BUS),
+       JH71X0_MDIV(JH7100_AUDCLK_I2S1_BCLK, "i2s1_bclk", 31, 2,
                    JH7100_AUDCLK_I2S1_MCLK,
                    JH7100_AUDCLK_I2SDAC_BCLK_IOPAD),
-       JH7100__INV(JH7100_AUDCLK_I2S1_BCLK_N, "i2s1_bclk_n", JH7100_AUDCLK_I2S1_BCLK),
-       JH7100_MDIV(JH7100_AUDCLK_I2S1_LRCLK, "i2s1_lrclk", 63, 3,
+       JH71X0__INV(JH7100_AUDCLK_I2S1_BCLK_N, "i2s1_bclk_n", JH7100_AUDCLK_I2S1_BCLK),
+       JH71X0_MDIV(JH7100_AUDCLK_I2S1_LRCLK, "i2s1_lrclk", 63, 3,
                    JH7100_AUDCLK_I2S1_BCLK_N,
                    JH7100_AUDCLK_I2SDAC_LRCLK_IOPAD),
-       JH7100_GATE(JH7100_AUDCLK_I2SDAC16K_APB, "i2s1dac16k_apb", 0, JH7100_AUDCLK_APB0_BUS),
-       JH7100__DIV(JH7100_AUDCLK_APB0_BUS, "apb0_bus", 8, JH7100_AUDCLK_DOM7AHB_BUS),
-       JH7100_GATE(JH7100_AUDCLK_DMA1P_AHB, "dma1p_ahb", 0, JH7100_AUDCLK_DOM7AHB_BUS),
-       JH7100_GATE(JH7100_AUDCLK_USB_APB, "usb_apb", CLK_IGNORE_UNUSED, JH7100_AUDCLK_APB_EN),
-       JH7100_GDIV(JH7100_AUDCLK_USB_LPM, "usb_lpm", CLK_IGNORE_UNUSED, 4, JH7100_AUDCLK_USB_APB),
-       JH7100_GDIV(JH7100_AUDCLK_USB_STB, "usb_stb", CLK_IGNORE_UNUSED, 3, JH7100_AUDCLK_USB_APB),
-       JH7100__DIV(JH7100_AUDCLK_APB_EN, "apb_en", 8, JH7100_AUDCLK_DOM7AHB_BUS),
-       JH7100__MUX(JH7100_AUDCLK_VAD_MEM, "vad_mem", 2,
+       JH71X0_GATE(JH7100_AUDCLK_I2SDAC16K_APB, "i2s1dac16k_apb", 0, JH7100_AUDCLK_APB0_BUS),
+       JH71X0__DIV(JH7100_AUDCLK_APB0_BUS, "apb0_bus", 8, JH7100_AUDCLK_DOM7AHB_BUS),
+       JH71X0_GATE(JH7100_AUDCLK_DMA1P_AHB, "dma1p_ahb", 0, JH7100_AUDCLK_DOM7AHB_BUS),
+       JH71X0_GATE(JH7100_AUDCLK_USB_APB, "usb_apb", CLK_IGNORE_UNUSED, JH7100_AUDCLK_APB_EN),
+       JH71X0_GDIV(JH7100_AUDCLK_USB_LPM, "usb_lpm", CLK_IGNORE_UNUSED, 4, JH7100_AUDCLK_USB_APB),
+       JH71X0_GDIV(JH7100_AUDCLK_USB_STB, "usb_stb", CLK_IGNORE_UNUSED, 3, JH7100_AUDCLK_USB_APB),
+       JH71X0__DIV(JH7100_AUDCLK_APB_EN, "apb_en", 8, JH7100_AUDCLK_DOM7AHB_BUS),
+       JH71X0__MUX(JH7100_AUDCLK_VAD_MEM, "vad_mem", 2,
                    JH7100_AUDCLK_VAD_INTMEM,
                    JH7100_AUDCLK_AUDIO_12288),
 };
 
 static struct clk_hw *jh7100_audclk_get(struct of_phandle_args *clkspec, void *data)
 {
-       struct jh7100_clk_priv *priv = data;
+       struct jh71x0_clk_priv *priv = data;
        unsigned int idx = clkspec->args[0];
 
        if (idx < JH7100_AUDCLK_END)
@@ -98,7 +98,7 @@ static struct clk_hw *jh7100_audclk_get(struct of_phandle_args *clkspec, void *d
 
 static int jh7100_audclk_probe(struct platform_device *pdev)
 {
-       struct jh7100_clk_priv *priv;
+       struct jh71x0_clk_priv *priv;
        unsigned int idx;
        int ret;
 
@@ -117,12 +117,12 @@ static int jh7100_audclk_probe(struct platform_device *pdev)
                struct clk_parent_data parents[4] = {};
                struct clk_init_data init = {
                        .name = jh7100_audclk_data[idx].name,
-                       .ops = starfive_jh7100_clk_ops(max),
+                       .ops = starfive_jh71x0_clk_ops(max),
                        .parent_data = parents,
-                       .num_parents = ((max & JH7100_CLK_MUX_MASK) >> JH7100_CLK_MUX_SHIFT) + 1,
+                       .num_parents = ((max & JH71X0_CLK_MUX_MASK) >> JH71X0_CLK_MUX_SHIFT) + 1,
                        .flags = jh7100_audclk_data[idx].flags,
                };
-               struct jh7100_clk *clk = &priv->reg[idx];
+               struct jh71x0_clk *clk = &priv->reg[idx];
                unsigned int i;
 
                for (i = 0; i < init.num_parents; i++) {
@@ -140,7 +140,7 @@ static int jh7100_audclk_probe(struct platform_device *pdev)
 
                clk->hw.init = &init;
                clk->idx = idx;
-               clk->max_div = max & JH7100_CLK_DIV_MASK;
+               clk->max_div = max & JH71X0_CLK_DIV_MASK;
 
                ret = devm_clk_hw_register(priv->dev, &clk->hw);
                if (ret)
index 691aeebc709278eff145ed07cbeffdbb70d10704..69cc11ea7e334144fee1cbad744a5abc1425ccd1 100644 (file)
@@ -7,20 +7,15 @@
  * Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>
  */
 
-#include <linux/bits.h>
 #include <linux/clk-provider.h>
-#include <linux/debugfs.h>
 #include <linux/device.h>
 #include <linux/init.h>
-#include <linux/io.h>
-#include <linux/kernel.h>
 #include <linux/mod_devicetable.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
 
 #include <dt-bindings/clock/starfive-jh7100.h>
 
-#include "clk-starfive-jh7100.h"
+#include "clk-starfive-jh71x0.h"
 
 /* external clocks */
 #define JH7100_CLK_OSC_SYS             (JH7100_CLK_END + 0)
 #define JH7100_CLK_GMAC_RMII_REF       (JH7100_CLK_END + 2)
 #define JH7100_CLK_GMAC_GR_MII_RX      (JH7100_CLK_END + 3)
 
-static const struct jh7100_clk_data jh7100_clk_data[] __initconst = {
-       JH7100__MUX(JH7100_CLK_CPUNDBUS_ROOT, "cpundbus_root", 4,
+static const struct jh71x0_clk_data jh7100_clk_data[] __initconst = {
+       JH71X0__MUX(JH7100_CLK_CPUNDBUS_ROOT, "cpundbus_root", 4,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_PLL0_OUT,
                    JH7100_CLK_PLL1_OUT,
                    JH7100_CLK_PLL2_OUT),
-       JH7100__MUX(JH7100_CLK_DLA_ROOT, "dla_root", 3,
+       JH71X0__MUX(JH7100_CLK_DLA_ROOT, "dla_root", 3,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_PLL1_OUT,
                    JH7100_CLK_PLL2_OUT),
-       JH7100__MUX(JH7100_CLK_DSP_ROOT, "dsp_root", 4,
+       JH71X0__MUX(JH7100_CLK_DSP_ROOT, "dsp_root", 4,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_PLL0_OUT,
                    JH7100_CLK_PLL1_OUT,
                    JH7100_CLK_PLL2_OUT),
-       JH7100__MUX(JH7100_CLK_GMACUSB_ROOT, "gmacusb_root", 3,
+       JH71X0__MUX(JH7100_CLK_GMACUSB_ROOT, "gmacusb_root", 3,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_PLL0_OUT,
                    JH7100_CLK_PLL2_OUT),
-       JH7100__MUX(JH7100_CLK_PERH0_ROOT, "perh0_root", 2,
+       JH71X0__MUX(JH7100_CLK_PERH0_ROOT, "perh0_root", 2,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_PLL0_OUT),
-       JH7100__MUX(JH7100_CLK_PERH1_ROOT, "perh1_root", 2,
+       JH71X0__MUX(JH7100_CLK_PERH1_ROOT, "perh1_root", 2,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_PLL2_OUT),
-       JH7100__MUX(JH7100_CLK_VIN_ROOT, "vin_root", 3,
+       JH71X0__MUX(JH7100_CLK_VIN_ROOT, "vin_root", 3,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_PLL1_OUT,
                    JH7100_CLK_PLL2_OUT),
-       JH7100__MUX(JH7100_CLK_VOUT_ROOT, "vout_root", 3,
+       JH71X0__MUX(JH7100_CLK_VOUT_ROOT, "vout_root", 3,
                    JH7100_CLK_OSC_AUD,
                    JH7100_CLK_PLL0_OUT,
                    JH7100_CLK_PLL2_OUT),
-       JH7100_GDIV(JH7100_CLK_AUDIO_ROOT, "audio_root", 0, 8, JH7100_CLK_PLL0_OUT),
-       JH7100__MUX(JH7100_CLK_CDECHIFI4_ROOT, "cdechifi4_root", 3,
+       JH71X0_GDIV(JH7100_CLK_AUDIO_ROOT, "audio_root", 0, 8, JH7100_CLK_PLL0_OUT),
+       JH71X0__MUX(JH7100_CLK_CDECHIFI4_ROOT, "cdechifi4_root", 3,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_PLL1_OUT,
                    JH7100_CLK_PLL2_OUT),
-       JH7100__MUX(JH7100_CLK_CDEC_ROOT, "cdec_root", 3,
+       JH71X0__MUX(JH7100_CLK_CDEC_ROOT, "cdec_root", 3,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_PLL0_OUT,
                    JH7100_CLK_PLL1_OUT),
-       JH7100__MUX(JH7100_CLK_VOUTBUS_ROOT, "voutbus_root", 3,
+       JH71X0__MUX(JH7100_CLK_VOUTBUS_ROOT, "voutbus_root", 3,
                    JH7100_CLK_OSC_AUD,
                    JH7100_CLK_PLL0_OUT,
                    JH7100_CLK_PLL2_OUT),
-       JH7100__DIV(JH7100_CLK_CPUNBUS_ROOT_DIV, "cpunbus_root_div", 2, JH7100_CLK_CPUNDBUS_ROOT),
-       JH7100__DIV(JH7100_CLK_DSP_ROOT_DIV, "dsp_root_div", 4, JH7100_CLK_DSP_ROOT),
-       JH7100__DIV(JH7100_CLK_PERH0_SRC, "perh0_src", 4, JH7100_CLK_PERH0_ROOT),
-       JH7100__DIV(JH7100_CLK_PERH1_SRC, "perh1_src", 4, JH7100_CLK_PERH1_ROOT),
-       JH7100_GDIV(JH7100_CLK_PLL0_TESTOUT, "pll0_testout", 0, 31, JH7100_CLK_PERH0_SRC),
-       JH7100_GDIV(JH7100_CLK_PLL1_TESTOUT, "pll1_testout", 0, 31, JH7100_CLK_DLA_ROOT),
-       JH7100_GDIV(JH7100_CLK_PLL2_TESTOUT, "pll2_testout", 0, 31, JH7100_CLK_PERH1_SRC),
-       JH7100__MUX(JH7100_CLK_PLL2_REF, "pll2_refclk", 2,
+       JH71X0__DIV(JH7100_CLK_CPUNBUS_ROOT_DIV, "cpunbus_root_div", 2, JH7100_CLK_CPUNDBUS_ROOT),
+       JH71X0__DIV(JH7100_CLK_DSP_ROOT_DIV, "dsp_root_div", 4, JH7100_CLK_DSP_ROOT),
+       JH71X0__DIV(JH7100_CLK_PERH0_SRC, "perh0_src", 4, JH7100_CLK_PERH0_ROOT),
+       JH71X0__DIV(JH7100_CLK_PERH1_SRC, "perh1_src", 4, JH7100_CLK_PERH1_ROOT),
+       JH71X0_GDIV(JH7100_CLK_PLL0_TESTOUT, "pll0_testout", 0, 31, JH7100_CLK_PERH0_SRC),
+       JH71X0_GDIV(JH7100_CLK_PLL1_TESTOUT, "pll1_testout", 0, 31, JH7100_CLK_DLA_ROOT),
+       JH71X0_GDIV(JH7100_CLK_PLL2_TESTOUT, "pll2_testout", 0, 31, JH7100_CLK_PERH1_SRC),
+       JH71X0__MUX(JH7100_CLK_PLL2_REF, "pll2_refclk", 2,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_OSC_AUD),
-       JH7100__DIV(JH7100_CLK_CPU_CORE, "cpu_core", 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
-       JH7100__DIV(JH7100_CLK_CPU_AXI, "cpu_axi", 8, JH7100_CLK_CPU_CORE),
-       JH7100__DIV(JH7100_CLK_AHB_BUS, "ahb_bus", 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
-       JH7100__DIV(JH7100_CLK_APB1_BUS, "apb1_bus", 8, JH7100_CLK_AHB_BUS),
-       JH7100__DIV(JH7100_CLK_APB2_BUS, "apb2_bus", 8, JH7100_CLK_AHB_BUS),
-       JH7100_GATE(JH7100_CLK_DOM3AHB_BUS, "dom3ahb_bus", CLK_IS_CRITICAL, JH7100_CLK_AHB_BUS),
-       JH7100_GATE(JH7100_CLK_DOM7AHB_BUS, "dom7ahb_bus", CLK_IS_CRITICAL, JH7100_CLK_AHB_BUS),
-       JH7100_GATE(JH7100_CLK_U74_CORE0, "u74_core0", CLK_IS_CRITICAL, JH7100_CLK_CPU_CORE),
-       JH7100_GDIV(JH7100_CLK_U74_CORE1, "u74_core1", CLK_IS_CRITICAL, 8, JH7100_CLK_CPU_CORE),
-       JH7100_GATE(JH7100_CLK_U74_AXI, "u74_axi", CLK_IS_CRITICAL, JH7100_CLK_CPU_AXI),
-       JH7100_GATE(JH7100_CLK_U74RTC_TOGGLE, "u74rtc_toggle", CLK_IS_CRITICAL, JH7100_CLK_OSC_SYS),
-       JH7100_GATE(JH7100_CLK_SGDMA2P_AXI, "sgdma2p_axi", 0, JH7100_CLK_CPU_AXI),
-       JH7100_GATE(JH7100_CLK_DMA2PNOC_AXI, "dma2pnoc_axi", 0, JH7100_CLK_CPU_AXI),
-       JH7100_GATE(JH7100_CLK_SGDMA2P_AHB, "sgdma2p_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100__DIV(JH7100_CLK_DLA_BUS, "dla_bus", 4, JH7100_CLK_DLA_ROOT),
-       JH7100_GATE(JH7100_CLK_DLA_AXI, "dla_axi", 0, JH7100_CLK_DLA_BUS),
-       JH7100_GATE(JH7100_CLK_DLANOC_AXI, "dlanoc_axi", 0, JH7100_CLK_DLA_BUS),
-       JH7100_GATE(JH7100_CLK_DLA_APB, "dla_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_VP6_CORE, "vp6_core", 0, 4, JH7100_CLK_DSP_ROOT_DIV),
-       JH7100__DIV(JH7100_CLK_VP6BUS_SRC, "vp6bus_src", 4, JH7100_CLK_DSP_ROOT),
-       JH7100_GDIV(JH7100_CLK_VP6_AXI, "vp6_axi", 0, 4, JH7100_CLK_VP6BUS_SRC),
-       JH7100__DIV(JH7100_CLK_VCDECBUS_SRC, "vcdecbus_src", 4, JH7100_CLK_CDECHIFI4_ROOT),
-       JH7100__DIV(JH7100_CLK_VDEC_BUS, "vdec_bus", 8, JH7100_CLK_VCDECBUS_SRC),
-       JH7100_GATE(JH7100_CLK_VDEC_AXI, "vdec_axi", 0, JH7100_CLK_VDEC_BUS),
-       JH7100_GATE(JH7100_CLK_VDECBRG_MAIN, "vdecbrg_mainclk", 0, JH7100_CLK_VDEC_BUS),
-       JH7100_GDIV(JH7100_CLK_VDEC_BCLK, "vdec_bclk", 0, 8, JH7100_CLK_VCDECBUS_SRC),
-       JH7100_GDIV(JH7100_CLK_VDEC_CCLK, "vdec_cclk", 0, 8, JH7100_CLK_CDEC_ROOT),
-       JH7100_GATE(JH7100_CLK_VDEC_APB, "vdec_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_JPEG_AXI, "jpeg_axi", 0, 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
-       JH7100_GDIV(JH7100_CLK_JPEG_CCLK, "jpeg_cclk", 0, 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
-       JH7100_GATE(JH7100_CLK_JPEG_APB, "jpeg_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_GC300_2X, "gc300_2x", 0, 8, JH7100_CLK_CDECHIFI4_ROOT),
-       JH7100_GATE(JH7100_CLK_GC300_AHB, "gc300_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100__DIV(JH7100_CLK_JPCGC300_AXIBUS, "jpcgc300_axibus", 8, JH7100_CLK_VCDECBUS_SRC),
-       JH7100_GATE(JH7100_CLK_GC300_AXI, "gc300_axi", 0, JH7100_CLK_JPCGC300_AXIBUS),
-       JH7100_GATE(JH7100_CLK_JPCGC300_MAIN, "jpcgc300_mainclk", 0, JH7100_CLK_JPCGC300_AXIBUS),
-       JH7100__DIV(JH7100_CLK_VENC_BUS, "venc_bus", 8, JH7100_CLK_VCDECBUS_SRC),
-       JH7100_GATE(JH7100_CLK_VENC_AXI, "venc_axi", 0, JH7100_CLK_VENC_BUS),
-       JH7100_GATE(JH7100_CLK_VENCBRG_MAIN, "vencbrg_mainclk", 0, JH7100_CLK_VENC_BUS),
-       JH7100_GDIV(JH7100_CLK_VENC_BCLK, "venc_bclk", 0, 8, JH7100_CLK_VCDECBUS_SRC),
-       JH7100_GDIV(JH7100_CLK_VENC_CCLK, "venc_cclk", 0, 8, JH7100_CLK_CDEC_ROOT),
-       JH7100_GATE(JH7100_CLK_VENC_APB, "venc_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_DDRPLL_DIV2, "ddrpll_div2", CLK_IS_CRITICAL, 2, JH7100_CLK_PLL1_OUT),
-       JH7100_GDIV(JH7100_CLK_DDRPLL_DIV4, "ddrpll_div4", CLK_IS_CRITICAL, 2, JH7100_CLK_DDRPLL_DIV2),
-       JH7100_GDIV(JH7100_CLK_DDRPLL_DIV8, "ddrpll_div8", CLK_IS_CRITICAL, 2, JH7100_CLK_DDRPLL_DIV4),
-       JH7100_GDIV(JH7100_CLK_DDROSC_DIV2, "ddrosc_div2", CLK_IS_CRITICAL, 2, JH7100_CLK_OSC_SYS),
-       JH7100_GMUX(JH7100_CLK_DDRC0, "ddrc0", CLK_IS_CRITICAL, 4,
+       JH71X0__DIV(JH7100_CLK_CPU_CORE, "cpu_core", 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
+       JH71X0__DIV(JH7100_CLK_CPU_AXI, "cpu_axi", 8, JH7100_CLK_CPU_CORE),
+       JH71X0__DIV(JH7100_CLK_AHB_BUS, "ahb_bus", 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
+       JH71X0__DIV(JH7100_CLK_APB1_BUS, "apb1_bus", 8, JH7100_CLK_AHB_BUS),
+       JH71X0__DIV(JH7100_CLK_APB2_BUS, "apb2_bus", 8, JH7100_CLK_AHB_BUS),
+       JH71X0_GATE(JH7100_CLK_DOM3AHB_BUS, "dom3ahb_bus", CLK_IS_CRITICAL, JH7100_CLK_AHB_BUS),
+       JH71X0_GATE(JH7100_CLK_DOM7AHB_BUS, "dom7ahb_bus", CLK_IS_CRITICAL, JH7100_CLK_AHB_BUS),
+       JH71X0_GATE(JH7100_CLK_U74_CORE0, "u74_core0", CLK_IS_CRITICAL, JH7100_CLK_CPU_CORE),
+       JH71X0_GDIV(JH7100_CLK_U74_CORE1, "u74_core1", CLK_IS_CRITICAL, 8, JH7100_CLK_CPU_CORE),
+       JH71X0_GATE(JH7100_CLK_U74_AXI, "u74_axi", CLK_IS_CRITICAL, JH7100_CLK_CPU_AXI),
+       JH71X0_GATE(JH7100_CLK_U74RTC_TOGGLE, "u74rtc_toggle", CLK_IS_CRITICAL, JH7100_CLK_OSC_SYS),
+       JH71X0_GATE(JH7100_CLK_SGDMA2P_AXI, "sgdma2p_axi", 0, JH7100_CLK_CPU_AXI),
+       JH71X0_GATE(JH7100_CLK_DMA2PNOC_AXI, "dma2pnoc_axi", 0, JH7100_CLK_CPU_AXI),
+       JH71X0_GATE(JH7100_CLK_SGDMA2P_AHB, "sgdma2p_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0__DIV(JH7100_CLK_DLA_BUS, "dla_bus", 4, JH7100_CLK_DLA_ROOT),
+       JH71X0_GATE(JH7100_CLK_DLA_AXI, "dla_axi", 0, JH7100_CLK_DLA_BUS),
+       JH71X0_GATE(JH7100_CLK_DLANOC_AXI, "dlanoc_axi", 0, JH7100_CLK_DLA_BUS),
+       JH71X0_GATE(JH7100_CLK_DLA_APB, "dla_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_VP6_CORE, "vp6_core", 0, 4, JH7100_CLK_DSP_ROOT_DIV),
+       JH71X0__DIV(JH7100_CLK_VP6BUS_SRC, "vp6bus_src", 4, JH7100_CLK_DSP_ROOT),
+       JH71X0_GDIV(JH7100_CLK_VP6_AXI, "vp6_axi", 0, 4, JH7100_CLK_VP6BUS_SRC),
+       JH71X0__DIV(JH7100_CLK_VCDECBUS_SRC, "vcdecbus_src", 4, JH7100_CLK_CDECHIFI4_ROOT),
+       JH71X0__DIV(JH7100_CLK_VDEC_BUS, "vdec_bus", 8, JH7100_CLK_VCDECBUS_SRC),
+       JH71X0_GATE(JH7100_CLK_VDEC_AXI, "vdec_axi", 0, JH7100_CLK_VDEC_BUS),
+       JH71X0_GATE(JH7100_CLK_VDECBRG_MAIN, "vdecbrg_mainclk", 0, JH7100_CLK_VDEC_BUS),
+       JH71X0_GDIV(JH7100_CLK_VDEC_BCLK, "vdec_bclk", 0, 8, JH7100_CLK_VCDECBUS_SRC),
+       JH71X0_GDIV(JH7100_CLK_VDEC_CCLK, "vdec_cclk", 0, 8, JH7100_CLK_CDEC_ROOT),
+       JH71X0_GATE(JH7100_CLK_VDEC_APB, "vdec_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_JPEG_AXI, "jpeg_axi", 0, 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
+       JH71X0_GDIV(JH7100_CLK_JPEG_CCLK, "jpeg_cclk", 0, 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
+       JH71X0_GATE(JH7100_CLK_JPEG_APB, "jpeg_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_GC300_2X, "gc300_2x", 0, 8, JH7100_CLK_CDECHIFI4_ROOT),
+       JH71X0_GATE(JH7100_CLK_GC300_AHB, "gc300_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0__DIV(JH7100_CLK_JPCGC300_AXIBUS, "jpcgc300_axibus", 8, JH7100_CLK_VCDECBUS_SRC),
+       JH71X0_GATE(JH7100_CLK_GC300_AXI, "gc300_axi", 0, JH7100_CLK_JPCGC300_AXIBUS),
+       JH71X0_GATE(JH7100_CLK_JPCGC300_MAIN, "jpcgc300_mainclk", 0, JH7100_CLK_JPCGC300_AXIBUS),
+       JH71X0__DIV(JH7100_CLK_VENC_BUS, "venc_bus", 8, JH7100_CLK_VCDECBUS_SRC),
+       JH71X0_GATE(JH7100_CLK_VENC_AXI, "venc_axi", 0, JH7100_CLK_VENC_BUS),
+       JH71X0_GATE(JH7100_CLK_VENCBRG_MAIN, "vencbrg_mainclk", 0, JH7100_CLK_VENC_BUS),
+       JH71X0_GDIV(JH7100_CLK_VENC_BCLK, "venc_bclk", 0, 8, JH7100_CLK_VCDECBUS_SRC),
+       JH71X0_GDIV(JH7100_CLK_VENC_CCLK, "venc_cclk", 0, 8, JH7100_CLK_CDEC_ROOT),
+       JH71X0_GATE(JH7100_CLK_VENC_APB, "venc_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_DDRPLL_DIV2, "ddrpll_div2", CLK_IS_CRITICAL, 2, JH7100_CLK_PLL1_OUT),
+       JH71X0_GDIV(JH7100_CLK_DDRPLL_DIV4, "ddrpll_div4", CLK_IS_CRITICAL, 2,
+                   JH7100_CLK_DDRPLL_DIV2),
+       JH71X0_GDIV(JH7100_CLK_DDRPLL_DIV8, "ddrpll_div8", CLK_IS_CRITICAL, 2,
+                   JH7100_CLK_DDRPLL_DIV4),
+       JH71X0_GDIV(JH7100_CLK_DDROSC_DIV2, "ddrosc_div2", CLK_IS_CRITICAL, 2, JH7100_CLK_OSC_SYS),
+       JH71X0_GMUX(JH7100_CLK_DDRC0, "ddrc0", CLK_IS_CRITICAL, 4,
                    JH7100_CLK_DDROSC_DIV2,
                    JH7100_CLK_DDRPLL_DIV2,
                    JH7100_CLK_DDRPLL_DIV4,
                    JH7100_CLK_DDRPLL_DIV8),
-       JH7100_GMUX(JH7100_CLK_DDRC1, "ddrc1", CLK_IS_CRITICAL, 4,
+       JH71X0_GMUX(JH7100_CLK_DDRC1, "ddrc1", CLK_IS_CRITICAL, 4,
                    JH7100_CLK_DDROSC_DIV2,
                    JH7100_CLK_DDRPLL_DIV2,
                    JH7100_CLK_DDRPLL_DIV4,
                    JH7100_CLK_DDRPLL_DIV8),
-       JH7100_GATE(JH7100_CLK_DDRPHY_APB, "ddrphy_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100__DIV(JH7100_CLK_NOC_ROB, "noc_rob", 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
-       JH7100__DIV(JH7100_CLK_NOC_COG, "noc_cog", 8, JH7100_CLK_DLA_ROOT),
-       JH7100_GATE(JH7100_CLK_NNE_AHB, "nne_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100__DIV(JH7100_CLK_NNEBUS_SRC1, "nnebus_src1", 4, JH7100_CLK_DSP_ROOT),
-       JH7100__MUX(JH7100_CLK_NNE_BUS, "nne_bus", 2,
+       JH71X0_GATE(JH7100_CLK_DDRPHY_APB, "ddrphy_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0__DIV(JH7100_CLK_NOC_ROB, "noc_rob", 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
+       JH71X0__DIV(JH7100_CLK_NOC_COG, "noc_cog", 8, JH7100_CLK_DLA_ROOT),
+       JH71X0_GATE(JH7100_CLK_NNE_AHB, "nne_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0__DIV(JH7100_CLK_NNEBUS_SRC1, "nnebus_src1", 4, JH7100_CLK_DSP_ROOT),
+       JH71X0__MUX(JH7100_CLK_NNE_BUS, "nne_bus", 2,
                    JH7100_CLK_CPU_AXI,
                    JH7100_CLK_NNEBUS_SRC1),
-       JH7100_GATE(JH7100_CLK_NNE_AXI, "nne_axi", 0, JH7100_CLK_NNE_BUS),
-       JH7100_GATE(JH7100_CLK_NNENOC_AXI, "nnenoc_axi", 0, JH7100_CLK_NNE_BUS),
-       JH7100_GATE(JH7100_CLK_DLASLV_AXI, "dlaslv_axi", 0, JH7100_CLK_NNE_BUS),
-       JH7100_GATE(JH7100_CLK_DSPX2C_AXI, "dspx2c_axi", CLK_IS_CRITICAL, JH7100_CLK_NNE_BUS),
-       JH7100__DIV(JH7100_CLK_HIFI4_SRC, "hifi4_src", 4, JH7100_CLK_CDECHIFI4_ROOT),
-       JH7100__DIV(JH7100_CLK_HIFI4_COREFREE, "hifi4_corefree", 8, JH7100_CLK_HIFI4_SRC),
-       JH7100_GATE(JH7100_CLK_HIFI4_CORE, "hifi4_core", 0, JH7100_CLK_HIFI4_COREFREE),
-       JH7100__DIV(JH7100_CLK_HIFI4_BUS, "hifi4_bus", 8, JH7100_CLK_HIFI4_COREFREE),
-       JH7100_GATE(JH7100_CLK_HIFI4_AXI, "hifi4_axi", 0, JH7100_CLK_HIFI4_BUS),
-       JH7100_GATE(JH7100_CLK_HIFI4NOC_AXI, "hifi4noc_axi", 0, JH7100_CLK_HIFI4_BUS),
-       JH7100__DIV(JH7100_CLK_SGDMA1P_BUS, "sgdma1p_bus", 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
-       JH7100_GATE(JH7100_CLK_SGDMA1P_AXI, "sgdma1p_axi", 0, JH7100_CLK_SGDMA1P_BUS),
-       JH7100_GATE(JH7100_CLK_DMA1P_AXI, "dma1p_axi", 0, JH7100_CLK_SGDMA1P_BUS),
-       JH7100_GDIV(JH7100_CLK_X2C_AXI, "x2c_axi", CLK_IS_CRITICAL, 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
-       JH7100__DIV(JH7100_CLK_USB_BUS, "usb_bus", 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
-       JH7100_GATE(JH7100_CLK_USB_AXI, "usb_axi", 0, JH7100_CLK_USB_BUS),
-       JH7100_GATE(JH7100_CLK_USBNOC_AXI, "usbnoc_axi", 0, JH7100_CLK_USB_BUS),
-       JH7100__DIV(JH7100_CLK_USBPHY_ROOTDIV, "usbphy_rootdiv", 4, JH7100_CLK_GMACUSB_ROOT),
-       JH7100_GDIV(JH7100_CLK_USBPHY_125M, "usbphy_125m", 0, 8, JH7100_CLK_USBPHY_ROOTDIV),
-       JH7100_GDIV(JH7100_CLK_USBPHY_PLLDIV25M, "usbphy_plldiv25m", 0, 32, JH7100_CLK_USBPHY_ROOTDIV),
-       JH7100__MUX(JH7100_CLK_USBPHY_25M, "usbphy_25m", 2,
+       JH71X0_GATE(JH7100_CLK_NNE_AXI, "nne_axi", 0, JH7100_CLK_NNE_BUS),
+       JH71X0_GATE(JH7100_CLK_NNENOC_AXI, "nnenoc_axi", 0, JH7100_CLK_NNE_BUS),
+       JH71X0_GATE(JH7100_CLK_DLASLV_AXI, "dlaslv_axi", 0, JH7100_CLK_NNE_BUS),
+       JH71X0_GATE(JH7100_CLK_DSPX2C_AXI, "dspx2c_axi", CLK_IS_CRITICAL, JH7100_CLK_NNE_BUS),
+       JH71X0__DIV(JH7100_CLK_HIFI4_SRC, "hifi4_src", 4, JH7100_CLK_CDECHIFI4_ROOT),
+       JH71X0__DIV(JH7100_CLK_HIFI4_COREFREE, "hifi4_corefree", 8, JH7100_CLK_HIFI4_SRC),
+       JH71X0_GATE(JH7100_CLK_HIFI4_CORE, "hifi4_core", 0, JH7100_CLK_HIFI4_COREFREE),
+       JH71X0__DIV(JH7100_CLK_HIFI4_BUS, "hifi4_bus", 8, JH7100_CLK_HIFI4_COREFREE),
+       JH71X0_GATE(JH7100_CLK_HIFI4_AXI, "hifi4_axi", 0, JH7100_CLK_HIFI4_BUS),
+       JH71X0_GATE(JH7100_CLK_HIFI4NOC_AXI, "hifi4noc_axi", 0, JH7100_CLK_HIFI4_BUS),
+       JH71X0__DIV(JH7100_CLK_SGDMA1P_BUS, "sgdma1p_bus", 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
+       JH71X0_GATE(JH7100_CLK_SGDMA1P_AXI, "sgdma1p_axi", 0, JH7100_CLK_SGDMA1P_BUS),
+       JH71X0_GATE(JH7100_CLK_DMA1P_AXI, "dma1p_axi", 0, JH7100_CLK_SGDMA1P_BUS),
+       JH71X0_GDIV(JH7100_CLK_X2C_AXI, "x2c_axi", CLK_IS_CRITICAL, 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
+       JH71X0__DIV(JH7100_CLK_USB_BUS, "usb_bus", 8, JH7100_CLK_CPUNBUS_ROOT_DIV),
+       JH71X0_GATE(JH7100_CLK_USB_AXI, "usb_axi", 0, JH7100_CLK_USB_BUS),
+       JH71X0_GATE(JH7100_CLK_USBNOC_AXI, "usbnoc_axi", 0, JH7100_CLK_USB_BUS),
+       JH71X0__DIV(JH7100_CLK_USBPHY_ROOTDIV, "usbphy_rootdiv", 4, JH7100_CLK_GMACUSB_ROOT),
+       JH71X0_GDIV(JH7100_CLK_USBPHY_125M, "usbphy_125m", 0, 8, JH7100_CLK_USBPHY_ROOTDIV),
+       JH71X0_GDIV(JH7100_CLK_USBPHY_PLLDIV25M, "usbphy_plldiv25m", 0, 32,
+                   JH7100_CLK_USBPHY_ROOTDIV),
+       JH71X0__MUX(JH7100_CLK_USBPHY_25M, "usbphy_25m", 2,
                    JH7100_CLK_OSC_SYS,
                    JH7100_CLK_USBPHY_PLLDIV25M),
-       JH7100_FDIV(JH7100_CLK_AUDIO_DIV, "audio_div", JH7100_CLK_AUDIO_ROOT),
-       JH7100_GATE(JH7100_CLK_AUDIO_SRC, "audio_src", 0, JH7100_CLK_AUDIO_DIV),
-       JH7100_GATE(JH7100_CLK_AUDIO_12288, "audio_12288", 0, JH7100_CLK_OSC_AUD),
-       JH7100_GDIV(JH7100_CLK_VIN_SRC, "vin_src", 0, 4, JH7100_CLK_VIN_ROOT),
-       JH7100__DIV(JH7100_CLK_ISP0_BUS, "isp0_bus", 8, JH7100_CLK_VIN_SRC),
-       JH7100_GATE(JH7100_CLK_ISP0_AXI, "isp0_axi", 0, JH7100_CLK_ISP0_BUS),
-       JH7100_GATE(JH7100_CLK_ISP0NOC_AXI, "isp0noc_axi", 0, JH7100_CLK_ISP0_BUS),
-       JH7100_GATE(JH7100_CLK_ISPSLV_AXI, "ispslv_axi", 0, JH7100_CLK_ISP0_BUS),
-       JH7100__DIV(JH7100_CLK_ISP1_BUS, "isp1_bus", 8, JH7100_CLK_VIN_SRC),
-       JH7100_GATE(JH7100_CLK_ISP1_AXI, "isp1_axi", 0, JH7100_CLK_ISP1_BUS),
-       JH7100_GATE(JH7100_CLK_ISP1NOC_AXI, "isp1noc_axi", 0, JH7100_CLK_ISP1_BUS),
-       JH7100__DIV(JH7100_CLK_VIN_BUS, "vin_bus", 8, JH7100_CLK_VIN_SRC),
-       JH7100_GATE(JH7100_CLK_VIN_AXI, "vin_axi", 0, JH7100_CLK_VIN_BUS),
-       JH7100_GATE(JH7100_CLK_VINNOC_AXI, "vinnoc_axi", 0, JH7100_CLK_VIN_BUS),
-       JH7100_GDIV(JH7100_CLK_VOUT_SRC, "vout_src", 0, 4, JH7100_CLK_VOUT_ROOT),
-       JH7100__DIV(JH7100_CLK_DISPBUS_SRC, "dispbus_src", 4, JH7100_CLK_VOUTBUS_ROOT),
-       JH7100__DIV(JH7100_CLK_DISP_BUS, "disp_bus", 4, JH7100_CLK_DISPBUS_SRC),
-       JH7100_GATE(JH7100_CLK_DISP_AXI, "disp_axi", 0, JH7100_CLK_DISP_BUS),
-       JH7100_GATE(JH7100_CLK_DISPNOC_AXI, "dispnoc_axi", 0, JH7100_CLK_DISP_BUS),
-       JH7100_GATE(JH7100_CLK_SDIO0_AHB, "sdio0_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100_GDIV(JH7100_CLK_SDIO0_CCLKINT, "sdio0_cclkint", 0, 24, JH7100_CLK_PERH0_SRC),
-       JH7100__INV(JH7100_CLK_SDIO0_CCLKINT_INV, "sdio0_cclkint_inv", JH7100_CLK_SDIO0_CCLKINT),
-       JH7100_GATE(JH7100_CLK_SDIO1_AHB, "sdio1_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100_GDIV(JH7100_CLK_SDIO1_CCLKINT, "sdio1_cclkint", 0, 24, JH7100_CLK_PERH1_SRC),
-       JH7100__INV(JH7100_CLK_SDIO1_CCLKINT_INV, "sdio1_cclkint_inv", JH7100_CLK_SDIO1_CCLKINT),
-       JH7100_GATE(JH7100_CLK_GMAC_AHB, "gmac_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100__DIV(JH7100_CLK_GMAC_ROOT_DIV, "gmac_root_div", 8, JH7100_CLK_GMACUSB_ROOT),
-       JH7100_GDIV(JH7100_CLK_GMAC_PTP_REF, "gmac_ptp_refclk", 0, 31, JH7100_CLK_GMAC_ROOT_DIV),
-       JH7100_GDIV(JH7100_CLK_GMAC_GTX, "gmac_gtxclk", 0, 255, JH7100_CLK_GMAC_ROOT_DIV),
-       JH7100_GDIV(JH7100_CLK_GMAC_RMII_TX, "gmac_rmii_txclk", 0, 8, JH7100_CLK_GMAC_RMII_REF),
-       JH7100_GDIV(JH7100_CLK_GMAC_RMII_RX, "gmac_rmii_rxclk", 0, 8, JH7100_CLK_GMAC_RMII_REF),
-       JH7100__MUX(JH7100_CLK_GMAC_TX, "gmac_tx", 3,
+       JH71X0_FDIV(JH7100_CLK_AUDIO_DIV, "audio_div", JH7100_CLK_AUDIO_ROOT),
+       JH71X0_GATE(JH7100_CLK_AUDIO_SRC, "audio_src", 0, JH7100_CLK_AUDIO_DIV),
+       JH71X0_GATE(JH7100_CLK_AUDIO_12288, "audio_12288", 0, JH7100_CLK_OSC_AUD),
+       JH71X0_GDIV(JH7100_CLK_VIN_SRC, "vin_src", 0, 4, JH7100_CLK_VIN_ROOT),
+       JH71X0__DIV(JH7100_CLK_ISP0_BUS, "isp0_bus", 8, JH7100_CLK_VIN_SRC),
+       JH71X0_GATE(JH7100_CLK_ISP0_AXI, "isp0_axi", 0, JH7100_CLK_ISP0_BUS),
+       JH71X0_GATE(JH7100_CLK_ISP0NOC_AXI, "isp0noc_axi", 0, JH7100_CLK_ISP0_BUS),
+       JH71X0_GATE(JH7100_CLK_ISPSLV_AXI, "ispslv_axi", 0, JH7100_CLK_ISP0_BUS),
+       JH71X0__DIV(JH7100_CLK_ISP1_BUS, "isp1_bus", 8, JH7100_CLK_VIN_SRC),
+       JH71X0_GATE(JH7100_CLK_ISP1_AXI, "isp1_axi", 0, JH7100_CLK_ISP1_BUS),
+       JH71X0_GATE(JH7100_CLK_ISP1NOC_AXI, "isp1noc_axi", 0, JH7100_CLK_ISP1_BUS),
+       JH71X0__DIV(JH7100_CLK_VIN_BUS, "vin_bus", 8, JH7100_CLK_VIN_SRC),
+       JH71X0_GATE(JH7100_CLK_VIN_AXI, "vin_axi", 0, JH7100_CLK_VIN_BUS),
+       JH71X0_GATE(JH7100_CLK_VINNOC_AXI, "vinnoc_axi", 0, JH7100_CLK_VIN_BUS),
+       JH71X0_GDIV(JH7100_CLK_VOUT_SRC, "vout_src", 0, 4, JH7100_CLK_VOUT_ROOT),
+       JH71X0__DIV(JH7100_CLK_DISPBUS_SRC, "dispbus_src", 4, JH7100_CLK_VOUTBUS_ROOT),
+       JH71X0__DIV(JH7100_CLK_DISP_BUS, "disp_bus", 4, JH7100_CLK_DISPBUS_SRC),
+       JH71X0_GATE(JH7100_CLK_DISP_AXI, "disp_axi", 0, JH7100_CLK_DISP_BUS),
+       JH71X0_GATE(JH7100_CLK_DISPNOC_AXI, "dispnoc_axi", 0, JH7100_CLK_DISP_BUS),
+       JH71X0_GATE(JH7100_CLK_SDIO0_AHB, "sdio0_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0_GDIV(JH7100_CLK_SDIO0_CCLKINT, "sdio0_cclkint", 0, 24, JH7100_CLK_PERH0_SRC),
+       JH71X0__INV(JH7100_CLK_SDIO0_CCLKINT_INV, "sdio0_cclkint_inv", JH7100_CLK_SDIO0_CCLKINT),
+       JH71X0_GATE(JH7100_CLK_SDIO1_AHB, "sdio1_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0_GDIV(JH7100_CLK_SDIO1_CCLKINT, "sdio1_cclkint", 0, 24, JH7100_CLK_PERH1_SRC),
+       JH71X0__INV(JH7100_CLK_SDIO1_CCLKINT_INV, "sdio1_cclkint_inv", JH7100_CLK_SDIO1_CCLKINT),
+       JH71X0_GATE(JH7100_CLK_GMAC_AHB, "gmac_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0__DIV(JH7100_CLK_GMAC_ROOT_DIV, "gmac_root_div", 8, JH7100_CLK_GMACUSB_ROOT),
+       JH71X0_GDIV(JH7100_CLK_GMAC_PTP_REF, "gmac_ptp_refclk", 0, 31, JH7100_CLK_GMAC_ROOT_DIV),
+       JH71X0_GDIV(JH7100_CLK_GMAC_GTX, "gmac_gtxclk", 0, 255, JH7100_CLK_GMAC_ROOT_DIV),
+       JH71X0_GDIV(JH7100_CLK_GMAC_RMII_TX, "gmac_rmii_txclk", 0, 8, JH7100_CLK_GMAC_RMII_REF),
+       JH71X0_GDIV(JH7100_CLK_GMAC_RMII_RX, "gmac_rmii_rxclk", 0, 8, JH7100_CLK_GMAC_RMII_REF),
+       JH71X0__MUX(JH7100_CLK_GMAC_TX, "gmac_tx", 3,
                    JH7100_CLK_GMAC_GTX,
                    JH7100_CLK_GMAC_TX_INV,
                    JH7100_CLK_GMAC_RMII_TX),
-       JH7100__INV(JH7100_CLK_GMAC_TX_INV, "gmac_tx_inv", JH7100_CLK_GMAC_TX),
-       JH7100__MUX(JH7100_CLK_GMAC_RX_PRE, "gmac_rx_pre", 2,
+       JH71X0__INV(JH7100_CLK_GMAC_TX_INV, "gmac_tx_inv", JH7100_CLK_GMAC_TX),
+       JH71X0__MUX(JH7100_CLK_GMAC_RX_PRE, "gmac_rx_pre", 2,
                    JH7100_CLK_GMAC_GR_MII_RX,
                    JH7100_CLK_GMAC_RMII_RX),
-       JH7100__INV(JH7100_CLK_GMAC_RX_INV, "gmac_rx_inv", JH7100_CLK_GMAC_RX_PRE),
-       JH7100_GATE(JH7100_CLK_GMAC_RMII, "gmac_rmii", 0, JH7100_CLK_GMAC_RMII_REF),
-       JH7100_GDIV(JH7100_CLK_GMAC_TOPHYREF, "gmac_tophyref", 0, 127, JH7100_CLK_GMAC_ROOT_DIV),
-       JH7100_GATE(JH7100_CLK_SPI2AHB_AHB, "spi2ahb_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100_GDIV(JH7100_CLK_SPI2AHB_CORE, "spi2ahb_core", 0, 31, JH7100_CLK_PERH0_SRC),
-       JH7100_GATE(JH7100_CLK_EZMASTER_AHB, "ezmaster_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100_GATE(JH7100_CLK_E24_AHB, "e24_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100_GATE(JH7100_CLK_E24RTC_TOGGLE, "e24rtc_toggle", 0, JH7100_CLK_OSC_SYS),
-       JH7100_GATE(JH7100_CLK_QSPI_AHB, "qspi_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100_GATE(JH7100_CLK_QSPI_APB, "qspi_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_QSPI_REF, "qspi_refclk", 0, 31, JH7100_CLK_PERH0_SRC),
-       JH7100_GATE(JH7100_CLK_SEC_AHB, "sec_ahb", 0, JH7100_CLK_AHB_BUS),
-       JH7100_GATE(JH7100_CLK_AES, "aes_clk", 0, JH7100_CLK_SEC_AHB),
-       JH7100_GATE(JH7100_CLK_SHA, "sha_clk", 0, JH7100_CLK_SEC_AHB),
-       JH7100_GATE(JH7100_CLK_PKA, "pka_clk", 0, JH7100_CLK_SEC_AHB),
-       JH7100_GATE(JH7100_CLK_TRNG_APB, "trng_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GATE(JH7100_CLK_OTP_APB, "otp_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GATE(JH7100_CLK_UART0_APB, "uart0_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_UART0_CORE, "uart0_core", 0, 63, JH7100_CLK_PERH1_SRC),
-       JH7100_GATE(JH7100_CLK_UART1_APB, "uart1_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_UART1_CORE, "uart1_core", 0, 63, JH7100_CLK_PERH1_SRC),
-       JH7100_GATE(JH7100_CLK_SPI0_APB, "spi0_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_SPI0_CORE, "spi0_core", 0, 63, JH7100_CLK_PERH1_SRC),
-       JH7100_GATE(JH7100_CLK_SPI1_APB, "spi1_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_SPI1_CORE, "spi1_core", 0, 63, JH7100_CLK_PERH1_SRC),
-       JH7100_GATE(JH7100_CLK_I2C0_APB, "i2c0_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_I2C0_CORE, "i2c0_core", 0, 63, JH7100_CLK_PERH1_SRC),
-       JH7100_GATE(JH7100_CLK_I2C1_APB, "i2c1_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GDIV(JH7100_CLK_I2C1_CORE, "i2c1_core", 0, 63, JH7100_CLK_PERH1_SRC),
-       JH7100_GATE(JH7100_CLK_GPIO_APB, "gpio_apb", 0, JH7100_CLK_APB1_BUS),
-       JH7100_GATE(JH7100_CLK_UART2_APB, "uart2_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GDIV(JH7100_CLK_UART2_CORE, "uart2_core", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GATE(JH7100_CLK_UART3_APB, "uart3_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GDIV(JH7100_CLK_UART3_CORE, "uart3_core", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GATE(JH7100_CLK_SPI2_APB, "spi2_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GDIV(JH7100_CLK_SPI2_CORE, "spi2_core", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GATE(JH7100_CLK_SPI3_APB, "spi3_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GDIV(JH7100_CLK_SPI3_CORE, "spi3_core", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GATE(JH7100_CLK_I2C2_APB, "i2c2_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GDIV(JH7100_CLK_I2C2_CORE, "i2c2_core", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GATE(JH7100_CLK_I2C3_APB, "i2c3_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GDIV(JH7100_CLK_I2C3_CORE, "i2c3_core", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GATE(JH7100_CLK_WDTIMER_APB, "wdtimer_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GDIV(JH7100_CLK_WDT_CORE, "wdt_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GDIV(JH7100_CLK_TIMER0_CORE, "timer0_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GDIV(JH7100_CLK_TIMER1_CORE, "timer1_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GDIV(JH7100_CLK_TIMER2_CORE, "timer2_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GDIV(JH7100_CLK_TIMER3_CORE, "timer3_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GDIV(JH7100_CLK_TIMER4_CORE, "timer4_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GDIV(JH7100_CLK_TIMER5_CORE, "timer5_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GDIV(JH7100_CLK_TIMER6_CORE, "timer6_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
-       JH7100_GATE(JH7100_CLK_VP6INTC_APB, "vp6intc_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GATE(JH7100_CLK_PWM_APB, "pwm_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GATE(JH7100_CLK_MSI_APB, "msi_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GATE(JH7100_CLK_TEMP_APB, "temp_apb", 0, JH7100_CLK_APB2_BUS),
-       JH7100_GDIV(JH7100_CLK_TEMP_SENSE, "temp_sense", 0, 31, JH7100_CLK_OSC_SYS),
-       JH7100_GATE(JH7100_CLK_SYSERR_APB, "syserr_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0__INV(JH7100_CLK_GMAC_RX_INV, "gmac_rx_inv", JH7100_CLK_GMAC_RX_PRE),
+       JH71X0_GATE(JH7100_CLK_GMAC_RMII, "gmac_rmii", 0, JH7100_CLK_GMAC_RMII_REF),
+       JH71X0_GDIV(JH7100_CLK_GMAC_TOPHYREF, "gmac_tophyref", 0, 127, JH7100_CLK_GMAC_ROOT_DIV),
+       JH71X0_GATE(JH7100_CLK_SPI2AHB_AHB, "spi2ahb_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0_GDIV(JH7100_CLK_SPI2AHB_CORE, "spi2ahb_core", 0, 31, JH7100_CLK_PERH0_SRC),
+       JH71X0_GATE(JH7100_CLK_EZMASTER_AHB, "ezmaster_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0_GATE(JH7100_CLK_E24_AHB, "e24_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0_GATE(JH7100_CLK_E24RTC_TOGGLE, "e24rtc_toggle", 0, JH7100_CLK_OSC_SYS),
+       JH71X0_GATE(JH7100_CLK_QSPI_AHB, "qspi_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0_GATE(JH7100_CLK_QSPI_APB, "qspi_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_QSPI_REF, "qspi_refclk", 0, 31, JH7100_CLK_PERH0_SRC),
+       JH71X0_GATE(JH7100_CLK_SEC_AHB, "sec_ahb", 0, JH7100_CLK_AHB_BUS),
+       JH71X0_GATE(JH7100_CLK_AES, "aes_clk", 0, JH7100_CLK_SEC_AHB),
+       JH71X0_GATE(JH7100_CLK_SHA, "sha_clk", 0, JH7100_CLK_SEC_AHB),
+       JH71X0_GATE(JH7100_CLK_PKA, "pka_clk", 0, JH7100_CLK_SEC_AHB),
+       JH71X0_GATE(JH7100_CLK_TRNG_APB, "trng_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GATE(JH7100_CLK_OTP_APB, "otp_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GATE(JH7100_CLK_UART0_APB, "uart0_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_UART0_CORE, "uart0_core", 0, 63, JH7100_CLK_PERH1_SRC),
+       JH71X0_GATE(JH7100_CLK_UART1_APB, "uart1_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_UART1_CORE, "uart1_core", 0, 63, JH7100_CLK_PERH1_SRC),
+       JH71X0_GATE(JH7100_CLK_SPI0_APB, "spi0_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_SPI0_CORE, "spi0_core", 0, 63, JH7100_CLK_PERH1_SRC),
+       JH71X0_GATE(JH7100_CLK_SPI1_APB, "spi1_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_SPI1_CORE, "spi1_core", 0, 63, JH7100_CLK_PERH1_SRC),
+       JH71X0_GATE(JH7100_CLK_I2C0_APB, "i2c0_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_I2C0_CORE, "i2c0_core", 0, 63, JH7100_CLK_PERH1_SRC),
+       JH71X0_GATE(JH7100_CLK_I2C1_APB, "i2c1_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GDIV(JH7100_CLK_I2C1_CORE, "i2c1_core", 0, 63, JH7100_CLK_PERH1_SRC),
+       JH71X0_GATE(JH7100_CLK_GPIO_APB, "gpio_apb", 0, JH7100_CLK_APB1_BUS),
+       JH71X0_GATE(JH7100_CLK_UART2_APB, "uart2_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GDIV(JH7100_CLK_UART2_CORE, "uart2_core", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GATE(JH7100_CLK_UART3_APB, "uart3_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GDIV(JH7100_CLK_UART3_CORE, "uart3_core", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GATE(JH7100_CLK_SPI2_APB, "spi2_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GDIV(JH7100_CLK_SPI2_CORE, "spi2_core", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GATE(JH7100_CLK_SPI3_APB, "spi3_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GDIV(JH7100_CLK_SPI3_CORE, "spi3_core", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GATE(JH7100_CLK_I2C2_APB, "i2c2_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GDIV(JH7100_CLK_I2C2_CORE, "i2c2_core", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GATE(JH7100_CLK_I2C3_APB, "i2c3_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GDIV(JH7100_CLK_I2C3_CORE, "i2c3_core", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GATE(JH7100_CLK_WDTIMER_APB, "wdtimer_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GDIV(JH7100_CLK_WDT_CORE, "wdt_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GDIV(JH7100_CLK_TIMER0_CORE, "timer0_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GDIV(JH7100_CLK_TIMER1_CORE, "timer1_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GDIV(JH7100_CLK_TIMER2_CORE, "timer2_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GDIV(JH7100_CLK_TIMER3_CORE, "timer3_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GDIV(JH7100_CLK_TIMER4_CORE, "timer4_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GDIV(JH7100_CLK_TIMER5_CORE, "timer5_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GDIV(JH7100_CLK_TIMER6_CORE, "timer6_coreclk", 0, 63, JH7100_CLK_PERH0_SRC),
+       JH71X0_GATE(JH7100_CLK_VP6INTC_APB, "vp6intc_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GATE(JH7100_CLK_PWM_APB, "pwm_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GATE(JH7100_CLK_MSI_APB, "msi_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GATE(JH7100_CLK_TEMP_APB, "temp_apb", 0, JH7100_CLK_APB2_BUS),
+       JH71X0_GDIV(JH7100_CLK_TEMP_SENSE, "temp_sense", 0, 31, JH7100_CLK_OSC_SYS),
+       JH71X0_GATE(JH7100_CLK_SYSERR_APB, "syserr_apb", 0, JH7100_CLK_APB2_BUS),
 };
 
-static struct jh7100_clk *jh7100_clk_from(struct clk_hw *hw)
-{
-       return container_of(hw, struct jh7100_clk, hw);
-}
-
-static struct jh7100_clk_priv *jh7100_priv_from(struct jh7100_clk *clk)
-{
-       return container_of(clk, struct jh7100_clk_priv, reg[clk->idx]);
-}
-
-static u32 jh7100_clk_reg_get(struct jh7100_clk *clk)
-{
-       struct jh7100_clk_priv *priv = jh7100_priv_from(clk);
-       void __iomem *reg = priv->base + 4 * clk->idx;
-
-       return readl_relaxed(reg);
-}
-
-static void jh7100_clk_reg_rmw(struct jh7100_clk *clk, u32 mask, u32 value)
-{
-       struct jh7100_clk_priv *priv = jh7100_priv_from(clk);
-       void __iomem *reg = priv->base + 4 * clk->idx;
-       unsigned long flags;
-
-       spin_lock_irqsave(&priv->rmw_lock, flags);
-       value |= readl_relaxed(reg) & ~mask;
-       writel_relaxed(value, reg);
-       spin_unlock_irqrestore(&priv->rmw_lock, flags);
-}
-
-static int jh7100_clk_enable(struct clk_hw *hw)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-
-       jh7100_clk_reg_rmw(clk, JH7100_CLK_ENABLE, JH7100_CLK_ENABLE);
-       return 0;
-}
-
-static void jh7100_clk_disable(struct clk_hw *hw)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-
-       jh7100_clk_reg_rmw(clk, JH7100_CLK_ENABLE, 0);
-}
-
-static int jh7100_clk_is_enabled(struct clk_hw *hw)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-
-       return !!(jh7100_clk_reg_get(clk) & JH7100_CLK_ENABLE);
-}
-
-static unsigned long jh7100_clk_recalc_rate(struct clk_hw *hw,
-                                           unsigned long parent_rate)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-       u32 div = jh7100_clk_reg_get(clk) & JH7100_CLK_DIV_MASK;
-
-       return div ? parent_rate / div : 0;
-}
-
-static int jh7100_clk_determine_rate(struct clk_hw *hw,
-                                    struct clk_rate_request *req)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-       unsigned long parent = req->best_parent_rate;
-       unsigned long rate = clamp(req->rate, req->min_rate, req->max_rate);
-       unsigned long div = min_t(unsigned long, DIV_ROUND_UP(parent, rate), clk->max_div);
-       unsigned long result = parent / div;
-
-       /*
-        * we want the result clamped by min_rate and max_rate if possible:
-        * case 1: div hits the max divider value, which means it's less than
-        * parent / rate, so the result is greater than rate and min_rate in
-        * particular. we can't do anything about result > max_rate because the
-        * divider doesn't go any further.
-        * case 2: div = DIV_ROUND_UP(parent, rate) which means the result is
-        * always lower or equal to rate and max_rate. however the result may
-        * turn out lower than min_rate, but then the next higher rate is fine:
-        *   div - 1 = ceil(parent / rate) - 1 < parent / rate
-        * and thus
-        *   min_rate <= rate < parent / (div - 1)
-        */
-       if (result < req->min_rate && div > 1)
-               result = parent / (div - 1);
-
-       req->rate = result;
-       return 0;
-}
-
-static int jh7100_clk_set_rate(struct clk_hw *hw,
-                              unsigned long rate,
-                              unsigned long parent_rate)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-       unsigned long div = clamp(DIV_ROUND_CLOSEST(parent_rate, rate),
-                                 1UL, (unsigned long)clk->max_div);
-
-       jh7100_clk_reg_rmw(clk, JH7100_CLK_DIV_MASK, div);
-       return 0;
-}
-
-static unsigned long jh7100_clk_frac_recalc_rate(struct clk_hw *hw,
-                                                unsigned long parent_rate)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-       u32 reg = jh7100_clk_reg_get(clk);
-       unsigned long div100 = 100 * (reg & JH7100_CLK_INT_MASK) +
-                              ((reg & JH7100_CLK_FRAC_MASK) >> JH7100_CLK_FRAC_SHIFT);
-
-       return (div100 >= JH7100_CLK_FRAC_MIN) ? 100 * parent_rate / div100 : 0;
-}
-
-static int jh7100_clk_frac_determine_rate(struct clk_hw *hw,
-                                         struct clk_rate_request *req)
-{
-       unsigned long parent100 = 100 * req->best_parent_rate;
-       unsigned long rate = clamp(req->rate, req->min_rate, req->max_rate);
-       unsigned long div100 = clamp(DIV_ROUND_CLOSEST(parent100, rate),
-                                    JH7100_CLK_FRAC_MIN, JH7100_CLK_FRAC_MAX);
-       unsigned long result = parent100 / div100;
-
-       /* clamp the result as in jh7100_clk_determine_rate() above */
-       if (result > req->max_rate && div100 < JH7100_CLK_FRAC_MAX)
-               result = parent100 / (div100 + 1);
-       if (result < req->min_rate && div100 > JH7100_CLK_FRAC_MIN)
-               result = parent100 / (div100 - 1);
-
-       req->rate = result;
-       return 0;
-}
-
-static int jh7100_clk_frac_set_rate(struct clk_hw *hw,
-                                   unsigned long rate,
-                                   unsigned long parent_rate)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-       unsigned long div100 = clamp(DIV_ROUND_CLOSEST(100 * parent_rate, rate),
-                                    JH7100_CLK_FRAC_MIN, JH7100_CLK_FRAC_MAX);
-       u32 value = ((div100 % 100) << JH7100_CLK_FRAC_SHIFT) | (div100 / 100);
-
-       jh7100_clk_reg_rmw(clk, JH7100_CLK_DIV_MASK, value);
-       return 0;
-}
-
-static u8 jh7100_clk_get_parent(struct clk_hw *hw)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-       u32 value = jh7100_clk_reg_get(clk);
-
-       return (value & JH7100_CLK_MUX_MASK) >> JH7100_CLK_MUX_SHIFT;
-}
-
-static int jh7100_clk_set_parent(struct clk_hw *hw, u8 index)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-       u32 value = (u32)index << JH7100_CLK_MUX_SHIFT;
-
-       jh7100_clk_reg_rmw(clk, JH7100_CLK_MUX_MASK, value);
-       return 0;
-}
-
-static int jh7100_clk_mux_determine_rate(struct clk_hw *hw,
-                                        struct clk_rate_request *req)
-{
-       return clk_mux_determine_rate_flags(hw, req, 0);
-}
-
-static int jh7100_clk_get_phase(struct clk_hw *hw)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-       u32 value = jh7100_clk_reg_get(clk);
-
-       return (value & JH7100_CLK_INVERT) ? 180 : 0;
-}
-
-static int jh7100_clk_set_phase(struct clk_hw *hw, int degrees)
-{
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-       u32 value;
-
-       if (degrees == 0)
-               value = 0;
-       else if (degrees == 180)
-               value = JH7100_CLK_INVERT;
-       else
-               return -EINVAL;
-
-       jh7100_clk_reg_rmw(clk, JH7100_CLK_INVERT, value);
-       return 0;
-}
-
-#ifdef CONFIG_DEBUG_FS
-static void jh7100_clk_debug_init(struct clk_hw *hw, struct dentry *dentry)
-{
-       static const struct debugfs_reg32 jh7100_clk_reg = {
-               .name = "CTRL",
-               .offset = 0,
-       };
-       struct jh7100_clk *clk = jh7100_clk_from(hw);
-       struct jh7100_clk_priv *priv = jh7100_priv_from(clk);
-       struct debugfs_regset32 *regset;
-
-       regset = devm_kzalloc(priv->dev, sizeof(*regset), GFP_KERNEL);
-       if (!regset)
-               return;
-
-       regset->regs = &jh7100_clk_reg;
-       regset->nregs = 1;
-       regset->base = priv->base + 4 * clk->idx;
-
-       debugfs_create_regset32("registers", 0400, dentry, regset);
-}
-#else
-#define jh7100_clk_debug_init NULL
-#endif
-
-static const struct clk_ops jh7100_clk_gate_ops = {
-       .enable = jh7100_clk_enable,
-       .disable = jh7100_clk_disable,
-       .is_enabled = jh7100_clk_is_enabled,
-       .debug_init = jh7100_clk_debug_init,
-};
-
-static const struct clk_ops jh7100_clk_div_ops = {
-       .recalc_rate = jh7100_clk_recalc_rate,
-       .determine_rate = jh7100_clk_determine_rate,
-       .set_rate = jh7100_clk_set_rate,
-       .debug_init = jh7100_clk_debug_init,
-};
-
-static const struct clk_ops jh7100_clk_fdiv_ops = {
-       .recalc_rate = jh7100_clk_frac_recalc_rate,
-       .determine_rate = jh7100_clk_frac_determine_rate,
-       .set_rate = jh7100_clk_frac_set_rate,
-       .debug_init = jh7100_clk_debug_init,
-};
-
-static const struct clk_ops jh7100_clk_gdiv_ops = {
-       .enable = jh7100_clk_enable,
-       .disable = jh7100_clk_disable,
-       .is_enabled = jh7100_clk_is_enabled,
-       .recalc_rate = jh7100_clk_recalc_rate,
-       .determine_rate = jh7100_clk_determine_rate,
-       .set_rate = jh7100_clk_set_rate,
-       .debug_init = jh7100_clk_debug_init,
-};
-
-static const struct clk_ops jh7100_clk_mux_ops = {
-       .determine_rate = jh7100_clk_mux_determine_rate,
-       .set_parent = jh7100_clk_set_parent,
-       .get_parent = jh7100_clk_get_parent,
-       .debug_init = jh7100_clk_debug_init,
-};
-
-static const struct clk_ops jh7100_clk_gmux_ops = {
-       .enable = jh7100_clk_enable,
-       .disable = jh7100_clk_disable,
-       .is_enabled = jh7100_clk_is_enabled,
-       .determine_rate = jh7100_clk_mux_determine_rate,
-       .set_parent = jh7100_clk_set_parent,
-       .get_parent = jh7100_clk_get_parent,
-       .debug_init = jh7100_clk_debug_init,
-};
-
-static const struct clk_ops jh7100_clk_mdiv_ops = {
-       .recalc_rate = jh7100_clk_recalc_rate,
-       .determine_rate = jh7100_clk_determine_rate,
-       .get_parent = jh7100_clk_get_parent,
-       .set_parent = jh7100_clk_set_parent,
-       .set_rate = jh7100_clk_set_rate,
-       .debug_init = jh7100_clk_debug_init,
-};
-
-static const struct clk_ops jh7100_clk_gmd_ops = {
-       .enable = jh7100_clk_enable,
-       .disable = jh7100_clk_disable,
-       .is_enabled = jh7100_clk_is_enabled,
-       .recalc_rate = jh7100_clk_recalc_rate,
-       .determine_rate = jh7100_clk_determine_rate,
-       .get_parent = jh7100_clk_get_parent,
-       .set_parent = jh7100_clk_set_parent,
-       .set_rate = jh7100_clk_set_rate,
-       .debug_init = jh7100_clk_debug_init,
-};
-
-static const struct clk_ops jh7100_clk_inv_ops = {
-       .get_phase = jh7100_clk_get_phase,
-       .set_phase = jh7100_clk_set_phase,
-       .debug_init = jh7100_clk_debug_init,
-};
-
-const struct clk_ops *starfive_jh7100_clk_ops(u32 max)
-{
-       if (max & JH7100_CLK_DIV_MASK) {
-               if (max & JH7100_CLK_MUX_MASK) {
-                       if (max & JH7100_CLK_ENABLE)
-                               return &jh7100_clk_gmd_ops;
-                       return &jh7100_clk_mdiv_ops;
-               }
-               if (max & JH7100_CLK_ENABLE)
-                       return &jh7100_clk_gdiv_ops;
-               if (max == JH7100_CLK_FRAC_MAX)
-                       return &jh7100_clk_fdiv_ops;
-               return &jh7100_clk_div_ops;
-       }
-
-       if (max & JH7100_CLK_MUX_MASK) {
-               if (max & JH7100_CLK_ENABLE)
-                       return &jh7100_clk_gmux_ops;
-               return &jh7100_clk_mux_ops;
-       }
-
-       if (max & JH7100_CLK_ENABLE)
-               return &jh7100_clk_gate_ops;
-
-       return &jh7100_clk_inv_ops;
-}
-EXPORT_SYMBOL_GPL(starfive_jh7100_clk_ops);
-
 static struct clk_hw *jh7100_clk_get(struct of_phandle_args *clkspec, void *data)
 {
-       struct jh7100_clk_priv *priv = data;
+       struct jh71x0_clk_priv *priv = data;
        unsigned int idx = clkspec->args[0];
 
        if (idx < JH7100_CLK_PLL0_OUT)
@@ -605,7 +283,7 @@ static struct clk_hw *jh7100_clk_get(struct of_phandle_args *clkspec, void *data
 
 static int __init clk_starfive_jh7100_probe(struct platform_device *pdev)
 {
-       struct jh7100_clk_priv *priv;
+       struct jh71x0_clk_priv *priv;
        unsigned int idx;
        int ret;
 
@@ -639,12 +317,12 @@ static int __init clk_starfive_jh7100_probe(struct platform_device *pdev)
                struct clk_parent_data parents[4] = {};
                struct clk_init_data init = {
                        .name = jh7100_clk_data[idx].name,
-                       .ops = starfive_jh7100_clk_ops(max),
+                       .ops = starfive_jh71x0_clk_ops(max),
                        .parent_data = parents,
-                       .num_parents = ((max & JH7100_CLK_MUX_MASK) >> JH7100_CLK_MUX_SHIFT) + 1,
+                       .num_parents = ((max & JH71X0_CLK_MUX_MASK) >> JH71X0_CLK_MUX_SHIFT) + 1,
                        .flags = jh7100_clk_data[idx].flags,
                };
-               struct jh7100_clk *clk = &priv->reg[idx];
+               struct jh71x0_clk *clk = &priv->reg[idx];
                unsigned int i;
 
                for (i = 0; i < init.num_parents; i++) {
@@ -666,7 +344,7 @@ static int __init clk_starfive_jh7100_probe(struct platform_device *pdev)
 
                clk->hw.init = &init;
                clk->idx = idx;
-               clk->max_div = max & JH7100_CLK_DIV_MASK;
+               clk->max_div = max & JH71X0_CLK_DIV_MASK;
 
                ret = devm_clk_hw_register(priv->dev, &clk->hw);
                if (ret)
diff --git a/drivers/clk/starfive/clk-starfive-jh7100.h b/drivers/clk/starfive/clk-starfive-jh7100.h
deleted file mode 100644 (file)
index f116be5..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __CLK_STARFIVE_JH7100_H
-#define __CLK_STARFIVE_JH7100_H
-
-#include <linux/bits.h>
-#include <linux/clk-provider.h>
-
-/* register fields */
-#define JH7100_CLK_ENABLE      BIT(31)
-#define JH7100_CLK_INVERT      BIT(30)
-#define JH7100_CLK_MUX_MASK    GENMASK(27, 24)
-#define JH7100_CLK_MUX_SHIFT   24
-#define JH7100_CLK_DIV_MASK    GENMASK(23, 0)
-#define JH7100_CLK_FRAC_MASK   GENMASK(15, 8)
-#define JH7100_CLK_FRAC_SHIFT  8
-#define JH7100_CLK_INT_MASK    GENMASK(7, 0)
-
-/* fractional divider min/max */
-#define JH7100_CLK_FRAC_MIN    100UL
-#define JH7100_CLK_FRAC_MAX    25599UL
-
-/* clock data */
-struct jh7100_clk_data {
-       const char *name;
-       unsigned long flags;
-       u32 max;
-       u8 parents[4];
-};
-
-#define JH7100_GATE(_idx, _name, _flags, _parent) [_idx] = {                   \
-       .name = _name,                                                          \
-       .flags = CLK_SET_RATE_PARENT | (_flags),                                \
-       .max = JH7100_CLK_ENABLE,                                               \
-       .parents = { [0] = _parent },                                           \
-}
-
-#define JH7100__DIV(_idx, _name, _max, _parent) [_idx] = {                     \
-       .name = _name,                                                          \
-       .flags = 0,                                                             \
-       .max = _max,                                                            \
-       .parents = { [0] = _parent },                                           \
-}
-
-#define JH7100_GDIV(_idx, _name, _flags, _max, _parent) [_idx] = {             \
-       .name = _name,                                                          \
-       .flags = _flags,                                                        \
-       .max = JH7100_CLK_ENABLE | (_max),                                      \
-       .parents = { [0] = _parent },                                           \
-}
-
-#define JH7100_FDIV(_idx, _name, _parent) [_idx] = {                           \
-       .name = _name,                                                          \
-       .flags = 0,                                                             \
-       .max = JH7100_CLK_FRAC_MAX,                                             \
-       .parents = { [0] = _parent },                                           \
-}
-
-#define JH7100__MUX(_idx, _name, _nparents, ...) [_idx] = {                    \
-       .name = _name,                                                          \
-       .flags = 0,                                                             \
-       .max = ((_nparents) - 1) << JH7100_CLK_MUX_SHIFT,                       \
-       .parents = { __VA_ARGS__ },                                             \
-}
-
-#define JH7100_GMUX(_idx, _name, _flags, _nparents, ...) [_idx] = {            \
-       .name = _name,                                                          \
-       .flags = _flags,                                                        \
-       .max = JH7100_CLK_ENABLE |                                              \
-               (((_nparents) - 1) << JH7100_CLK_MUX_SHIFT),                    \
-       .parents = { __VA_ARGS__ },                                             \
-}
-
-#define JH7100_MDIV(_idx, _name, _max, _nparents, ...) [_idx] = {              \
-       .name = _name,                                                          \
-       .flags = 0,                                                             \
-       .max = (((_nparents) - 1) << JH7100_CLK_MUX_SHIFT) | (_max),            \
-       .parents = { __VA_ARGS__ },                                             \
-}
-
-#define JH7100__GMD(_idx, _name, _flags, _max, _nparents, ...) [_idx] = {      \
-       .name = _name,                                                          \
-       .flags = _flags,                                                        \
-       .max = JH7100_CLK_ENABLE |                                              \
-               (((_nparents) - 1) << JH7100_CLK_MUX_SHIFT) | (_max),           \
-       .parents = { __VA_ARGS__ },                                             \
-}
-
-#define JH7100__INV(_idx, _name, _parent) [_idx] = {                           \
-       .name = _name,                                                          \
-       .flags = CLK_SET_RATE_PARENT,                                           \
-       .max = JH7100_CLK_INVERT,                                               \
-       .parents = { [0] = _parent },                                           \
-}
-
-struct jh7100_clk {
-       struct clk_hw hw;
-       unsigned int idx;
-       unsigned int max_div;
-};
-
-struct jh7100_clk_priv {
-       /* protect clk enable and set rate/parent from happening at the same time */
-       spinlock_t rmw_lock;
-       struct device *dev;
-       void __iomem *base;
-       struct clk_hw *pll[3];
-       struct jh7100_clk reg[];
-};
-
-const struct clk_ops *starfive_jh7100_clk_ops(u32 max);
-
-#endif
diff --git a/drivers/clk/starfive/clk-starfive-jh7110-aon.c b/drivers/clk/starfive/clk-starfive-jh7110-aon.c
new file mode 100644 (file)
index 0000000..62954eb
--- /dev/null
@@ -0,0 +1,154 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * StarFive JH7110 Always-On Clock Driver
+ *
+ * Copyright (C) 2022 Emil Renner Berthing <kernel@esmil.dk>
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+
+#include <dt-bindings/clock/starfive,jh7110-crg.h>
+
+#include "clk-starfive-jh7110.h"
+
+/* external clocks */
+#define JH7110_AONCLK_OSC              (JH7110_AONCLK_END + 0)
+#define JH7110_AONCLK_GMAC0_RMII_REFIN (JH7110_AONCLK_END + 1)
+#define JH7110_AONCLK_GMAC0_RGMII_RXIN (JH7110_AONCLK_END + 2)
+#define JH7110_AONCLK_STG_AXIAHB       (JH7110_AONCLK_END + 3)
+#define JH7110_AONCLK_APB_BUS          (JH7110_AONCLK_END + 4)
+#define JH7110_AONCLK_GMAC0_GTXCLK     (JH7110_AONCLK_END + 5)
+#define JH7110_AONCLK_RTC_OSC          (JH7110_AONCLK_END + 6)
+
+static const struct jh71x0_clk_data jh7110_aonclk_data[] = {
+       /* source */
+       JH71X0__DIV(JH7110_AONCLK_OSC_DIV4, "osc_div4", 4, JH7110_AONCLK_OSC),
+       JH71X0__MUX(JH7110_AONCLK_APB_FUNC, "apb_func", 2,
+                   JH7110_AONCLK_OSC_DIV4,
+                   JH7110_AONCLK_OSC),
+       /* gmac0 */
+       JH71X0_GATE(JH7110_AONCLK_GMAC0_AHB, "gmac0_ahb", 0, JH7110_AONCLK_STG_AXIAHB),
+       JH71X0_GATE(JH7110_AONCLK_GMAC0_AXI, "gmac0_axi", 0, JH7110_AONCLK_STG_AXIAHB),
+       JH71X0__DIV(JH7110_AONCLK_GMAC0_RMII_RTX, "gmac0_rmii_rtx", 30,
+                   JH7110_AONCLK_GMAC0_RMII_REFIN),
+       JH71X0_GMUX(JH7110_AONCLK_GMAC0_TX, "gmac0_tx",
+                   CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT, 2,
+                   JH7110_AONCLK_GMAC0_GTXCLK,
+                   JH7110_AONCLK_GMAC0_RMII_RTX),
+       JH71X0__INV(JH7110_AONCLK_GMAC0_TX_INV, "gmac0_tx_inv", JH7110_AONCLK_GMAC0_TX),
+       JH71X0__MUX(JH7110_AONCLK_GMAC0_RX, "gmac0_rx", 2,
+                   JH7110_AONCLK_GMAC0_RGMII_RXIN,
+                   JH7110_AONCLK_GMAC0_RMII_RTX),
+       JH71X0__INV(JH7110_AONCLK_GMAC0_RX_INV, "gmac0_rx_inv", JH7110_AONCLK_GMAC0_RX),
+       /* otpc */
+       JH71X0_GATE(JH7110_AONCLK_OTPC_APB, "otpc_apb", 0, JH7110_AONCLK_APB_BUS),
+       /* rtc */
+       JH71X0_GATE(JH7110_AONCLK_RTC_APB, "rtc_apb", 0, JH7110_AONCLK_APB_BUS),
+       JH71X0__DIV(JH7110_AONCLK_RTC_INTERNAL, "rtc_internal", 1022, JH7110_AONCLK_OSC),
+       JH71X0__MUX(JH7110_AONCLK_RTC_32K, "rtc_32k", 2,
+                   JH7110_AONCLK_RTC_OSC,
+                   JH7110_AONCLK_RTC_INTERNAL),
+       JH71X0_GATE(JH7110_AONCLK_RTC_CAL, "rtc_cal", 0, JH7110_AONCLK_OSC),
+};
+
+static struct clk_hw *jh7110_aonclk_get(struct of_phandle_args *clkspec, void *data)
+{
+       struct jh71x0_clk_priv *priv = data;
+       unsigned int idx = clkspec->args[0];
+
+       if (idx < JH7110_AONCLK_END)
+               return &priv->reg[idx].hw;
+
+       return ERR_PTR(-EINVAL);
+}
+
+static int jh7110_aoncrg_probe(struct platform_device *pdev)
+{
+       struct jh71x0_clk_priv *priv;
+       unsigned int idx;
+       int ret;
+
+       priv = devm_kzalloc(&pdev->dev,
+                           struct_size(priv, reg, JH7110_AONCLK_END),
+                           GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       spin_lock_init(&priv->rmw_lock);
+       priv->dev = &pdev->dev;
+       priv->base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(priv->base))
+               return PTR_ERR(priv->base);
+
+       for (idx = 0; idx < JH7110_AONCLK_END; idx++) {
+               u32 max = jh7110_aonclk_data[idx].max;
+               struct clk_parent_data parents[4] = {};
+               struct clk_init_data init = {
+                       .name = jh7110_aonclk_data[idx].name,
+                       .ops = starfive_jh71x0_clk_ops(max),
+                       .parent_data = parents,
+                       .num_parents =
+                               ((max & JH71X0_CLK_MUX_MASK) >> JH71X0_CLK_MUX_SHIFT) + 1,
+                       .flags = jh7110_aonclk_data[idx].flags,
+               };
+               struct jh71x0_clk *clk = &priv->reg[idx];
+               unsigned int i;
+
+               for (i = 0; i < init.num_parents; i++) {
+                       unsigned int pidx = jh7110_aonclk_data[idx].parents[i];
+
+                       if (pidx < JH7110_AONCLK_END)
+                               parents[i].hw = &priv->reg[pidx].hw;
+                       else if (pidx == JH7110_AONCLK_OSC)
+                               parents[i].fw_name = "osc";
+                       else if (pidx == JH7110_AONCLK_GMAC0_RMII_REFIN)
+                               parents[i].fw_name = "gmac0_rmii_refin";
+                       else if (pidx == JH7110_AONCLK_GMAC0_RGMII_RXIN)
+                               parents[i].fw_name = "gmac0_rgmii_rxin";
+                       else if (pidx == JH7110_AONCLK_STG_AXIAHB)
+                               parents[i].fw_name = "stg_axiahb";
+                       else if (pidx == JH7110_AONCLK_APB_BUS)
+                               parents[i].fw_name = "apb_bus";
+                       else if (pidx == JH7110_AONCLK_GMAC0_GTXCLK)
+                               parents[i].fw_name = "gmac0_gtxclk";
+                       else if (pidx == JH7110_AONCLK_RTC_OSC)
+                               parents[i].fw_name = "rtc_osc";
+               }
+
+               clk->hw.init = &init;
+               clk->idx = idx;
+               clk->max_div = max & JH71X0_CLK_DIV_MASK;
+
+               ret = devm_clk_hw_register(&pdev->dev, &clk->hw);
+               if (ret)
+                       return ret;
+       }
+
+       ret = devm_of_clk_add_hw_provider(&pdev->dev, jh7110_aonclk_get, priv);
+       if (ret)
+               return ret;
+
+       return jh7110_reset_controller_register(priv, "rst-aon", 1);
+}
+
+static const struct of_device_id jh7110_aoncrg_match[] = {
+       { .compatible = "starfive,jh7110-aoncrg" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, jh7110_aoncrg_match);
+
+static struct platform_driver jh7110_aoncrg_driver = {
+       .probe = jh7110_aoncrg_probe,
+       .driver = {
+               .name = "clk-starfive-jh7110-aon",
+               .of_match_table = jh7110_aoncrg_match,
+       },
+};
+module_platform_driver(jh7110_aoncrg_driver);
+
+MODULE_AUTHOR("Emil Renner Berthing");
+MODULE_DESCRIPTION("StarFive JH7110 always-on clock driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/clk/starfive/clk-starfive-jh7110-sys.c b/drivers/clk/starfive/clk-starfive-jh7110-sys.c
new file mode 100644 (file)
index 0000000..e603134
--- /dev/null
@@ -0,0 +1,497 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * StarFive JH7110 System Clock Driver
+ *
+ * Copyright (C) 2022 Emil Renner Berthing <kernel@esmil.dk>
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/clk-provider.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <soc/starfive/reset-starfive-jh71x0.h>
+
+#include <dt-bindings/clock/starfive,jh7110-crg.h>
+
+#include "clk-starfive-jh7110.h"
+
+/* external clocks */
+#define JH7110_SYSCLK_OSC                      (JH7110_SYSCLK_END + 0)
+#define JH7110_SYSCLK_GMAC1_RMII_REFIN         (JH7110_SYSCLK_END + 1)
+#define JH7110_SYSCLK_GMAC1_RGMII_RXIN         (JH7110_SYSCLK_END + 2)
+#define JH7110_SYSCLK_I2STX_BCLK_EXT           (JH7110_SYSCLK_END + 3)
+#define JH7110_SYSCLK_I2STX_LRCK_EXT           (JH7110_SYSCLK_END + 4)
+#define JH7110_SYSCLK_I2SRX_BCLK_EXT           (JH7110_SYSCLK_END + 5)
+#define JH7110_SYSCLK_I2SRX_LRCK_EXT           (JH7110_SYSCLK_END + 6)
+#define JH7110_SYSCLK_TDM_EXT                  (JH7110_SYSCLK_END + 7)
+#define JH7110_SYSCLK_MCLK_EXT                 (JH7110_SYSCLK_END + 8)
+#define JH7110_SYSCLK_PLL0_OUT                 (JH7110_SYSCLK_END + 9)
+#define JH7110_SYSCLK_PLL1_OUT                 (JH7110_SYSCLK_END + 10)
+#define JH7110_SYSCLK_PLL2_OUT                 (JH7110_SYSCLK_END + 11)
+
+static const struct jh71x0_clk_data jh7110_sysclk_data[] __initconst = {
+       /* root */
+       JH71X0__MUX(JH7110_SYSCLK_CPU_ROOT, "cpu_root", 2,
+                   JH7110_SYSCLK_OSC,
+                   JH7110_SYSCLK_PLL0_OUT),
+       JH71X0__DIV(JH7110_SYSCLK_CPU_CORE, "cpu_core", 7, JH7110_SYSCLK_CPU_ROOT),
+       JH71X0__DIV(JH7110_SYSCLK_CPU_BUS, "cpu_bus", 2, JH7110_SYSCLK_CPU_CORE),
+       JH71X0__MUX(JH7110_SYSCLK_GPU_ROOT, "gpu_root", 2,
+                   JH7110_SYSCLK_PLL2_OUT,
+                   JH7110_SYSCLK_PLL1_OUT),
+       JH71X0_MDIV(JH7110_SYSCLK_PERH_ROOT, "perh_root", 2, 2,
+                   JH7110_SYSCLK_PLL0_OUT,
+                   JH7110_SYSCLK_PLL2_OUT),
+       JH71X0__MUX(JH7110_SYSCLK_BUS_ROOT, "bus_root", 2,
+                   JH7110_SYSCLK_OSC,
+                   JH7110_SYSCLK_PLL2_OUT),
+       JH71X0__DIV(JH7110_SYSCLK_NOCSTG_BUS, "nocstg_bus", 3, JH7110_SYSCLK_BUS_ROOT),
+       JH71X0__DIV(JH7110_SYSCLK_AXI_CFG0, "axi_cfg0", 3, JH7110_SYSCLK_BUS_ROOT),
+       JH71X0__DIV(JH7110_SYSCLK_STG_AXIAHB, "stg_axiahb", 2, JH7110_SYSCLK_AXI_CFG0),
+       JH71X0_GATE(JH7110_SYSCLK_AHB0, "ahb0", CLK_IS_CRITICAL, JH7110_SYSCLK_STG_AXIAHB),
+       JH71X0_GATE(JH7110_SYSCLK_AHB1, "ahb1", CLK_IS_CRITICAL, JH7110_SYSCLK_STG_AXIAHB),
+       JH71X0__DIV(JH7110_SYSCLK_APB_BUS, "apb_bus", 8, JH7110_SYSCLK_STG_AXIAHB),
+       JH71X0_GATE(JH7110_SYSCLK_APB0, "apb0", CLK_IS_CRITICAL, JH7110_SYSCLK_APB_BUS),
+       JH71X0__DIV(JH7110_SYSCLK_PLL0_DIV2, "pll0_div2", 2, JH7110_SYSCLK_PLL0_OUT),
+       JH71X0__DIV(JH7110_SYSCLK_PLL1_DIV2, "pll1_div2", 2, JH7110_SYSCLK_PLL1_OUT),
+       JH71X0__DIV(JH7110_SYSCLK_PLL2_DIV2, "pll2_div2", 2, JH7110_SYSCLK_PLL2_OUT),
+       JH71X0__DIV(JH7110_SYSCLK_AUDIO_ROOT, "audio_root", 8, JH7110_SYSCLK_PLL2_OUT),
+       JH71X0__DIV(JH7110_SYSCLK_MCLK_INNER, "mclk_inner", 64, JH7110_SYSCLK_AUDIO_ROOT),
+       JH71X0__MUX(JH7110_SYSCLK_MCLK, "mclk", 2,
+                   JH7110_SYSCLK_MCLK_INNER,
+                   JH7110_SYSCLK_MCLK_EXT),
+       JH71X0_GATE(JH7110_SYSCLK_MCLK_OUT, "mclk_out", 0, JH7110_SYSCLK_MCLK_INNER),
+       JH71X0_MDIV(JH7110_SYSCLK_ISP_2X, "isp_2x", 8, 2,
+                   JH7110_SYSCLK_PLL2_OUT,
+                   JH7110_SYSCLK_PLL1_OUT),
+       JH71X0__DIV(JH7110_SYSCLK_ISP_AXI, "isp_axi", 4, JH7110_SYSCLK_ISP_2X),
+       JH71X0_GDIV(JH7110_SYSCLK_GCLK0, "gclk0", 0, 62, JH7110_SYSCLK_PLL0_DIV2),
+       JH71X0_GDIV(JH7110_SYSCLK_GCLK1, "gclk1", 0, 62, JH7110_SYSCLK_PLL1_DIV2),
+       JH71X0_GDIV(JH7110_SYSCLK_GCLK2, "gclk2", 0, 62, JH7110_SYSCLK_PLL2_DIV2),
+       /* cores */
+       JH71X0_GATE(JH7110_SYSCLK_CORE, "core", CLK_IS_CRITICAL, JH7110_SYSCLK_CPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_CORE1, "core1", CLK_IS_CRITICAL, JH7110_SYSCLK_CPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_CORE2, "core2", CLK_IS_CRITICAL, JH7110_SYSCLK_CPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_CORE3, "core3", CLK_IS_CRITICAL, JH7110_SYSCLK_CPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_CORE4, "core4", CLK_IS_CRITICAL, JH7110_SYSCLK_CPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_DEBUG, "debug", 0, JH7110_SYSCLK_CPU_BUS),
+       JH71X0__DIV(JH7110_SYSCLK_RTC_TOGGLE, "rtc_toggle", 6, JH7110_SYSCLK_OSC),
+       JH71X0_GATE(JH7110_SYSCLK_TRACE0, "trace0", 0, JH7110_SYSCLK_CPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_TRACE1, "trace1", 0, JH7110_SYSCLK_CPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_TRACE2, "trace2", 0, JH7110_SYSCLK_CPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_TRACE3, "trace3", 0, JH7110_SYSCLK_CPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_TRACE4, "trace4", 0, JH7110_SYSCLK_CPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_TRACE_COM, "trace_com", 0, JH7110_SYSCLK_CPU_BUS),
+       /* noc */
+       JH71X0_GATE(JH7110_SYSCLK_NOC_BUS_CPU_AXI, "noc_bus_cpu_axi", CLK_IS_CRITICAL,
+                   JH7110_SYSCLK_CPU_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_NOC_BUS_AXICFG0_AXI, "noc_bus_axicfg0_axi", CLK_IS_CRITICAL,
+                   JH7110_SYSCLK_AXI_CFG0),
+       /* ddr */
+       JH71X0__DIV(JH7110_SYSCLK_OSC_DIV2, "osc_div2", 2, JH7110_SYSCLK_OSC),
+       JH71X0__DIV(JH7110_SYSCLK_PLL1_DIV4, "pll1_div4", 2, JH7110_SYSCLK_PLL1_DIV2),
+       JH71X0__DIV(JH7110_SYSCLK_PLL1_DIV8, "pll1_div8", 2, JH7110_SYSCLK_PLL1_DIV4),
+       JH71X0__MUX(JH7110_SYSCLK_DDR_BUS, "ddr_bus", 4,
+                   JH7110_SYSCLK_OSC_DIV2,
+                   JH7110_SYSCLK_PLL1_DIV2,
+                   JH7110_SYSCLK_PLL1_DIV4,
+                   JH7110_SYSCLK_PLL1_DIV8),
+       JH71X0_GATE(JH7110_SYSCLK_DDR_AXI, "ddr_axi", CLK_IS_CRITICAL, JH7110_SYSCLK_DDR_BUS),
+       /* gpu */
+       JH71X0__DIV(JH7110_SYSCLK_GPU_CORE, "gpu_core", 7, JH7110_SYSCLK_GPU_ROOT),
+       JH71X0_GATE(JH7110_SYSCLK_GPU_CORE_CLK, "gpu_core_clk", 0, JH7110_SYSCLK_GPU_CORE),
+       JH71X0_GATE(JH7110_SYSCLK_GPU_SYS_CLK, "gpu_sys_clk", 0, JH7110_SYSCLK_ISP_AXI),
+       JH71X0_GATE(JH7110_SYSCLK_GPU_APB, "gpu_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GDIV(JH7110_SYSCLK_GPU_RTC_TOGGLE, "gpu_rtc_toggle", 0, 12, JH7110_SYSCLK_OSC),
+       JH71X0_GATE(JH7110_SYSCLK_NOC_BUS_GPU_AXI, "noc_bus_gpu_axi", 0, JH7110_SYSCLK_GPU_CORE),
+       /* isp */
+       JH71X0_GATE(JH7110_SYSCLK_ISP_TOP_CORE, "isp_top_core", 0, JH7110_SYSCLK_ISP_2X),
+       JH71X0_GATE(JH7110_SYSCLK_ISP_TOP_AXI, "isp_top_axi", 0, JH7110_SYSCLK_ISP_AXI),
+       JH71X0_GATE(JH7110_SYSCLK_NOC_BUS_ISP_AXI, "noc_bus_isp_axi", CLK_IS_CRITICAL,
+                   JH7110_SYSCLK_ISP_AXI),
+       /* hifi4 */
+       JH71X0__DIV(JH7110_SYSCLK_HIFI4_CORE, "hifi4_core", 15, JH7110_SYSCLK_BUS_ROOT),
+       JH71X0__DIV(JH7110_SYSCLK_HIFI4_AXI, "hifi4_axi", 2, JH7110_SYSCLK_HIFI4_CORE),
+       /* axi_cfg1 */
+       JH71X0_GATE(JH7110_SYSCLK_AXI_CFG1_MAIN, "axi_cfg1_main", CLK_IS_CRITICAL,
+                   JH7110_SYSCLK_ISP_AXI),
+       JH71X0_GATE(JH7110_SYSCLK_AXI_CFG1_AHB, "axi_cfg1_ahb", CLK_IS_CRITICAL,
+                   JH7110_SYSCLK_AHB0),
+       /* vout */
+       JH71X0_GATE(JH7110_SYSCLK_VOUT_SRC, "vout_src", 0, JH7110_SYSCLK_PLL2_OUT),
+       JH71X0__DIV(JH7110_SYSCLK_VOUT_AXI, "vout_axi", 7, JH7110_SYSCLK_PLL2_OUT),
+       JH71X0_GATE(JH7110_SYSCLK_NOC_BUS_DISP_AXI, "noc_bus_disp_axi", 0, JH7110_SYSCLK_VOUT_AXI),
+       JH71X0_GATE(JH7110_SYSCLK_VOUT_TOP_AHB, "vout_top_ahb", 0, JH7110_SYSCLK_AHB1),
+       JH71X0_GATE(JH7110_SYSCLK_VOUT_TOP_AXI, "vout_top_axi", 0, JH7110_SYSCLK_VOUT_AXI),
+       JH71X0_GATE(JH7110_SYSCLK_VOUT_TOP_HDMITX0_MCLK, "vout_top_hdmitx0_mclk", 0,
+                   JH7110_SYSCLK_MCLK),
+       JH71X0__DIV(JH7110_SYSCLK_VOUT_TOP_MIPIPHY_REF, "vout_top_mipiphy_ref", 2,
+                   JH7110_SYSCLK_OSC),
+       /* jpegc */
+       JH71X0__DIV(JH7110_SYSCLK_JPEGC_AXI, "jpegc_axi", 16, JH7110_SYSCLK_PLL2_OUT),
+       JH71X0_GATE(JH7110_SYSCLK_CODAJ12_AXI, "codaj12_axi", 0, JH7110_SYSCLK_JPEGC_AXI),
+       JH71X0_GDIV(JH7110_SYSCLK_CODAJ12_CORE, "codaj12_core", 0, 16, JH7110_SYSCLK_PLL2_OUT),
+       JH71X0_GATE(JH7110_SYSCLK_CODAJ12_APB, "codaj12_apb", 0, JH7110_SYSCLK_APB_BUS),
+       /* vdec */
+       JH71X0__DIV(JH7110_SYSCLK_VDEC_AXI, "vdec_axi", 7, JH7110_SYSCLK_BUS_ROOT),
+       JH71X0_GATE(JH7110_SYSCLK_WAVE511_AXI, "wave511_axi", 0, JH7110_SYSCLK_VDEC_AXI),
+       JH71X0_GDIV(JH7110_SYSCLK_WAVE511_BPU, "wave511_bpu", 0, 7, JH7110_SYSCLK_BUS_ROOT),
+       JH71X0_GDIV(JH7110_SYSCLK_WAVE511_VCE, "wave511_vce", 0, 7, JH7110_SYSCLK_PLL0_OUT),
+       JH71X0_GATE(JH7110_SYSCLK_WAVE511_APB, "wave511_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_VDEC_JPG, "vdec_jpg", 0, JH7110_SYSCLK_JPEGC_AXI),
+       JH71X0_GATE(JH7110_SYSCLK_VDEC_MAIN, "vdec_main", 0, JH7110_SYSCLK_VDEC_AXI),
+       JH71X0_GATE(JH7110_SYSCLK_NOC_BUS_VDEC_AXI, "noc_bus_vdec_axi", 0, JH7110_SYSCLK_VDEC_AXI),
+       /* venc */
+       JH71X0__DIV(JH7110_SYSCLK_VENC_AXI, "venc_axi", 15, JH7110_SYSCLK_PLL2_OUT),
+       JH71X0_GATE(JH7110_SYSCLK_WAVE420L_AXI, "wave420l_axi", 0, JH7110_SYSCLK_VENC_AXI),
+       JH71X0_GDIV(JH7110_SYSCLK_WAVE420L_BPU, "wave420l_bpu", 0, 15, JH7110_SYSCLK_PLL2_OUT),
+       JH71X0_GDIV(JH7110_SYSCLK_WAVE420L_VCE, "wave420l_vce", 0, 15, JH7110_SYSCLK_PLL2_OUT),
+       JH71X0_GATE(JH7110_SYSCLK_WAVE420L_APB, "wave420l_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_NOC_BUS_VENC_AXI, "noc_bus_venc_axi", 0, JH7110_SYSCLK_VENC_AXI),
+       /* axi_cfg0 */
+       JH71X0_GATE(JH7110_SYSCLK_AXI_CFG0_MAIN_DIV, "axi_cfg0_main_div", CLK_IS_CRITICAL,
+                   JH7110_SYSCLK_AHB1),
+       JH71X0_GATE(JH7110_SYSCLK_AXI_CFG0_MAIN, "axi_cfg0_main", CLK_IS_CRITICAL,
+                   JH7110_SYSCLK_AXI_CFG0),
+       JH71X0_GATE(JH7110_SYSCLK_AXI_CFG0_HIFI4, "axi_cfg0_hifi4", CLK_IS_CRITICAL,
+                   JH7110_SYSCLK_HIFI4_AXI),
+       /* intmem */
+       JH71X0_GATE(JH7110_SYSCLK_AXIMEM2_AXI, "aximem2_axi", 0, JH7110_SYSCLK_AXI_CFG0),
+       /* qspi */
+       JH71X0_GATE(JH7110_SYSCLK_QSPI_AHB, "qspi_ahb", 0, JH7110_SYSCLK_AHB1),
+       JH71X0_GATE(JH7110_SYSCLK_QSPI_APB, "qspi_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0__DIV(JH7110_SYSCLK_QSPI_REF_SRC, "qspi_ref_src", 16, JH7110_SYSCLK_PLL0_OUT),
+       JH71X0_GMUX(JH7110_SYSCLK_QSPI_REF, "qspi_ref", 0, 2,
+                   JH7110_SYSCLK_OSC,
+                   JH7110_SYSCLK_QSPI_REF_SRC),
+       /* sdio */
+       JH71X0_GATE(JH7110_SYSCLK_SDIO0_AHB, "sdio0_ahb", 0, JH7110_SYSCLK_AHB0),
+       JH71X0_GATE(JH7110_SYSCLK_SDIO1_AHB, "sdio1_ahb", 0, JH7110_SYSCLK_AHB0),
+       JH71X0_GDIV(JH7110_SYSCLK_SDIO0_SDCARD, "sdio0_sdcard", 0, 15, JH7110_SYSCLK_AXI_CFG0),
+       JH71X0_GDIV(JH7110_SYSCLK_SDIO1_SDCARD, "sdio1_sdcard", 0, 15, JH7110_SYSCLK_AXI_CFG0),
+       /* stg */
+       JH71X0__DIV(JH7110_SYSCLK_USB_125M, "usb_125m", 15, JH7110_SYSCLK_PLL0_OUT),
+       JH71X0_GATE(JH7110_SYSCLK_NOC_BUS_STG_AXI, "noc_bus_stg_axi", CLK_IS_CRITICAL,
+                   JH7110_SYSCLK_NOCSTG_BUS),
+       /* gmac1 */
+       JH71X0_GATE(JH7110_SYSCLK_GMAC1_AHB, "gmac1_ahb", 0, JH7110_SYSCLK_AHB0),
+       JH71X0_GATE(JH7110_SYSCLK_GMAC1_AXI, "gmac1_axi", 0, JH7110_SYSCLK_STG_AXIAHB),
+       JH71X0__DIV(JH7110_SYSCLK_GMAC_SRC, "gmac_src", 7, JH7110_SYSCLK_PLL0_OUT),
+       JH71X0__DIV(JH7110_SYSCLK_GMAC1_GTXCLK, "gmac1_gtxclk", 15, JH7110_SYSCLK_PLL0_OUT),
+       JH71X0__DIV(JH7110_SYSCLK_GMAC1_RMII_RTX, "gmac1_rmii_rtx", 30,
+                   JH7110_SYSCLK_GMAC1_RMII_REFIN),
+       JH71X0_GDIV(JH7110_SYSCLK_GMAC1_PTP, "gmac1_ptp", 0, 31, JH7110_SYSCLK_GMAC_SRC),
+       JH71X0__MUX(JH7110_SYSCLK_GMAC1_RX, "gmac1_rx", 2,
+                   JH7110_SYSCLK_GMAC1_RGMII_RXIN,
+                   JH7110_SYSCLK_GMAC1_RMII_RTX),
+       JH71X0__INV(JH7110_SYSCLK_GMAC1_RX_INV, "gmac1_rx_inv", JH7110_SYSCLK_GMAC1_RX),
+       JH71X0_GMUX(JH7110_SYSCLK_GMAC1_TX, "gmac1_tx",
+                   CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT, 2,
+                   JH7110_SYSCLK_GMAC1_GTXCLK,
+                   JH7110_SYSCLK_GMAC1_RMII_RTX),
+       JH71X0__INV(JH7110_SYSCLK_GMAC1_TX_INV, "gmac1_tx_inv", JH7110_SYSCLK_GMAC1_TX),
+       JH71X0_GATE(JH7110_SYSCLK_GMAC1_GTXC, "gmac1_gtxc", 0, JH7110_SYSCLK_GMAC1_GTXCLK),
+       /* gmac0 */
+       JH71X0_GDIV(JH7110_SYSCLK_GMAC0_GTXCLK, "gmac0_gtxclk", 0, 15, JH7110_SYSCLK_PLL0_OUT),
+       JH71X0_GDIV(JH7110_SYSCLK_GMAC0_PTP, "gmac0_ptp", 0, 31, JH7110_SYSCLK_GMAC_SRC),
+       JH71X0_GDIV(JH7110_SYSCLK_GMAC_PHY, "gmac_phy", 0, 31, JH7110_SYSCLK_GMAC_SRC),
+       JH71X0_GATE(JH7110_SYSCLK_GMAC0_GTXC, "gmac0_gtxc", 0, JH7110_SYSCLK_GMAC0_GTXCLK),
+       /* apb misc */
+       JH71X0_GATE(JH7110_SYSCLK_IOMUX_APB, "iomux_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_MAILBOX_APB, "mailbox_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_INT_CTRL_APB, "int_ctrl_apb", 0, JH7110_SYSCLK_APB_BUS),
+       /* can0 */
+       JH71X0_GATE(JH7110_SYSCLK_CAN0_APB, "can0_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GDIV(JH7110_SYSCLK_CAN0_TIMER, "can0_timer", 0, 24, JH7110_SYSCLK_OSC),
+       JH71X0_GDIV(JH7110_SYSCLK_CAN0_CAN, "can0_can", 0, 63, JH7110_SYSCLK_PERH_ROOT),
+       /* can1 */
+       JH71X0_GATE(JH7110_SYSCLK_CAN1_APB, "can1_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GDIV(JH7110_SYSCLK_CAN1_TIMER, "can1_timer", 0, 24, JH7110_SYSCLK_OSC),
+       JH71X0_GDIV(JH7110_SYSCLK_CAN1_CAN, "can1_can", 0, 63, JH7110_SYSCLK_PERH_ROOT),
+       /* pwm */
+       JH71X0_GATE(JH7110_SYSCLK_PWM_APB, "pwm_apb", 0, JH7110_SYSCLK_APB_BUS),
+       /* wdt */
+       JH71X0_GATE(JH7110_SYSCLK_WDT_APB, "wdt_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_WDT_CORE, "wdt_core", 0, JH7110_SYSCLK_OSC),
+       /* timer */
+       JH71X0_GATE(JH7110_SYSCLK_TIMER_APB, "timer_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_TIMER0, "timer0", 0, JH7110_SYSCLK_OSC),
+       JH71X0_GATE(JH7110_SYSCLK_TIMER1, "timer1", 0, JH7110_SYSCLK_OSC),
+       JH71X0_GATE(JH7110_SYSCLK_TIMER2, "timer2", 0, JH7110_SYSCLK_OSC),
+       JH71X0_GATE(JH7110_SYSCLK_TIMER3, "timer3", 0, JH7110_SYSCLK_OSC),
+       /* temp sensor */
+       JH71X0_GATE(JH7110_SYSCLK_TEMP_APB, "temp_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GDIV(JH7110_SYSCLK_TEMP_CORE, "temp_core", 0, 24, JH7110_SYSCLK_OSC),
+       /* spi */
+       JH71X0_GATE(JH7110_SYSCLK_SPI0_APB, "spi0_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GATE(JH7110_SYSCLK_SPI1_APB, "spi1_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GATE(JH7110_SYSCLK_SPI2_APB, "spi2_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GATE(JH7110_SYSCLK_SPI3_APB, "spi3_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_SPI4_APB, "spi4_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_SPI5_APB, "spi5_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_SPI6_APB, "spi6_apb", 0, JH7110_SYSCLK_APB_BUS),
+       /* i2c */
+       JH71X0_GATE(JH7110_SYSCLK_I2C0_APB, "i2c0_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GATE(JH7110_SYSCLK_I2C1_APB, "i2c1_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GATE(JH7110_SYSCLK_I2C2_APB, "i2c2_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GATE(JH7110_SYSCLK_I2C3_APB, "i2c3_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_I2C4_APB, "i2c4_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_I2C5_APB, "i2c5_apb", 0, JH7110_SYSCLK_APB_BUS),
+       JH71X0_GATE(JH7110_SYSCLK_I2C6_APB, "i2c6_apb", 0, JH7110_SYSCLK_APB_BUS),
+       /* uart */
+       JH71X0_GATE(JH7110_SYSCLK_UART0_APB, "uart0_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GATE(JH7110_SYSCLK_UART0_CORE, "uart0_core", 0, JH7110_SYSCLK_OSC),
+       JH71X0_GATE(JH7110_SYSCLK_UART1_APB, "uart1_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GATE(JH7110_SYSCLK_UART1_CORE, "uart1_core", 0, JH7110_SYSCLK_OSC),
+       JH71X0_GATE(JH7110_SYSCLK_UART2_APB, "uart2_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GATE(JH7110_SYSCLK_UART2_CORE, "uart2_core", 0, JH7110_SYSCLK_OSC),
+       JH71X0_GATE(JH7110_SYSCLK_UART3_APB, "uart3_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GDIV(JH7110_SYSCLK_UART3_CORE, "uart3_core", 0, 10, JH7110_SYSCLK_PERH_ROOT),
+       JH71X0_GATE(JH7110_SYSCLK_UART4_APB, "uart4_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GDIV(JH7110_SYSCLK_UART4_CORE, "uart4_core", 0, 10, JH7110_SYSCLK_PERH_ROOT),
+       JH71X0_GATE(JH7110_SYSCLK_UART5_APB, "uart5_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GDIV(JH7110_SYSCLK_UART5_CORE, "uart5_core", 0, 10, JH7110_SYSCLK_PERH_ROOT),
+       /* pwmdac */
+       JH71X0_GATE(JH7110_SYSCLK_PWMDAC_APB, "pwmdac_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GDIV(JH7110_SYSCLK_PWMDAC_CORE, "pwmdac_core", 0, 256, JH7110_SYSCLK_AUDIO_ROOT),
+       /* spdif */
+       JH71X0_GATE(JH7110_SYSCLK_SPDIF_APB, "spdif_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GATE(JH7110_SYSCLK_SPDIF_CORE, "spdif_core", 0, JH7110_SYSCLK_MCLK),
+       /* i2stx0 */
+       JH71X0_GATE(JH7110_SYSCLK_I2STX0_APB, "i2stx0_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GDIV(JH7110_SYSCLK_I2STX0_BCLK_MST, "i2stx0_bclk_mst", 0, 32, JH7110_SYSCLK_MCLK),
+       JH71X0__INV(JH7110_SYSCLK_I2STX0_BCLK_MST_INV, "i2stx0_bclk_mst_inv",
+                   JH7110_SYSCLK_I2STX0_BCLK_MST),
+       JH71X0_MDIV(JH7110_SYSCLK_I2STX0_LRCK_MST, "i2stx0_lrck_mst", 64, 2,
+                   JH7110_SYSCLK_I2STX0_BCLK_MST_INV,
+                   JH7110_SYSCLK_I2STX0_BCLK_MST),
+       JH71X0__MUX(JH7110_SYSCLK_I2STX0_BCLK, "i2stx0_bclk",   2,
+                   JH7110_SYSCLK_I2STX0_BCLK_MST,
+                   JH7110_SYSCLK_I2STX_BCLK_EXT),
+       JH71X0__INV(JH7110_SYSCLK_I2STX0_BCLK_INV, "i2stx0_bclk_inv", JH7110_SYSCLK_I2STX0_BCLK),
+       JH71X0__MUX(JH7110_SYSCLK_I2STX0_LRCK, "i2stx0_lrck", 2,
+                   JH7110_SYSCLK_I2STX0_LRCK_MST,
+                   JH7110_SYSCLK_I2STX_LRCK_EXT),
+       /* i2stx1 */
+       JH71X0_GATE(JH7110_SYSCLK_I2STX1_APB, "i2stx1_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GDIV(JH7110_SYSCLK_I2STX1_BCLK_MST, "i2stx1_bclk_mst", 0, 32, JH7110_SYSCLK_MCLK),
+       JH71X0__INV(JH7110_SYSCLK_I2STX1_BCLK_MST_INV, "i2stx1_bclk_mst_inv",
+                   JH7110_SYSCLK_I2STX1_BCLK_MST),
+       JH71X0_MDIV(JH7110_SYSCLK_I2STX1_LRCK_MST, "i2stx1_lrck_mst", 64, 2,
+                   JH7110_SYSCLK_I2STX1_BCLK_MST_INV,
+                   JH7110_SYSCLK_I2STX1_BCLK_MST),
+       JH71X0__MUX(JH7110_SYSCLK_I2STX1_BCLK, "i2stx1_bclk", 2,
+                   JH7110_SYSCLK_I2STX1_BCLK_MST,
+                   JH7110_SYSCLK_I2STX_BCLK_EXT),
+       JH71X0__INV(JH7110_SYSCLK_I2STX1_BCLK_INV, "i2stx1_bclk_inv", JH7110_SYSCLK_I2STX1_BCLK),
+       JH71X0__MUX(JH7110_SYSCLK_I2STX1_LRCK, "i2stx1_lrck", 2,
+                   JH7110_SYSCLK_I2STX1_LRCK_MST,
+                   JH7110_SYSCLK_I2STX_LRCK_EXT),
+       /* i2srx */
+       JH71X0_GATE(JH7110_SYSCLK_I2SRX_APB, "i2srx_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GDIV(JH7110_SYSCLK_I2SRX_BCLK_MST, "i2srx_bclk_mst", 0, 32, JH7110_SYSCLK_MCLK),
+       JH71X0__INV(JH7110_SYSCLK_I2SRX_BCLK_MST_INV, "i2srx_bclk_mst_inv",
+                   JH7110_SYSCLK_I2SRX_BCLK_MST),
+       JH71X0_MDIV(JH7110_SYSCLK_I2SRX_LRCK_MST, "i2srx_lrck_mst", 64, 2,
+                   JH7110_SYSCLK_I2SRX_BCLK_MST_INV,
+                   JH7110_SYSCLK_I2SRX_BCLK_MST),
+       JH71X0__MUX(JH7110_SYSCLK_I2SRX_BCLK, "i2srx_bclk", 2,
+                   JH7110_SYSCLK_I2SRX_BCLK_MST,
+                   JH7110_SYSCLK_I2SRX_BCLK_EXT),
+       JH71X0__INV(JH7110_SYSCLK_I2SRX_BCLK_INV, "i2srx_bclk_inv", JH7110_SYSCLK_I2SRX_BCLK),
+       JH71X0__MUX(JH7110_SYSCLK_I2SRX_LRCK, "i2srx_lrck", 2,
+                   JH7110_SYSCLK_I2SRX_LRCK_MST,
+                   JH7110_SYSCLK_I2SRX_LRCK_EXT),
+       /* pdm */
+       JH71X0_GDIV(JH7110_SYSCLK_PDM_DMIC, "pdm_dmic", 0, 64, JH7110_SYSCLK_MCLK),
+       JH71X0_GATE(JH7110_SYSCLK_PDM_APB, "pdm_apb", 0, JH7110_SYSCLK_APB0),
+       /* tdm */
+       JH71X0_GATE(JH7110_SYSCLK_TDM_AHB, "tdm_ahb", 0, JH7110_SYSCLK_AHB0),
+       JH71X0_GATE(JH7110_SYSCLK_TDM_APB, "tdm_apb", 0, JH7110_SYSCLK_APB0),
+       JH71X0_GDIV(JH7110_SYSCLK_TDM_INTERNAL, "tdm_internal", 0, 64, JH7110_SYSCLK_MCLK),
+       JH71X0__MUX(JH7110_SYSCLK_TDM_TDM, "tdm_tdm", 2,
+                   JH7110_SYSCLK_TDM_INTERNAL,
+                   JH7110_SYSCLK_TDM_EXT),
+       JH71X0__INV(JH7110_SYSCLK_TDM_TDM_INV, "tdm_tdm_inv", JH7110_SYSCLK_TDM_TDM),
+       /* jtag */
+       JH71X0__DIV(JH7110_SYSCLK_JTAG_CERTIFICATION_TRNG, "jtag_certification_trng", 4,
+                   JH7110_SYSCLK_OSC),
+};
+
+static struct clk_hw *jh7110_sysclk_get(struct of_phandle_args *clkspec, void *data)
+{
+       struct jh71x0_clk_priv *priv = data;
+       unsigned int idx = clkspec->args[0];
+
+       if (idx < JH7110_SYSCLK_END)
+               return &priv->reg[idx].hw;
+
+       return ERR_PTR(-EINVAL);
+}
+
+static void jh7110_reset_unregister_adev(void *_adev)
+{
+       struct auxiliary_device *adev = _adev;
+
+       auxiliary_device_delete(adev);
+       auxiliary_device_uninit(adev);
+}
+
+static void jh7110_reset_adev_release(struct device *dev)
+{
+       struct auxiliary_device *adev = to_auxiliary_dev(dev);
+       struct jh71x0_reset_adev *rdev = to_jh71x0_reset_adev(adev);
+
+       kfree(rdev);
+}
+
+int jh7110_reset_controller_register(struct jh71x0_clk_priv *priv,
+                                    const char *adev_name,
+                                    u32 adev_id)
+{
+       struct jh71x0_reset_adev *rdev;
+       struct auxiliary_device *adev;
+       int ret;
+
+       rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
+       if (!rdev)
+               return -ENOMEM;
+
+       rdev->base = priv->base;
+
+       adev = &rdev->adev;
+       adev->name = adev_name;
+       adev->dev.parent = priv->dev;
+       adev->dev.release = jh7110_reset_adev_release;
+       adev->id = adev_id;
+
+       ret = auxiliary_device_init(adev);
+       if (ret)
+               return ret;
+
+       ret = auxiliary_device_add(adev);
+       if (ret) {
+               auxiliary_device_uninit(adev);
+               return ret;
+       }
+
+       return devm_add_action_or_reset(priv->dev,
+                                       jh7110_reset_unregister_adev, adev);
+}
+EXPORT_SYMBOL_GPL(jh7110_reset_controller_register);
+
+static int __init jh7110_syscrg_probe(struct platform_device *pdev)
+{
+       struct jh71x0_clk_priv *priv;
+       unsigned int idx;
+       int ret;
+
+       priv = devm_kzalloc(&pdev->dev,
+                           struct_size(priv, reg, JH7110_SYSCLK_END),
+                           GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       spin_lock_init(&priv->rmw_lock);
+       priv->dev = &pdev->dev;
+       priv->base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(priv->base))
+               return PTR_ERR(priv->base);
+
+       /*
+        * These PLL clocks are not actually fixed factor clocks and can be
+        * controlled by the syscon registers of JH7110. They will be dropped
+        * and registered in the PLL clock driver instead.
+        */
+       /* 24MHz -> 1000.0MHz */
+       priv->pll[0] = devm_clk_hw_register_fixed_factor(priv->dev, "pll0_out",
+                                                        "osc", 0, 125, 3);
+       if (IS_ERR(priv->pll[0]))
+               return PTR_ERR(priv->pll[0]);
+
+       /* 24MHz -> 1066.0MHz */
+       priv->pll[1] = devm_clk_hw_register_fixed_factor(priv->dev, "pll1_out",
+                                                        "osc", 0, 533, 12);
+       if (IS_ERR(priv->pll[1]))
+               return PTR_ERR(priv->pll[1]);
+
+       /* 24MHz -> 1188.0MHz */
+       priv->pll[2] = devm_clk_hw_register_fixed_factor(priv->dev, "pll2_out",
+                                                        "osc", 0, 99, 2);
+       if (IS_ERR(priv->pll[2]))
+               return PTR_ERR(priv->pll[2]);
+
+       for (idx = 0; idx < JH7110_SYSCLK_END; idx++) {
+               u32 max = jh7110_sysclk_data[idx].max;
+               struct clk_parent_data parents[4] = {};
+               struct clk_init_data init = {
+                       .name = jh7110_sysclk_data[idx].name,
+                       .ops = starfive_jh71x0_clk_ops(max),
+                       .parent_data = parents,
+                       .num_parents =
+                               ((max & JH71X0_CLK_MUX_MASK) >> JH71X0_CLK_MUX_SHIFT) + 1,
+                       .flags = jh7110_sysclk_data[idx].flags,
+               };
+               struct jh71x0_clk *clk = &priv->reg[idx];
+               unsigned int i;
+
+               for (i = 0; i < init.num_parents; i++) {
+                       unsigned int pidx = jh7110_sysclk_data[idx].parents[i];
+
+                       if (pidx < JH7110_SYSCLK_END)
+                               parents[i].hw = &priv->reg[pidx].hw;
+                       else if (pidx == JH7110_SYSCLK_OSC)
+                               parents[i].fw_name = "osc";
+                       else if (pidx == JH7110_SYSCLK_GMAC1_RMII_REFIN)
+                               parents[i].fw_name = "gmac1_rmii_refin";
+                       else if (pidx == JH7110_SYSCLK_GMAC1_RGMII_RXIN)
+                               parents[i].fw_name = "gmac1_rgmii_rxin";
+                       else if (pidx == JH7110_SYSCLK_I2STX_BCLK_EXT)
+                               parents[i].fw_name = "i2stx_bclk_ext";
+                       else if (pidx == JH7110_SYSCLK_I2STX_LRCK_EXT)
+                               parents[i].fw_name = "i2stx_lrck_ext";
+                       else if (pidx == JH7110_SYSCLK_I2SRX_BCLK_EXT)
+                               parents[i].fw_name = "i2srx_bclk_ext";
+                       else if (pidx == JH7110_SYSCLK_I2SRX_LRCK_EXT)
+                               parents[i].fw_name = "i2srx_lrck_ext";
+                       else if (pidx == JH7110_SYSCLK_TDM_EXT)
+                               parents[i].fw_name = "tdm_ext";
+                       else if (pidx == JH7110_SYSCLK_MCLK_EXT)
+                               parents[i].fw_name = "mclk_ext";
+                       else
+                               parents[i].hw = priv->pll[pidx - JH7110_SYSCLK_PLL0_OUT];
+               }
+
+               clk->hw.init = &init;
+               clk->idx = idx;
+               clk->max_div = max & JH71X0_CLK_DIV_MASK;
+
+               ret = devm_clk_hw_register(&pdev->dev, &clk->hw);
+               if (ret)
+                       return ret;
+       }
+
+       ret = devm_of_clk_add_hw_provider(&pdev->dev, jh7110_sysclk_get, priv);
+       if (ret)
+               return ret;
+
+       return jh7110_reset_controller_register(priv, "rst-sys", 0);
+}
+
+static const struct of_device_id jh7110_syscrg_match[] = {
+       { .compatible = "starfive,jh7110-syscrg" },
+       { /* sentinel */ }
+};
+
+static struct platform_driver jh7110_syscrg_driver = {
+       .driver = {
+               .name = "clk-starfive-jh7110-sys",
+               .of_match_table = jh7110_syscrg_match,
+               .suppress_bind_attrs = true,
+       },
+};
+builtin_platform_driver_probe(jh7110_syscrg_driver, jh7110_syscrg_probe);
diff --git a/drivers/clk/starfive/clk-starfive-jh7110.h b/drivers/clk/starfive/clk-starfive-jh7110.h
new file mode 100644 (file)
index 0000000..f29682b
--- /dev/null
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __CLK_STARFIVE_JH7110_H
+#define __CLK_STARFIVE_JH7110_H
+
+#include "clk-starfive-jh71x0.h"
+
+int jh7110_reset_controller_register(struct jh71x0_clk_priv *priv,
+                                    const char *adev_name,
+                                    u32 adev_id);
+
+#endif
diff --git a/drivers/clk/starfive/clk-starfive-jh71x0.c b/drivers/clk/starfive/clk-starfive-jh71x0.c
new file mode 100644 (file)
index 0000000..b372083
--- /dev/null
@@ -0,0 +1,333 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * StarFive JH71X0 Clock Generator Driver
+ *
+ * Copyright (C) 2021-2022 Emil Renner Berthing <kernel@esmil.dk>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/debugfs.h>
+#include <linux/device.h>
+#include <linux/io.h>
+
+#include "clk-starfive-jh71x0.h"
+
+static struct jh71x0_clk *jh71x0_clk_from(struct clk_hw *hw)
+{
+       return container_of(hw, struct jh71x0_clk, hw);
+}
+
+static struct jh71x0_clk_priv *jh71x0_priv_from(struct jh71x0_clk *clk)
+{
+       return container_of(clk, struct jh71x0_clk_priv, reg[clk->idx]);
+}
+
+static u32 jh71x0_clk_reg_get(struct jh71x0_clk *clk)
+{
+       struct jh71x0_clk_priv *priv = jh71x0_priv_from(clk);
+       void __iomem *reg = priv->base + 4 * clk->idx;
+
+       return readl_relaxed(reg);
+}
+
+static void jh71x0_clk_reg_rmw(struct jh71x0_clk *clk, u32 mask, u32 value)
+{
+       struct jh71x0_clk_priv *priv = jh71x0_priv_from(clk);
+       void __iomem *reg = priv->base + 4 * clk->idx;
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->rmw_lock, flags);
+       value |= readl_relaxed(reg) & ~mask;
+       writel_relaxed(value, reg);
+       spin_unlock_irqrestore(&priv->rmw_lock, flags);
+}
+
+static int jh71x0_clk_enable(struct clk_hw *hw)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+
+       jh71x0_clk_reg_rmw(clk, JH71X0_CLK_ENABLE, JH71X0_CLK_ENABLE);
+       return 0;
+}
+
+static void jh71x0_clk_disable(struct clk_hw *hw)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+
+       jh71x0_clk_reg_rmw(clk, JH71X0_CLK_ENABLE, 0);
+}
+
+static int jh71x0_clk_is_enabled(struct clk_hw *hw)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+
+       return !!(jh71x0_clk_reg_get(clk) & JH71X0_CLK_ENABLE);
+}
+
+static unsigned long jh71x0_clk_recalc_rate(struct clk_hw *hw,
+                                           unsigned long parent_rate)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+       u32 div = jh71x0_clk_reg_get(clk) & JH71X0_CLK_DIV_MASK;
+
+       return div ? parent_rate / div : 0;
+}
+
+static int jh71x0_clk_determine_rate(struct clk_hw *hw,
+                                    struct clk_rate_request *req)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+       unsigned long parent = req->best_parent_rate;
+       unsigned long rate = clamp(req->rate, req->min_rate, req->max_rate);
+       unsigned long div = min_t(unsigned long, DIV_ROUND_UP(parent, rate), clk->max_div);
+       unsigned long result = parent / div;
+
+       /*
+        * we want the result clamped by min_rate and max_rate if possible:
+        * case 1: div hits the max divider value, which means it's less than
+        * parent / rate, so the result is greater than rate and min_rate in
+        * particular. we can't do anything about result > max_rate because the
+        * divider doesn't go any further.
+        * case 2: div = DIV_ROUND_UP(parent, rate) which means the result is
+        * always lower or equal to rate and max_rate. however the result may
+        * turn out lower than min_rate, but then the next higher rate is fine:
+        *   div - 1 = ceil(parent / rate) - 1 < parent / rate
+        * and thus
+        *   min_rate <= rate < parent / (div - 1)
+        */
+       if (result < req->min_rate && div > 1)
+               result = parent / (div - 1);
+
+       req->rate = result;
+       return 0;
+}
+
+static int jh71x0_clk_set_rate(struct clk_hw *hw,
+                              unsigned long rate,
+                              unsigned long parent_rate)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+       unsigned long div = clamp(DIV_ROUND_CLOSEST(parent_rate, rate),
+                                 1UL, (unsigned long)clk->max_div);
+
+       jh71x0_clk_reg_rmw(clk, JH71X0_CLK_DIV_MASK, div);
+       return 0;
+}
+
+static unsigned long jh71x0_clk_frac_recalc_rate(struct clk_hw *hw,
+                                                unsigned long parent_rate)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+       u32 reg = jh71x0_clk_reg_get(clk);
+       unsigned long div100 = 100 * (reg & JH71X0_CLK_INT_MASK) +
+                              ((reg & JH71X0_CLK_FRAC_MASK) >> JH71X0_CLK_FRAC_SHIFT);
+
+       return (div100 >= JH71X0_CLK_FRAC_MIN) ? 100 * parent_rate / div100 : 0;
+}
+
+static int jh71x0_clk_frac_determine_rate(struct clk_hw *hw,
+                                         struct clk_rate_request *req)
+{
+       unsigned long parent100 = 100 * req->best_parent_rate;
+       unsigned long rate = clamp(req->rate, req->min_rate, req->max_rate);
+       unsigned long div100 = clamp(DIV_ROUND_CLOSEST(parent100, rate),
+                                    JH71X0_CLK_FRAC_MIN, JH71X0_CLK_FRAC_MAX);
+       unsigned long result = parent100 / div100;
+
+       /* clamp the result as in jh71x0_clk_determine_rate() above */
+       if (result > req->max_rate && div100 < JH71X0_CLK_FRAC_MAX)
+               result = parent100 / (div100 + 1);
+       if (result < req->min_rate && div100 > JH71X0_CLK_FRAC_MIN)
+               result = parent100 / (div100 - 1);
+
+       req->rate = result;
+       return 0;
+}
+
+static int jh71x0_clk_frac_set_rate(struct clk_hw *hw,
+                                   unsigned long rate,
+                                   unsigned long parent_rate)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+       unsigned long div100 = clamp(DIV_ROUND_CLOSEST(100 * parent_rate, rate),
+                                    JH71X0_CLK_FRAC_MIN, JH71X0_CLK_FRAC_MAX);
+       u32 value = ((div100 % 100) << JH71X0_CLK_FRAC_SHIFT) | (div100 / 100);
+
+       jh71x0_clk_reg_rmw(clk, JH71X0_CLK_DIV_MASK, value);
+       return 0;
+}
+
+static u8 jh71x0_clk_get_parent(struct clk_hw *hw)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+       u32 value = jh71x0_clk_reg_get(clk);
+
+       return (value & JH71X0_CLK_MUX_MASK) >> JH71X0_CLK_MUX_SHIFT;
+}
+
+static int jh71x0_clk_set_parent(struct clk_hw *hw, u8 index)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+       u32 value = (u32)index << JH71X0_CLK_MUX_SHIFT;
+
+       jh71x0_clk_reg_rmw(clk, JH71X0_CLK_MUX_MASK, value);
+       return 0;
+}
+
+static int jh71x0_clk_mux_determine_rate(struct clk_hw *hw,
+                                        struct clk_rate_request *req)
+{
+       return clk_mux_determine_rate_flags(hw, req, 0);
+}
+
+static int jh71x0_clk_get_phase(struct clk_hw *hw)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+       u32 value = jh71x0_clk_reg_get(clk);
+
+       return (value & JH71X0_CLK_INVERT) ? 180 : 0;
+}
+
+static int jh71x0_clk_set_phase(struct clk_hw *hw, int degrees)
+{
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+       u32 value;
+
+       if (degrees == 0)
+               value = 0;
+       else if (degrees == 180)
+               value = JH71X0_CLK_INVERT;
+       else
+               return -EINVAL;
+
+       jh71x0_clk_reg_rmw(clk, JH71X0_CLK_INVERT, value);
+       return 0;
+}
+
+#ifdef CONFIG_DEBUG_FS
+static void jh71x0_clk_debug_init(struct clk_hw *hw, struct dentry *dentry)
+{
+       static const struct debugfs_reg32 jh71x0_clk_reg = {
+               .name = "CTRL",
+               .offset = 0,
+       };
+       struct jh71x0_clk *clk = jh71x0_clk_from(hw);
+       struct jh71x0_clk_priv *priv = jh71x0_priv_from(clk);
+       struct debugfs_regset32 *regset;
+
+       regset = devm_kzalloc(priv->dev, sizeof(*regset), GFP_KERNEL);
+       if (!regset)
+               return;
+
+       regset->regs = &jh71x0_clk_reg;
+       regset->nregs = 1;
+       regset->base = priv->base + 4 * clk->idx;
+
+       debugfs_create_regset32("registers", 0400, dentry, regset);
+}
+#else
+#define jh71x0_clk_debug_init NULL
+#endif
+
+static const struct clk_ops jh71x0_clk_gate_ops = {
+       .enable = jh71x0_clk_enable,
+       .disable = jh71x0_clk_disable,
+       .is_enabled = jh71x0_clk_is_enabled,
+       .debug_init = jh71x0_clk_debug_init,
+};
+
+static const struct clk_ops jh71x0_clk_div_ops = {
+       .recalc_rate = jh71x0_clk_recalc_rate,
+       .determine_rate = jh71x0_clk_determine_rate,
+       .set_rate = jh71x0_clk_set_rate,
+       .debug_init = jh71x0_clk_debug_init,
+};
+
+static const struct clk_ops jh71x0_clk_fdiv_ops = {
+       .recalc_rate = jh71x0_clk_frac_recalc_rate,
+       .determine_rate = jh71x0_clk_frac_determine_rate,
+       .set_rate = jh71x0_clk_frac_set_rate,
+       .debug_init = jh71x0_clk_debug_init,
+};
+
+static const struct clk_ops jh71x0_clk_gdiv_ops = {
+       .enable = jh71x0_clk_enable,
+       .disable = jh71x0_clk_disable,
+       .is_enabled = jh71x0_clk_is_enabled,
+       .recalc_rate = jh71x0_clk_recalc_rate,
+       .determine_rate = jh71x0_clk_determine_rate,
+       .set_rate = jh71x0_clk_set_rate,
+       .debug_init = jh71x0_clk_debug_init,
+};
+
+static const struct clk_ops jh71x0_clk_mux_ops = {
+       .determine_rate = jh71x0_clk_mux_determine_rate,
+       .set_parent = jh71x0_clk_set_parent,
+       .get_parent = jh71x0_clk_get_parent,
+       .debug_init = jh71x0_clk_debug_init,
+};
+
+static const struct clk_ops jh71x0_clk_gmux_ops = {
+       .enable = jh71x0_clk_enable,
+       .disable = jh71x0_clk_disable,
+       .is_enabled = jh71x0_clk_is_enabled,
+       .determine_rate = jh71x0_clk_mux_determine_rate,
+       .set_parent = jh71x0_clk_set_parent,
+       .get_parent = jh71x0_clk_get_parent,
+       .debug_init = jh71x0_clk_debug_init,
+};
+
+static const struct clk_ops jh71x0_clk_mdiv_ops = {
+       .recalc_rate = jh71x0_clk_recalc_rate,
+       .determine_rate = jh71x0_clk_determine_rate,
+       .get_parent = jh71x0_clk_get_parent,
+       .set_parent = jh71x0_clk_set_parent,
+       .set_rate = jh71x0_clk_set_rate,
+       .debug_init = jh71x0_clk_debug_init,
+};
+
+static const struct clk_ops jh71x0_clk_gmd_ops = {
+       .enable = jh71x0_clk_enable,
+       .disable = jh71x0_clk_disable,
+       .is_enabled = jh71x0_clk_is_enabled,
+       .recalc_rate = jh71x0_clk_recalc_rate,
+       .determine_rate = jh71x0_clk_determine_rate,
+       .get_parent = jh71x0_clk_get_parent,
+       .set_parent = jh71x0_clk_set_parent,
+       .set_rate = jh71x0_clk_set_rate,
+       .debug_init = jh71x0_clk_debug_init,
+};
+
+static const struct clk_ops jh71x0_clk_inv_ops = {
+       .get_phase = jh71x0_clk_get_phase,
+       .set_phase = jh71x0_clk_set_phase,
+       .debug_init = jh71x0_clk_debug_init,
+};
+
+const struct clk_ops *starfive_jh71x0_clk_ops(u32 max)
+{
+       if (max & JH71X0_CLK_DIV_MASK) {
+               if (max & JH71X0_CLK_MUX_MASK) {
+                       if (max & JH71X0_CLK_ENABLE)
+                               return &jh71x0_clk_gmd_ops;
+                       return &jh71x0_clk_mdiv_ops;
+               }
+               if (max & JH71X0_CLK_ENABLE)
+                       return &jh71x0_clk_gdiv_ops;
+               if (max == JH71X0_CLK_FRAC_MAX)
+                       return &jh71x0_clk_fdiv_ops;
+               return &jh71x0_clk_div_ops;
+       }
+
+       if (max & JH71X0_CLK_MUX_MASK) {
+               if (max & JH71X0_CLK_ENABLE)
+                       return &jh71x0_clk_gmux_ops;
+               return &jh71x0_clk_mux_ops;
+       }
+
+       if (max & JH71X0_CLK_ENABLE)
+               return &jh71x0_clk_gate_ops;
+
+       return &jh71x0_clk_inv_ops;
+}
+EXPORT_SYMBOL_GPL(starfive_jh71x0_clk_ops);
diff --git a/drivers/clk/starfive/clk-starfive-jh71x0.h b/drivers/clk/starfive/clk-starfive-jh71x0.h
new file mode 100644 (file)
index 0000000..34bb11c
--- /dev/null
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __CLK_STARFIVE_JH71X0_H
+#define __CLK_STARFIVE_JH71X0_H
+
+#include <linux/bits.h>
+#include <linux/clk-provider.h>
+#include <linux/device.h>
+#include <linux/spinlock.h>
+
+/* register fields */
+#define JH71X0_CLK_ENABLE      BIT(31)
+#define JH71X0_CLK_INVERT      BIT(30)
+#define JH71X0_CLK_MUX_MASK    GENMASK(27, 24)
+#define JH71X0_CLK_MUX_SHIFT   24
+#define JH71X0_CLK_DIV_MASK    GENMASK(23, 0)
+#define JH71X0_CLK_FRAC_MASK   GENMASK(15, 8)
+#define JH71X0_CLK_FRAC_SHIFT  8
+#define JH71X0_CLK_INT_MASK    GENMASK(7, 0)
+
+/* fractional divider min/max */
+#define JH71X0_CLK_FRAC_MIN    100UL
+#define JH71X0_CLK_FRAC_MAX    25599UL
+
+/* clock data */
+struct jh71x0_clk_data {
+       const char *name;
+       unsigned long flags;
+       u32 max;
+       u8 parents[4];
+};
+
+#define JH71X0_GATE(_idx, _name, _flags, _parent)                              \
+[_idx] = {                                                                     \
+       .name = _name,                                                          \
+       .flags = CLK_SET_RATE_PARENT | (_flags),                                \
+       .max = JH71X0_CLK_ENABLE,                                               \
+       .parents = { [0] = _parent },                                           \
+}
+
+#define JH71X0__DIV(_idx, _name, _max, _parent)                                        \
+[_idx] = {                                                                     \
+       .name = _name,                                                          \
+       .flags = 0,                                                             \
+       .max = _max,                                                            \
+       .parents = { [0] = _parent },                                           \
+}
+
+#define JH71X0_GDIV(_idx, _name, _flags, _max, _parent)                                \
+[_idx] = {                                                                     \
+       .name = _name,                                                          \
+       .flags = _flags,                                                        \
+       .max = JH71X0_CLK_ENABLE | (_max),                                      \
+       .parents = { [0] = _parent },                                           \
+}
+
+#define JH71X0_FDIV(_idx, _name, _parent)                                      \
+[_idx] = {                                                                     \
+       .name = _name,                                                          \
+       .flags = 0,                                                             \
+       .max = JH71X0_CLK_FRAC_MAX,                                             \
+       .parents = { [0] = _parent },                                           \
+}
+
+#define JH71X0__MUX(_idx, _name, _nparents, ...)                               \
+[_idx] = {                                                                     \
+       .name = _name,                                                          \
+       .flags = 0,                                                             \
+       .max = ((_nparents) - 1) << JH71X0_CLK_MUX_SHIFT,                       \
+       .parents = { __VA_ARGS__ },                                             \
+}
+
+#define JH71X0_GMUX(_idx, _name, _flags, _nparents, ...)                       \
+[_idx] = {                                                                     \
+       .name = _name,                                                          \
+       .flags = _flags,                                                        \
+       .max = JH71X0_CLK_ENABLE |                                              \
+               (((_nparents) - 1) << JH71X0_CLK_MUX_SHIFT),                    \
+       .parents = { __VA_ARGS__ },                                             \
+}
+
+#define JH71X0_MDIV(_idx, _name, _max, _nparents, ...)                         \
+[_idx] = {                                                                     \
+       .name = _name,                                                          \
+       .flags = 0,                                                             \
+       .max = (((_nparents) - 1) << JH71X0_CLK_MUX_SHIFT) | (_max),            \
+       .parents = { __VA_ARGS__ },                                             \
+}
+
+#define JH71X0__GMD(_idx, _name, _flags, _max, _nparents, ...)                 \
+[_idx] = {                                                                     \
+       .name = _name,                                                          \
+       .flags = _flags,                                                        \
+       .max = JH71X0_CLK_ENABLE |                                              \
+               (((_nparents) - 1) << JH71X0_CLK_MUX_SHIFT) | (_max),           \
+       .parents = { __VA_ARGS__ },                                             \
+}
+
+#define JH71X0__INV(_idx, _name, _parent)                                      \
+[_idx] = {                                                                     \
+       .name = _name,                                                          \
+       .flags = CLK_SET_RATE_PARENT,                                           \
+       .max = JH71X0_CLK_INVERT,                                               \
+       .parents = { [0] = _parent },                                           \
+}
+
+struct jh71x0_clk {
+       struct clk_hw hw;
+       unsigned int idx;
+       unsigned int max_div;
+};
+
+struct jh71x0_clk_priv {
+       /* protect clk enable and set rate/parent from happening at the same time */
+       spinlock_t rmw_lock;
+       struct device *dev;
+       void __iomem *base;
+       struct clk_hw *pll[3];
+       struct jh71x0_clk reg[];
+};
+
+const struct clk_ops *starfive_jh71x0_clk_ops(u32 max);
+
+#endif
index 1192eee8abe48082828df6c09e4bd915fa341318..c4a737482fe5f153a0206a1b6d549108b65512c3 100644 (file)
@@ -1593,15 +1593,13 @@ static int stm32mp1_rcc_clocks_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int stm32mp1_rcc_clocks_remove(struct platform_device *pdev)
+static void stm32mp1_rcc_clocks_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct device_node *child, *np = dev_of_node(dev);
 
        for_each_available_child_of_node(np, child)
                of_clk_del_provider(child);
-
-       return 0;
 }
 
 static struct platform_driver stm32mp13_rcc_clocks_driver = {
@@ -1610,7 +1608,7 @@ static struct platform_driver stm32mp13_rcc_clocks_driver = {
                .of_match_table = stm32mp13_match_data,
        },
        .probe = stm32mp1_rcc_clocks_probe,
-       .remove = stm32mp1_rcc_clocks_remove,
+       .remove_new = stm32mp1_rcc_clocks_remove,
 };
 
 static int __init stm32mp13_clocks_init(void)
index 41433927b55c58428e33fcbcb21a01d439166281..58fa5a59e0c71efe143d393d0a9c15d46f0c21da 100644 (file)
@@ -2081,7 +2081,10 @@ struct tegra_dfll_soc_data *tegra_dfll_unregister(struct platform_device *pdev)
 {
        struct tegra_dfll *td = platform_get_drvdata(pdev);
 
-       /* Try to prevent removal while the DFLL is active */
+       /*
+        * Note that exiting early here doesn't prevent unbinding the driver.
+        * Exiting early here only leaks some resources.
+        */
        if (td->mode != DFLL_DISABLED) {
                dev_err(&pdev->dev,
                        "must disable DFLL before removing driver\n");
index 5e339ad0a97c398fc90ead6be2a5867b0e244081..2a164e565c864b75984e29f213b9ed6a1bf11ae1 100644 (file)
@@ -612,20 +612,19 @@ static int tegra124_dfll_fcpu_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int tegra124_dfll_fcpu_remove(struct platform_device *pdev)
+static void tegra124_dfll_fcpu_remove(struct platform_device *pdev)
 {
        struct tegra_dfll_soc_data *soc;
 
+       /*
+        * Note that exiting early here is dangerous as after this function
+        * returns *soc is freed.
+        */
        soc = tegra_dfll_unregister(pdev);
-       if (IS_ERR(soc)) {
-               dev_err(&pdev->dev, "failed to unregister DFLL: %ld\n",
-                       PTR_ERR(soc));
-               return PTR_ERR(soc);
-       }
+       if (IS_ERR(soc))
+               return;
 
        tegra_cvb_remove_opp_table(soc->dev, soc->cvb, soc->max_freq);
-
-       return 0;
 }
 
 static const struct dev_pm_ops tegra124_dfll_pm_ops = {
@@ -636,7 +635,7 @@ static const struct dev_pm_ops tegra124_dfll_pm_ops = {
 
 static struct platform_driver tegra124_dfll_fcpu_driver = {
        .probe = tegra124_dfll_fcpu_probe,
-       .remove = tegra124_dfll_fcpu_remove,
+       .remove_new = tegra124_dfll_fcpu_remove,
        .driver = {
                .name = "tegra124-dfll",
                .of_match_table = tegra124_dfll_fcpu_of_match,
index 422d782475532b3362cdd5f42664dd53298763b5..dcacc5064d339dc79a41784c3f162aaae56b8165 100644 (file)
 #define MISC_CLK_ENB 0x48
 
 #define OSC_CTRL 0x50
-#define OSC_CTRL_OSC_FREQ_MASK (3<<30)
-#define OSC_CTRL_OSC_FREQ_13MHZ (0<<30)
-#define OSC_CTRL_OSC_FREQ_19_2MHZ (1<<30)
-#define OSC_CTRL_OSC_FREQ_12MHZ (2<<30)
-#define OSC_CTRL_OSC_FREQ_26MHZ (3<<30)
-#define OSC_CTRL_MASK (0x3f2 | OSC_CTRL_OSC_FREQ_MASK)
-
-#define OSC_CTRL_PLL_REF_DIV_MASK (3<<28)
-#define OSC_CTRL_PLL_REF_DIV_1         (0<<28)
-#define OSC_CTRL_PLL_REF_DIV_2         (1<<28)
-#define OSC_CTRL_PLL_REF_DIV_4         (2<<28)
+#define OSC_CTRL_OSC_FREQ_MASK (3u<<30)
+#define OSC_CTRL_OSC_FREQ_13MHZ (0u<<30)
+#define OSC_CTRL_OSC_FREQ_19_2MHZ (1u<<30)
+#define OSC_CTRL_OSC_FREQ_12MHZ (2u<<30)
+#define OSC_CTRL_OSC_FREQ_26MHZ (3u<<30)
+#define OSC_CTRL_MASK (0x3f2u | OSC_CTRL_OSC_FREQ_MASK)
+
+#define OSC_CTRL_PLL_REF_DIV_MASK      (3u<<28)
+#define OSC_CTRL_PLL_REF_DIV_1         (0u<<28)
+#define OSC_CTRL_PLL_REF_DIV_2         (1u<<28)
+#define OSC_CTRL_PLL_REF_DIV_4         (2u<<28)
 
 #define OSC_FREQ_DET 0x58
-#define OSC_FREQ_DET_TRIG (1<<31)
+#define OSC_FREQ_DET_TRIG (1u<<31)
 
 #define OSC_FREQ_DET_STATUS 0x5c
-#define OSC_FREQ_DET_BUSY (1<<31)
-#define OSC_FREQ_DET_CNT_MASK 0xFFFF
+#define OSC_FREQ_DET_BUSYu (1<<31)
+#define OSC_FREQ_DET_CNT_MASK 0xFFFFu
 
 #define TEGRA20_CLK_PERIPH_BANKS       3
 
index f5e7e20492418af7f70247391577a64fe1c37a33..6ecbba4342c58c23de094e18e871d6c33409c79f 100644 (file)
@@ -931,13 +931,11 @@ free:
        return err;
 }
 
-static int ti_adpll_remove(struct platform_device *pdev)
+static void ti_adpll_remove(struct platform_device *pdev)
 {
        struct ti_adpll_data *d = dev_get_drvdata(&pdev->dev);
 
        ti_adpll_free_resources(d);
-
-       return 0;
 }
 
 static struct platform_driver ti_adpll_driver = {
@@ -946,7 +944,7 @@ static struct platform_driver ti_adpll_driver = {
                .of_match_table = ti_adpll_match,
        },
        .probe = ti_adpll_probe,
-       .remove = ti_adpll_remove,
+       .remove_new = ti_adpll_remove,
 };
 
 static int __init ti_adpll_init(void)
index f73f402ff7de90ff2af2018ec8706ad501bab7a9..b6fce916967cea8c9e5dd000004983830648ec82 100644 (file)
@@ -512,16 +512,16 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
        struct clk_hw_omap *hw;
        struct clk *clk;
        struct omap_clkctrl_clk *clkctrl_clk = NULL;
-       const __be32 *addrp;
        bool legacy_naming;
        const char *clkctrl_name;
        u32 addr;
        int ret;
        char *c;
        u16 soc_mask = 0;
+       struct resource res;
 
-       addrp = of_get_address(node, 0, NULL, NULL);
-       addr = (u32)of_translate_address(node, addrp);
+       of_address_to_resource(node, 0, &res);
+       addr = (u32)res.start;
 
 #ifdef CONFIG_ARCH_OMAP4
        if (of_machine_is_compatible("ti,omap4"))
index 46c66fac48e6a796bb2efaed527e389980ee0b82..a61213311d6c2e18c2212ddcbb609401f4e51d8d 100644 (file)
@@ -87,15 +87,8 @@ static int uniphier_clk_probe(struct platform_device *pdev)
                        hw_data->hws[p->idx] = hw;
        }
 
-       return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
-                                     hw_data);
-}
-
-static int uniphier_clk_remove(struct platform_device *pdev)
-{
-       of_clk_del_provider(pdev->dev.of_node);
-
-       return 0;
+       return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+                                          hw_data);
 }
 
 static const struct of_device_id uniphier_clk_match[] = {
@@ -220,7 +213,6 @@ static const struct of_device_id uniphier_clk_match[] = {
 
 static struct platform_driver uniphier_clk_driver = {
        .probe = uniphier_clk_probe,
-       .remove = uniphier_clk_remove,
        .driver = {
                .name = "uniphier-clk",
                .of_match_table = uniphier_clk_match,
index 16dae35ab370120a35999d2fdb5a29bafda4fc2d..01d07f1bf01b1031bc61b88826953cdeabb017de 100644 (file)
@@ -15,7 +15,6 @@
 
 struct visconti_pll_provider {
        void __iomem *reg_base;
-       struct regmap *regmap;
        struct clk_hw_onecell_data clk_data;
        struct device_node *node;
 };
index fdc060e75839f8cffb7abf43c0aae8de56a49b99..aed7d22fae63130999d7888068407a91792a9134 100644 (file)
@@ -92,14 +92,14 @@ static int fch_clk_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int fch_clk_remove(struct platform_device *pdev)
+static void fch_clk_remove(struct platform_device *pdev)
 {
        int i, clks;
        struct pci_dev *rdev;
 
        rdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0));
        if (!rdev)
-               return -ENODEV;
+               return;
 
        clks = pci_match_id(fch_pci_ids, rdev) ? CLK_MAX_FIXED : ST_MAX_CLKS;
 
@@ -107,7 +107,6 @@ static int fch_clk_remove(struct platform_device *pdev)
                clk_hw_unregister(hws[i]);
 
        pci_dev_put(rdev);
-       return 0;
 }
 
 static struct platform_driver fch_clk_driver = {
@@ -116,6 +115,6 @@ static struct platform_driver fch_clk_driver = {
                .suppress_bind_attrs = true,
        },
        .probe = fch_clk_probe,
-       .remove = fch_clk_remove,
+       .remove_new = fch_clk_remove,
 };
 builtin_platform_driver(fch_clk_driver);
index e746e3f8d05a9c21c5526d6138fdc46600be7077..2974dd0ec6f4d0162dfbeec2b814e94ada5b2035 100644 (file)
@@ -367,7 +367,7 @@ err_unreg_clk_plt:
        return err;
 }
 
-static int plt_clk_remove(struct platform_device *pdev)
+static void plt_clk_remove(struct platform_device *pdev)
 {
        struct clk_plt_data *data;
 
@@ -377,7 +377,6 @@ static int plt_clk_remove(struct platform_device *pdev)
        clkdev_drop(data->mclk_lookup);
        plt_clk_unregister_loop(data, PMC_CLK_NUM);
        plt_clk_unregister_parents(data);
-       return 0;
 }
 
 static struct platform_driver plt_clk_driver = {
@@ -385,6 +384,6 @@ static struct platform_driver plt_clk_driver = {
                .name = "clk-pmc-atom",
        },
        .probe = plt_clk_probe,
-       .remove = plt_clk_remove,
+       .remove_new = plt_clk_remove,
 };
 builtin_platform_driver(plt_clk_driver);
index eb1dfe7ecc1b43edddc1db13ca5b32d99a58e97f..e83f104fad029815ee245531cdac8413eaef2349 100644 (file)
@@ -8,12 +8,14 @@
  *
  */
 
+#include <linux/bitfield.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/math64.h>
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/iopoll.h>
@@ -37,6 +39,7 @@
 #define WZRD_CLKOUT_DIVIDE_MASK                (0xff << WZRD_DIVCLK_DIVIDE_SHIFT)
 #define WZRD_CLKOUT_FRAC_SHIFT         8
 #define WZRD_CLKOUT_FRAC_MASK          0x3ff
+#define WZRD_CLKOUT0_FRAC_MASK         GENMASK(17, 8)
 
 #define WZRD_DR_MAX_INT_DIV_VALUE      255
 #define WZRD_DR_STATUS_REG_OFFSET      0x04
 
 #define WZRD_USEC_POLL         10
 #define WZRD_TIMEOUT_POLL              1000
+
+/* Divider limits, from UG572 Table 3-4 for Ultrascale+ */
+#define DIV_O                          0x01
+#define DIV_ALL                                0x03
+
+#define WZRD_M_MIN                     2
+#define WZRD_M_MAX                     128
+#define WZRD_D_MIN                     1
+#define WZRD_D_MAX                     106
+#define WZRD_VCO_MIN                   800000000
+#define WZRD_VCO_MAX                   1600000000
+#define WZRD_O_MIN                     1
+#define WZRD_O_MAX                     128
+#define WZRD_MIN_ERR                   20000
+#define WZRD_FRAC_POINTS               1000
+
 /* Get the mask from width */
 #define div_mask(width)                        ((1 << (width)) - 1)
 
@@ -97,6 +116,9 @@ struct clk_wzrd {
  * @width:     width of the divider bit field
  * @flags:     clk_wzrd divider flags
  * @table:     array of value/divider pairs, last entry should have div = 0
+ * @m: value of the multiplier
+ * @d: value of the common divider
+ * @o: value of the leaf divider
  * @lock:      register lock
  */
 struct clk_wzrd_divider {
@@ -107,6 +129,9 @@ struct clk_wzrd_divider {
        u8 width;
        u8 flags;
        const struct clk_div_table *table;
+       u32 m;
+       u32 d;
+       u32 o;
        spinlock_t *lock;  /* divider lock */
 };
 
@@ -198,12 +223,155 @@ static long clk_wzrd_round_rate(struct clk_hw *hw, unsigned long rate,
        return *prate / div;
 }
 
+static int clk_wzrd_get_divisors(struct clk_hw *hw, unsigned long rate,
+                                unsigned long parent_rate)
+{
+       struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+       unsigned long vco_freq, freq, diff;
+       u32 m, d, o;
+
+       for (m = WZRD_M_MIN; m <= WZRD_M_MAX; m++) {
+               for (d = WZRD_D_MIN; d <= WZRD_D_MAX; d++) {
+                       vco_freq = DIV_ROUND_CLOSEST((parent_rate * m), d);
+                       if (vco_freq >= WZRD_VCO_MIN && vco_freq <= WZRD_VCO_MAX) {
+                               for (o = WZRD_O_MIN; o <= WZRD_O_MAX; o++) {
+                                       freq = DIV_ROUND_CLOSEST_ULL(vco_freq, o);
+                                       diff = abs(freq - rate);
+
+                                       if (diff < WZRD_MIN_ERR) {
+                                               divider->m = m;
+                                               divider->d = d;
+                                               divider->o = o;
+                                               return 0;
+                                       }
+                               }
+                       }
+               }
+       }
+       return -EBUSY;
+}
+
+static int clk_wzrd_dynamic_all_nolock(struct clk_hw *hw, unsigned long rate,
+                                      unsigned long parent_rate)
+{
+       struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+       unsigned long vco_freq, rate_div, clockout0_div;
+       u32 reg, pre, value, f;
+       int err;
+
+       err = clk_wzrd_get_divisors(hw, rate, parent_rate);
+       if (err)
+               return err;
+
+       vco_freq = DIV_ROUND_CLOSEST(parent_rate * divider->m, divider->d);
+       rate_div = DIV_ROUND_CLOSEST_ULL((vco_freq * WZRD_FRAC_POINTS), rate);
+
+       clockout0_div = div_u64(rate_div,  WZRD_FRAC_POINTS);
+
+       pre = DIV_ROUND_CLOSEST_ULL(vco_freq * WZRD_FRAC_POINTS, rate);
+       f = (pre - (clockout0_div * WZRD_FRAC_POINTS));
+       f &= WZRD_CLKOUT_FRAC_MASK;
+
+       reg = FIELD_PREP(WZRD_CLKOUT_DIVIDE_MASK, clockout0_div) |
+             FIELD_PREP(WZRD_CLKOUT0_FRAC_MASK, f);
+
+       writel(reg, divider->base + WZRD_CLK_CFG_REG(2));
+       /* Set divisor and clear phase offset */
+       reg = FIELD_PREP(WZRD_CLKFBOUT_MULT_MASK, divider->m) |
+             FIELD_PREP(WZRD_DIVCLK_DIVIDE_MASK, divider->d);
+       writel(reg, divider->base + WZRD_CLK_CFG_REG(0));
+       writel(divider->o, divider->base + WZRD_CLK_CFG_REG(2));
+       writel(0, divider->base + WZRD_CLK_CFG_REG(3));
+       /* Check status register */
+       err = readl_poll_timeout(divider->base + WZRD_DR_STATUS_REG_OFFSET, value,
+                                value & WZRD_DR_LOCK_BIT_MASK,
+                                WZRD_USEC_POLL, WZRD_TIMEOUT_POLL);
+       if (err)
+               return -ETIMEDOUT;
+
+       /* Initiate reconfiguration */
+       writel(WZRD_DR_BEGIN_DYNA_RECONF,
+              divider->base + WZRD_DR_INIT_REG_OFFSET);
+
+       /* Check status register */
+       return readl_poll_timeout(divider->base + WZRD_DR_STATUS_REG_OFFSET, value,
+                                value & WZRD_DR_LOCK_BIT_MASK,
+                                WZRD_USEC_POLL, WZRD_TIMEOUT_POLL);
+}
+
+static int clk_wzrd_dynamic_all(struct clk_hw *hw, unsigned long rate,
+                               unsigned long parent_rate)
+{
+       struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+       unsigned long flags = 0;
+       int ret;
+
+       spin_lock_irqsave(divider->lock, flags);
+
+       ret = clk_wzrd_dynamic_all_nolock(hw, rate, parent_rate);
+
+       spin_unlock_irqrestore(divider->lock, flags);
+
+       return ret;
+}
+
+static unsigned long clk_wzrd_recalc_rate_all(struct clk_hw *hw,
+                                             unsigned long parent_rate)
+{
+       struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+       u32 m, d, o, div, reg, f;
+
+       reg = readl(divider->base + WZRD_CLK_CFG_REG(0));
+       d = FIELD_GET(WZRD_DIVCLK_DIVIDE_MASK, reg);
+       m = FIELD_GET(WZRD_CLKFBOUT_MULT_MASK, reg);
+       reg = readl(divider->base + WZRD_CLK_CFG_REG(2));
+       o = FIELD_GET(WZRD_DIVCLK_DIVIDE_MASK, reg);
+       f = FIELD_GET(WZRD_CLKOUT0_FRAC_MASK, reg);
+
+       div = DIV_ROUND_CLOSEST(d * (WZRD_FRAC_POINTS * o + f), WZRD_FRAC_POINTS);
+       return divider_recalc_rate(hw, parent_rate * m, div, divider->table,
+                       divider->flags, divider->width);
+}
+
+static long clk_wzrd_round_rate_all(struct clk_hw *hw, unsigned long rate,
+                                   unsigned long *prate)
+{
+       struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+       unsigned long int_freq;
+       u32 m, d, o, div, f;
+       int err;
+
+       err = clk_wzrd_get_divisors(hw, rate, *prate);
+       if (err)
+               return err;
+
+       m = divider->m;
+       d = divider->d;
+       o = divider->o;
+
+       div = d * o;
+       int_freq =  divider_recalc_rate(hw, *prate * m, div, divider->table,
+                                       divider->flags, divider->width);
+
+       if (rate > int_freq) {
+               f = DIV_ROUND_CLOSEST_ULL(rate * WZRD_FRAC_POINTS, int_freq);
+               rate = DIV_ROUND_CLOSEST(int_freq * f, WZRD_FRAC_POINTS);
+       }
+       return rate;
+}
+
 static const struct clk_ops clk_wzrd_clk_divider_ops = {
        .round_rate = clk_wzrd_round_rate,
        .set_rate = clk_wzrd_dynamic_reconfig,
        .recalc_rate = clk_wzrd_recalc_rate,
 };
 
+static const struct clk_ops clk_wzrd_clk_div_all_ops = {
+       .round_rate = clk_wzrd_round_rate_all,
+       .set_rate = clk_wzrd_dynamic_all,
+       .recalc_rate = clk_wzrd_recalc_rate_all,
+};
+
 static unsigned long clk_wzrd_recalc_ratef(struct clk_hw *hw,
                                           unsigned long parent_rate)
 {
@@ -280,7 +448,7 @@ static struct clk *clk_wzrd_register_divf(struct device *dev,
                                          void __iomem *base, u16 offset,
                                          u8 shift, u8 width,
                                          u8 clk_divider_flags,
-                                         const struct clk_div_table *table,
+                                         u32 div_type,
                                          spinlock_t *lock)
 {
        struct clk_wzrd_divider *div;
@@ -307,7 +475,6 @@ static struct clk *clk_wzrd_register_divf(struct device *dev,
        div->flags = clk_divider_flags;
        div->lock = lock;
        div->hw.init = &init;
-       div->table = table;
 
        hw = &div->hw;
        ret =  devm_clk_hw_register(dev, hw);
@@ -324,7 +491,7 @@ static struct clk *clk_wzrd_register_divider(struct device *dev,
                                             void __iomem *base, u16 offset,
                                             u8 shift, u8 width,
                                             u8 clk_divider_flags,
-                                            const struct clk_div_table *table,
+                                            u32 div_type,
                                             spinlock_t *lock)
 {
        struct clk_wzrd_divider *div;
@@ -337,7 +504,12 @@ static struct clk *clk_wzrd_register_divider(struct device *dev,
                return ERR_PTR(-ENOMEM);
 
        init.name = name;
-       init.ops = &clk_wzrd_clk_divider_ops;
+       if (clk_divider_flags & CLK_DIVIDER_READ_ONLY)
+               init.ops = &clk_divider_ro_ops;
+       else if (div_type == DIV_O)
+               init.ops = &clk_wzrd_clk_divider_ops;
+       else
+               init.ops = &clk_wzrd_clk_div_all_ops;
        init.flags = flags;
        init.parent_names =  &parent_name;
        init.num_parents =  1;
@@ -349,7 +521,6 @@ static struct clk *clk_wzrd_register_divider(struct device *dev,
        div->flags = clk_divider_flags;
        div->lock = lock;
        div->hw.init = &init;
-       div->table = table;
 
        hw = &div->hw;
        ret = devm_clk_hw_register(dev, hw);
@@ -425,6 +596,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
        const char *clk_name;
        void __iomem *ctrl_reg;
        struct clk_wzrd *clk_wzrd;
+       const char *clkout_name;
        struct device_node *np = pdev->dev.of_node;
        int nr_outputs;
        unsigned long flags = 0;
@@ -469,6 +641,26 @@ static int clk_wzrd_probe(struct platform_device *pdev)
                goto err_disable_clk;
        }
 
+       ret = of_property_read_u32(np, "xlnx,nr-outputs", &nr_outputs);
+       if (ret || nr_outputs > WZRD_NUM_OUTPUTS) {
+               ret = -EINVAL;
+               goto err_disable_clk;
+       }
+
+       clkout_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_out0", dev_name(&pdev->dev));
+       if (nr_outputs == 1) {
+               clk_wzrd->clkout[0] = clk_wzrd_register_divider
+                               (&pdev->dev, clkout_name,
+                               __clk_get_name(clk_wzrd->clk_in1), 0,
+                               clk_wzrd->base, WZRD_CLK_CFG_REG(3),
+                               WZRD_CLKOUT_DIVIDE_SHIFT,
+                               WZRD_CLKOUT_DIVIDE_WIDTH,
+                               CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
+                               DIV_ALL, &clkwzrd_lock);
+
+               goto out;
+       }
+
        reg = readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0));
        reg_f = reg & WZRD_CLKFBOUT_FRAC_MASK;
        reg_f =  reg_f >> WZRD_CLKFBOUT_FRAC_SHIFT;
@@ -476,20 +668,11 @@ static int clk_wzrd_probe(struct platform_device *pdev)
        reg = reg & WZRD_CLKFBOUT_MULT_MASK;
        reg =  reg >> WZRD_CLKFBOUT_MULT_SHIFT;
        mult = (reg * 1000) + reg_f;
-       clk_name = kasprintf(GFP_KERNEL, "%s_mul", dev_name(&pdev->dev));
+       clk_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_mul", dev_name(&pdev->dev));
        if (!clk_name) {
                ret = -ENOMEM;
                goto err_disable_clk;
        }
-
-       ret = of_property_read_u32(np, "xlnx,nr-outputs", &nr_outputs);
-       if (ret || nr_outputs > WZRD_NUM_OUTPUTS) {
-               ret = -EINVAL;
-               goto err_disable_clk;
-       }
-       if (nr_outputs == 1)
-               flags = CLK_SET_RATE_PARENT;
-
        clk_wzrd->clks_internal[wzrd_clk_mul] = clk_register_fixed_factor
                        (&pdev->dev, clk_name,
                         __clk_get_name(clk_wzrd->clk_in1),
@@ -500,7 +683,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
                goto err_disable_clk;
        }
 
-       clk_name = kasprintf(GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev));
+       clk_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev));
        if (!clk_name) {
                ret = -ENOMEM;
                goto err_rm_int_clk;
@@ -521,9 +704,8 @@ static int clk_wzrd_probe(struct platform_device *pdev)
 
        /* register div per output */
        for (i = nr_outputs - 1; i >= 0 ; i--) {
-               const char *clkout_name;
-
-               clkout_name = kasprintf(GFP_KERNEL, "%s_out%d", dev_name(&pdev->dev), i);
+               clkout_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
+                                            "%s_out%d", dev_name(&pdev->dev), i);
                if (!clkout_name) {
                        ret = -ENOMEM;
                        goto err_rm_int_clk;
@@ -537,7 +719,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
                                WZRD_CLKOUT_DIVIDE_SHIFT,
                                WZRD_CLKOUT_DIVIDE_WIDTH,
                                CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
-                               NULL, &clkwzrd_lock);
+                               DIV_O, &clkwzrd_lock);
                else
                        clk_wzrd->clkout[i] = clk_wzrd_register_divider
                                (&pdev->dev, clkout_name,
@@ -546,7 +728,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
                                WZRD_CLKOUT_DIVIDE_SHIFT,
                                WZRD_CLKOUT_DIVIDE_WIDTH,
                                CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
-                               NULL, &clkwzrd_lock);
+                               DIV_O, &clkwzrd_lock);
                if (IS_ERR(clk_wzrd->clkout[i])) {
                        int j;
 
@@ -559,8 +741,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
                }
        }
 
-       kfree(clk_name);
-
+out:
        clk_wzrd->clk_data.clks = clk_wzrd->clkout;
        clk_wzrd->clk_data.clk_num = ARRAY_SIZE(clk_wzrd->clkout);
        of_clk_add_provider(np, of_clk_src_onecell_get, &clk_wzrd->clk_data);
@@ -585,7 +766,6 @@ static int clk_wzrd_probe(struct platform_device *pdev)
 err_rm_int_clks:
        clk_unregister(clk_wzrd->clks_internal[1]);
 err_rm_int_clk:
-       kfree(clk_name);
        clk_unregister(clk_wzrd->clks_internal[0]);
 err_disable_clk:
        clk_disable_unprepare(clk_wzrd->axi_clk);
@@ -593,7 +773,7 @@ err_disable_clk:
        return ret;
 }
 
-static int clk_wzrd_remove(struct platform_device *pdev)
+static void clk_wzrd_remove(struct platform_device *pdev)
 {
        int i;
        struct clk_wzrd *clk_wzrd = platform_get_drvdata(pdev);
@@ -611,8 +791,6 @@ static int clk_wzrd_remove(struct platform_device *pdev)
        }
 
        clk_disable_unprepare(clk_wzrd->axi_clk);
-
-       return 0;
 }
 
 static const struct of_device_id clk_wzrd_ids[] = {
@@ -630,7 +808,7 @@ static struct platform_driver clk_wzrd_driver = {
                .pm = &clk_wzrd_dev_pm_ops,
        },
        .probe = clk_wzrd_probe,
-       .remove = clk_wzrd_remove,
+       .remove_new = clk_wzrd_remove,
 };
 module_platform_driver(clk_wzrd_driver);
 
index d66b1315114e652370c16768dc3e3b0228800843..0786f15ebbe83fad65c4278b5685be5a4c1f0783 100644 (file)
@@ -702,13 +702,11 @@ error_clk_provider:
  * Return:     Returns 0 on success
  *             Negative error code otherwise
  */
-static int xvcu_remove(struct platform_device *pdev)
+static void xvcu_remove(struct platform_device *pdev)
 {
        struct xvcu_device *xvcu;
 
        xvcu = platform_get_drvdata(pdev);
-       if (!xvcu)
-               return -ENODEV;
 
        xvcu_unregister_clock_provider(xvcu);
 
@@ -716,8 +714,6 @@ static int xvcu_remove(struct platform_device *pdev)
        regmap_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, 0);
 
        clk_disable_unprepare(xvcu->aclk);
-
-       return 0;
 }
 
 static const struct of_device_id xvcu_of_id_table[] = {
@@ -733,7 +729,7 @@ static struct platform_driver xvcu_driver = {
                .of_match_table = xvcu_of_id_table,
        },
        .probe                  = xvcu_probe,
-       .remove                 = xvcu_remove,
+       .remove_new             = xvcu_remove,
 };
 
 module_platform_driver(xvcu_driver);
index 0d3e1377b092ca149885bd0c7d5c92a4edd06916..7411a7fd50acf7b718f789074598c25bec509aa1 100644 (file)
@@ -341,7 +341,5 @@ struct clk_hw *zynqmp_clk_register_pll(const char *name, u32 clk_id,
                return ERR_PTR(ret);
        }
 
-       clk_hw_set_rate_range(hw, PS_PLL_VCO_MIN, PS_PLL_VCO_MAX);
-
        return hw;
 }
index b719852daa071a00c543485a75f43af2fb45e28b..1a3cb53d2e0d0cc977c756635cf5146a51d50007 100644 (file)
@@ -543,6 +543,7 @@ static void amdgpu_discovery_read_from_harvest_table(struct amdgpu_device *adev,
        struct harvest_table *harvest_info;
        u16 offset;
        int i;
+       uint32_t umc_harvest_config = 0;
 
        bhdr = (struct binary_header *)adev->mman.discovery_bin;
        offset = le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset);
@@ -570,12 +571,17 @@ static void amdgpu_discovery_read_from_harvest_table(struct amdgpu_device *adev,
                        adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
                        break;
                case UMC_HWID:
+                       umc_harvest_config |=
+                               1 << (le16_to_cpu(harvest_info->list[i].number_instance));
                        (*umc_harvest_count)++;
                        break;
                default:
                        break;
                }
        }
+
+       adev->umc.active_mask = ((1 << adev->umc.node_inst_num) - 1) &
+                               ~umc_harvest_config;
 }
 
 /* ================================================== */
@@ -1156,8 +1162,10 @@ static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
                                                AMDGPU_MAX_SDMA_INSTANCES);
                        }
 
-                       if (le16_to_cpu(ip->hw_id) == UMC_HWID)
+                       if (le16_to_cpu(ip->hw_id) == UMC_HWID) {
                                adev->gmc.num_umc++;
+                               adev->umc.node_inst_num++;
+                       }
 
                        for (k = 0; k < num_base_address; k++) {
                                /*
index e3e1ed4314dd65a84a918e4fc343a023abc713f5..6c7d672412b21454278ecd151f61c1ef5c59987e 100644 (file)
@@ -1315,7 +1315,7 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo)
 
        if (!bo->resource || bo->resource->mem_type != TTM_PL_VRAM ||
            !(abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE) ||
-           adev->in_suspend || adev->shutdown)
+           adev->in_suspend || drm_dev_is_unplugged(adev_to_drm(adev)))
                return;
 
        if (WARN_ON_ONCE(!dma_resv_trylock(bo->base.resv)))
index 28fe6d94105409b9783985183ddae9606b1e7c84..3f5d13035aff0ce55b4740a01bbdaa4306a137ff 100644 (file)
@@ -602,27 +602,14 @@ psp_cmd_submit_buf(struct psp_context *psp,
                   struct psp_gfx_cmd_resp *cmd, uint64_t fence_mc_addr)
 {
        int ret;
-       int index, idx;
+       int index;
        int timeout = 20000;
        bool ras_intr = false;
        bool skip_unsupport = false;
-       bool dev_entered;
 
        if (psp->adev->no_hw_access)
                return 0;
 
-       dev_entered = drm_dev_enter(adev_to_drm(psp->adev), &idx);
-       /*
-        * We allow sending PSP messages LOAD_ASD and UNLOAD_TA without acquiring
-        * a lock in drm_dev_enter during driver unload because we must call
-        * drm_dev_unplug as the beginning  of unload driver sequence . It is very
-        * crucial that userspace can't access device instances anymore.
-        */
-       if (!dev_entered)
-               WARN_ON(psp->cmd_buf_mem->cmd_id != GFX_CMD_ID_LOAD_ASD &&
-                       psp->cmd_buf_mem->cmd_id != GFX_CMD_ID_UNLOAD_TA &&
-                       psp->cmd_buf_mem->cmd_id != GFX_CMD_ID_INVOKE_CMD);
-
        memset(psp->cmd_buf_mem, 0, PSP_CMD_BUFFER_SIZE);
 
        memcpy(psp->cmd_buf_mem, cmd, sizeof(struct psp_gfx_cmd_resp));
@@ -686,8 +673,6 @@ psp_cmd_submit_buf(struct psp_context *psp,
        }
 
 exit:
-       if (dev_entered)
-               drm_dev_exit(idx);
        return ret;
 }
 
index f2bf979af5883596169c12aba6db42ceaaa66f30..36e19336f3b34ee8d71883658a7352b61b96de3e 100644 (file)
@@ -42,7 +42,7 @@
 #define LOOP_UMC_INST_AND_CH(umc_inst, ch_inst) LOOP_UMC_INST((umc_inst)) LOOP_UMC_CH_INST((ch_inst))
 
 #define LOOP_UMC_NODE_INST(node_inst) \
-               for ((node_inst) = 0; (node_inst) < adev->umc.node_inst_num; (node_inst)++)
+               for_each_set_bit((node_inst), &(adev->umc.active_mask), adev->umc.node_inst_num)
 
 #define LOOP_UMC_EACH_NODE_INST_AND_CH(node_inst, umc_inst, ch_inst) \
                LOOP_UMC_NODE_INST((node_inst)) LOOP_UMC_INST_AND_CH((umc_inst), (ch_inst))
@@ -69,7 +69,7 @@ struct amdgpu_umc {
        /* number of umc instance with memory map register access */
        uint32_t umc_inst_num;
 
-       /*number of umc node instance with memory map register access*/
+       /* Total number of umc node instance including harvest one */
        uint32_t node_inst_num;
 
        /* UMC regiser per channel offset */
@@ -82,6 +82,9 @@ struct amdgpu_umc {
 
        const struct amdgpu_umc_funcs *funcs;
        struct amdgpu_umc_ras *ras;
+
+       /* active mask for umc node instance */
+       unsigned long active_mask;
 };
 
 int amdgpu_umc_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block);
index 85e0afc3d4f7f336715629779c44170eb4ab7c8f..af7b3ba1ca0002caae1c0dc47080f6b49c24a8ec 100644 (file)
@@ -567,7 +567,6 @@ static void gmc_v11_0_set_umc_funcs(struct amdgpu_device *adev)
        case IP_VERSION(8, 10, 0):
                adev->umc.channel_inst_num = UMC_V8_10_CHANNEL_INSTANCE_NUM;
                adev->umc.umc_inst_num = UMC_V8_10_UMC_INSTANCE_NUM;
-               adev->umc.node_inst_num = adev->gmc.num_umc;
                adev->umc.max_ras_err_cnt_per_query = UMC_V8_10_TOTAL_CHANNEL_NUM(adev);
                adev->umc.channel_offs = UMC_V8_10_PER_CHANNEL_OFFSET;
                adev->umc.retire_unit = UMC_V8_10_NA_COL_2BITS_POWER_OF_2_NUM;
index 4b0d563c6522c7b050591c49f0cd89595b96d7d0..4ef1fa4603c8ec994698847d91627608627e9d27 100644 (file)
@@ -382,11 +382,6 @@ static void nbio_v7_2_init_registers(struct amdgpu_device *adev)
                if (def != data)
                        WREG32_PCIE_PORT(SOC15_REG_OFFSET(NBIO, 0, regBIF1_PCIE_MST_CTRL_3), data);
                break;
-       case IP_VERSION(7, 5, 1):
-               data = RREG32_SOC15(NBIO, 0, regRCC_DEV2_EPF0_STRAP2);
-               data &= ~RCC_DEV2_EPF0_STRAP2__STRAP_NO_SOFT_RESET_DEV2_F0_MASK;
-               WREG32_SOC15(NBIO, 0, regRCC_DEV2_EPF0_STRAP2, data);
-               fallthrough;
        default:
                def = data = RREG32_PCIE_PORT(SOC15_REG_OFFSET(NBIO, 0, regPCIE_CONFIG_CNTL));
                data = REG_SET_FIELD(data, PCIE_CONFIG_CNTL,
@@ -399,6 +394,15 @@ static void nbio_v7_2_init_registers(struct amdgpu_device *adev)
                break;
        }
 
+       switch (adev->ip_versions[NBIO_HWIP][0]) {
+       case IP_VERSION(7, 3, 0):
+       case IP_VERSION(7, 5, 1):
+               data = RREG32_SOC15(NBIO, 0, regRCC_DEV2_EPF0_STRAP2);
+               data &= ~RCC_DEV2_EPF0_STRAP2__STRAP_NO_SOFT_RESET_DEV2_F0_MASK;
+               WREG32_SOC15(NBIO, 0, regRCC_DEV2_EPF0_STRAP2, data);
+               break;
+       }
+
        if (amdgpu_sriov_vf(adev))
                adev->rmmio_remap.reg_offset = SOC15_REG_OFFSET(NBIO, 0,
                        regBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL) << 2;
index d972025f0d20f59a9d06808ad2c2f103c0c09bea..855d390c41de159c85b3341289da14c7671931f4 100644 (file)
@@ -444,9 +444,10 @@ static int nv_read_register(struct amdgpu_device *adev, u32 se_num,
        *value = 0;
        for (i = 0; i < ARRAY_SIZE(nv_allowed_read_registers); i++) {
                en = &nv_allowed_read_registers[i];
-               if (adev->reg_offset[en->hwip][en->inst] &&
-                   reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
-                                  + en->reg_offset))
+               if (!adev->reg_offset[en->hwip][en->inst])
+                       continue;
+               else if (reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
+                                       + en->reg_offset))
                        continue;
 
                *value = nv_get_register_value(adev,
index 7cd17dda32ceb3026425c8db3e293f19b7613ec5..2eddd7f6cd41e02564ea079a0a9d08b67d697cd8 100644 (file)
@@ -439,8 +439,9 @@ static int soc15_read_register(struct amdgpu_device *adev, u32 se_num,
        *value = 0;
        for (i = 0; i < ARRAY_SIZE(soc15_allowed_read_registers); i++) {
                en = &soc15_allowed_read_registers[i];
-               if (adev->reg_offset[en->hwip][en->inst] &&
-                       reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
+               if (!adev->reg_offset[en->hwip][en->inst])
+                       continue;
+               else if (reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
                                        + en->reg_offset))
                        continue;
 
index 620f7409825dfe24d69f85d427f8c579c7bd1aad..061793d390ccc5d38eb25e252bd92852366aaa57 100644 (file)
@@ -111,6 +111,7 @@ static int soc21_query_video_codecs(struct amdgpu_device *adev, bool encode,
        switch (adev->ip_versions[UVD_HWIP][0]) {
        case IP_VERSION(4, 0, 0):
        case IP_VERSION(4, 0, 2):
+       case IP_VERSION(4, 0, 4):
                if (adev->vcn.harvest_config & AMDGPU_VCN_HARVEST_VCN0) {
                        if (encode)
                                *codecs = &vcn_4_0_0_video_codecs_encode_vcn1;
@@ -291,9 +292,10 @@ static int soc21_read_register(struct amdgpu_device *adev, u32 se_num,
        *value = 0;
        for (i = 0; i < ARRAY_SIZE(soc21_allowed_read_registers); i++) {
                en = &soc21_allowed_read_registers[i];
-               if (adev->reg_offset[en->hwip][en->inst] &&
-                   reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
-                                  + en->reg_offset))
+               if (!adev->reg_offset[en->hwip][en->inst])
+                       continue;
+               else if (reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
+                                       + en->reg_offset))
                        continue;
 
                *value = soc21_get_register_value(adev,
index 25eaf4af5fcf4b510f253d8ef7dcb725baa3b67f..c6dfd433fec7bc4f85338f8bffbb19f6b5fd4e82 100644 (file)
@@ -31,9 +31,9 @@
 /* number of umc instance with memory map register access */
 #define UMC_V8_10_UMC_INSTANCE_NUM             2
 
-/* Total channel instances for all umc nodes */
+/* Total channel instances for all available umc nodes */
 #define UMC_V8_10_TOTAL_CHANNEL_NUM(adev) \
-       (UMC_V8_10_CHANNEL_INSTANCE_NUM * UMC_V8_10_UMC_INSTANCE_NUM * (adev)->umc.node_inst_num)
+       (UMC_V8_10_CHANNEL_INSTANCE_NUM * UMC_V8_10_UMC_INSTANCE_NUM * (adev)->gmc.num_umc)
 
 /* UMC regiser per channel offset */
 #define UMC_V8_10_PER_CHANNEL_OFFSET   0x400
index cbef2e147da5898df3b85de6b567f88fc96c892a..38c9e1ca66913006ed8b62b3e215f9828dd212c5 100644 (file)
@@ -280,7 +280,7 @@ phys_addr_t kfd_get_process_doorbells(struct kfd_process_device *pdd)
        if (!pdd->doorbell_index) {
                int r = kfd_alloc_process_doorbells(pdd->dev,
                                                    &pdd->doorbell_index);
-               if (r)
+               if (r < 0)
                        return 0;
        }
 
index 24715ca2fa9441a26050399e2ff3941fda47ec59..01383aac6b4190f84e12765e6782c209b8309ed3 100644 (file)
@@ -529,6 +529,19 @@ static struct clk_bw_params vg_bw_params = {
 
 };
 
+static uint32_t find_max_clk_value(const uint32_t clocks[], uint32_t num_clocks)
+{
+       uint32_t max = 0;
+       int i;
+
+       for (i = 0; i < num_clocks; ++i) {
+               if (clocks[i] > max)
+                       max = clocks[i];
+       }
+
+       return max;
+}
+
 static unsigned int find_dcfclk_for_voltage(const struct vg_dpm_clocks *clock_table,
                unsigned int voltage)
 {
@@ -572,12 +585,16 @@ static void vg_clk_mgr_helper_populate_bw_params(
 
        bw_params->clk_table.num_entries = j + 1;
 
-       for (i = 0; i < bw_params->clk_table.num_entries; i++, j--) {
+       for (i = 0; i < bw_params->clk_table.num_entries - 1; i++, j--) {
                bw_params->clk_table.entries[i].fclk_mhz = clock_table->DfPstateTable[j].fclk;
                bw_params->clk_table.entries[i].memclk_mhz = clock_table->DfPstateTable[j].memclk;
                bw_params->clk_table.entries[i].voltage = clock_table->DfPstateTable[j].voltage;
                bw_params->clk_table.entries[i].dcfclk_mhz = find_dcfclk_for_voltage(clock_table, clock_table->DfPstateTable[j].voltage);
        }
+       bw_params->clk_table.entries[i].fclk_mhz = clock_table->DfPstateTable[j].fclk;
+       bw_params->clk_table.entries[i].memclk_mhz = clock_table->DfPstateTable[j].memclk;
+       bw_params->clk_table.entries[i].voltage = clock_table->DfPstateTable[j].voltage;
+       bw_params->clk_table.entries[i].dcfclk_mhz = find_max_clk_value(clock_table->DcfClocks, VG_NUM_DCFCLK_DPM_LEVELS);
 
        bw_params->vram_type = bios_info->memory_type;
        bw_params->num_channels = bios_info->ma_channel_number;
index 923a9fb3c8873cd4eb175710ec11887d08b27848..27448ffe60a43950591badc8a16cbc38ad214fd1 100644 (file)
@@ -46,6 +46,7 @@
 #include "asic_reg/mp/mp_13_0_0_sh_mask.h"
 #include "smu_cmn.h"
 #include "amdgpu_ras.h"
+#include "umc_v8_10.h"
 
 /*
  * DO NOT use these for err/warn/info/debug messages.
 
 #define DEBUGSMC_MSG_Mode1Reset        2
 
+/*
+ * SMU_v13_0_10 supports ECCTABLE since version 80.34.0,
+ * use this to check ECCTABLE feature whether support
+ */
+#define SUPPORT_ECCTABLE_SMU_13_0_10_VERSION 0x00502200
+
 static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] = {
        MSG_MAP(TestMessage,                    PPSMC_MSG_TestMessage,                 1),
        MSG_MAP(GetSmuVersion,                  PPSMC_MSG_GetSmuVersion,               1),
@@ -229,6 +236,7 @@ static struct cmn2asic_mapping smu_v13_0_0_table_map[SMU_TABLE_COUNT] = {
        TAB_MAP(ACTIVITY_MONITOR_COEFF),
        [SMU_TABLE_COMBO_PPTABLE] = {1, TABLE_COMBO_PPTABLE},
        TAB_MAP(I2C_COMMANDS),
+       TAB_MAP(ECCINFO),
 };
 
 static struct cmn2asic_mapping smu_v13_0_0_pwr_src_map[SMU_POWER_SOURCE_COUNT] = {
@@ -462,6 +470,8 @@ static int smu_v13_0_0_tables_init(struct smu_context *smu)
                       AMDGPU_GEM_DOMAIN_VRAM);
        SMU_TABLE_INIT(tables, SMU_TABLE_COMBO_PPTABLE, MP0_MP1_DATA_REGION_SIZE_COMBOPPTABLE,
                        PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
+       SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO, sizeof(EccInfoTable_t),
+                       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
 
        smu_table->metrics_table = kzalloc(sizeof(SmuMetricsExternal_t), GFP_KERNEL);
        if (!smu_table->metrics_table)
@@ -477,8 +487,14 @@ static int smu_v13_0_0_tables_init(struct smu_context *smu)
        if (!smu_table->watermarks_table)
                goto err2_out;
 
+       smu_table->ecc_table = kzalloc(tables[SMU_TABLE_ECCINFO].size, GFP_KERNEL);
+       if (!smu_table->ecc_table)
+               goto err3_out;
+
        return 0;
 
+err3_out:
+       kfree(smu_table->watermarks_table);
 err2_out:
        kfree(smu_table->gpu_metrics_table);
 err1_out:
@@ -2036,6 +2052,64 @@ static int smu_v13_0_0_send_bad_mem_channel_flag(struct smu_context *smu,
        return ret;
 }
 
+static int smu_v13_0_0_check_ecc_table_support(struct smu_context *smu)
+{
+       struct amdgpu_device *adev = smu->adev;
+       uint32_t if_version = 0xff, smu_version = 0xff;
+       int ret = 0;
+
+       ret = smu_cmn_get_smc_version(smu, &if_version, &smu_version);
+       if (ret)
+               return -EOPNOTSUPP;
+
+       if ((adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 10)) &&
+               (smu_version >= SUPPORT_ECCTABLE_SMU_13_0_10_VERSION))
+               return ret;
+       else
+               return -EOPNOTSUPP;
+}
+
+static ssize_t smu_v13_0_0_get_ecc_info(struct smu_context *smu,
+                                                                       void *table)
+{
+       struct smu_table_context *smu_table = &smu->smu_table;
+       struct amdgpu_device *adev = smu->adev;
+       EccInfoTable_t *ecc_table = NULL;
+       struct ecc_info_per_ch *ecc_info_per_channel = NULL;
+       int i, ret = 0;
+       struct umc_ecc_info *eccinfo = (struct umc_ecc_info *)table;
+
+       ret = smu_v13_0_0_check_ecc_table_support(smu);
+       if (ret)
+               return ret;
+
+       ret = smu_cmn_update_table(smu,
+                                       SMU_TABLE_ECCINFO,
+                                       0,
+                                       smu_table->ecc_table,
+                                       false);
+       if (ret) {
+               dev_info(adev->dev, "Failed to export SMU ecc table!\n");
+               return ret;
+       }
+
+       ecc_table = (EccInfoTable_t *)smu_table->ecc_table;
+
+       for (i = 0; i < UMC_V8_10_TOTAL_CHANNEL_NUM(adev); i++) {
+               ecc_info_per_channel = &(eccinfo->ecc[i]);
+               ecc_info_per_channel->ce_count_lo_chip =
+                               ecc_table->EccInfo[i].ce_count_lo_chip;
+               ecc_info_per_channel->ce_count_hi_chip =
+                               ecc_table->EccInfo[i].ce_count_hi_chip;
+               ecc_info_per_channel->mca_umc_status =
+                               ecc_table->EccInfo[i].mca_umc_status;
+               ecc_info_per_channel->mca_umc_addr =
+                               ecc_table->EccInfo[i].mca_umc_addr;
+       }
+
+       return ret;
+}
+
 static const struct pptable_funcs smu_v13_0_0_ppt_funcs = {
        .get_allowed_feature_mask = smu_v13_0_0_get_allowed_feature_mask,
        .set_default_dpm_table = smu_v13_0_0_set_default_dpm_table,
@@ -2111,6 +2185,7 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = {
        .send_hbm_bad_pages_num = smu_v13_0_0_smu_send_bad_mem_page_num,
        .send_hbm_bad_channel_flag = smu_v13_0_0_send_bad_mem_channel_flag,
        .gpo_control = smu_v13_0_gpo_control,
+       .get_ecc_info = smu_v13_0_0_get_ecc_info,
 };
 
 void smu_v13_0_0_set_ppt_funcs(struct smu_context *smu)
index 0264abe552788fc934d6c16a7fae878947a5cc15..faf5e9efa7d3380b0c76603ab86544a360fe83d5 100644 (file)
@@ -44,10 +44,8 @@ int drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame,
 
        /* Sink EOTF is Bit map while infoframe is absolute values */
        if (!is_eotf_supported(hdr_metadata->hdmi_metadata_type1.eotf,
-           connector->hdr_sink_metadata.hdmi_type1.eotf)) {
-               DRM_DEBUG_KMS("EOTF Not Supported\n");
-               return -EINVAL;
-       }
+           connector->hdr_sink_metadata.hdmi_type1.eotf))
+               DRM_DEBUG_KMS("Unknown EOTF %d\n", hdr_metadata->hdmi_metadata_type1.eotf);
 
        err = hdmi_drm_infoframe_init(frame);
        if (err < 0)
index 5457c02ca1abcad673f2bafa0e7b8ee3a7b57cce..fed41800fea737c2f1c231892be471c9a5ead22a 100644 (file)
@@ -1070,6 +1070,7 @@ static void drm_atomic_connector_print_state(struct drm_printer *p,
        drm_printf(p, "connector[%u]: %s\n", connector->base.id, connector->name);
        drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)");
        drm_printf(p, "\tself_refresh_aware=%d\n", state->self_refresh_aware);
+       drm_printf(p, "\tmax_requested_bpc=%d\n", state->max_requested_bpc);
 
        if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
                if (state->writeback_job && state->writeback_job->fb)
index 871870ddf7ec1892ac260fc101804ac26fe03ac9..949b18a29a5540af3f327cd9466e55a09e3fb135 100644 (file)
@@ -23,7 +23,6 @@ config DRM_MSM
        select SHMEM
        select TMPFS
        select QCOM_SCM
-       select DEVFREQ_GOV_SIMPLE_ONDEMAND
        select WANT_DEV_COREDUMP
        select SND_SOC_HDMI_CODEC if SND_SOC
        select SYNC_FILE
index d09221f97f71c38f64b38b5fe12a55ddfb95bc64..a1e006ec5dcec2eaa5c72d34d06d31e4f0ba1308 100644 (file)
@@ -151,8 +151,8 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)
        OUT_RING(ring, 1);
 
        /* Enable local preemption for finegrain preemption */
-       OUT_PKT7(ring, CP_PREEMPT_ENABLE_GLOBAL, 1);
-       OUT_RING(ring, 0x02);
+       OUT_PKT7(ring, CP_PREEMPT_ENABLE_LOCAL, 1);
+       OUT_RING(ring, 0x1);
 
        /* Allow CP_CONTEXT_SWITCH_YIELD packets in the IB2 */
        OUT_PKT7(ring, CP_YIELD_ENABLE, 1);
@@ -806,7 +806,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
        gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL2, 0x0000003F);
 
        /* Set the highest bank bit */
-       if (adreno_is_a540(adreno_gpu))
+       if (adreno_is_a540(adreno_gpu) || adreno_is_a530(adreno_gpu))
                regbit = 2;
        else
                regbit = 1;
index 7658e89844b460bac2336a297844a05dc7ca94cb..f58dd564d122badde91a998b8f8f476849d533d5 100644 (file)
@@ -63,7 +63,7 @@ static struct msm_ringbuffer *get_next_ring(struct msm_gpu *gpu)
                struct msm_ringbuffer *ring = gpu->rb[i];
 
                spin_lock_irqsave(&ring->preempt_lock, flags);
-               empty = (get_wptr(ring) == ring->memptrs->rptr);
+               empty = (get_wptr(ring) == gpu->funcs->get_rptr(gpu, ring));
                spin_unlock_irqrestore(&ring->preempt_lock, flags);
 
                if (!empty)
@@ -207,6 +207,7 @@ void a5xx_preempt_hw_init(struct msm_gpu *gpu)
                a5xx_gpu->preempt[i]->wptr = 0;
                a5xx_gpu->preempt[i]->rptr = 0;
                a5xx_gpu->preempt[i]->rbase = gpu->rb[i]->iova;
+               a5xx_gpu->preempt[i]->rptr_addr = shadowptr(a5xx_gpu, gpu->rb[i]);
        }
 
        /* Write a 0 to signal that we aren't switching pagetables */
@@ -257,7 +258,6 @@ static int preempt_init_ring(struct a5xx_gpu *a5xx_gpu,
        ptr->data = 0;
        ptr->cntl = MSM_GPU_RB_CNTL_DEFAULT | AXXX_CP_RB_CNTL_NO_UPDATE;
 
-       ptr->rptr_addr = shadowptr(a5xx_gpu, ring);
        ptr->counter = counters_iova;
 
        return 0;
index f3c9600221d48c0a0551e4ecf86b57b5f391f763..7f5bc73b204024944b302c6c34c0a6e48de9c6ae 100644 (file)
@@ -974,7 +974,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
        int status, ret;
 
        if (WARN(!gmu->initialized, "The GMU is not set up yet\n"))
-               return 0;
+               return -EINVAL;
 
        gmu->hung = false;
 
index aae60cbd9164d347a3693186f2eda5f29c7749df..6faea5049f765dd64c2c895a48f2822fe9e21247 100644 (file)
@@ -1746,7 +1746,9 @@ static void a6xx_destroy(struct msm_gpu *gpu)
 
        a6xx_llc_slices_destroy(a6xx_gpu);
 
+       mutex_lock(&a6xx_gpu->gmu.lock);
        a6xx_gmu_remove(a6xx_gpu);
+       mutex_unlock(&a6xx_gpu->gmu.lock);
 
        adreno_gpu_cleanup(adreno_gpu);
 
index 36f062c7582f9a8ec7b7b54c6a3e8abb1804252a..c5c4c93b3689c0e9bc9b3928a88c3e0497d07620 100644 (file)
@@ -558,7 +558,8 @@ static void adreno_unbind(struct device *dev, struct device *master,
        struct msm_drm_private *priv = dev_get_drvdata(master);
        struct msm_gpu *gpu = dev_to_gpu(dev);
 
-       WARN_ON_ONCE(adreno_system_suspend(dev));
+       if (pm_runtime_enabled(dev))
+               WARN_ON_ONCE(adreno_system_suspend(dev));
        gpu->funcs->destroy(gpu);
 
        priv->gpu_pdev = NULL;
index cf053e8f081e9ecd9aa32ce94fa862b5b7a2d870..497c9e1673abbb842492e19b4233f0da1d9e3940 100644 (file)
 #include "dpu_hw_catalog.h"
 #include "dpu_kms.h"
 
-#define VIG_MASK \
+#define VIG_BASE_MASK \
        (BIT(DPU_SSPP_SRC) | BIT(DPU_SSPP_QOS) |\
-       BIT(DPU_SSPP_CSC_10BIT) | BIT(DPU_SSPP_CDP) |\
+       BIT(DPU_SSPP_CDP) |\
        BIT(DPU_SSPP_TS_PREFILL) | BIT(DPU_SSPP_EXCL_RECT))
 
+#define VIG_MASK \
+       (VIG_BASE_MASK | \
+       BIT(DPU_SSPP_CSC_10BIT))
+
 #define VIG_MSM8998_MASK \
        (VIG_MASK | BIT(DPU_SSPP_SCALER_QSEED3))
 
 #define VIG_SC7180_MASK \
        (VIG_MASK | BIT(DPU_SSPP_QOS_8LVL) | BIT(DPU_SSPP_SCALER_QSEED4))
 
-#define VIG_SM8250_MASK \
-       (VIG_MASK | BIT(DPU_SSPP_QOS_8LVL) | BIT(DPU_SSPP_SCALER_QSEED3LITE))
-
-#define VIG_QCM2290_MASK (VIG_MASK | BIT(DPU_SSPP_QOS_8LVL))
+#define VIG_QCM2290_MASK (VIG_BASE_MASK | BIT(DPU_SSPP_QOS_8LVL))
 
 #define DMA_MSM8998_MASK \
        (BIT(DPU_SSPP_SRC) | BIT(DPU_SSPP_QOS) |\
@@ -51,7 +52,7 @@
        (DMA_MSM8998_MASK | BIT(DPU_SSPP_CURSOR))
 
 #define MIXER_MSM8998_MASK \
-       (BIT(DPU_MIXER_SOURCESPLIT) | BIT(DPU_DIM_LAYER))
+       (BIT(DPU_MIXER_SOURCESPLIT))
 
 #define MIXER_SDM845_MASK \
        (BIT(DPU_MIXER_SOURCESPLIT) | BIT(DPU_DIM_LAYER) | BIT(DPU_MIXER_COMBINED_ALPHA))
@@ -314,10 +315,9 @@ static const struct dpu_caps msm8998_dpu_caps = {
 };
 
 static const struct dpu_caps qcm2290_dpu_caps = {
-       .max_mixer_width = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
+       .max_mixer_width = DEFAULT_DPU_LINE_WIDTH,
        .max_mixer_blendstages = 0x4,
        .smart_dma_rev = DPU_SSPP_SMART_DMA_V2,
-       .ubwc_version = DPU_HW_UBWC_VER_20,
        .has_dim_layer = true,
        .has_idle_pc = true,
        .max_linewidth = 2160,
@@ -353,9 +353,9 @@ static const struct dpu_caps sc7180_dpu_caps = {
 };
 
 static const struct dpu_caps sm6115_dpu_caps = {
-       .max_mixer_width = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
+       .max_mixer_width = DEFAULT_DPU_LINE_WIDTH,
        .max_mixer_blendstages = 0x4,
-       .qseed_type = DPU_SSPP_SCALER_QSEED3LITE,
+       .qseed_type = DPU_SSPP_SCALER_QSEED4,
        .smart_dma_rev = DPU_SSPP_SMART_DMA_V2, /* TODO: v2.5 */
        .ubwc_version = DPU_HW_UBWC_VER_10,
        .has_dim_layer = true,
@@ -399,7 +399,7 @@ static const struct dpu_caps sc8180x_dpu_caps = {
 static const struct dpu_caps sc8280xp_dpu_caps = {
        .max_mixer_width = 2560,
        .max_mixer_blendstages = 11,
-       .qseed_type = DPU_SSPP_SCALER_QSEED3LITE,
+       .qseed_type = DPU_SSPP_SCALER_QSEED4,
        .smart_dma_rev = DPU_SSPP_SMART_DMA_V2, /* TODO: v2.5 */
        .ubwc_version = DPU_HW_UBWC_VER_40,
        .has_src_split = true,
@@ -413,7 +413,7 @@ static const struct dpu_caps sc8280xp_dpu_caps = {
 static const struct dpu_caps sm8250_dpu_caps = {
        .max_mixer_width = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
        .max_mixer_blendstages = 0xb,
-       .qseed_type = DPU_SSPP_SCALER_QSEED3LITE,
+       .qseed_type = DPU_SSPP_SCALER_QSEED4,
        .smart_dma_rev = DPU_SSPP_SMART_DMA_V2, /* TODO: v2.5 */
        .ubwc_version = DPU_HW_UBWC_VER_40,
        .has_src_split = true,
@@ -427,7 +427,7 @@ static const struct dpu_caps sm8250_dpu_caps = {
 static const struct dpu_caps sm8350_dpu_caps = {
        .max_mixer_width = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
        .max_mixer_blendstages = 0xb,
-       .qseed_type = DPU_SSPP_SCALER_QSEED3LITE,
+       .qseed_type = DPU_SSPP_SCALER_QSEED4,
        .smart_dma_rev = DPU_SSPP_SMART_DMA_V2, /* TODO: v2.5 */
        .ubwc_version = DPU_HW_UBWC_VER_40,
        .has_src_split = true,
@@ -455,7 +455,7 @@ static const struct dpu_caps sm8450_dpu_caps = {
 static const struct dpu_caps sm8550_dpu_caps = {
        .max_mixer_width = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
        .max_mixer_blendstages = 0xb,
-       .qseed_type = DPU_SSPP_SCALER_QSEED3LITE,
+       .qseed_type = DPU_SSPP_SCALER_QSEED4,
        .smart_dma_rev = DPU_SSPP_SMART_DMA_V2, /* TODO: v2.5 */
        .ubwc_version = DPU_HW_UBWC_VER_40,
        .has_src_split = true,
@@ -525,9 +525,9 @@ static const struct dpu_mdp_cfg sdm845_mdp[] = {
                        .reg_off = 0x2AC, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_DMA1] = {
                        .reg_off = 0x2B4, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR0] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA2] = {
                        .reg_off = 0x2BC, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR1] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA3] = {
                        .reg_off = 0x2C4, .bit_off = 8},
        },
 };
@@ -542,9 +542,9 @@ static const struct dpu_mdp_cfg sc7180_mdp[] = {
                .reg_off = 0x2AC, .bit_off = 0},
        .clk_ctrls[DPU_CLK_CTRL_DMA0] = {
                .reg_off = 0x2AC, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR0] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA1] = {
                .reg_off = 0x2B4, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR1] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA2] = {
                .reg_off = 0x2C4, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_WB2] = {
                .reg_off = 0x3B8, .bit_off = 24},
@@ -569,9 +569,9 @@ static const struct dpu_mdp_cfg sc8180x_mdp[] = {
                        .reg_off = 0x2AC, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_DMA1] = {
                        .reg_off = 0x2B4, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR0] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA2] = {
                        .reg_off = 0x2BC, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR1] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA3] = {
                        .reg_off = 0x2C4, .bit_off = 8},
        },
 };
@@ -609,9 +609,9 @@ static const struct dpu_mdp_cfg sm8250_mdp[] = {
                        .reg_off = 0x2AC, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_DMA1] = {
                        .reg_off = 0x2B4, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR0] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA2] = {
                        .reg_off = 0x2BC, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR1] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA3] = {
                        .reg_off = 0x2C4, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_REG_DMA] = {
                        .reg_off = 0x2BC, .bit_off = 20},
@@ -638,9 +638,9 @@ static const struct dpu_mdp_cfg sm8350_mdp[] = {
                        .reg_off = 0x2ac, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_DMA1] = {
                        .reg_off = 0x2b4, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR0] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA2] = {
                        .reg_off = 0x2bc, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR1] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA3] = {
                        .reg_off = 0x2c4, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_REG_DMA] = {
                        .reg_off = 0x2bc, .bit_off = 20},
@@ -666,9 +666,9 @@ static const struct dpu_mdp_cfg sm8450_mdp[] = {
                        .reg_off = 0x2AC, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_DMA1] = {
                        .reg_off = 0x2B4, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR0] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA2] = {
                        .reg_off = 0x2BC, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR1] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA3] = {
                        .reg_off = 0x2C4, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_REG_DMA] = {
                        .reg_off = 0x2BC, .bit_off = 20},
@@ -685,9 +685,9 @@ static const struct dpu_mdp_cfg sc7280_mdp[] = {
                .reg_off = 0x2AC, .bit_off = 0},
        .clk_ctrls[DPU_CLK_CTRL_DMA0] = {
                .reg_off = 0x2AC, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR0] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA1] = {
                .reg_off = 0x2B4, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR1] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA2] = {
                .reg_off = 0x2C4, .bit_off = 8},
        },
 };
@@ -696,7 +696,7 @@ static const struct dpu_mdp_cfg sc8280xp_mdp[] = {
        {
        .name = "top_0", .id = MDP_TOP,
        .base = 0x0, .len = 0x494,
-       .features = 0,
+       .features = BIT(DPU_MDP_PERIPH_0_REMOVED),
        .highest_bank_bit = 2,
        .ubwc_swizzle = 6,
        .clk_ctrls[DPU_CLK_CTRL_VIG0] = { .reg_off = 0x2ac, .bit_off = 0},
@@ -705,8 +705,8 @@ static const struct dpu_mdp_cfg sc8280xp_mdp[] = {
        .clk_ctrls[DPU_CLK_CTRL_VIG3] = { .reg_off = 0x2c4, .bit_off = 0},
        .clk_ctrls[DPU_CLK_CTRL_DMA0] = { .reg_off = 0x2ac, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_DMA1] = { .reg_off = 0x2b4, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR0] = { .reg_off = 0x2bc, .bit_off = 8},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR1] = { .reg_off = 0x2c4, .bit_off = 8},
+       .clk_ctrls[DPU_CLK_CTRL_DMA2] = { .reg_off = 0x2bc, .bit_off = 8},
+       .clk_ctrls[DPU_CLK_CTRL_DMA3] = { .reg_off = 0x2c4, .bit_off = 8},
        .clk_ctrls[DPU_CLK_CTRL_REG_DMA] = { .reg_off = 0x2bc, .bit_off = 20},
        },
 };
@@ -734,9 +734,9 @@ static const struct dpu_mdp_cfg sm8550_mdp[] = {
                        .reg_off = 0x28330, .bit_off = 0},
        .clk_ctrls[DPU_CLK_CTRL_DMA3] = {
                        .reg_off = 0x2a330, .bit_off = 0},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR0] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA4] = {
                        .reg_off = 0x2c330, .bit_off = 0},
-       .clk_ctrls[DPU_CLK_CTRL_CURSOR1] = {
+       .clk_ctrls[DPU_CLK_CTRL_DMA5] = {
                        .reg_off = 0x2e330, .bit_off = 0},
        .clk_ctrls[DPU_CLK_CTRL_REG_DMA] = {
                        .reg_off = 0x2bc, .bit_off = 20},
@@ -828,19 +828,19 @@ static const struct dpu_ctl_cfg sdm845_ctl[] = {
 static const struct dpu_ctl_cfg sc7180_ctl[] = {
        {
        .name = "ctl_0", .id = CTL_0,
-       .base = 0x1000, .len = 0xE4,
+       .base = 0x1000, .len = 0x1dc,
        .features = BIT(DPU_CTL_ACTIVE_CFG),
        .intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 9),
        },
        {
        .name = "ctl_1", .id = CTL_1,
-       .base = 0x1200, .len = 0xE4,
+       .base = 0x1200, .len = 0x1dc,
        .features = BIT(DPU_CTL_ACTIVE_CFG),
        .intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 10),
        },
        {
        .name = "ctl_2", .id = CTL_2,
-       .base = 0x1400, .len = 0xE4,
+       .base = 0x1400, .len = 0x1dc,
        .features = BIT(DPU_CTL_ACTIVE_CFG),
        .intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 11),
        },
@@ -1190,9 +1190,9 @@ static const struct dpu_sspp_cfg msm8998_sspp[] = {
        SSPP_BLK("sspp_9", SSPP_DMA1, 0x26000,  DMA_MSM8998_MASK,
                sdm845_dma_sblk_1, 5, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA1),
        SSPP_BLK("sspp_10", SSPP_DMA2, 0x28000,  DMA_CURSOR_MSM8998_MASK,
-               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR0),
+               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA2),
        SSPP_BLK("sspp_11", SSPP_DMA3, 0x2a000,  DMA_CURSOR_MSM8998_MASK,
-               sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR1),
+               sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA3),
 };
 
 static const struct dpu_sspp_cfg sdm845_sspp[] = {
@@ -1209,9 +1209,9 @@ static const struct dpu_sspp_cfg sdm845_sspp[] = {
        SSPP_BLK("sspp_9", SSPP_DMA1, 0x26000,  DMA_SDM845_MASK,
                sdm845_dma_sblk_1, 5, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA1),
        SSPP_BLK("sspp_10", SSPP_DMA2, 0x28000,  DMA_CURSOR_SDM845_MASK,
-               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR0),
+               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA2),
        SSPP_BLK("sspp_11", SSPP_DMA3, 0x2a000,  DMA_CURSOR_SDM845_MASK,
-               sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR1),
+               sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA3),
 };
 
 static const struct dpu_sspp_sub_blks sc7180_vig_sblk_0 =
@@ -1226,57 +1226,57 @@ static const struct dpu_sspp_cfg sc7180_sspp[] = {
        SSPP_BLK("sspp_8", SSPP_DMA0, 0x24000,  DMA_SDM845_MASK,
                sdm845_dma_sblk_0, 1, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA0),
        SSPP_BLK("sspp_9", SSPP_DMA1, 0x26000,  DMA_CURSOR_SDM845_MASK,
-               sdm845_dma_sblk_1, 5, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR0),
+               sdm845_dma_sblk_1, 5, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA1),
        SSPP_BLK("sspp_10", SSPP_DMA2, 0x28000,  DMA_CURSOR_SDM845_MASK,
-               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR1),
+               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA2),
 };
 
 static const struct dpu_sspp_sub_blks sm6115_vig_sblk_0 =
-                               _VIG_SBLK("0", 2, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("0", 2, DPU_SSPP_SCALER_QSEED4);
 
 static const struct dpu_sspp_cfg sm6115_sspp[] = {
-       SSPP_BLK("sspp_0", SSPP_VIG0, 0x4000, VIG_SM8250_MASK,
+       SSPP_BLK("sspp_0", SSPP_VIG0, 0x4000, VIG_SC7180_MASK,
                sm6115_vig_sblk_0, 0, SSPP_TYPE_VIG, DPU_CLK_CTRL_VIG0),
        SSPP_BLK("sspp_8", SSPP_DMA0, 0x24000,  DMA_SDM845_MASK,
                sdm845_dma_sblk_0, 1, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA0),
 };
 
 static const struct dpu_sspp_sub_blks sm8250_vig_sblk_0 =
-                               _VIG_SBLK("0", 5, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("0", 5, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sm8250_vig_sblk_1 =
-                               _VIG_SBLK("1", 6, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("1", 6, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sm8250_vig_sblk_2 =
-                               _VIG_SBLK("2", 7, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("2", 7, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sm8250_vig_sblk_3 =
-                               _VIG_SBLK("3", 8, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("3", 8, DPU_SSPP_SCALER_QSEED4);
 
 static const struct dpu_sspp_cfg sm8250_sspp[] = {
-       SSPP_BLK("sspp_0", SSPP_VIG0, 0x4000, VIG_SM8250_MASK,
+       SSPP_BLK("sspp_0", SSPP_VIG0, 0x4000, VIG_SC7180_MASK,
                sm8250_vig_sblk_0, 0,  SSPP_TYPE_VIG, DPU_CLK_CTRL_VIG0),
-       SSPP_BLK("sspp_1", SSPP_VIG1, 0x6000, VIG_SM8250_MASK,
+       SSPP_BLK("sspp_1", SSPP_VIG1, 0x6000, VIG_SC7180_MASK,
                sm8250_vig_sblk_1, 4,  SSPP_TYPE_VIG, DPU_CLK_CTRL_VIG1),
-       SSPP_BLK("sspp_2", SSPP_VIG2, 0x8000, VIG_SM8250_MASK,
+       SSPP_BLK("sspp_2", SSPP_VIG2, 0x8000, VIG_SC7180_MASK,
                sm8250_vig_sblk_2, 8, SSPP_TYPE_VIG, DPU_CLK_CTRL_VIG2),
-       SSPP_BLK("sspp_3", SSPP_VIG3, 0xa000, VIG_SM8250_MASK,
+       SSPP_BLK("sspp_3", SSPP_VIG3, 0xa000, VIG_SC7180_MASK,
                sm8250_vig_sblk_3, 12,  SSPP_TYPE_VIG, DPU_CLK_CTRL_VIG3),
        SSPP_BLK("sspp_8", SSPP_DMA0, 0x24000,  DMA_SDM845_MASK,
                sdm845_dma_sblk_0, 1, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA0),
        SSPP_BLK("sspp_9", SSPP_DMA1, 0x26000,  DMA_SDM845_MASK,
                sdm845_dma_sblk_1, 5, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA1),
        SSPP_BLK("sspp_10", SSPP_DMA2, 0x28000,  DMA_CURSOR_SDM845_MASK,
-               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR0),
+               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA2),
        SSPP_BLK("sspp_11", SSPP_DMA3, 0x2a000,  DMA_CURSOR_SDM845_MASK,
-               sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR1),
+               sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA3),
 };
 
 static const struct dpu_sspp_sub_blks sm8450_vig_sblk_0 =
-                               _VIG_SBLK("0", 5, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("0", 5, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sm8450_vig_sblk_1 =
-                               _VIG_SBLK("1", 6, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("1", 6, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sm8450_vig_sblk_2 =
-                               _VIG_SBLK("2", 7, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("2", 7, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sm8450_vig_sblk_3 =
-                               _VIG_SBLK("3", 8, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("3", 8, DPU_SSPP_SCALER_QSEED4);
 
 static const struct dpu_sspp_cfg sm8450_sspp[] = {
        SSPP_BLK("sspp_0", SSPP_VIG0, 0x4000, VIG_SC7180_MASK,
@@ -1292,21 +1292,21 @@ static const struct dpu_sspp_cfg sm8450_sspp[] = {
        SSPP_BLK("sspp_9", SSPP_DMA1, 0x26000,  DMA_SDM845_MASK,
                sdm845_dma_sblk_1, 5, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA1),
        SSPP_BLK("sspp_10", SSPP_DMA2, 0x28000,  DMA_CURSOR_SDM845_MASK,
-               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR0),
+               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA2),
        SSPP_BLK("sspp_11", SSPP_DMA3, 0x2a000,  DMA_CURSOR_SDM845_MASK,
-               sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR1),
+               sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA3),
 };
 
 static const struct dpu_sspp_sub_blks sm8550_vig_sblk_0 =
-                               _VIG_SBLK("0", 7, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("0", 7, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sm8550_vig_sblk_1 =
-                               _VIG_SBLK("1", 8, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("1", 8, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sm8550_vig_sblk_2 =
-                               _VIG_SBLK("2", 9, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("2", 9, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sm8550_vig_sblk_3 =
-                               _VIG_SBLK("3", 10, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("3", 10, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sm8550_dma_sblk_4 = _DMA_SBLK("12", 5);
-static const struct dpu_sspp_sub_blks sd8550_dma_sblk_5 = _DMA_SBLK("13", 6);
+static const struct dpu_sspp_sub_blks sm8550_dma_sblk_5 = _DMA_SBLK("13", 6);
 
 static const struct dpu_sspp_cfg sm8550_sspp[] = {
        SSPP_BLK("sspp_0", SSPP_VIG0, 0x4000, VIG_SC7180_MASK,
@@ -1326,9 +1326,9 @@ static const struct dpu_sspp_cfg sm8550_sspp[] = {
        SSPP_BLK("sspp_11", SSPP_DMA3, 0x2a000,  DMA_SDM845_MASK,
                sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA3),
        SSPP_BLK("sspp_12", SSPP_DMA4, 0x2c000,  DMA_CURSOR_SDM845_MASK,
-               sm8550_dma_sblk_4, 14, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR0),
+               sm8550_dma_sblk_4, 14, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA4),
        SSPP_BLK("sspp_13", SSPP_DMA5, 0x2e000,  DMA_CURSOR_SDM845_MASK,
-               sd8550_dma_sblk_5, 15, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR1),
+               sm8550_dma_sblk_5, 15, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA5),
 };
 
 static const struct dpu_sspp_cfg sc7280_sspp[] = {
@@ -1337,37 +1337,37 @@ static const struct dpu_sspp_cfg sc7280_sspp[] = {
        SSPP_BLK("sspp_8", SSPP_DMA0, 0x24000,  DMA_SDM845_MASK,
                sdm845_dma_sblk_0, 1, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA0),
        SSPP_BLK("sspp_9", SSPP_DMA1, 0x26000,  DMA_CURSOR_SDM845_MASK,
-               sdm845_dma_sblk_1, 5, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR0),
+               sdm845_dma_sblk_1, 5, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA1),
        SSPP_BLK("sspp_10", SSPP_DMA2, 0x28000,  DMA_CURSOR_SDM845_MASK,
-               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR1),
+               sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA2),
 };
 
 static const struct dpu_sspp_sub_blks sc8280xp_vig_sblk_0 =
-                               _VIG_SBLK("0", 5, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("0", 5, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sc8280xp_vig_sblk_1 =
-                               _VIG_SBLK("1", 6, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("1", 6, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sc8280xp_vig_sblk_2 =
-                               _VIG_SBLK("2", 7, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("2", 7, DPU_SSPP_SCALER_QSEED4);
 static const struct dpu_sspp_sub_blks sc8280xp_vig_sblk_3 =
-                               _VIG_SBLK("3", 8, DPU_SSPP_SCALER_QSEED3LITE);
+                               _VIG_SBLK("3", 8, DPU_SSPP_SCALER_QSEED4);
 
 static const struct dpu_sspp_cfg sc8280xp_sspp[] = {
-       SSPP_BLK("sspp_0", SSPP_VIG0, 0x4000, VIG_SM8250_MASK,
+       SSPP_BLK("sspp_0", SSPP_VIG0, 0x4000, VIG_SC7180_MASK,
                 sc8280xp_vig_sblk_0, 0,  SSPP_TYPE_VIG, DPU_CLK_CTRL_VIG0),
-       SSPP_BLK("sspp_1", SSPP_VIG1, 0x6000, VIG_SM8250_MASK,
+       SSPP_BLK("sspp_1", SSPP_VIG1, 0x6000, VIG_SC7180_MASK,
                 sc8280xp_vig_sblk_1, 4,  SSPP_TYPE_VIG, DPU_CLK_CTRL_VIG1),
-       SSPP_BLK("sspp_2", SSPP_VIG2, 0x8000, VIG_SM8250_MASK,
+       SSPP_BLK("sspp_2", SSPP_VIG2, 0x8000, VIG_SC7180_MASK,
                 sc8280xp_vig_sblk_2, 8, SSPP_TYPE_VIG, DPU_CLK_CTRL_VIG2),
-       SSPP_BLK("sspp_3", SSPP_VIG3, 0xa000, VIG_SM8250_MASK,
+       SSPP_BLK("sspp_3", SSPP_VIG3, 0xa000, VIG_SC7180_MASK,
                 sc8280xp_vig_sblk_3, 12,  SSPP_TYPE_VIG, DPU_CLK_CTRL_VIG3),
        SSPP_BLK("sspp_8", SSPP_DMA0, 0x24000, DMA_SDM845_MASK,
                 sdm845_dma_sblk_0, 1, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA0),
        SSPP_BLK("sspp_9", SSPP_DMA1, 0x26000, DMA_SDM845_MASK,
                 sdm845_dma_sblk_1, 5, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA1),
        SSPP_BLK("sspp_10", SSPP_DMA2, 0x28000, DMA_CURSOR_SDM845_MASK,
-                sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR0),
+                sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA2),
        SSPP_BLK("sspp_11", SSPP_DMA3, 0x2a000, DMA_CURSOR_SDM845_MASK,
-                sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR1),
+                sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA3),
 };
 
 #define _VIG_SBLK_NOSCALE(num, sdma_pri) \
@@ -1517,7 +1517,7 @@ static const struct dpu_lm_cfg sc7280_lm[] = {
 /* QCM2290 */
 
 static const struct dpu_lm_sub_blks qcm2290_lm_sblk = {
-       .maxwidth = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
+       .maxwidth = DEFAULT_DPU_LINE_WIDTH,
        .maxblendstages = 4, /* excluding base layer */
        .blendstage_base = { /* offsets relative to mixer base */
                0x20, 0x38, 0x50, 0x68
@@ -1714,7 +1714,7 @@ static const struct dpu_pingpong_cfg sm8350_pp[] = {
 };
 
 static const struct dpu_pingpong_cfg sc7280_pp[] = {
-       PP_BLK("pingpong_0", PINGPONG_0, 0x59000, 0, sc7280_pp_sblk, -1, -1),
+       PP_BLK("pingpong_0", PINGPONG_0, 0x69000, 0, sc7280_pp_sblk, -1, -1),
        PP_BLK("pingpong_1", PINGPONG_1, 0x6a000, 0, sc7280_pp_sblk, -1, -1),
        PP_BLK("pingpong_2", PINGPONG_2, 0x6b000, 0, sc7280_pp_sblk, -1, -1),
        PP_BLK("pingpong_3", PINGPONG_3, 0x6c000, 0, sc7280_pp_sblk, -1, -1),
@@ -2841,8 +2841,6 @@ static const struct dpu_mdss_cfg qcm2290_dpu_cfg = {
        .intf = qcm2290_intf,
        .vbif_count = ARRAY_SIZE(sdm845_vbif),
        .vbif = sdm845_vbif,
-       .reg_dma_count = 1,
-       .dma_cfg = &sdm845_regdma,
        .perf = &qcm2290_perf_data,
        .mdss_irqs = IRQ_SC7180_MASK,
 };
index ddab9caebb18c40d4d30e7b08ea03a53face758a..e6590302b3bfc0e29d51645c5530c04d6ee42bec 100644 (file)
@@ -515,6 +515,8 @@ enum dpu_clk_ctrl_type {
        DPU_CLK_CTRL_DMA1,
        DPU_CLK_CTRL_DMA2,
        DPU_CLK_CTRL_DMA3,
+       DPU_CLK_CTRL_DMA4,
+       DPU_CLK_CTRL_DMA5,
        DPU_CLK_CTRL_CURSOR0,
        DPU_CLK_CTRL_CURSOR1,
        DPU_CLK_CTRL_INLINE_ROT0_SSPP,
index b88a2f3724e6dd491ab29ce661e7b877cfd82798..6c53ea560ffaa734ace47fb28798dc9c6168ae0e 100644 (file)
@@ -446,7 +446,9 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
                         * CTL_LAYER has 3-bit field (and extra bits in EXT register),
                         * all EXT registers has 4-bit fields.
                         */
-                       if (cfg->idx == 0) {
+                       if (cfg->idx == -1) {
+                               continue;
+                       } else if (cfg->idx == 0) {
                                mixercfg[0] |= mix << cfg->shift;
                                mixercfg[1] |= ext << cfg->ext_shift;
                        } else {
index 396429e63756b5e82dc42f0e69587a54ea136000..66c1b70d244fcb3ca91d511cb8baa039c8b0793b 100644 (file)
@@ -577,6 +577,8 @@ void dpu_rm_release(struct dpu_global_state *global_state,
                ARRAY_SIZE(global_state->ctl_to_enc_id), enc->base.id);
        _dpu_rm_clear_mapping(global_state->dsc_to_enc_id,
                ARRAY_SIZE(global_state->dsc_to_enc_id), enc->base.id);
+       _dpu_rm_clear_mapping(global_state->dspp_to_enc_id,
+               ARRAY_SIZE(global_state->dspp_to_enc_id), enc->base.id);
 }
 
 int dpu_rm_reserve(
index be4bf77103cd753adadcd10584250fc85b55c9df..ac8ed731f76d9007bdaf97df6cb163aa703dbe92 100644 (file)
@@ -637,8 +637,8 @@ static struct msm_submit_post_dep *msm_parse_post_deps(struct drm_device *dev,
        int ret = 0;
        uint32_t i, j;
 
-       post_deps = kmalloc_array(nr_syncobjs, sizeof(*post_deps),
-                                 GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
+       post_deps = kcalloc(nr_syncobjs, sizeof(*post_deps),
+                           GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
        if (!post_deps)
                return ERR_PTR(-ENOMEM);
 
@@ -653,7 +653,6 @@ static struct msm_submit_post_dep *msm_parse_post_deps(struct drm_device *dev,
                }
 
                post_deps[i].point = syncobj_desc.point;
-               post_deps[i].chain = NULL;
 
                if (syncobj_desc.flags) {
                        ret = -EINVAL;
index 591c852f326b92c97ea862c3bb6ecae6400a37e6..76a6ae5d565268c50bde978b4fc45f1eded04e58 100644 (file)
@@ -35,8 +35,9 @@ struct nv50_wndw {
 
 int nv50_wndw_new_(const struct nv50_wndw_func *, struct drm_device *,
                   enum drm_plane_type, const char *name, int index,
-                  const u32 *format, enum nv50_disp_interlock_type,
-                  u32 interlock_data, u32 heads, struct nv50_wndw **);
+                  const u32 *format, u32 heads,
+                  enum nv50_disp_interlock_type, u32 interlock_data,
+                  struct nv50_wndw **);
 void nv50_wndw_flush_set(struct nv50_wndw *, u32 *interlock,
                         struct nv50_wndw_atom *);
 void nv50_wndw_flush_clr(struct nv50_wndw *, u32 *interlock, bool flush,
index c5a4f49ee2065416137af9fc64180b1b4ce9e570..01a22a13b452047425a63914cad7f2f081c8d37b 100644 (file)
@@ -2,6 +2,7 @@
 #ifndef __NVKM_FB_H__
 #define __NVKM_FB_H__
 #include <core/subdev.h>
+#include <core/falcon.h>
 #include <core/mm.h>
 
 /* memory type/access flags, do not match hardware values */
@@ -33,7 +34,7 @@ struct nvkm_fb {
        const struct nvkm_fb_func *func;
        struct nvkm_subdev subdev;
 
-       struct nvkm_blob vpr_scrubber;
+       struct nvkm_falcon_fw vpr_scrubber;
 
        struct {
                struct page *flush_page;
index bac7dcc4c2c1308fc36c3ea2b5ef5ef3351ce4d4..0955340cc421898625fa06d33dfb3a34658d17a1 100644 (file)
@@ -143,6 +143,10 @@ nvkm_fb_mem_unlock(struct nvkm_fb *fb)
        if (!fb->func->vpr.scrub_required)
                return 0;
 
+       ret = nvkm_subdev_oneinit(subdev);
+       if (ret)
+               return ret;
+
        if (!fb->func->vpr.scrub_required(fb)) {
                nvkm_debug(subdev, "VPR not locked\n");
                return 0;
@@ -150,7 +154,7 @@ nvkm_fb_mem_unlock(struct nvkm_fb *fb)
 
        nvkm_debug(subdev, "VPR locked, running scrubber binary\n");
 
-       if (!fb->vpr_scrubber.size) {
+       if (!fb->vpr_scrubber.fw.img) {
                nvkm_warn(subdev, "VPR locked, but no scrubber binary!\n");
                return 0;
        }
@@ -229,7 +233,7 @@ nvkm_fb_dtor(struct nvkm_subdev *subdev)
 
        nvkm_ram_del(&fb->ram);
 
-       nvkm_blob_dtor(&fb->vpr_scrubber);
+       nvkm_falcon_fw_dtor(&fb->vpr_scrubber);
 
        if (fb->sysmem.flush_page) {
                dma_unmap_page(subdev->device->dev, fb->sysmem.flush_page_addr,
index 5098f219e3e6f86b6c1ad2a284f99d34e0125edb..a7456e7864636978b0fad6da210ce1e4a201a1ce 100644 (file)
@@ -37,5 +37,5 @@ ga100_fb = {
 int
 ga100_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
 {
-       return gp102_fb_new_(&ga100_fb, device, type, inst, pfb);
+       return gf100_fb_new_(&ga100_fb, device, type, inst, pfb);
 }
index 5a21b0ae459580b1318727e00e1432a94f1abbeb..dd476e079fe1cbf0c0abb876585de69d60c9f36a 100644 (file)
 #include <engine/nvdec.h>
 
 static int
-ga102_fb_vpr_scrub(struct nvkm_fb *fb)
+ga102_fb_oneinit(struct nvkm_fb *fb)
 {
-       struct nvkm_falcon_fw fw = {};
-       int ret;
+       struct nvkm_subdev *subdev = &fb->subdev;
 
-       ret = nvkm_falcon_fw_ctor_hs_v2(&ga102_flcn_fw, "mem-unlock", &fb->subdev, "nvdec/scrubber",
-                                       0, &fb->subdev.device->nvdec[0]->falcon, &fw);
-       if (ret)
-               return ret;
+       nvkm_falcon_fw_ctor_hs_v2(&ga102_flcn_fw, "mem-unlock", subdev, "nvdec/scrubber",
+                                 0, &subdev->device->nvdec[0]->falcon, &fb->vpr_scrubber);
 
-       ret = nvkm_falcon_fw_boot(&fw, &fb->subdev, true, NULL, NULL, 0, 0);
-       nvkm_falcon_fw_dtor(&fw);
-       return ret;
+       return gf100_fb_oneinit(fb);
 }
 
 static const struct nvkm_fb_func
 ga102_fb = {
        .dtor = gf100_fb_dtor,
-       .oneinit = gf100_fb_oneinit,
+       .oneinit = ga102_fb_oneinit,
        .init = gm200_fb_init,
        .init_page = gv100_fb_init_page,
        .init_unkn = gp100_fb_init_unkn,
@@ -51,13 +46,13 @@ ga102_fb = {
        .ram_new = ga102_ram_new,
        .default_bigpage = 16,
        .vpr.scrub_required = tu102_fb_vpr_scrub_required,
-       .vpr.scrub = ga102_fb_vpr_scrub,
+       .vpr.scrub = gp102_fb_vpr_scrub,
 };
 
 int
 ga102_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
 {
-       return gp102_fb_new_(&ga102_fb, device, type, inst, pfb);
+       return gf100_fb_new_(&ga102_fb, device, type, inst, pfb);
 }
 
 MODULE_FIRMWARE("nvidia/ga102/nvdec/scrubber.bin");
index 2658481d575b62c9db6ffbe63beb4477c5dc65e6..14d942e8b857f43566fb7359d52464a092f69480 100644 (file)
 int
 gp102_fb_vpr_scrub(struct nvkm_fb *fb)
 {
-       struct nvkm_subdev *subdev = &fb->subdev;
-       struct nvkm_falcon_fw fw = {};
-       int ret;
-
-       ret = nvkm_falcon_fw_ctor_hs(&gm200_flcn_fw, "mem-unlock", subdev, NULL,
-                                    "nvdec/scrubber", 0, &subdev->device->nvdec[0]->falcon, &fw);
-       if (ret)
-               return ret;
-
-       ret = nvkm_falcon_fw_boot(&fw, subdev, true, NULL, NULL, 0, 0x00000000);
-       nvkm_falcon_fw_dtor(&fw);
-       return ret;
+       return nvkm_falcon_fw_boot(&fb->vpr_scrubber, &fb->subdev, true, NULL, NULL, 0, 0x00000000);
 }
 
 bool
@@ -51,10 +40,21 @@ gp102_fb_vpr_scrub_required(struct nvkm_fb *fb)
        return (nvkm_rd32(device, 0x100cd0) & 0x00000010) != 0;
 }
 
+int
+gp102_fb_oneinit(struct nvkm_fb *fb)
+{
+       struct nvkm_subdev *subdev = &fb->subdev;
+
+       nvkm_falcon_fw_ctor_hs(&gm200_flcn_fw, "mem-unlock", subdev, NULL, "nvdec/scrubber",
+                              0, &subdev->device->nvdec[0]->falcon, &fb->vpr_scrubber);
+
+       return gf100_fb_oneinit(fb);
+}
+
 static const struct nvkm_fb_func
 gp102_fb = {
        .dtor = gf100_fb_dtor,
-       .oneinit = gf100_fb_oneinit,
+       .oneinit = gp102_fb_oneinit,
        .init = gm200_fb_init,
        .init_remapper = gp100_fb_init_remapper,
        .init_page = gm200_fb_init_page,
@@ -64,23 +64,10 @@ gp102_fb = {
        .ram_new = gp100_ram_new,
 };
 
-int
-gp102_fb_new_(const struct nvkm_fb_func *func, struct nvkm_device *device,
-             enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
-{
-       int ret = gf100_fb_new_(func, device, type, inst, pfb);
-       if (ret)
-               return ret;
-
-       nvkm_firmware_load_blob(&(*pfb)->subdev, "nvdec/scrubber", "", 0,
-                               &(*pfb)->vpr_scrubber);
-       return 0;
-}
-
 int
 gp102_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
 {
-       return gp102_fb_new_(&gp102_fb, device, type, inst, pfb);
+       return gf100_fb_new_(&gp102_fb, device, type, inst, pfb);
 }
 
 MODULE_FIRMWARE("nvidia/gp102/nvdec/scrubber.bin");
index 0e3c0a8f5d716e6796d0a40f790b6c312ccf479e..4d8a286a7a348ce2e918720716a12143b152da66 100644 (file)
@@ -31,7 +31,7 @@ gv100_fb_init_page(struct nvkm_fb *fb)
 static const struct nvkm_fb_func
 gv100_fb = {
        .dtor = gf100_fb_dtor,
-       .oneinit = gf100_fb_oneinit,
+       .oneinit = gp102_fb_oneinit,
        .init = gm200_fb_init,
        .init_page = gv100_fb_init_page,
        .init_unkn = gp100_fb_init_unkn,
@@ -45,7 +45,7 @@ gv100_fb = {
 int
 gv100_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
 {
-       return gp102_fb_new_(&gv100_fb, device, type, inst, pfb);
+       return gf100_fb_new_(&gv100_fb, device, type, inst, pfb);
 }
 
 MODULE_FIRMWARE("nvidia/gv100/nvdec/scrubber.bin");
index f517751f94acddc5f4c1d585085cc644f72c931c..726c30c8bf95d3fa27864d06fc26704b25242e49 100644 (file)
@@ -83,8 +83,7 @@ int gm200_fb_init_page(struct nvkm_fb *);
 void gp100_fb_init_remapper(struct nvkm_fb *);
 void gp100_fb_init_unkn(struct nvkm_fb *);
 
-int gp102_fb_new_(const struct nvkm_fb_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
-                 struct nvkm_fb **);
+int gp102_fb_oneinit(struct nvkm_fb *);
 bool gp102_fb_vpr_scrub_required(struct nvkm_fb *);
 int gp102_fb_vpr_scrub(struct nvkm_fb *);
 
index be82af0364ee449081c6936b7dbe3f3757146baa..b8803c124c3b2307df5214ca3463d9c0d683fbb8 100644 (file)
@@ -31,7 +31,7 @@ tu102_fb_vpr_scrub_required(struct nvkm_fb *fb)
 static const struct nvkm_fb_func
 tu102_fb = {
        .dtor = gf100_fb_dtor,
-       .oneinit = gf100_fb_oneinit,
+       .oneinit = gp102_fb_oneinit,
        .init = gm200_fb_init,
        .init_page = gv100_fb_init_page,
        .init_unkn = gp100_fb_init_unkn,
@@ -45,7 +45,7 @@ tu102_fb = {
 int
 tu102_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
 {
-       return gp102_fb_new_(&tu102_fb, device, type, inst, pfb);
+       return gf100_fb_new_(&tu102_fb, device, type, inst, pfb);
 }
 
 MODULE_FIRMWARE("nvidia/tu102/nvdec/scrubber.bin");
index cf35b609050322e4946190d76d1f82d1b4010ff6..accfa52e78c51881571e61c55468419022f8ad16 100644 (file)
@@ -455,7 +455,7 @@ static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe,
        if (state->fb && cirrus->cpp != cirrus_cpp(state->fb))
                cirrus_mode_set(cirrus, &crtc->mode, state->fb);
 
-       if (drm_atomic_helper_damage_merged(old_state, state, &rect))
+       if (state->fb && drm_atomic_helper_damage_merged(old_state, state, &rect))
                cirrus_fb_blit_rect(state->fb, &shadow_plane_state->data[0], &rect);
 }
 
index 842afc88a9496c382cb936fd24b78baef054e2bd..22623eb4f72f2979b8f282b85c7fb006faa47241 100644 (file)
@@ -256,6 +256,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
 {
        struct hid_report *report;
        struct hid_field *field;
+       unsigned int max_buffer_size = HID_MAX_BUFFER_SIZE;
        unsigned int usages;
        unsigned int offset;
        unsigned int i;
@@ -286,8 +287,11 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
        offset = report->size;
        report->size += parser->global.report_size * parser->global.report_count;
 
+       if (parser->device->ll_driver->max_buffer_size)
+               max_buffer_size = parser->device->ll_driver->max_buffer_size;
+
        /* Total size check: Allow for possible report index byte */
-       if (report->size > (HID_MAX_BUFFER_SIZE - 1) << 3) {
+       if (report->size > (max_buffer_size - 1) << 3) {
                hid_err(parser->device, "report is too long\n");
                return -1;
        }
@@ -1963,6 +1967,7 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *
        struct hid_report_enum *report_enum = hid->report_enum + type;
        struct hid_report *report;
        struct hid_driver *hdrv;
+       int max_buffer_size = HID_MAX_BUFFER_SIZE;
        u32 rsize, csize = size;
        u8 *cdata = data;
        int ret = 0;
@@ -1978,10 +1983,13 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *
 
        rsize = hid_compute_report_size(report);
 
-       if (report_enum->numbered && rsize >= HID_MAX_BUFFER_SIZE)
-               rsize = HID_MAX_BUFFER_SIZE - 1;
-       else if (rsize > HID_MAX_BUFFER_SIZE)
-               rsize = HID_MAX_BUFFER_SIZE;
+       if (hid->ll_driver->max_buffer_size)
+               max_buffer_size = hid->ll_driver->max_buffer_size;
+
+       if (report_enum->numbered && rsize >= max_buffer_size)
+               rsize = max_buffer_size - 1;
+       else if (rsize > max_buffer_size)
+               rsize = max_buffer_size;
 
        if (csize < rsize) {
                dbg_hid("report %d is too short, (%d < %d)\n", report->id,
@@ -2396,7 +2404,12 @@ int hid_hw_raw_request(struct hid_device *hdev,
                       unsigned char reportnum, __u8 *buf,
                       size_t len, enum hid_report_type rtype, enum hid_class_request reqtype)
 {
-       if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf)
+       unsigned int max_buffer_size = HID_MAX_BUFFER_SIZE;
+
+       if (hdev->ll_driver->max_buffer_size)
+               max_buffer_size = hdev->ll_driver->max_buffer_size;
+
+       if (len < 1 || len > max_buffer_size || !buf)
                return -EINVAL;
 
        return hdev->ll_driver->raw_request(hdev, reportnum, buf, len,
@@ -2415,7 +2428,12 @@ EXPORT_SYMBOL_GPL(hid_hw_raw_request);
  */
 int hid_hw_output_report(struct hid_device *hdev, __u8 *buf, size_t len)
 {
-       if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf)
+       unsigned int max_buffer_size = HID_MAX_BUFFER_SIZE;
+
+       if (hdev->ll_driver->max_buffer_size)
+               max_buffer_size = hdev->ll_driver->max_buffer_size;
+
+       if (len < 1 || len > max_buffer_size || !buf)
                return -EINVAL;
 
        if (hdev->ll_driver->output_report)
index 1e16b0fa310d16994b61845df5428fe007ac6693..27cadadda7c9d8c781f6d7d8575bc1fbf54a1e7b 100644 (file)
@@ -1354,6 +1354,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
        girq->parents = NULL;
        girq->default_type = IRQ_TYPE_NONE;
        girq->handler = handle_simple_irq;
+       girq->threaded = true;
 
        ret = gpiochip_add_data(&dev->gc, dev);
        if (ret < 0) {
index 25dcda76d6c7bb481c366bdb971b87827860f049..5fc88a063297856931ce625aba974af3c07bb7e5 100644 (file)
@@ -4399,6 +4399,8 @@ static const struct hid_device_id hidpp_devices[] = {
          HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb02a) },
        { /* MX Master 3 mouse over Bluetooth */
          HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb023) },
+       { /* MX Master 3S mouse over Bluetooth */
+         HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb034) },
        {}
 };
 
index 15e14239af829bd7574b6440e4a5b097eaca893f..a49c6affd7c4c48cdd09e3bdcca95139d0c066b8 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (c) 2014-2016, Intel Corporation.
  */
 
+#include <linux/devm-helpers.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/delay.h>
@@ -621,7 +622,6 @@ static void recv_ipc(struct ishtp_device *dev, uint32_t doorbell_val)
        case MNG_RESET_NOTIFY:
                if (!ishtp_dev) {
                        ishtp_dev = dev;
-                       INIT_WORK(&fw_reset_work, fw_reset_work_fn);
                }
                schedule_work(&fw_reset_work);
                break;
@@ -940,6 +940,7 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev)
 {
        struct ishtp_device *dev;
        int     i;
+       int     ret;
 
        dev = devm_kzalloc(&pdev->dev,
                           sizeof(struct ishtp_device) + sizeof(struct ish_hw),
@@ -975,6 +976,12 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev)
                list_add_tail(&tx_buf->link, &dev->wr_free_list);
        }
 
+       ret = devm_work_autocancel(&pdev->dev, &fw_reset_work, fw_reset_work_fn);
+       if (ret) {
+               dev_err(dev->devc, "Failed to initialise FW reset work\n");
+               return NULL;
+       }
+
        dev->ops = &ish_hw_ops;
        dev->devc = &pdev->dev;
        dev->mtu = IPC_PAYLOAD_SIZE - sizeof(struct ishtp_msg_hdr);
index f161c95a1ad2e9bc65316a06898eafc27ec18a5e..4588d2cd4ea4444fdbb5bb5388d9eeffc6cc55eb 100644 (file)
@@ -395,6 +395,7 @@ static const struct hid_ll_driver uhid_hid_driver = {
        .parse = uhid_hid_parse,
        .raw_request = uhid_hid_raw_request,
        .output_report = uhid_hid_output_report,
+       .max_buffer_size = UHID_DATA_MAX,
 };
 
 #ifdef CONFIG_COMPAT
index cb5fa971d67e2a004a2be854e4b94387fff0404b..ae3af738b03f5cf73c54eb893ccec45d28ef627d 100644 (file)
@@ -561,15 +561,8 @@ static int i2c_device_probe(struct device *dev)
                goto err_detach_pm_domain;
        }
 
-       /*
-        * When there are no more users of probe(),
-        * rename probe_new to probe.
-        */
-       if (driver->probe_new)
-               status = driver->probe_new(client);
-       else if (driver->probe)
-               status = driver->probe(client,
-                                      i2c_match_id(driver->id_table, client));
+       if (driver->probe)
+               status = driver->probe(client);
        else
                status = -EINVAL;
 
@@ -1057,7 +1050,7 @@ static int dummy_probe(struct i2c_client *client)
 
 static struct i2c_driver dummy_driver = {
        .driver.name    = "dummy",
-       .probe_new      = dummy_probe,
+       .probe          = dummy_probe,
        .id_table       = dummy_id,
 };
 
index 107623c4cc14aaf95e5bf930f45ca8a179884d51..95a0b63ac560cf336a6c5204a79c65838e9a9962 100644 (file)
@@ -646,7 +646,7 @@ static void i2cdev_dev_release(struct device *dev)
        kfree(i2c_dev);
 }
 
-static int i2cdev_attach_adapter(struct device *dev, void *dummy)
+static int i2cdev_attach_adapter(struct device *dev)
 {
        struct i2c_adapter *adap;
        struct i2c_dev *i2c_dev;
@@ -685,7 +685,7 @@ err_put_i2c_dev:
        return NOTIFY_DONE;
 }
 
-static int i2cdev_detach_adapter(struct device *dev, void *dummy)
+static int i2cdev_detach_adapter(struct device *dev)
 {
        struct i2c_adapter *adap;
        struct i2c_dev *i2c_dev;
@@ -711,9 +711,9 @@ static int i2cdev_notifier_call(struct notifier_block *nb, unsigned long action,
 
        switch (action) {
        case BUS_NOTIFY_ADD_DEVICE:
-               return i2cdev_attach_adapter(dev, NULL);
+               return i2cdev_attach_adapter(dev);
        case BUS_NOTIFY_DEL_DEVICE:
-               return i2cdev_detach_adapter(dev, NULL);
+               return i2cdev_detach_adapter(dev);
        }
 
        return NOTIFY_DONE;
@@ -725,6 +725,18 @@ static struct notifier_block i2cdev_notifier = {
 
 /* ------------------------------------------------------------------------- */
 
+static int __init i2c_dev_attach_adapter(struct device *dev, void *dummy)
+{
+       i2cdev_attach_adapter(dev);
+       return 0;
+}
+
+static int __exit i2c_dev_detach_adapter(struct device *dev, void *dummy)
+{
+       i2cdev_detach_adapter(dev);
+       return 0;
+}
+
 /*
  * module load/unload record keeping
  */
@@ -752,7 +764,7 @@ static int __init i2c_dev_init(void)
                goto out_unreg_class;
 
        /* Bind to already existing adapters right away */
-       i2c_for_each_dev(NULL, i2cdev_attach_adapter);
+       i2c_for_each_dev(NULL, i2c_dev_attach_adapter);
 
        return 0;
 
@@ -768,7 +780,7 @@ out:
 static void __exit i2c_dev_exit(void)
 {
        bus_unregister_notifier(&i2c_bus_type, &i2cdev_notifier);
-       i2c_for_each_dev(NULL, i2cdev_detach_adapter);
+       i2c_for_each_dev(NULL, i2c_dev_detach_adapter);
        class_destroy(i2c_dev_class);
        unregister_chrdev_region(MKDEV(I2C_MAJOR, 0), I2C_MINORS);
 }
index 5f25f23c4ff8cb3d3573c39f5f52118bb84e4d05..5946c0d0aef991aaa280a2df1d74d8a2ef09120f 100644 (file)
@@ -207,7 +207,7 @@ static struct i2c_driver i2c_slave_eeprom_driver = {
        .driver = {
                .name = "i2c-slave-eeprom",
        },
-       .probe_new = i2c_slave_eeprom_probe,
+       .probe = i2c_slave_eeprom_probe,
        .remove = i2c_slave_eeprom_remove,
        .id_table = i2c_slave_eeprom_id,
 };
index 75ee7ebdb614feb03436fd532e5f302bbe1199d1..a49642bbae4b7077f7fa3af34f9423d6dba58045 100644 (file)
@@ -171,7 +171,7 @@ static struct i2c_driver i2c_slave_testunit_driver = {
        .driver = {
                .name = "i2c-slave-testunit",
        },
-       .probe_new = i2c_slave_testunit_probe,
+       .probe = i2c_slave_testunit_probe,
        .remove = i2c_slave_testunit_remove,
        .id_table = i2c_slave_testunit_id,
 };
index cd19546d31fcb0f9735f432ee9f15c86d2998b01..138c3f5e0093a5c2f8ceeb6ddeca991dd70fbad6 100644 (file)
@@ -169,7 +169,7 @@ static struct i2c_driver smbalert_driver = {
        .driver = {
                .name   = "smbus_alert",
        },
-       .probe_new      = smbalert_probe,
+       .probe          = smbalert_probe,
        .remove         = smbalert_remove,
        .id_table       = smbalert_ids,
 };
index 70835825083f529d6b58fdbeb3f86b82e33ae8d9..5a03031519bee0e44eae93352142965c1f58291f 100644 (file)
@@ -306,7 +306,7 @@ static struct i2c_driver ltc4306_driver = {
                .name   = "ltc4306",
                .of_match_table = of_match_ptr(ltc4306_of_match),
        },
-       .probe_new      = ltc4306_probe,
+       .probe          = ltc4306_probe,
        .remove         = ltc4306_remove,
        .id_table       = ltc4306_id,
 };
index 09d1d9e67e31f39e5b863ced5e9a43e40de23312..ce0fb69249a8fa4a7f696ba4bbe0e7ca461717be 100644 (file)
@@ -336,7 +336,7 @@ static struct i2c_driver pca9541_driver = {
                   .name = "pca9541",
                   .of_match_table = of_match_ptr(pca9541_of_match),
                   },
-       .probe_new = pca9541_probe,
+       .probe = pca9541_probe,
        .remove = pca9541_remove,
        .id_table = pca9541_id,
 };
index 3639e6d7304cd2a13ce83420ab64cc474bf1a044..0ccee2ae57204aa7af9979f7dbd8d6495ad91981 100644 (file)
@@ -554,7 +554,7 @@ static struct i2c_driver pca954x_driver = {
                .pm     = &pca954x_pm,
                .of_match_table = pca954x_of_match,
        },
-       .probe_new      = pca954x_probe,
+       .probe          = pca954x_probe,
        .remove         = pca954x_remove,
        .id_table       = pca954x_id,
 };
index a3b524f15d89afcd00e20d27b3cd1cb64d64ccf0..1c80b121e7d6d0d67ae372eb8229ad35a31e3b2b 100644 (file)
@@ -707,8 +707,7 @@ static int ov2685_configure_regulators(struct ov2685 *ov2685)
                                       ov2685->supplies);
 }
 
-static int ov2685_probe(struct i2c_client *client,
-                       const struct i2c_device_id *id)
+static int ov2685_probe(struct i2c_client *client)
 {
        struct device *dev = &client->dev;
        struct ov2685 *ov2685;
@@ -830,7 +829,7 @@ static struct i2c_driver ov2685_i2c_driver = {
                .pm = &ov2685_pm_ops,
                .of_match_table = of_match_ptr(ov2685_of_match),
        },
-       .probe          = &ov2685_probe,
+       .probe_new      = &ov2685_probe,
        .remove         = &ov2685_remove,
 };
 
index 61906fc54e370d32d3f01852e2b0a8a68a1ddde1..b287c28920a687bad19633ce79e0620c3d472820 100644 (file)
@@ -1267,8 +1267,7 @@ static int ov5695_configure_regulators(struct ov5695 *ov5695)
                                       ov5695->supplies);
 }
 
-static int ov5695_probe(struct i2c_client *client,
-                       const struct i2c_device_id *id)
+static int ov5695_probe(struct i2c_client *client)
 {
        struct device *dev = &client->dev;
        struct ov5695 *ov5695;
@@ -1393,7 +1392,7 @@ static struct i2c_driver ov5695_i2c_driver = {
                .pm = &ov5695_pm_ops,
                .of_match_table = of_match_ptr(ov5695_of_match),
        },
-       .probe          = &ov5695_probe,
+       .probe_new      = &ov5695_probe,
        .remove         = &ov5695_remove,
 };
 
index 28ffb4377d98992600c905088b6da5ffbc88b494..3856d5c04c5fdca66df37d175e785b7a7208afe1 100644 (file)
@@ -50,9 +50,9 @@ static const struct ad_dpot_bus_ops bops = {
        .write_r8d16    = write_r8d16,
 };
 
-static int ad_dpot_i2c_probe(struct i2c_client *client,
-                                     const struct i2c_device_id *id)
+static int ad_dpot_i2c_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct ad_dpot_bus_data bdata = {
                .client = client,
                .bops = &bops,
@@ -106,7 +106,7 @@ static struct i2c_driver ad_dpot_i2c_driver = {
        .driver = {
                .name   = "ad_dpot",
        },
-       .probe          = ad_dpot_i2c_probe,
+       .probe_new      = ad_dpot_i2c_probe,
        .remove         = ad_dpot_i2c_remove,
        .id_table       = ad_dpot_id,
 };
index 5fcefcd0bacac165c481bdddd2eb6be1391a4518..3e0fff3f129e7cbc6bc18963b046824e7ce2caaa 100644 (file)
@@ -206,8 +206,7 @@ static void pismo_remove(struct i2c_client *client)
        kfree(pismo);
 }
 
-static int pismo_probe(struct i2c_client *client,
-                      const struct i2c_device_id *id)
+static int pismo_probe(struct i2c_client *client)
 {
        struct pismo_pdata *pdata = client->dev.platform_data;
        struct pismo_eeprom eeprom;
@@ -260,7 +259,7 @@ static struct i2c_driver pismo_driver = {
        .driver = {
                .name   = "pismo",
        },
-       .probe          = pismo_probe,
+       .probe_new      = pismo_probe,
        .remove         = pismo_remove,
        .id_table       = pismo_id,
 };
index 1de87062c67b9b54ca6664abeadefaf4971dbafb..3711d7f746003d3902a3b7b41865f81aea0c97b3 100644 (file)
@@ -221,7 +221,10 @@ static blk_status_t ubiblock_read(struct request *req)
 
        rq_for_each_segment(bvec, req, iter)
                flush_dcache_page(bvec.bv_page);
-       return errno_to_blk_status(ret);
+
+       blk_mq_end_request(req, errno_to_blk_status(ret));
+
+       return BLK_STS_OK;
 }
 
 static int ubiblock_open(struct block_device *bdev, fmode_t mode)
index 3a15015bc409eb72f76aeb81668ae4ffbd717d6d..a508402c4ecbf60379097106a47a7dc53bb96ac8 100644 (file)
@@ -393,6 +393,24 @@ mt7530_fdb_write(struct mt7530_priv *priv, u16 vid,
                mt7530_write(priv, MT7530_ATA1 + (i * 4), reg[i]);
 }
 
+/* Set up switch core clock for MT7530 */
+static void mt7530_pll_setup(struct mt7530_priv *priv)
+{
+       /* Disable PLL */
+       core_write(priv, CORE_GSWPLL_GRP1, 0);
+
+       /* Set core clock into 500Mhz */
+       core_write(priv, CORE_GSWPLL_GRP2,
+                  RG_GSWPLL_POSDIV_500M(1) |
+                  RG_GSWPLL_FBKDIV_500M(25));
+
+       /* Enable PLL */
+       core_write(priv, CORE_GSWPLL_GRP1,
+                  RG_GSWPLL_EN_PRE |
+                  RG_GSWPLL_POSDIV_200M(2) |
+                  RG_GSWPLL_FBKDIV_200M(32));
+}
+
 /* Setup TX circuit including relevant PAD and driving */
 static int
 mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
@@ -453,21 +471,6 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
        core_clear(priv, CORE_TRGMII_GSW_CLK_CG,
                   REG_GSWCK_EN | REG_TRGMIICK_EN);
 
-       /* Setup core clock for MT7530 */
-       /* Disable PLL */
-       core_write(priv, CORE_GSWPLL_GRP1, 0);
-
-       /* Set core clock into 500Mhz */
-       core_write(priv, CORE_GSWPLL_GRP2,
-                  RG_GSWPLL_POSDIV_500M(1) |
-                  RG_GSWPLL_FBKDIV_500M(25));
-
-       /* Enable PLL */
-       core_write(priv, CORE_GSWPLL_GRP1,
-                  RG_GSWPLL_EN_PRE |
-                  RG_GSWPLL_POSDIV_200M(2) |
-                  RG_GSWPLL_FBKDIV_200M(32));
-
        /* Setup the MT7530 TRGMII Tx Clock */
        core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1));
        core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0));
@@ -2196,6 +2199,8 @@ mt7530_setup(struct dsa_switch *ds)
                     SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST |
                     SYS_CTRL_REG_RST);
 
+       mt7530_pll_setup(priv);
+
        /* Enable Port 6 only; P5 as GMAC5 which currently is not supported */
        val = mt7530_read(priv, MT7530_MHWTRAP);
        val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS;
index 323ec56e8a74c37f1ce859a564d08b14b32545ca..1917da784191988ea5c0cbc995ec946f647a4b29 100644 (file)
@@ -132,6 +132,16 @@ source "drivers/net/ethernet/mscc/Kconfig"
 source "drivers/net/ethernet/microsoft/Kconfig"
 source "drivers/net/ethernet/moxa/Kconfig"
 source "drivers/net/ethernet/myricom/Kconfig"
+
+config FEALNX
+       tristate "Myson MTD-8xx PCI Ethernet support"
+       depends on PCI
+       select CRC32
+       select MII
+       help
+         Say Y here to support the Myson MTD-800 family of PCI-based Ethernet
+         cards. <http://www.myson.com.tw/>
+
 source "drivers/net/ethernet/ni/Kconfig"
 source "drivers/net/ethernet/natsemi/Kconfig"
 source "drivers/net/ethernet/neterion/Kconfig"
index 2fedbaa545eb1cb4aa7de091335733f8d0f12148..0d872d4efcd10b1d29752e7fcd6aede2ec657902 100644 (file)
@@ -64,6 +64,7 @@ obj-$(CONFIG_NET_VENDOR_MICROCHIP) += microchip/
 obj-$(CONFIG_NET_VENDOR_MICROSEMI) += mscc/
 obj-$(CONFIG_NET_VENDOR_MOXART) += moxa/
 obj-$(CONFIG_NET_VENDOR_MYRI) += myricom/
+obj-$(CONFIG_FEALNX) += fealnx.o
 obj-$(CONFIG_NET_VENDOR_NATSEMI) += natsemi/
 obj-$(CONFIG_NET_VENDOR_NETERION) += neterion/
 obj-$(CONFIG_NET_VENDOR_NETRONOME) += netronome/
index 3038386a5afd8c4297c801fb9c1642eb6a25f7c5..1761df8fb7f96888017e0a4f7cad0c22aad67c77 100644 (file)
@@ -890,13 +890,13 @@ static void bgmac_chip_reset_idm_config(struct bgmac *bgmac)
 
                if (iost & BGMAC_BCMA_IOST_ATTACHED) {
                        flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
-                       if (!bgmac->has_robosw)
+                       if (bgmac->in_init || !bgmac->has_robosw)
                                flags |= BGMAC_BCMA_IOCTL_SW_RESET;
                }
                bgmac_clk_enable(bgmac, flags);
        }
 
-       if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
+       if (iost & BGMAC_BCMA_IOST_ATTACHED && (bgmac->in_init || !bgmac->has_robosw))
                bgmac_idm_write(bgmac, BCMA_IOCTL,
                                bgmac_idm_read(bgmac, BCMA_IOCTL) &
                                ~BGMAC_BCMA_IOCTL_SW_RESET);
@@ -1490,6 +1490,8 @@ int bgmac_enet_probe(struct bgmac *bgmac)
        struct net_device *net_dev = bgmac->net_dev;
        int err;
 
+       bgmac->in_init = true;
+
        bgmac_chip_intrs_off(bgmac);
 
        net_dev->irq = bgmac->irq;
@@ -1542,6 +1544,8 @@ int bgmac_enet_probe(struct bgmac *bgmac)
        /* Omit FCS from max MTU size */
        net_dev->max_mtu = BGMAC_RX_MAX_FRAME_SIZE - ETH_FCS_LEN;
 
+       bgmac->in_init = false;
+
        err = register_netdev(bgmac->net_dev);
        if (err) {
                dev_err(bgmac->dev, "Cannot register net device\n");
index e05ac92c0650406012915460ea22c96743bcf128..d73ef262991d61a13ddedaf288678386ebb4d256 100644 (file)
@@ -472,6 +472,8 @@ struct bgmac {
        int irq;
        u32 int_mask;
 
+       bool in_init;
+
        /* Current MAC state */
        int mac_speed;
        int mac_duplex;
index 5d4b1f2ebeac7c844e8778656ab16264358fd6d5..808236dc898b8d15fe41dc7f508fe40e87a13000 100644 (file)
@@ -3145,7 +3145,7 @@ static int bnxt_alloc_ring(struct bnxt *bp, struct bnxt_ring_mem_info *rmem)
 
 static void bnxt_free_tpa_info(struct bnxt *bp)
 {
-       int i;
+       int i, j;
 
        for (i = 0; i < bp->rx_nr_rings; i++) {
                struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];
@@ -3153,8 +3153,10 @@ static void bnxt_free_tpa_info(struct bnxt *bp)
                kfree(rxr->rx_tpa_idx_map);
                rxr->rx_tpa_idx_map = NULL;
                if (rxr->rx_tpa) {
-                       kfree(rxr->rx_tpa[0].agg_arr);
-                       rxr->rx_tpa[0].agg_arr = NULL;
+                       for (j = 0; j < bp->max_tpa; j++) {
+                               kfree(rxr->rx_tpa[j].agg_arr);
+                               rxr->rx_tpa[j].agg_arr = NULL;
+                       }
                }
                kfree(rxr->rx_tpa);
                rxr->rx_tpa = NULL;
@@ -3163,14 +3165,13 @@ static void bnxt_free_tpa_info(struct bnxt *bp)
 
 static int bnxt_alloc_tpa_info(struct bnxt *bp)
 {
-       int i, j, total_aggs = 0;
+       int i, j;
 
        bp->max_tpa = MAX_TPA;
        if (bp->flags & BNXT_FLAG_CHIP_P5) {
                if (!bp->max_tpa_v2)
                        return 0;
                bp->max_tpa = max_t(u16, bp->max_tpa_v2, MAX_TPA_P5);
-               total_aggs = bp->max_tpa * MAX_SKB_FRAGS;
        }
 
        for (i = 0; i < bp->rx_nr_rings; i++) {
@@ -3184,12 +3185,12 @@ static int bnxt_alloc_tpa_info(struct bnxt *bp)
 
                if (!(bp->flags & BNXT_FLAG_CHIP_P5))
                        continue;
-               agg = kcalloc(total_aggs, sizeof(*agg), GFP_KERNEL);
-               rxr->rx_tpa[0].agg_arr = agg;
-               if (!agg)
-                       return -ENOMEM;
-               for (j = 1; j < bp->max_tpa; j++)
-                       rxr->rx_tpa[j].agg_arr = agg + j * MAX_SKB_FRAGS;
+               for (j = 0; j < bp->max_tpa; j++) {
+                       agg = kcalloc(MAX_SKB_FRAGS, sizeof(*agg), GFP_KERNEL);
+                       if (!agg)
+                               return -ENOMEM;
+                       rxr->rx_tpa[j].agg_arr = agg;
+               }
                rxr->rx_tpa_idx_map = kzalloc(sizeof(*rxr->rx_tpa_idx_map),
                                              GFP_KERNEL);
                if (!rxr->rx_tpa_idx_map)
@@ -13204,8 +13205,6 @@ static void bnxt_remove_one(struct pci_dev *pdev)
        bnxt_free_hwrm_resources(bp);
        bnxt_ethtool_free(bp);
        bnxt_dcb_free(bp);
-       kfree(bp->edev);
-       bp->edev = NULL;
        kfree(bp->ptp_cfg);
        bp->ptp_cfg = NULL;
        kfree(bp->fw_health);
index d4cc9c371e7bcb820af7afe77fd57a1a25b9fc5e..e7b5e28ee29f185eebf92662dc37f5881f1f186d 100644 (file)
@@ -317,9 +317,11 @@ static void bnxt_aux_dev_release(struct device *dev)
 {
        struct bnxt_aux_priv *aux_priv =
                container_of(dev, struct bnxt_aux_priv, aux_dev.dev);
+       struct bnxt *bp = netdev_priv(aux_priv->edev->net);
 
        ida_free(&bnxt_aux_dev_ids, aux_priv->id);
        kfree(aux_priv->edev->ulp_tbl);
+       bp->edev = NULL;
        kfree(aux_priv->edev);
        kfree(aux_priv);
 }
diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c
new file mode 100644 (file)
index 0000000..ed18450
--- /dev/null
@@ -0,0 +1,1953 @@
+/*
+       Written 1998-2000 by Donald Becker.
+
+       This software may be used and distributed according to the terms of
+       the GNU General Public License (GPL), incorporated herein by reference.
+       Drivers based on or derived from this code fall under the GPL and must
+       retain the authorship, copyright and license notice.  This file is not
+       a complete program and may only be used when the entire operating
+       system is licensed under the GPL.
+
+       The author may be reached as becker@scyld.com, or C/O
+       Scyld Computing Corporation
+       410 Severn Ave., Suite 210
+       Annapolis MD 21403
+
+       Support information and updates available at
+       http://www.scyld.com/network/pci-skeleton.html
+
+       Linux kernel updates:
+
+       Version 2.51, Nov 17, 2001 (jgarzik):
+       - Add ethtool support
+       - Replace some MII-related magic numbers with constants
+
+*/
+
+#define DRV_NAME       "fealnx"
+
+static int debug;              /* 1-> print debug message */
+static int max_interrupt_work = 20;
+
+/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). */
+static int multicast_filter_limit = 32;
+
+/* Set the copy breakpoint for the copy-only-tiny-frames scheme. */
+/* Setting to > 1518 effectively disables this feature.          */
+static int rx_copybreak;
+
+/* Used to pass the media type, etc.                            */
+/* Both 'options[]' and 'full_duplex[]' should exist for driver */
+/* interoperability.                                            */
+/* The media type is usually passed in 'options[]'.             */
+#define MAX_UNITS 8            /* More are supported, limit only on options */
+static int options[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
+static int full_duplex[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
+
+/* Operational parameters that are set at compile time.                 */
+/* Keep the ring sizes a power of two for compile efficiency.           */
+/* The compiler will convert <unsigned>'%'<2^N> into a bit mask.        */
+/* Making the Tx ring too large decreases the effectiveness of channel  */
+/* bonding and packet priority.                                         */
+/* There are no ill effects from too-large receive rings.               */
+// 88-12-9 modify,
+// #define TX_RING_SIZE    16
+// #define RX_RING_SIZE    32
+#define TX_RING_SIZE    6
+#define RX_RING_SIZE    12
+#define TX_TOTAL_SIZE  TX_RING_SIZE*sizeof(struct fealnx_desc)
+#define RX_TOTAL_SIZE  RX_RING_SIZE*sizeof(struct fealnx_desc)
+
+/* Operational parameters that usually are not changed. */
+/* Time in jiffies before concluding the transmitter is hung. */
+#define TX_TIMEOUT      (2*HZ)
+
+#define PKT_BUF_SZ      1536   /* Size of each temporary Rx buffer. */
+
+
+/* Include files, designed to support most kernel versions 2.0.0 and later. */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/timer.h>
+#include <linux/errno.h>
+#include <linux/ioport.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/init.h>
+#include <linux/mii.h>
+#include <linux/ethtool.h>
+#include <linux/crc32.h>
+#include <linux/delay.h>
+#include <linux/bitops.h>
+
+#include <asm/processor.h>     /* Processor type for cache alignment. */
+#include <asm/io.h>
+#include <linux/uaccess.h>
+#include <asm/byteorder.h>
+
+/* This driver was written to use PCI memory space, however some x86 systems
+   work only with I/O space accesses. */
+#ifndef __alpha__
+#define USE_IO_OPS
+#endif
+
+/* Kernel compatibility defines, some common to David Hinds' PCMCIA package. */
+/* This is only in the support-all-kernels source code. */
+
+#define RUN_AT(x) (jiffies + (x))
+
+MODULE_AUTHOR("Myson or whoever");
+MODULE_DESCRIPTION("Myson MTD-8xx 100/10M Ethernet PCI Adapter Driver");
+MODULE_LICENSE("GPL");
+module_param(max_interrupt_work, int, 0);
+module_param(debug, int, 0);
+module_param(rx_copybreak, int, 0);
+module_param(multicast_filter_limit, int, 0);
+module_param_array(options, int, NULL, 0);
+module_param_array(full_duplex, int, NULL, 0);
+MODULE_PARM_DESC(max_interrupt_work, "fealnx maximum events handled per interrupt");
+MODULE_PARM_DESC(debug, "fealnx enable debugging (0-1)");
+MODULE_PARM_DESC(rx_copybreak, "fealnx copy breakpoint for copy-only-tiny-frames");
+MODULE_PARM_DESC(multicast_filter_limit, "fealnx maximum number of filtered multicast addresses");
+MODULE_PARM_DESC(options, "fealnx: Bits 0-3: media type, bit 17: full duplex");
+MODULE_PARM_DESC(full_duplex, "fealnx full duplex setting(s) (1)");
+
+enum {
+       MIN_REGION_SIZE         = 136,
+};
+
+/* A chip capabilities table, matching the entries in pci_tbl[] above. */
+enum chip_capability_flags {
+       HAS_MII_XCVR,
+       HAS_CHIP_XCVR,
+};
+
+/* 89/6/13 add, */
+/* for different PHY */
+enum phy_type_flags {
+       MysonPHY = 1,
+       AhdocPHY = 2,
+       SeeqPHY = 3,
+       MarvellPHY = 4,
+       Myson981 = 5,
+       LevelOnePHY = 6,
+       OtherPHY = 10,
+};
+
+struct chip_info {
+       char *chip_name;
+       int flags;
+};
+
+static const struct chip_info skel_netdrv_tbl[] = {
+       { "100/10M Ethernet PCI Adapter",       HAS_MII_XCVR },
+       { "100/10M Ethernet PCI Adapter",       HAS_CHIP_XCVR },
+       { "1000/100/10M Ethernet PCI Adapter",  HAS_MII_XCVR },
+};
+
+/* Offsets to the Command and Status Registers. */
+enum fealnx_offsets {
+       PAR0 = 0x0,             /* physical address 0-3 */
+       PAR1 = 0x04,            /* physical address 4-5 */
+       MAR0 = 0x08,            /* multicast address 0-3 */
+       MAR1 = 0x0C,            /* multicast address 4-7 */
+       FAR0 = 0x10,            /* flow-control address 0-3 */
+       FAR1 = 0x14,            /* flow-control address 4-5 */
+       TCRRCR = 0x18,          /* receive & transmit configuration */
+       BCR = 0x1C,             /* bus command */
+       TXPDR = 0x20,           /* transmit polling demand */
+       RXPDR = 0x24,           /* receive polling demand */
+       RXCWP = 0x28,           /* receive current word pointer */
+       TXLBA = 0x2C,           /* transmit list base address */
+       RXLBA = 0x30,           /* receive list base address */
+       ISR = 0x34,             /* interrupt status */
+       IMR = 0x38,             /* interrupt mask */
+       FTH = 0x3C,             /* flow control high/low threshold */
+       MANAGEMENT = 0x40,      /* bootrom/eeprom and mii management */
+       TALLY = 0x44,           /* tally counters for crc and mpa */
+       TSR = 0x48,             /* tally counter for transmit status */
+       BMCRSR = 0x4c,          /* basic mode control and status */
+       PHYIDENTIFIER = 0x50,   /* phy identifier */
+       ANARANLPAR = 0x54,      /* auto-negotiation advertisement and link
+                                  partner ability */
+       ANEROCR = 0x58,         /* auto-negotiation expansion and pci conf. */
+       BPREMRPSR = 0x5c,       /* bypass & receive error mask and phy status */
+};
+
+/* Bits in the interrupt status/enable registers. */
+/* The bits in the Intr Status/Enable registers, mostly interrupt sources. */
+enum intr_status_bits {
+       RFCON = 0x00020000,     /* receive flow control xon packet */
+       RFCOFF = 0x00010000,    /* receive flow control xoff packet */
+       LSCStatus = 0x00008000, /* link status change */
+       ANCStatus = 0x00004000, /* autonegotiation completed */
+       FBE = 0x00002000,       /* fatal bus error */
+       FBEMask = 0x00001800,   /* mask bit12-11 */
+       ParityErr = 0x00000000, /* parity error */
+       TargetErr = 0x00001000, /* target abort */
+       MasterErr = 0x00000800, /* master error */
+       TUNF = 0x00000400,      /* transmit underflow */
+       ROVF = 0x00000200,      /* receive overflow */
+       ETI = 0x00000100,       /* transmit early int */
+       ERI = 0x00000080,       /* receive early int */
+       CNTOVF = 0x00000040,    /* counter overflow */
+       RBU = 0x00000020,       /* receive buffer unavailable */
+       TBU = 0x00000010,       /* transmit buffer unavilable */
+       TI = 0x00000008,        /* transmit interrupt */
+       RI = 0x00000004,        /* receive interrupt */
+       RxErr = 0x00000002,     /* receive error */
+};
+
+/* Bits in the NetworkConfig register, W for writing, R for reading */
+/* FIXME: some names are invented by me. Marked with (name?) */
+/* If you have docs and know bit names, please fix 'em */
+enum rx_mode_bits {
+       CR_W_ENH        = 0x02000000,   /* enhanced mode (name?) */
+       CR_W_FD         = 0x00100000,   /* full duplex */
+       CR_W_PS10       = 0x00080000,   /* 10 mbit */
+       CR_W_TXEN       = 0x00040000,   /* tx enable (name?) */
+       CR_W_PS1000     = 0x00010000,   /* 1000 mbit */
+     /* CR_W_RXBURSTMASK= 0x00000e00, Im unsure about this */
+       CR_W_RXMODEMASK = 0x000000e0,
+       CR_W_PROM       = 0x00000080,   /* promiscuous mode */
+       CR_W_AB         = 0x00000040,   /* accept broadcast */
+       CR_W_AM         = 0x00000020,   /* accept mutlicast */
+       CR_W_ARP        = 0x00000008,   /* receive runt pkt */
+       CR_W_ALP        = 0x00000004,   /* receive long pkt */
+       CR_W_SEP        = 0x00000002,   /* receive error pkt */
+       CR_W_RXEN       = 0x00000001,   /* rx enable (unicast?) (name?) */
+
+       CR_R_TXSTOP     = 0x04000000,   /* tx stopped (name?) */
+       CR_R_FD         = 0x00100000,   /* full duplex detected */
+       CR_R_PS10       = 0x00080000,   /* 10 mbit detected */
+       CR_R_RXSTOP     = 0x00008000,   /* rx stopped (name?) */
+};
+
+/* The Tulip Rx and Tx buffer descriptors. */
+struct fealnx_desc {
+       s32 status;
+       s32 control;
+       u32 buffer;
+       u32 next_desc;
+       struct fealnx_desc *next_desc_logical;
+       struct sk_buff *skbuff;
+       u32 reserved1;
+       u32 reserved2;
+};
+
+/* Bits in network_desc.status */
+enum rx_desc_status_bits {
+       RXOWN = 0x80000000,     /* own bit */
+       FLNGMASK = 0x0fff0000,  /* frame length */
+       FLNGShift = 16,
+       MARSTATUS = 0x00004000, /* multicast address received */
+       BARSTATUS = 0x00002000, /* broadcast address received */
+       PHYSTATUS = 0x00001000, /* physical address received */
+       RXFSD = 0x00000800,     /* first descriptor */
+       RXLSD = 0x00000400,     /* last descriptor */
+       ErrorSummary = 0x80,    /* error summary */
+       RUNTPKT = 0x40,         /* runt packet received */
+       LONGPKT = 0x20,         /* long packet received */
+       FAE = 0x10,             /* frame align error */
+       CRC = 0x08,             /* crc error */
+       RXER = 0x04,            /* receive error */
+};
+
+enum rx_desc_control_bits {
+       RXIC = 0x00800000,      /* interrupt control */
+       RBSShift = 0,
+};
+
+enum tx_desc_status_bits {
+       TXOWN = 0x80000000,     /* own bit */
+       JABTO = 0x00004000,     /* jabber timeout */
+       CSL = 0x00002000,       /* carrier sense lost */
+       LC = 0x00001000,        /* late collision */
+       EC = 0x00000800,        /* excessive collision */
+       UDF = 0x00000400,       /* fifo underflow */
+       DFR = 0x00000200,       /* deferred */
+       HF = 0x00000100,        /* heartbeat fail */
+       NCRMask = 0x000000ff,   /* collision retry count */
+       NCRShift = 0,
+};
+
+enum tx_desc_control_bits {
+       TXIC = 0x80000000,      /* interrupt control */
+       ETIControl = 0x40000000,        /* early transmit interrupt */
+       TXLD = 0x20000000,      /* last descriptor */
+       TXFD = 0x10000000,      /* first descriptor */
+       CRCEnable = 0x08000000, /* crc control */
+       PADEnable = 0x04000000, /* padding control */
+       RetryTxLC = 0x02000000, /* retry late collision */
+       PKTSMask = 0x3ff800,    /* packet size bit21-11 */
+       PKTSShift = 11,
+       TBSMask = 0x000007ff,   /* transmit buffer bit 10-0 */
+       TBSShift = 0,
+};
+
+/* BootROM/EEPROM/MII Management Register */
+#define MASK_MIIR_MII_READ       0x00000000
+#define MASK_MIIR_MII_WRITE      0x00000008
+#define MASK_MIIR_MII_MDO        0x00000004
+#define MASK_MIIR_MII_MDI        0x00000002
+#define MASK_MIIR_MII_MDC        0x00000001
+
+/* ST+OP+PHYAD+REGAD+TA */
+#define OP_READ             0x6000     /* ST:01+OP:10+PHYAD+REGAD+TA:Z0 */
+#define OP_WRITE            0x5002     /* ST:01+OP:01+PHYAD+REGAD+TA:10 */
+
+/* ------------------------------------------------------------------------- */
+/*      Constants for Myson PHY                                              */
+/* ------------------------------------------------------------------------- */
+#define MysonPHYID      0xd0000302
+/* 89-7-27 add, (begin) */
+#define MysonPHYID0     0x0302
+#define StatusRegister  18
+#define SPEED100        0x0400 // bit10
+#define FULLMODE        0x0800 // bit11
+/* 89-7-27 add, (end) */
+
+/* ------------------------------------------------------------------------- */
+/*      Constants for Seeq 80225 PHY                                         */
+/* ------------------------------------------------------------------------- */
+#define SeeqPHYID0      0x0016
+
+#define MIIRegister18   18
+#define SPD_DET_100     0x80
+#define DPLX_DET_FULL   0x40
+
+/* ------------------------------------------------------------------------- */
+/*      Constants for Ahdoc 101 PHY                                          */
+/* ------------------------------------------------------------------------- */
+#define AhdocPHYID0     0x0022
+
+#define DiagnosticReg   18
+#define DPLX_FULL       0x0800
+#define Speed_100       0x0400
+
+/* 89/6/13 add, */
+/* -------------------------------------------------------------------------- */
+/*      Constants                                                             */
+/* -------------------------------------------------------------------------- */
+#define MarvellPHYID0           0x0141
+#define LevelOnePHYID0         0x0013
+
+#define MII1000BaseTControlReg  9
+#define MII1000BaseTStatusReg   10
+#define SpecificReg            17
+
+/* for 1000BaseT Control Register */
+#define PHYAbletoPerform1000FullDuplex  0x0200
+#define PHYAbletoPerform1000HalfDuplex  0x0100
+#define PHY1000AbilityMask              0x300
+
+// for phy specific status register, marvell phy.
+#define SpeedMask       0x0c000
+#define Speed_1000M     0x08000
+#define Speed_100M      0x4000
+#define Speed_10M       0
+#define Full_Duplex     0x2000
+
+// 89/12/29 add, for phy specific status register, levelone phy, (begin)
+#define LXT1000_100M    0x08000
+#define LXT1000_1000M   0x0c000
+#define LXT1000_Full    0x200
+// 89/12/29 add, for phy specific status register, levelone phy, (end)
+
+/* for 3-in-1 case, BMCRSR register */
+#define LinkIsUp2      0x00040000
+
+/* for PHY */
+#define LinkIsUp        0x0004
+
+
+struct netdev_private {
+       /* Descriptor rings first for alignment. */
+       struct fealnx_desc *rx_ring;
+       struct fealnx_desc *tx_ring;
+
+       dma_addr_t rx_ring_dma;
+       dma_addr_t tx_ring_dma;
+
+       spinlock_t lock;
+
+       /* Media monitoring timer. */
+       struct timer_list timer;
+
+       /* Reset timer */
+       struct timer_list reset_timer;
+       int reset_timer_armed;
+       unsigned long crvalue_sv;
+       unsigned long imrvalue_sv;
+
+       /* Frequently used values: keep some adjacent for cache effect. */
+       int flags;
+       struct pci_dev *pci_dev;
+       unsigned long crvalue;
+       unsigned long bcrvalue;
+       unsigned long imrvalue;
+       struct fealnx_desc *cur_rx;
+       struct fealnx_desc *lack_rxbuf;
+       int really_rx_count;
+       struct fealnx_desc *cur_tx;
+       struct fealnx_desc *cur_tx_copy;
+       int really_tx_count;
+       int free_tx_count;
+       unsigned int rx_buf_sz; /* Based on MTU+slack. */
+
+       /* These values are keep track of the transceiver/media in use. */
+       unsigned int linkok;
+       unsigned int line_speed;
+       unsigned int duplexmode;
+       unsigned int default_port:4;    /* Last dev->if_port value. */
+       unsigned int PHYType;
+
+       /* MII transceiver section. */
+       int mii_cnt;            /* MII device addresses. */
+       unsigned char phys[2];  /* MII device addresses. */
+       struct mii_if_info mii;
+       void __iomem *mem;
+};
+
+
+static int mdio_read(struct net_device *dev, int phy_id, int location);
+static void mdio_write(struct net_device *dev, int phy_id, int location, int value);
+static int netdev_open(struct net_device *dev);
+static void getlinktype(struct net_device *dev);
+static void getlinkstatus(struct net_device *dev);
+static void netdev_timer(struct timer_list *t);
+static void reset_timer(struct timer_list *t);
+static void fealnx_tx_timeout(struct net_device *dev, unsigned int txqueue);
+static void init_ring(struct net_device *dev);
+static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev);
+static irqreturn_t intr_handler(int irq, void *dev_instance);
+static int netdev_rx(struct net_device *dev);
+static void set_rx_mode(struct net_device *dev);
+static void __set_rx_mode(struct net_device *dev);
+static struct net_device_stats *get_stats(struct net_device *dev);
+static int mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+static const struct ethtool_ops netdev_ethtool_ops;
+static int netdev_close(struct net_device *dev);
+static void reset_rx_descriptors(struct net_device *dev);
+static void reset_tx_descriptors(struct net_device *dev);
+
+static void stop_nic_rx(void __iomem *ioaddr, long crvalue)
+{
+       int delay = 0x1000;
+       iowrite32(crvalue & ~(CR_W_RXEN), ioaddr + TCRRCR);
+       while (--delay) {
+               if ( (ioread32(ioaddr + TCRRCR) & CR_R_RXSTOP) == CR_R_RXSTOP)
+                       break;
+       }
+}
+
+
+static void stop_nic_rxtx(void __iomem *ioaddr, long crvalue)
+{
+       int delay = 0x1000;
+       iowrite32(crvalue & ~(CR_W_RXEN+CR_W_TXEN), ioaddr + TCRRCR);
+       while (--delay) {
+               if ( (ioread32(ioaddr + TCRRCR) & (CR_R_RXSTOP+CR_R_TXSTOP))
+                                           == (CR_R_RXSTOP+CR_R_TXSTOP) )
+                       break;
+       }
+}
+
+static const struct net_device_ops netdev_ops = {
+       .ndo_open               = netdev_open,
+       .ndo_stop               = netdev_close,
+       .ndo_start_xmit         = start_tx,
+       .ndo_get_stats          = get_stats,
+       .ndo_set_rx_mode        = set_rx_mode,
+       .ndo_eth_ioctl          = mii_ioctl,
+       .ndo_tx_timeout         = fealnx_tx_timeout,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
+static int fealnx_init_one(struct pci_dev *pdev,
+                          const struct pci_device_id *ent)
+{
+       struct netdev_private *np;
+       int i, option, err, irq;
+       static int card_idx = -1;
+       char boardname[12];
+       void __iomem *ioaddr;
+       unsigned long len;
+       unsigned int chip_id = ent->driver_data;
+       struct net_device *dev;
+       void *ring_space;
+       dma_addr_t ring_dma;
+       u8 addr[ETH_ALEN];
+#ifdef USE_IO_OPS
+       int bar = 0;
+#else
+       int bar = 1;
+#endif
+
+       card_idx++;
+       sprintf(boardname, "fealnx%d", card_idx);
+
+       option = card_idx < MAX_UNITS ? options[card_idx] : 0;
+
+       i = pci_enable_device(pdev);
+       if (i) return i;
+       pci_set_master(pdev);
+
+       len = pci_resource_len(pdev, bar);
+       if (len < MIN_REGION_SIZE) {
+               dev_err(&pdev->dev,
+                          "region size %ld too small, aborting\n", len);
+               return -ENODEV;
+       }
+
+       i = pci_request_regions(pdev, boardname);
+       if (i)
+               return i;
+
+       irq = pdev->irq;
+
+       ioaddr = pci_iomap(pdev, bar, len);
+       if (!ioaddr) {
+               err = -ENOMEM;
+               goto err_out_res;
+       }
+
+       dev = alloc_etherdev(sizeof(struct netdev_private));
+       if (!dev) {
+               err = -ENOMEM;
+               goto err_out_unmap;
+       }
+       SET_NETDEV_DEV(dev, &pdev->dev);
+
+       /* read ethernet id */
+       for (i = 0; i < 6; ++i)
+               addr[i] = ioread8(ioaddr + PAR0 + i);
+       eth_hw_addr_set(dev, addr);
+
+       /* Reset the chip to erase previous misconfiguration. */
+       iowrite32(0x00000001, ioaddr + BCR);
+
+       /* Make certain the descriptor lists are aligned. */
+       np = netdev_priv(dev);
+       np->mem = ioaddr;
+       spin_lock_init(&np->lock);
+       np->pci_dev = pdev;
+       np->flags = skel_netdrv_tbl[chip_id].flags;
+       pci_set_drvdata(pdev, dev);
+       np->mii.dev = dev;
+       np->mii.mdio_read = mdio_read;
+       np->mii.mdio_write = mdio_write;
+       np->mii.phy_id_mask = 0x1f;
+       np->mii.reg_num_mask = 0x1f;
+
+       ring_space = dma_alloc_coherent(&pdev->dev, RX_TOTAL_SIZE, &ring_dma,
+                                       GFP_KERNEL);
+       if (!ring_space) {
+               err = -ENOMEM;
+               goto err_out_free_dev;
+       }
+       np->rx_ring = ring_space;
+       np->rx_ring_dma = ring_dma;
+
+       ring_space = dma_alloc_coherent(&pdev->dev, TX_TOTAL_SIZE, &ring_dma,
+                                       GFP_KERNEL);
+       if (!ring_space) {
+               err = -ENOMEM;
+               goto err_out_free_rx;
+       }
+       np->tx_ring = ring_space;
+       np->tx_ring_dma = ring_dma;
+
+       /* find the connected MII xcvrs */
+       if (np->flags == HAS_MII_XCVR) {
+               int phy, phy_idx = 0;
+
+               for (phy = 1; phy < 32 && phy_idx < ARRAY_SIZE(np->phys);
+                              phy++) {
+                       int mii_status = mdio_read(dev, phy, 1);
+
+                       if (mii_status != 0xffff && mii_status != 0x0000) {
+                               np->phys[phy_idx++] = phy;
+                               dev_info(&pdev->dev,
+                                      "MII PHY found at address %d, status "
+                                      "0x%4.4x.\n", phy, mii_status);
+                               /* get phy type */
+                               {
+                                       unsigned int data;
+
+                                       data = mdio_read(dev, np->phys[0], 2);
+                                       if (data == SeeqPHYID0)
+                                               np->PHYType = SeeqPHY;
+                                       else if (data == AhdocPHYID0)
+                                               np->PHYType = AhdocPHY;
+                                       else if (data == MarvellPHYID0)
+                                               np->PHYType = MarvellPHY;
+                                       else if (data == MysonPHYID0)
+                                               np->PHYType = Myson981;
+                                       else if (data == LevelOnePHYID0)
+                                               np->PHYType = LevelOnePHY;
+                                       else
+                                               np->PHYType = OtherPHY;
+                               }
+                       }
+               }
+
+               np->mii_cnt = phy_idx;
+               if (phy_idx == 0)
+                       dev_warn(&pdev->dev,
+                               "MII PHY not found -- this device may "
+                              "not operate correctly.\n");
+       } else {
+               np->phys[0] = 32;
+/* 89/6/23 add, (begin) */
+               /* get phy type */
+               if (ioread32(ioaddr + PHYIDENTIFIER) == MysonPHYID)
+                       np->PHYType = MysonPHY;
+               else
+                       np->PHYType = OtherPHY;
+       }
+       np->mii.phy_id = np->phys[0];
+
+       if (dev->mem_start)
+               option = dev->mem_start;
+
+       /* The lower four bits are the media type. */
+       if (option > 0) {
+               if (option & 0x200)
+                       np->mii.full_duplex = 1;
+               np->default_port = option & 15;
+       }
+
+       if (card_idx < MAX_UNITS && full_duplex[card_idx] > 0)
+               np->mii.full_duplex = full_duplex[card_idx];
+
+       if (np->mii.full_duplex) {
+               dev_info(&pdev->dev, "Media type forced to Full Duplex.\n");
+/* 89/6/13 add, (begin) */
+//      if (np->PHYType==MarvellPHY)
+               if ((np->PHYType == MarvellPHY) || (np->PHYType == LevelOnePHY)) {
+                       unsigned int data;
+
+                       data = mdio_read(dev, np->phys[0], 9);
+                       data = (data & 0xfcff) | 0x0200;
+                       mdio_write(dev, np->phys[0], 9, data);
+               }
+/* 89/6/13 add, (end) */
+               if (np->flags == HAS_MII_XCVR)
+                       mdio_write(dev, np->phys[0], MII_ADVERTISE, ADVERTISE_FULL);
+               else
+                       iowrite32(ADVERTISE_FULL, ioaddr + ANARANLPAR);
+               np->mii.force_media = 1;
+       }
+
+       dev->netdev_ops = &netdev_ops;
+       dev->ethtool_ops = &netdev_ethtool_ops;
+       dev->watchdog_timeo = TX_TIMEOUT;
+
+       err = register_netdev(dev);
+       if (err)
+               goto err_out_free_tx;
+
+       printk(KERN_INFO "%s: %s at %p, %pM, IRQ %d.\n",
+              dev->name, skel_netdrv_tbl[chip_id].chip_name, ioaddr,
+              dev->dev_addr, irq);
+
+       return 0;
+
+err_out_free_tx:
+       dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, np->tx_ring,
+                         np->tx_ring_dma);
+err_out_free_rx:
+       dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, np->rx_ring,
+                         np->rx_ring_dma);
+err_out_free_dev:
+       free_netdev(dev);
+err_out_unmap:
+       pci_iounmap(pdev, ioaddr);
+err_out_res:
+       pci_release_regions(pdev);
+       return err;
+}
+
+
+static void fealnx_remove_one(struct pci_dev *pdev)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+
+       if (dev) {
+               struct netdev_private *np = netdev_priv(dev);
+
+               dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, np->tx_ring,
+                                 np->tx_ring_dma);
+               dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, np->rx_ring,
+                                 np->rx_ring_dma);
+               unregister_netdev(dev);
+               pci_iounmap(pdev, np->mem);
+               free_netdev(dev);
+               pci_release_regions(pdev);
+       } else
+               printk(KERN_ERR "fealnx: remove for unknown device\n");
+}
+
+
+static ulong m80x_send_cmd_to_phy(void __iomem *miiport, int opcode, int phyad, int regad)
+{
+       ulong miir;
+       int i;
+       unsigned int mask, data;
+
+       /* enable MII output */
+       miir = (ulong) ioread32(miiport);
+       miir &= 0xfffffff0;
+
+       miir |= MASK_MIIR_MII_WRITE + MASK_MIIR_MII_MDO;
+
+       /* send 32 1's preamble */
+       for (i = 0; i < 32; i++) {
+               /* low MDC; MDO is already high (miir) */
+               miir &= ~MASK_MIIR_MII_MDC;
+               iowrite32(miir, miiport);
+
+               /* high MDC */
+               miir |= MASK_MIIR_MII_MDC;
+               iowrite32(miir, miiport);
+       }
+
+       /* calculate ST+OP+PHYAD+REGAD+TA */
+       data = opcode | (phyad << 7) | (regad << 2);
+
+       /* sent out */
+       mask = 0x8000;
+       while (mask) {
+               /* low MDC, prepare MDO */
+               miir &= ~(MASK_MIIR_MII_MDC + MASK_MIIR_MII_MDO);
+               if (mask & data)
+                       miir |= MASK_MIIR_MII_MDO;
+
+               iowrite32(miir, miiport);
+               /* high MDC */
+               miir |= MASK_MIIR_MII_MDC;
+               iowrite32(miir, miiport);
+               udelay(30);
+
+               /* next */
+               mask >>= 1;
+               if (mask == 0x2 && opcode == OP_READ)
+                       miir &= ~MASK_MIIR_MII_WRITE;
+       }
+       return miir;
+}
+
+
+static int mdio_read(struct net_device *dev, int phyad, int regad)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *miiport = np->mem + MANAGEMENT;
+       ulong miir;
+       unsigned int mask, data;
+
+       miir = m80x_send_cmd_to_phy(miiport, OP_READ, phyad, regad);
+
+       /* read data */
+       mask = 0x8000;
+       data = 0;
+       while (mask) {
+               /* low MDC */
+               miir &= ~MASK_MIIR_MII_MDC;
+               iowrite32(miir, miiport);
+
+               /* read MDI */
+               miir = ioread32(miiport);
+               if (miir & MASK_MIIR_MII_MDI)
+                       data |= mask;
+
+               /* high MDC, and wait */
+               miir |= MASK_MIIR_MII_MDC;
+               iowrite32(miir, miiport);
+               udelay(30);
+
+               /* next */
+               mask >>= 1;
+       }
+
+       /* low MDC */
+       miir &= ~MASK_MIIR_MII_MDC;
+       iowrite32(miir, miiport);
+
+       return data & 0xffff;
+}
+
+
+static void mdio_write(struct net_device *dev, int phyad, int regad, int data)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *miiport = np->mem + MANAGEMENT;
+       ulong miir;
+       unsigned int mask;
+
+       miir = m80x_send_cmd_to_phy(miiport, OP_WRITE, phyad, regad);
+
+       /* write data */
+       mask = 0x8000;
+       while (mask) {
+               /* low MDC, prepare MDO */
+               miir &= ~(MASK_MIIR_MII_MDC + MASK_MIIR_MII_MDO);
+               if (mask & data)
+                       miir |= MASK_MIIR_MII_MDO;
+               iowrite32(miir, miiport);
+
+               /* high MDC */
+               miir |= MASK_MIIR_MII_MDC;
+               iowrite32(miir, miiport);
+
+               /* next */
+               mask >>= 1;
+       }
+
+       /* low MDC */
+       miir &= ~MASK_MIIR_MII_MDC;
+       iowrite32(miir, miiport);
+}
+
+
+static int netdev_open(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->mem;
+       const int irq = np->pci_dev->irq;
+       int rc, i;
+
+       iowrite32(0x00000001, ioaddr + BCR);    /* Reset */
+
+       rc = request_irq(irq, intr_handler, IRQF_SHARED, dev->name, dev);
+       if (rc)
+               return -EAGAIN;
+
+       for (i = 0; i < 3; i++)
+               iowrite16(((const unsigned short *)dev->dev_addr)[i],
+                               ioaddr + PAR0 + i*2);
+
+       init_ring(dev);
+
+       iowrite32(np->rx_ring_dma, ioaddr + RXLBA);
+       iowrite32(np->tx_ring_dma, ioaddr + TXLBA);
+
+       /* Initialize other registers. */
+       /* Configure the PCI bus bursts and FIFO thresholds.
+          486: Set 8 longword burst.
+          586: no burst limit.
+          Burst length 5:3
+          0 0 0   1
+          0 0 1   4
+          0 1 0   8
+          0 1 1   16
+          1 0 0   32
+          1 0 1   64
+          1 1 0   128
+          1 1 1   256
+          Wait the specified 50 PCI cycles after a reset by initializing
+          Tx and Rx queues and the address filter list.
+          FIXME (Ueimor): optimistic for alpha + posted writes ? */
+
+       np->bcrvalue = 0x10;    /* little-endian, 8 burst length */
+#ifdef __BIG_ENDIAN
+       np->bcrvalue |= 0x04;   /* big-endian */
+#endif
+
+#if defined(__i386__) && !defined(MODULE) && !defined(CONFIG_UML)
+       if (boot_cpu_data.x86 <= 4)
+               np->crvalue = 0xa00;
+       else
+#endif
+               np->crvalue = 0xe00;    /* rx 128 burst length */
+
+
+// 89/12/29 add,
+// 90/1/16 modify,
+//   np->imrvalue=FBE|TUNF|CNTOVF|RBU|TI|RI;
+       np->imrvalue = TUNF | CNTOVF | RBU | TI | RI;
+       if (np->pci_dev->device == 0x891) {
+               np->bcrvalue |= 0x200;  /* set PROG bit */
+               np->crvalue |= CR_W_ENH;        /* set enhanced bit */
+               np->imrvalue |= ETI;
+       }
+       iowrite32(np->bcrvalue, ioaddr + BCR);
+
+       if (dev->if_port == 0)
+               dev->if_port = np->default_port;
+
+       iowrite32(0, ioaddr + RXPDR);
+// 89/9/1 modify,
+//   np->crvalue = 0x00e40001;    /* tx store and forward, tx/rx enable */
+       np->crvalue |= 0x00e40001;      /* tx store and forward, tx/rx enable */
+       np->mii.full_duplex = np->mii.force_media;
+       getlinkstatus(dev);
+       if (np->linkok)
+               getlinktype(dev);
+       __set_rx_mode(dev);
+
+       netif_start_queue(dev);
+
+       /* Clear and Enable interrupts by setting the interrupt mask. */
+       iowrite32(FBE | TUNF | CNTOVF | RBU | TI | RI, ioaddr + ISR);
+       iowrite32(np->imrvalue, ioaddr + IMR);
+
+       if (debug)
+               printk(KERN_DEBUG "%s: Done netdev_open().\n", dev->name);
+
+       /* Set the timer to check for link beat. */
+       timer_setup(&np->timer, netdev_timer, 0);
+       np->timer.expires = RUN_AT(3 * HZ);
+
+       /* timer handler */
+       add_timer(&np->timer);
+
+       timer_setup(&np->reset_timer, reset_timer, 0);
+       np->reset_timer_armed = 0;
+       return rc;
+}
+
+
+static void getlinkstatus(struct net_device *dev)
+/* function: Routine will read MII Status Register to get link status.       */
+/* input   : dev... pointer to the adapter block.                            */
+/* output  : none.                                                           */
+{
+       struct netdev_private *np = netdev_priv(dev);
+       unsigned int i, DelayTime = 0x1000;
+
+       np->linkok = 0;
+
+       if (np->PHYType == MysonPHY) {
+               for (i = 0; i < DelayTime; ++i) {
+                       if (ioread32(np->mem + BMCRSR) & LinkIsUp2) {
+                               np->linkok = 1;
+                               return;
+                       }
+                       udelay(100);
+               }
+       } else {
+               for (i = 0; i < DelayTime; ++i) {
+                       if (mdio_read(dev, np->phys[0], MII_BMSR) & BMSR_LSTATUS) {
+                               np->linkok = 1;
+                               return;
+                       }
+                       udelay(100);
+               }
+       }
+}
+
+
+static void getlinktype(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+
+       if (np->PHYType == MysonPHY) {  /* 3-in-1 case */
+               if (ioread32(np->mem + TCRRCR) & CR_R_FD)
+                       np->duplexmode = 2;     /* full duplex */
+               else
+                       np->duplexmode = 1;     /* half duplex */
+               if (ioread32(np->mem + TCRRCR) & CR_R_PS10)
+                       np->line_speed = 1;     /* 10M */
+               else
+                       np->line_speed = 2;     /* 100M */
+       } else {
+               if (np->PHYType == SeeqPHY) {   /* this PHY is SEEQ 80225 */
+                       unsigned int data;
+
+                       data = mdio_read(dev, np->phys[0], MIIRegister18);
+                       if (data & SPD_DET_100)
+                               np->line_speed = 2;     /* 100M */
+                       else
+                               np->line_speed = 1;     /* 10M */
+                       if (data & DPLX_DET_FULL)
+                               np->duplexmode = 2;     /* full duplex mode */
+                       else
+                               np->duplexmode = 1;     /* half duplex mode */
+               } else if (np->PHYType == AhdocPHY) {
+                       unsigned int data;
+
+                       data = mdio_read(dev, np->phys[0], DiagnosticReg);
+                       if (data & Speed_100)
+                               np->line_speed = 2;     /* 100M */
+                       else
+                               np->line_speed = 1;     /* 10M */
+                       if (data & DPLX_FULL)
+                               np->duplexmode = 2;     /* full duplex mode */
+                       else
+                               np->duplexmode = 1;     /* half duplex mode */
+               }
+/* 89/6/13 add, (begin) */
+               else if (np->PHYType == MarvellPHY) {
+                       unsigned int data;
+
+                       data = mdio_read(dev, np->phys[0], SpecificReg);
+                       if (data & Full_Duplex)
+                               np->duplexmode = 2;     /* full duplex mode */
+                       else
+                               np->duplexmode = 1;     /* half duplex mode */
+                       data &= SpeedMask;
+                       if (data == Speed_1000M)
+                               np->line_speed = 3;     /* 1000M */
+                       else if (data == Speed_100M)
+                               np->line_speed = 2;     /* 100M */
+                       else
+                               np->line_speed = 1;     /* 10M */
+               }
+/* 89/6/13 add, (end) */
+/* 89/7/27 add, (begin) */
+               else if (np->PHYType == Myson981) {
+                       unsigned int data;
+
+                       data = mdio_read(dev, np->phys[0], StatusRegister);
+
+                       if (data & SPEED100)
+                               np->line_speed = 2;
+                       else
+                               np->line_speed = 1;
+
+                       if (data & FULLMODE)
+                               np->duplexmode = 2;
+                       else
+                               np->duplexmode = 1;
+               }
+/* 89/7/27 add, (end) */
+/* 89/12/29 add */
+               else if (np->PHYType == LevelOnePHY) {
+                       unsigned int data;
+
+                       data = mdio_read(dev, np->phys[0], SpecificReg);
+                       if (data & LXT1000_Full)
+                               np->duplexmode = 2;     /* full duplex mode */
+                       else
+                               np->duplexmode = 1;     /* half duplex mode */
+                       data &= SpeedMask;
+                       if (data == LXT1000_1000M)
+                               np->line_speed = 3;     /* 1000M */
+                       else if (data == LXT1000_100M)
+                               np->line_speed = 2;     /* 100M */
+                       else
+                               np->line_speed = 1;     /* 10M */
+               }
+               np->crvalue &= (~CR_W_PS10) & (~CR_W_FD) & (~CR_W_PS1000);
+               if (np->line_speed == 1)
+                       np->crvalue |= CR_W_PS10;
+               else if (np->line_speed == 3)
+                       np->crvalue |= CR_W_PS1000;
+               if (np->duplexmode == 2)
+                       np->crvalue |= CR_W_FD;
+       }
+}
+
+
+/* Take lock before calling this */
+static void allocate_rx_buffers(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+
+       /*  allocate skb for rx buffers */
+       while (np->really_rx_count != RX_RING_SIZE) {
+               struct sk_buff *skb;
+
+               skb = netdev_alloc_skb(dev, np->rx_buf_sz);
+               if (skb == NULL)
+                       break;  /* Better luck next round. */
+
+               while (np->lack_rxbuf->skbuff)
+                       np->lack_rxbuf = np->lack_rxbuf->next_desc_logical;
+
+               np->lack_rxbuf->skbuff = skb;
+               np->lack_rxbuf->buffer = dma_map_single(&np->pci_dev->dev,
+                                                       skb->data,
+                                                       np->rx_buf_sz,
+                                                       DMA_FROM_DEVICE);
+               np->lack_rxbuf->status = RXOWN;
+               ++np->really_rx_count;
+       }
+}
+
+
+static void netdev_timer(struct timer_list *t)
+{
+       struct netdev_private *np = from_timer(np, t, timer);
+       struct net_device *dev = np->mii.dev;
+       void __iomem *ioaddr = np->mem;
+       int old_crvalue = np->crvalue;
+       unsigned int old_linkok = np->linkok;
+       unsigned long flags;
+
+       if (debug)
+               printk(KERN_DEBUG "%s: Media selection timer tick, status %8.8x "
+                      "config %8.8x.\n", dev->name, ioread32(ioaddr + ISR),
+                      ioread32(ioaddr + TCRRCR));
+
+       spin_lock_irqsave(&np->lock, flags);
+
+       if (np->flags == HAS_MII_XCVR) {
+               getlinkstatus(dev);
+               if ((old_linkok == 0) && (np->linkok == 1)) {   /* we need to detect the media type again */
+                       getlinktype(dev);
+                       if (np->crvalue != old_crvalue) {
+                               stop_nic_rxtx(ioaddr, np->crvalue);
+                               iowrite32(np->crvalue, ioaddr + TCRRCR);
+                       }
+               }
+       }
+
+       allocate_rx_buffers(dev);
+
+       spin_unlock_irqrestore(&np->lock, flags);
+
+       np->timer.expires = RUN_AT(10 * HZ);
+       add_timer(&np->timer);
+}
+
+
+/* Take lock before calling */
+/* Reset chip and disable rx, tx and interrupts */
+static void reset_and_disable_rxtx(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->mem;
+       int delay=51;
+
+       /* Reset the chip's Tx and Rx processes. */
+       stop_nic_rxtx(ioaddr, 0);
+
+       /* Disable interrupts by clearing the interrupt mask. */
+       iowrite32(0, ioaddr + IMR);
+
+       /* Reset the chip to erase previous misconfiguration. */
+       iowrite32(0x00000001, ioaddr + BCR);
+
+       /* Ueimor: wait for 50 PCI cycles (and flush posted writes btw).
+          We surely wait too long (address+data phase). Who cares? */
+       while (--delay) {
+               ioread32(ioaddr + BCR);
+               rmb();
+       }
+}
+
+
+/* Take lock before calling */
+/* Restore chip after reset */
+static void enable_rxtx(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->mem;
+
+       reset_rx_descriptors(dev);
+
+       iowrite32(np->tx_ring_dma + ((char*)np->cur_tx - (char*)np->tx_ring),
+               ioaddr + TXLBA);
+       iowrite32(np->rx_ring_dma + ((char*)np->cur_rx - (char*)np->rx_ring),
+               ioaddr + RXLBA);
+
+       iowrite32(np->bcrvalue, ioaddr + BCR);
+
+       iowrite32(0, ioaddr + RXPDR);
+       __set_rx_mode(dev); /* changes np->crvalue, writes it into TCRRCR */
+
+       /* Clear and Enable interrupts by setting the interrupt mask. */
+       iowrite32(FBE | TUNF | CNTOVF | RBU | TI | RI, ioaddr + ISR);
+       iowrite32(np->imrvalue, ioaddr + IMR);
+
+       iowrite32(0, ioaddr + TXPDR);
+}
+
+
+static void reset_timer(struct timer_list *t)
+{
+       struct netdev_private *np = from_timer(np, t, reset_timer);
+       struct net_device *dev = np->mii.dev;
+       unsigned long flags;
+
+       printk(KERN_WARNING "%s: resetting tx and rx machinery\n", dev->name);
+
+       spin_lock_irqsave(&np->lock, flags);
+       np->crvalue = np->crvalue_sv;
+       np->imrvalue = np->imrvalue_sv;
+
+       reset_and_disable_rxtx(dev);
+       /* works for me without this:
+       reset_tx_descriptors(dev); */
+       enable_rxtx(dev);
+       netif_start_queue(dev); /* FIXME: or netif_wake_queue(dev); ? */
+
+       np->reset_timer_armed = 0;
+
+       spin_unlock_irqrestore(&np->lock, flags);
+}
+
+
+static void fealnx_tx_timeout(struct net_device *dev, unsigned int txqueue)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->mem;
+       unsigned long flags;
+       int i;
+
+       printk(KERN_WARNING
+              "%s: Transmit timed out, status %8.8x, resetting...\n",
+              dev->name, ioread32(ioaddr + ISR));
+
+       {
+               printk(KERN_DEBUG "  Rx ring %p: ", np->rx_ring);
+               for (i = 0; i < RX_RING_SIZE; i++)
+                       printk(KERN_CONT " %8.8x",
+                              (unsigned int) np->rx_ring[i].status);
+               printk(KERN_CONT "\n");
+               printk(KERN_DEBUG "  Tx ring %p: ", np->tx_ring);
+               for (i = 0; i < TX_RING_SIZE; i++)
+                       printk(KERN_CONT " %4.4x", np->tx_ring[i].status);
+               printk(KERN_CONT "\n");
+       }
+
+       spin_lock_irqsave(&np->lock, flags);
+
+       reset_and_disable_rxtx(dev);
+       reset_tx_descriptors(dev);
+       enable_rxtx(dev);
+
+       spin_unlock_irqrestore(&np->lock, flags);
+
+       netif_trans_update(dev); /* prevent tx timeout */
+       dev->stats.tx_errors++;
+       netif_wake_queue(dev); /* or .._start_.. ?? */
+}
+
+
+/* Initialize the Rx and Tx rings, along with various 'dev' bits. */
+static void init_ring(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       int i;
+
+       /* initialize rx variables */
+       np->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32);
+       np->cur_rx = &np->rx_ring[0];
+       np->lack_rxbuf = np->rx_ring;
+       np->really_rx_count = 0;
+
+       /* initial rx descriptors. */
+       for (i = 0; i < RX_RING_SIZE; i++) {
+               np->rx_ring[i].status = 0;
+               np->rx_ring[i].control = np->rx_buf_sz << RBSShift;
+               np->rx_ring[i].next_desc = np->rx_ring_dma +
+                       (i + 1)*sizeof(struct fealnx_desc);
+               np->rx_ring[i].next_desc_logical = &np->rx_ring[i + 1];
+               np->rx_ring[i].skbuff = NULL;
+       }
+
+       /* for the last rx descriptor */
+       np->rx_ring[i - 1].next_desc = np->rx_ring_dma;
+       np->rx_ring[i - 1].next_desc_logical = np->rx_ring;
+
+       /* allocate skb for rx buffers */
+       for (i = 0; i < RX_RING_SIZE; i++) {
+               struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz);
+
+               if (skb == NULL) {
+                       np->lack_rxbuf = &np->rx_ring[i];
+                       break;
+               }
+
+               ++np->really_rx_count;
+               np->rx_ring[i].skbuff = skb;
+               np->rx_ring[i].buffer = dma_map_single(&np->pci_dev->dev,
+                                                      skb->data,
+                                                      np->rx_buf_sz,
+                                                      DMA_FROM_DEVICE);
+               np->rx_ring[i].status = RXOWN;
+               np->rx_ring[i].control |= RXIC;
+       }
+
+       /* initialize tx variables */
+       np->cur_tx = &np->tx_ring[0];
+       np->cur_tx_copy = &np->tx_ring[0];
+       np->really_tx_count = 0;
+       np->free_tx_count = TX_RING_SIZE;
+
+       for (i = 0; i < TX_RING_SIZE; i++) {
+               np->tx_ring[i].status = 0;
+               /* do we need np->tx_ring[i].control = XXX; ?? */
+               np->tx_ring[i].next_desc = np->tx_ring_dma +
+                       (i + 1)*sizeof(struct fealnx_desc);
+               np->tx_ring[i].next_desc_logical = &np->tx_ring[i + 1];
+               np->tx_ring[i].skbuff = NULL;
+       }
+
+       /* for the last tx descriptor */
+       np->tx_ring[i - 1].next_desc = np->tx_ring_dma;
+       np->tx_ring[i - 1].next_desc_logical = &np->tx_ring[0];
+}
+
+
+static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       unsigned long flags;
+
+       spin_lock_irqsave(&np->lock, flags);
+
+       np->cur_tx_copy->skbuff = skb;
+
+#define one_buffer
+#define BPT 1022
+#if defined(one_buffer)
+       np->cur_tx_copy->buffer = dma_map_single(&np->pci_dev->dev, skb->data,
+                                                skb->len, DMA_TO_DEVICE);
+       np->cur_tx_copy->control = TXIC | TXLD | TXFD | CRCEnable | PADEnable;
+       np->cur_tx_copy->control |= (skb->len << PKTSShift);    /* pkt size */
+       np->cur_tx_copy->control |= (skb->len << TBSShift);     /* buffer size */
+// 89/12/29 add,
+       if (np->pci_dev->device == 0x891)
+               np->cur_tx_copy->control |= ETIControl | RetryTxLC;
+       np->cur_tx_copy->status = TXOWN;
+       np->cur_tx_copy = np->cur_tx_copy->next_desc_logical;
+       --np->free_tx_count;
+#elif defined(two_buffer)
+       if (skb->len > BPT) {
+               struct fealnx_desc *next;
+
+               /* for the first descriptor */
+               np->cur_tx_copy->buffer = dma_map_single(&np->pci_dev->dev,
+                                                        skb->data, BPT,
+                                                        DMA_TO_DEVICE);
+               np->cur_tx_copy->control = TXIC | TXFD | CRCEnable | PADEnable;
+               np->cur_tx_copy->control |= (skb->len << PKTSShift);    /* pkt size */
+               np->cur_tx_copy->control |= (BPT << TBSShift);  /* buffer size */
+
+               /* for the last descriptor */
+               next = np->cur_tx_copy->next_desc_logical;
+               next->skbuff = skb;
+               next->control = TXIC | TXLD | CRCEnable | PADEnable;
+               next->control |= (skb->len << PKTSShift);       /* pkt size */
+               next->control |= ((skb->len - BPT) << TBSShift);        /* buf size */
+// 89/12/29 add,
+               if (np->pci_dev->device == 0x891)
+                       np->cur_tx_copy->control |= ETIControl | RetryTxLC;
+               next->buffer = dma_map_single(&ep->pci_dev->dev,
+                                             skb->data + BPT, skb->len - BPT,
+                                             DMA_TO_DEVICE);
+
+               next->status = TXOWN;
+               np->cur_tx_copy->status = TXOWN;
+
+               np->cur_tx_copy = next->next_desc_logical;
+               np->free_tx_count -= 2;
+       } else {
+               np->cur_tx_copy->buffer = dma_map_single(&np->pci_dev->dev,
+                                                        skb->data, skb->len,
+                                                        DMA_TO_DEVICE);
+               np->cur_tx_copy->control = TXIC | TXLD | TXFD | CRCEnable | PADEnable;
+               np->cur_tx_copy->control |= (skb->len << PKTSShift);    /* pkt size */
+               np->cur_tx_copy->control |= (skb->len << TBSShift);     /* buffer size */
+// 89/12/29 add,
+               if (np->pci_dev->device == 0x891)
+                       np->cur_tx_copy->control |= ETIControl | RetryTxLC;
+               np->cur_tx_copy->status = TXOWN;
+               np->cur_tx_copy = np->cur_tx_copy->next_desc_logical;
+               --np->free_tx_count;
+       }
+#endif
+
+       if (np->free_tx_count < 2)
+               netif_stop_queue(dev);
+       ++np->really_tx_count;
+       iowrite32(0, np->mem + TXPDR);
+
+       spin_unlock_irqrestore(&np->lock, flags);
+       return NETDEV_TX_OK;
+}
+
+
+/* Take lock before calling */
+/* Chip probably hosed tx ring. Clean up. */
+static void reset_tx_descriptors(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       struct fealnx_desc *cur;
+       int i;
+
+       /* initialize tx variables */
+       np->cur_tx = &np->tx_ring[0];
+       np->cur_tx_copy = &np->tx_ring[0];
+       np->really_tx_count = 0;
+       np->free_tx_count = TX_RING_SIZE;
+
+       for (i = 0; i < TX_RING_SIZE; i++) {
+               cur = &np->tx_ring[i];
+               if (cur->skbuff) {
+                       dma_unmap_single(&np->pci_dev->dev, cur->buffer,
+                                        cur->skbuff->len, DMA_TO_DEVICE);
+                       dev_kfree_skb_any(cur->skbuff);
+                       cur->skbuff = NULL;
+               }
+               cur->status = 0;
+               cur->control = 0;       /* needed? */
+               /* probably not needed. We do it for purely paranoid reasons */
+               cur->next_desc = np->tx_ring_dma +
+                       (i + 1)*sizeof(struct fealnx_desc);
+               cur->next_desc_logical = &np->tx_ring[i + 1];
+       }
+       /* for the last tx descriptor */
+       np->tx_ring[TX_RING_SIZE - 1].next_desc = np->tx_ring_dma;
+       np->tx_ring[TX_RING_SIZE - 1].next_desc_logical = &np->tx_ring[0];
+}
+
+
+/* Take lock and stop rx before calling this */
+static void reset_rx_descriptors(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       struct fealnx_desc *cur = np->cur_rx;
+       int i;
+
+       allocate_rx_buffers(dev);
+
+       for (i = 0; i < RX_RING_SIZE; i++) {
+               if (cur->skbuff)
+                       cur->status = RXOWN;
+               cur = cur->next_desc_logical;
+       }
+
+       iowrite32(np->rx_ring_dma + ((char*)np->cur_rx - (char*)np->rx_ring),
+               np->mem + RXLBA);
+}
+
+
+/* The interrupt handler does all of the Rx thread work and cleans up
+   after the Tx thread. */
+static irqreturn_t intr_handler(int irq, void *dev_instance)
+{
+       struct net_device *dev = (struct net_device *) dev_instance;
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->mem;
+       long boguscnt = max_interrupt_work;
+       unsigned int num_tx = 0;
+       int handled = 0;
+
+       spin_lock(&np->lock);
+
+       iowrite32(0, ioaddr + IMR);
+
+       do {
+               u32 intr_status = ioread32(ioaddr + ISR);
+
+               /* Acknowledge all of the current interrupt sources ASAP. */
+               iowrite32(intr_status, ioaddr + ISR);
+
+               if (debug)
+                       printk(KERN_DEBUG "%s: Interrupt, status %4.4x.\n", dev->name,
+                              intr_status);
+
+               if (!(intr_status & np->imrvalue))
+                       break;
+
+               handled = 1;
+
+// 90/1/16 delete,
+//
+//      if (intr_status & FBE)
+//      {   /* fatal error */
+//          stop_nic_tx(ioaddr, 0);
+//          stop_nic_rx(ioaddr, 0);
+//          break;
+//      };
+
+               if (intr_status & TUNF)
+                       iowrite32(0, ioaddr + TXPDR);
+
+               if (intr_status & CNTOVF) {
+                       /* missed pkts */
+                       dev->stats.rx_missed_errors +=
+                               ioread32(ioaddr + TALLY) & 0x7fff;
+
+                       /* crc error */
+                       dev->stats.rx_crc_errors +=
+                           (ioread32(ioaddr + TALLY) & 0x7fff0000) >> 16;
+               }
+
+               if (intr_status & (RI | RBU)) {
+                       if (intr_status & RI)
+                               netdev_rx(dev);
+                       else {
+                               stop_nic_rx(ioaddr, np->crvalue);
+                               reset_rx_descriptors(dev);
+                               iowrite32(np->crvalue, ioaddr + TCRRCR);
+                       }
+               }
+
+               while (np->really_tx_count) {
+                       long tx_status = np->cur_tx->status;
+                       long tx_control = np->cur_tx->control;
+
+                       if (!(tx_control & TXLD)) {     /* this pkt is combined by two tx descriptors */
+                               struct fealnx_desc *next;
+
+                               next = np->cur_tx->next_desc_logical;
+                               tx_status = next->status;
+                               tx_control = next->control;
+                       }
+
+                       if (tx_status & TXOWN)
+                               break;
+
+                       if (!(np->crvalue & CR_W_ENH)) {
+                               if (tx_status & (CSL | LC | EC | UDF | HF)) {
+                                       dev->stats.tx_errors++;
+                                       if (tx_status & EC)
+                                               dev->stats.tx_aborted_errors++;
+                                       if (tx_status & CSL)
+                                               dev->stats.tx_carrier_errors++;
+                                       if (tx_status & LC)
+                                               dev->stats.tx_window_errors++;
+                                       if (tx_status & UDF)
+                                               dev->stats.tx_fifo_errors++;
+                                       if ((tx_status & HF) && np->mii.full_duplex == 0)
+                                               dev->stats.tx_heartbeat_errors++;
+
+                               } else {
+                                       dev->stats.tx_bytes +=
+                                           ((tx_control & PKTSMask) >> PKTSShift);
+
+                                       dev->stats.collisions +=
+                                           ((tx_status & NCRMask) >> NCRShift);
+                                       dev->stats.tx_packets++;
+                               }
+                       } else {
+                               dev->stats.tx_bytes +=
+                                   ((tx_control & PKTSMask) >> PKTSShift);
+                               dev->stats.tx_packets++;
+                       }
+
+                       /* Free the original skb. */
+                       dma_unmap_single(&np->pci_dev->dev,
+                                        np->cur_tx->buffer,
+                                        np->cur_tx->skbuff->len,
+                                        DMA_TO_DEVICE);
+                       dev_consume_skb_irq(np->cur_tx->skbuff);
+                       np->cur_tx->skbuff = NULL;
+                       --np->really_tx_count;
+                       if (np->cur_tx->control & TXLD) {
+                               np->cur_tx = np->cur_tx->next_desc_logical;
+                               ++np->free_tx_count;
+                       } else {
+                               np->cur_tx = np->cur_tx->next_desc_logical;
+                               np->cur_tx = np->cur_tx->next_desc_logical;
+                               np->free_tx_count += 2;
+                       }
+                       num_tx++;
+               }               /* end of for loop */
+
+               if (num_tx && np->free_tx_count >= 2)
+                       netif_wake_queue(dev);
+
+               /* read transmit status for enhanced mode only */
+               if (np->crvalue & CR_W_ENH) {
+                       long data;
+
+                       data = ioread32(ioaddr + TSR);
+                       dev->stats.tx_errors += (data & 0xff000000) >> 24;
+                       dev->stats.tx_aborted_errors +=
+                               (data & 0xff000000) >> 24;
+                       dev->stats.tx_window_errors +=
+                               (data & 0x00ff0000) >> 16;
+                       dev->stats.collisions += (data & 0x0000ffff);
+               }
+
+               if (--boguscnt < 0) {
+                       printk(KERN_WARNING "%s: Too much work at interrupt, "
+                              "status=0x%4.4x.\n", dev->name, intr_status);
+                       if (!np->reset_timer_armed) {
+                               np->reset_timer_armed = 1;
+                               np->reset_timer.expires = RUN_AT(HZ/2);
+                               add_timer(&np->reset_timer);
+                               stop_nic_rxtx(ioaddr, 0);
+                               netif_stop_queue(dev);
+                               /* or netif_tx_disable(dev); ?? */
+                               /* Prevent other paths from enabling tx,rx,intrs */
+                               np->crvalue_sv = np->crvalue;
+                               np->imrvalue_sv = np->imrvalue;
+                               np->crvalue &= ~(CR_W_TXEN | CR_W_RXEN); /* or simply = 0? */
+                               np->imrvalue = 0;
+                       }
+
+                       break;
+               }
+       } while (1);
+
+       /* read the tally counters */
+       /* missed pkts */
+       dev->stats.rx_missed_errors += ioread32(ioaddr + TALLY) & 0x7fff;
+
+       /* crc error */
+       dev->stats.rx_crc_errors +=
+               (ioread32(ioaddr + TALLY) & 0x7fff0000) >> 16;
+
+       if (debug)
+               printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
+                      dev->name, ioread32(ioaddr + ISR));
+
+       iowrite32(np->imrvalue, ioaddr + IMR);
+
+       spin_unlock(&np->lock);
+
+       return IRQ_RETVAL(handled);
+}
+
+
+/* This routine is logically part of the interrupt handler, but separated
+   for clarity and better register allocation. */
+static int netdev_rx(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->mem;
+
+       /* If EOP is set on the next entry, it's a new packet. Send it up. */
+       while (!(np->cur_rx->status & RXOWN) && np->cur_rx->skbuff) {
+               s32 rx_status = np->cur_rx->status;
+
+               if (np->really_rx_count == 0)
+                       break;
+
+               if (debug)
+                       printk(KERN_DEBUG "  netdev_rx() status was %8.8x.\n", rx_status);
+
+               if ((!((rx_status & RXFSD) && (rx_status & RXLSD))) ||
+                   (rx_status & ErrorSummary)) {
+                       if (rx_status & ErrorSummary) { /* there was a fatal error */
+                               if (debug)
+                                       printk(KERN_DEBUG
+                                              "%s: Receive error, Rx status %8.8x.\n",
+                                              dev->name, rx_status);
+
+                               dev->stats.rx_errors++; /* end of a packet. */
+                               if (rx_status & (LONGPKT | RUNTPKT))
+                                       dev->stats.rx_length_errors++;
+                               if (rx_status & RXER)
+                                       dev->stats.rx_frame_errors++;
+                               if (rx_status & CRC)
+                                       dev->stats.rx_crc_errors++;
+                       } else {
+                               int need_to_reset = 0;
+                               int desno = 0;
+
+                               if (rx_status & RXFSD) {        /* this pkt is too long, over one rx buffer */
+                                       struct fealnx_desc *cur;
+
+                                       /* check this packet is received completely? */
+                                       cur = np->cur_rx;
+                                       while (desno <= np->really_rx_count) {
+                                               ++desno;
+                                               if ((!(cur->status & RXOWN)) &&
+                                                   (cur->status & RXLSD))
+                                                       break;
+                                               /* goto next rx descriptor */
+                                               cur = cur->next_desc_logical;
+                                       }
+                                       if (desno > np->really_rx_count)
+                                               need_to_reset = 1;
+                               } else  /* RXLSD did not find, something error */
+                                       need_to_reset = 1;
+
+                               if (need_to_reset == 0) {
+                                       int i;
+
+                                       dev->stats.rx_length_errors++;
+
+                                       /* free all rx descriptors related this long pkt */
+                                       for (i = 0; i < desno; ++i) {
+                                               if (!np->cur_rx->skbuff) {
+                                                       printk(KERN_DEBUG
+                                                               "%s: I'm scared\n", dev->name);
+                                                       break;
+                                               }
+                                               np->cur_rx->status = RXOWN;
+                                               np->cur_rx = np->cur_rx->next_desc_logical;
+                                       }
+                                       continue;
+                               } else {        /* rx error, need to reset this chip */
+                                       stop_nic_rx(ioaddr, np->crvalue);
+                                       reset_rx_descriptors(dev);
+                                       iowrite32(np->crvalue, ioaddr + TCRRCR);
+                               }
+                               break;  /* exit the while loop */
+                       }
+               } else {        /* this received pkt is ok */
+
+                       struct sk_buff *skb;
+                       /* Omit the four octet CRC from the length. */
+                       short pkt_len = ((rx_status & FLNGMASK) >> FLNGShift) - 4;
+
+#ifndef final_version
+                       if (debug)
+                               printk(KERN_DEBUG "  netdev_rx() normal Rx pkt length %d"
+                                      " status %x.\n", pkt_len, rx_status);
+#endif
+
+                       /* Check if the packet is long enough to accept without copying
+                          to a minimally-sized skbuff. */
+                       if (pkt_len < rx_copybreak &&
+                           (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
+                               skb_reserve(skb, 2);    /* 16 byte align the IP header */
+                               dma_sync_single_for_cpu(&np->pci_dev->dev,
+                                                       np->cur_rx->buffer,
+                                                       np->rx_buf_sz,
+                                                       DMA_FROM_DEVICE);
+                               /* Call copy + cksum if available. */
+
+#if ! defined(__alpha__)
+                               skb_copy_to_linear_data(skb,
+                                       np->cur_rx->skbuff->data, pkt_len);
+                               skb_put(skb, pkt_len);
+#else
+                               skb_put_data(skb, np->cur_rx->skbuff->data,
+                                            pkt_len);
+#endif
+                               dma_sync_single_for_device(&np->pci_dev->dev,
+                                                          np->cur_rx->buffer,
+                                                          np->rx_buf_sz,
+                                                          DMA_FROM_DEVICE);
+                       } else {
+                               dma_unmap_single(&np->pci_dev->dev,
+                                                np->cur_rx->buffer,
+                                                np->rx_buf_sz,
+                                                DMA_FROM_DEVICE);
+                               skb_put(skb = np->cur_rx->skbuff, pkt_len);
+                               np->cur_rx->skbuff = NULL;
+                               --np->really_rx_count;
+                       }
+                       skb->protocol = eth_type_trans(skb, dev);
+                       netif_rx(skb);
+                       dev->stats.rx_packets++;
+                       dev->stats.rx_bytes += pkt_len;
+               }
+
+               np->cur_rx = np->cur_rx->next_desc_logical;
+       }                       /* end of while loop */
+
+       /*  allocate skb for rx buffers */
+       allocate_rx_buffers(dev);
+
+       return 0;
+}
+
+
+static struct net_device_stats *get_stats(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->mem;
+
+       /* The chip only need report frame silently dropped. */
+       if (netif_running(dev)) {
+               dev->stats.rx_missed_errors +=
+                       ioread32(ioaddr + TALLY) & 0x7fff;
+               dev->stats.rx_crc_errors +=
+                       (ioread32(ioaddr + TALLY) & 0x7fff0000) >> 16;
+       }
+
+       return &dev->stats;
+}
+
+
+/* for dev->set_multicast_list */
+static void set_rx_mode(struct net_device *dev)
+{
+       spinlock_t *lp = &((struct netdev_private *)netdev_priv(dev))->lock;
+       unsigned long flags;
+       spin_lock_irqsave(lp, flags);
+       __set_rx_mode(dev);
+       spin_unlock_irqrestore(lp, flags);
+}
+
+
+/* Take lock before calling */
+static void __set_rx_mode(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->mem;
+       u32 mc_filter[2];       /* Multicast hash filter */
+       u32 rx_mode;
+
+       if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
+               memset(mc_filter, 0xff, sizeof(mc_filter));
+               rx_mode = CR_W_PROM | CR_W_AB | CR_W_AM;
+       } else if ((netdev_mc_count(dev) > multicast_filter_limit) ||
+                  (dev->flags & IFF_ALLMULTI)) {
+               /* Too many to match, or accept all multicasts. */
+               memset(mc_filter, 0xff, sizeof(mc_filter));
+               rx_mode = CR_W_AB | CR_W_AM;
+       } else {
+               struct netdev_hw_addr *ha;
+
+               memset(mc_filter, 0, sizeof(mc_filter));
+               netdev_for_each_mc_addr(ha, dev) {
+                       unsigned int bit;
+                       bit = (ether_crc(ETH_ALEN, ha->addr) >> 26) ^ 0x3F;
+                       mc_filter[bit >> 5] |= (1 << bit);
+               }
+               rx_mode = CR_W_AB | CR_W_AM;
+       }
+
+       stop_nic_rxtx(ioaddr, np->crvalue);
+
+       iowrite32(mc_filter[0], ioaddr + MAR0);
+       iowrite32(mc_filter[1], ioaddr + MAR1);
+       np->crvalue &= ~CR_W_RXMODEMASK;
+       np->crvalue |= rx_mode;
+       iowrite32(np->crvalue, ioaddr + TCRRCR);
+}
+
+static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+       struct netdev_private *np = netdev_priv(dev);
+
+       strscpy(info->driver, DRV_NAME, sizeof(info->driver));
+       strscpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info));
+}
+
+static int netdev_get_link_ksettings(struct net_device *dev,
+                                    struct ethtool_link_ksettings *cmd)
+{
+       struct netdev_private *np = netdev_priv(dev);
+
+       spin_lock_irq(&np->lock);
+       mii_ethtool_get_link_ksettings(&np->mii, cmd);
+       spin_unlock_irq(&np->lock);
+
+       return 0;
+}
+
+static int netdev_set_link_ksettings(struct net_device *dev,
+                                    const struct ethtool_link_ksettings *cmd)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       int rc;
+
+       spin_lock_irq(&np->lock);
+       rc = mii_ethtool_set_link_ksettings(&np->mii, cmd);
+       spin_unlock_irq(&np->lock);
+
+       return rc;
+}
+
+static int netdev_nway_reset(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       return mii_nway_restart(&np->mii);
+}
+
+static u32 netdev_get_link(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       return mii_link_ok(&np->mii);
+}
+
+static u32 netdev_get_msglevel(struct net_device *dev)
+{
+       return debug;
+}
+
+static void netdev_set_msglevel(struct net_device *dev, u32 value)
+{
+       debug = value;
+}
+
+static const struct ethtool_ops netdev_ethtool_ops = {
+       .get_drvinfo            = netdev_get_drvinfo,
+       .nway_reset             = netdev_nway_reset,
+       .get_link               = netdev_get_link,
+       .get_msglevel           = netdev_get_msglevel,
+       .set_msglevel           = netdev_set_msglevel,
+       .get_link_ksettings     = netdev_get_link_ksettings,
+       .set_link_ksettings     = netdev_set_link_ksettings,
+};
+
+static int mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       int rc;
+
+       if (!netif_running(dev))
+               return -EINVAL;
+
+       spin_lock_irq(&np->lock);
+       rc = generic_mii_ioctl(&np->mii, if_mii(rq), cmd, NULL);
+       spin_unlock_irq(&np->lock);
+
+       return rc;
+}
+
+
+static int netdev_close(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->mem;
+       int i;
+
+       netif_stop_queue(dev);
+
+       /* Disable interrupts by clearing the interrupt mask. */
+       iowrite32(0x0000, ioaddr + IMR);
+
+       /* Stop the chip's Tx and Rx processes. */
+       stop_nic_rxtx(ioaddr, 0);
+
+       del_timer_sync(&np->timer);
+       del_timer_sync(&np->reset_timer);
+
+       free_irq(np->pci_dev->irq, dev);
+
+       /* Free all the skbuffs in the Rx queue. */
+       for (i = 0; i < RX_RING_SIZE; i++) {
+               struct sk_buff *skb = np->rx_ring[i].skbuff;
+
+               np->rx_ring[i].status = 0;
+               if (skb) {
+                       dma_unmap_single(&np->pci_dev->dev,
+                                        np->rx_ring[i].buffer, np->rx_buf_sz,
+                                        DMA_FROM_DEVICE);
+                       dev_kfree_skb(skb);
+                       np->rx_ring[i].skbuff = NULL;
+               }
+       }
+
+       for (i = 0; i < TX_RING_SIZE; i++) {
+               struct sk_buff *skb = np->tx_ring[i].skbuff;
+
+               if (skb) {
+                       dma_unmap_single(&np->pci_dev->dev,
+                                        np->tx_ring[i].buffer, skb->len,
+                                        DMA_TO_DEVICE);
+                       dev_kfree_skb(skb);
+                       np->tx_ring[i].skbuff = NULL;
+               }
+       }
+
+       return 0;
+}
+
+static const struct pci_device_id fealnx_pci_tbl[] = {
+       {0x1516, 0x0800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       {0x1516, 0x0803, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
+       {0x1516, 0x0891, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
+       {} /* terminate list */
+};
+MODULE_DEVICE_TABLE(pci, fealnx_pci_tbl);
+
+
+static struct pci_driver fealnx_driver = {
+       .name           = "fealnx",
+       .id_table       = fealnx_pci_tbl,
+       .probe          = fealnx_init_one,
+       .remove         = fealnx_remove_one,
+};
+
+module_pci_driver(fealnx_driver);
index c557dfc50aadd4511df9fe73ecb08197664e35fe..396e555023aae06b9e62ef090fa60283f9b27d08 100644 (file)
@@ -1411,7 +1411,7 @@ ice_add_dscp_pfc_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
        tlv->ouisubtype = htonl(ouisubtype);
 
        buf[0] = dcbcfg->pfc.pfccap & 0xF;
-       buf[1] = dcbcfg->pfc.pfcena & 0xF;
+       buf[1] = dcbcfg->pfc.pfcena;
 }
 
 /**
index b360bd8f15998b2d5c54df7f11b4f4da00231c14..f86e814354a311b1fb70fe339aa96d153d222508 100644 (file)
@@ -4331,6 +4331,8 @@ ice_get_module_eeprom(struct net_device *netdev,
                 * SFP modules only ever use page 0.
                 */
                if (page == 0 || !(data[0x2] & 0x4)) {
+                       u32 copy_len;
+
                        /* If i2c bus is busy due to slow page change or
                         * link management access, call can fail. This is normal.
                         * So we retry this a few times.
@@ -4354,8 +4356,8 @@ ice_get_module_eeprom(struct net_device *netdev,
                        }
 
                        /* Make sure we have enough room for the new block */
-                       if ((i + SFF_READ_BLOCK_SIZE) < ee->len)
-                               memcpy(data + i, value, SFF_READ_BLOCK_SIZE);
+                       copy_len = min_t(u32, SFF_READ_BLOCK_SIZE, ee->len - i);
+                       memcpy(data + i, value, copy_len);
                }
        }
        return 0;
index 781475480ff2700762b0ab1ce2da2b9c6dac4553..0f52ea38b6f3a2a49fdf5420a2b395cc1b27a16e 100644 (file)
@@ -2126,7 +2126,7 @@ int ice_vsi_cfg_xdp_txqs(struct ice_vsi *vsi)
        ice_for_each_rxq(vsi, i)
                ice_tx_xsk_pool(vsi, i);
 
-       return ret;
+       return 0;
 }
 
 /**
@@ -2693,12 +2693,14 @@ ice_vsi_cfg_def(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params)
                return ret;
 
        /* allocate memory for Tx/Rx ring stat pointers */
-       if (ice_vsi_alloc_stat_arrays(vsi))
+       ret = ice_vsi_alloc_stat_arrays(vsi);
+       if (ret)
                goto unroll_vsi_alloc;
 
        ice_alloc_fd_res(vsi);
 
-       if (ice_vsi_get_qs(vsi)) {
+       ret = ice_vsi_get_qs(vsi);
+       if (ret) {
                dev_err(dev, "Failed to allocate queues. vsi->idx = %d\n",
                        vsi->idx);
                goto unroll_vsi_alloc_stat;
@@ -2811,6 +2813,7 @@ ice_vsi_cfg_def(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params)
                break;
        default:
                /* clean up the resources and exit */
+               ret = -EINVAL;
                goto unroll_vsi_init;
        }
 
@@ -3508,10 +3511,10 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags)
                if (vsi_flags & ICE_VSI_FLAG_INIT) {
                        ret = -EIO;
                        goto err_vsi_cfg_tc_lan;
-               } else {
-                       kfree(coalesce);
-                       return ice_schedule_reset(pf, ICE_RESET_PFR);
                }
+
+               kfree(coalesce);
+               return ice_schedule_reset(pf, ICE_RESET_PFR);
        }
 
        ice_vsi_realloc_stat_arrays(vsi, prev_txq, prev_rxq);
@@ -3759,7 +3762,7 @@ int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc)
        dev = ice_pf_to_dev(pf);
        if (vsi->tc_cfg.ena_tc == ena_tc &&
            vsi->mqprio_qopt.mode != TC_MQPRIO_MODE_CHANNEL)
-               return ret;
+               return 0;
 
        ice_for_each_traffic_class(i) {
                /* build bitmap of enabled TCs */
index 6b48cbc049c67178bbecfbfb12683770dada4b07..76f29a5bf8d73d6bc25f376370e17087c59f7f1f 100644 (file)
@@ -1455,8 +1455,8 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,
                if (match.mask->vlan_priority) {
                        fltr->flags |= ICE_TC_FLWR_FIELD_VLAN_PRIO;
                        headers->vlan_hdr.vlan_prio =
-                               cpu_to_be16((match.key->vlan_priority <<
-                                            VLAN_PRIO_SHIFT) & VLAN_PRIO_MASK);
+                               be16_encode_bits(match.key->vlan_priority,
+                                                VLAN_PRIO_MASK);
                }
 
                if (match.mask->vlan_tpid)
@@ -1489,8 +1489,8 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,
                if (match.mask->vlan_priority) {
                        fltr->flags |= ICE_TC_FLWR_FIELD_CVLAN_PRIO;
                        headers->cvlan_hdr.vlan_prio =
-                               cpu_to_be16((match.key->vlan_priority <<
-                                            VLAN_PRIO_SHIFT) & VLAN_PRIO_MASK);
+                               be16_encode_bits(match.key->vlan_priority,
+                                                VLAN_PRIO_MASK);
                }
        }
 
index 389663a13d1d1536a7c0f40267896e1951ef8959..ef721caeac49b1b9872cdf2aebbdc67515c9ad6d 100644 (file)
@@ -884,6 +884,9 @@ int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int lf,
 int rvu_cpt_ctx_flush(struct rvu *rvu, u16 pcifunc);
 int rvu_cpt_init(struct rvu *rvu);
 
+#define NDC_AF_BANK_MASK       GENMASK_ULL(7, 0)
+#define NDC_AF_BANK_LINE_MASK  GENMASK_ULL(31, 16)
+
 /* CN10K RVU */
 int rvu_set_channels_base(struct rvu *rvu);
 void rvu_program_channels(struct rvu *rvu);
@@ -902,6 +905,8 @@ static inline void rvu_dbg_init(struct rvu *rvu) {}
 static inline void rvu_dbg_exit(struct rvu *rvu) {}
 #endif
 
+int rvu_ndc_fix_locked_cacheline(struct rvu *rvu, int blkaddr);
+
 /* RVU Switch */
 void rvu_switch_enable(struct rvu *rvu);
 void rvu_switch_disable(struct rvu *rvu);
index fa280ebd3052b8ddd6bc7fe90a417f48643af6e7..26cfa501f1a112dd166b4260faeccd0cc65d1b17 100644 (file)
@@ -198,9 +198,6 @@ enum cpt_eng_type {
        CPT_IE_TYPE = 3,
 };
 
-#define NDC_MAX_BANK(rvu, blk_addr) (rvu_read64(rvu, \
-                                               blk_addr, NDC_AF_CONST) & 0xFF)
-
 #define rvu_dbg_NULL NULL
 #define rvu_dbg_open_NULL NULL
 
@@ -1448,6 +1445,7 @@ static int ndc_blk_hits_miss_stats(struct seq_file *s, int idx, int blk_addr)
        struct nix_hw *nix_hw;
        struct rvu *rvu;
        int bank, max_bank;
+       u64 ndc_af_const;
 
        if (blk_addr == BLKADDR_NDC_NPA0) {
                rvu = s->private;
@@ -1456,7 +1454,8 @@ static int ndc_blk_hits_miss_stats(struct seq_file *s, int idx, int blk_addr)
                rvu = nix_hw->rvu;
        }
 
-       max_bank = NDC_MAX_BANK(rvu, blk_addr);
+       ndc_af_const = rvu_read64(rvu, blk_addr, NDC_AF_CONST);
+       max_bank = FIELD_GET(NDC_AF_BANK_MASK, ndc_af_const);
        for (bank = 0; bank < max_bank; bank++) {
                seq_printf(s, "BANK:%d\n", bank);
                seq_printf(s, "\tHits:\t%lld\n",
index 26e639e57dae372d530009e8f46e87ff8977214e..4ad707e758b9f700cd675f0f093b59f5b088779d 100644 (file)
@@ -790,6 +790,7 @@ static int nix_aq_enqueue_wait(struct rvu *rvu, struct rvu_block *block,
        struct nix_aq_res_s *result;
        int timeout = 1000;
        u64 reg, head;
+       int ret;
 
        result = (struct nix_aq_res_s *)aq->res->base;
 
@@ -813,9 +814,22 @@ static int nix_aq_enqueue_wait(struct rvu *rvu, struct rvu_block *block,
                        return -EBUSY;
        }
 
-       if (result->compcode != NIX_AQ_COMP_GOOD)
+       if (result->compcode != NIX_AQ_COMP_GOOD) {
                /* TODO: Replace this with some error code */
+               if (result->compcode == NIX_AQ_COMP_CTX_FAULT ||
+                   result->compcode == NIX_AQ_COMP_LOCKERR ||
+                   result->compcode == NIX_AQ_COMP_CTX_POISON) {
+                       ret = rvu_ndc_fix_locked_cacheline(rvu, BLKADDR_NDC_NIX0_RX);
+                       ret |= rvu_ndc_fix_locked_cacheline(rvu, BLKADDR_NDC_NIX0_TX);
+                       ret |= rvu_ndc_fix_locked_cacheline(rvu, BLKADDR_NDC_NIX1_RX);
+                       ret |= rvu_ndc_fix_locked_cacheline(rvu, BLKADDR_NDC_NIX1_TX);
+                       if (ret)
+                               dev_err(rvu->dev,
+                                       "%s: Not able to unlock cachelines\n", __func__);
+               }
+
                return -EBUSY;
+       }
 
        return 0;
 }
index 70bd036ed76e42f184775fe7a5556ea0ead0dc66..4f5ca5ab13a40640578aed38f6ef1eea59609f56 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2018 Marvell.
  *
  */
-
+#include <linux/bitfield.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 
@@ -42,9 +42,18 @@ static int npa_aq_enqueue_wait(struct rvu *rvu, struct rvu_block *block,
                        return -EBUSY;
        }
 
-       if (result->compcode != NPA_AQ_COMP_GOOD)
+       if (result->compcode != NPA_AQ_COMP_GOOD) {
                /* TODO: Replace this with some error code */
+               if (result->compcode == NPA_AQ_COMP_CTX_FAULT ||
+                   result->compcode == NPA_AQ_COMP_LOCKERR ||
+                   result->compcode == NPA_AQ_COMP_CTX_POISON) {
+                       if (rvu_ndc_fix_locked_cacheline(rvu, BLKADDR_NDC_NPA0))
+                               dev_err(rvu->dev,
+                                       "%s: Not able to unlock cachelines\n", __func__);
+               }
+
                return -EBUSY;
+       }
 
        return 0;
 }
@@ -545,3 +554,48 @@ void rvu_npa_lf_teardown(struct rvu *rvu, u16 pcifunc, int npalf)
 
        npa_ctx_free(rvu, pfvf);
 }
+
+/* Due to an Hardware errata, in some corner cases, AQ context lock
+ * operations can result in a NDC way getting into an illegal state
+ * of not valid but locked.
+ *
+ * This API solves the problem by clearing the lock bit of the NDC block.
+ * The operation needs to be done for each line of all the NDC banks.
+ */
+int rvu_ndc_fix_locked_cacheline(struct rvu *rvu, int blkaddr)
+{
+       int bank, max_bank, line, max_line, err;
+       u64 reg, ndc_af_const;
+
+       /* Set the ENABLE bit(63) to '0' */
+       reg = rvu_read64(rvu, blkaddr, NDC_AF_CAMS_RD_INTERVAL);
+       rvu_write64(rvu, blkaddr, NDC_AF_CAMS_RD_INTERVAL, reg & GENMASK_ULL(62, 0));
+
+       /* Poll until the BUSY bits(47:32) are set to '0' */
+       err = rvu_poll_reg(rvu, blkaddr, NDC_AF_CAMS_RD_INTERVAL, GENMASK_ULL(47, 32), true);
+       if (err) {
+               dev_err(rvu->dev, "Timed out while polling for NDC CAM busy bits.\n");
+               return err;
+       }
+
+       ndc_af_const = rvu_read64(rvu, blkaddr, NDC_AF_CONST);
+       max_bank = FIELD_GET(NDC_AF_BANK_MASK, ndc_af_const);
+       max_line = FIELD_GET(NDC_AF_BANK_LINE_MASK, ndc_af_const);
+       for (bank = 0; bank < max_bank; bank++) {
+               for (line = 0; line < max_line; line++) {
+                       /* Check if 'cache line valid bit(63)' is not set
+                        * but 'cache line lock bit(60)' is set and on
+                        * success, reset the lock bit(60).
+                        */
+                       reg = rvu_read64(rvu, blkaddr,
+                                        NDC_AF_BANKX_LINEX_METADATA(bank, line));
+                       if (!(reg & BIT_ULL(63)) && (reg & BIT_ULL(60))) {
+                               rvu_write64(rvu, blkaddr,
+                                           NDC_AF_BANKX_LINEX_METADATA(bank, line),
+                                           reg & ~BIT_ULL(60));
+                       }
+               }
+       }
+
+       return 0;
+}
index 1729b22580ce1cd595290bc2ca7918a68d3a0332..7007f0b8e6591ab89a8871aff8fe5a49e80c1241 100644 (file)
 #define NDC_AF_INTR_ENA_W1S            (0x00068)
 #define NDC_AF_INTR_ENA_W1C            (0x00070)
 #define NDC_AF_ACTIVE_PC               (0x00078)
+#define NDC_AF_CAMS_RD_INTERVAL                (0x00080)
 #define NDC_AF_BP_TEST_ENABLE          (0x001F8)
 #define NDC_AF_BP_TEST(a)              (0x00200 | (a) << 3)
 #define NDC_AF_BLK_RST                 (0x002F0)
                (0x00F00 | (a) << 5 | (b) << 4)
 #define NDC_AF_BANKX_HIT_PC(a)         (0x01000 | (a) << 3)
 #define NDC_AF_BANKX_MISS_PC(a)                (0x01100 | (a) << 3)
+#define NDC_AF_BANKX_LINEX_METADATA(a, b) \
+               (0x10000 | (a) << 12 | (b) << 3)
 
 /* LBK */
 #define LBK_CONST                      (0x10ull)
index 14be6ea51b889f070874dafe3888afdff5b40290..3cb43623d3dbe9d2677bee3fd067c4ced5c07585 100644 (file)
@@ -616,7 +616,8 @@ static int mtk_mac_finish(struct phylink_config *config, unsigned int mode,
        mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
        mcr_new = mcr_cur;
        mcr_new |= MAC_MCR_IPG_CFG | MAC_MCR_FORCE_MODE |
-                  MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK;
+                  MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK |
+                  MAC_MCR_RX_FIFO_CLR_DIS;
 
        /* Only update control register when needed! */
        if (mcr_new != mcr_cur)
index afc9d52e79bfc673dbd7006807226771025a5304..b65de174c3d9b1c2a9d6d410a4db07762cb880e6 100644 (file)
 #define MAC_MCR_FORCE_MODE     BIT(15)
 #define MAC_MCR_TX_EN          BIT(14)
 #define MAC_MCR_RX_EN          BIT(13)
+#define MAC_MCR_RX_FIFO_CLR_DIS        BIT(12)
 #define MAC_MCR_BACKOFF_EN     BIT(9)
 #define MAC_MCR_BACKPR_EN      BIT(8)
 #define MAC_MCR_FORCE_RX_FC    BIT(5)
index a9aec900d608dd426496c642477b6250d4469f78..7d66fe75cd3bfcd1eb980d9929a68b55cfdbbfe4 100644 (file)
@@ -194,7 +194,7 @@ int lan966x_police_port_del(struct lan966x_port *port,
                return -EINVAL;
        }
 
-       err = lan966x_police_del(port, port->tc.police_id);
+       err = lan966x_police_del(port, POL_IDX_PORT + port->chip_port);
        if (err) {
                NL_SET_ERR_MSG_MOD(extack,
                                   "Failed to add policer to port");
index 871a3e62f85270c7f801ea8352c6a5c9e04b06e5..2d763664dcda18e1c67b5637a707e88984e3ee7d 100644 (file)
@@ -249,6 +249,21 @@ static int sparx5_dcb_ieee_dscp_setdel(struct net_device *dev,
        return 0;
 }
 
+static int sparx5_dcb_ieee_delapp(struct net_device *dev, struct dcb_app *app)
+{
+       int err;
+
+       if (app->selector == IEEE_8021QAZ_APP_SEL_DSCP)
+               err = sparx5_dcb_ieee_dscp_setdel(dev, app, dcb_ieee_delapp);
+       else
+               err = dcb_ieee_delapp(dev, app);
+
+       if (err < 0)
+               return err;
+
+       return sparx5_dcb_app_update(dev);
+}
+
 static int sparx5_dcb_ieee_setapp(struct net_device *dev, struct dcb_app *app)
 {
        struct dcb_app app_itr;
@@ -264,7 +279,7 @@ static int sparx5_dcb_ieee_setapp(struct net_device *dev, struct dcb_app *app)
        if (prio) {
                app_itr = *app;
                app_itr.priority = prio;
-               dcb_ieee_delapp(dev, &app_itr);
+               sparx5_dcb_ieee_delapp(dev, &app_itr);
        }
 
        if (app->selector == IEEE_8021QAZ_APP_SEL_DSCP)
@@ -281,21 +296,6 @@ out:
        return err;
 }
 
-static int sparx5_dcb_ieee_delapp(struct net_device *dev, struct dcb_app *app)
-{
-       int err;
-
-       if (app->selector == IEEE_8021QAZ_APP_SEL_DSCP)
-               err = sparx5_dcb_ieee_dscp_setdel(dev, app, dcb_ieee_delapp);
-       else
-               err = dcb_ieee_delapp(dev, app);
-
-       if (err < 0)
-               return err;
-
-       return sparx5_dcb_app_update(dev);
-}
-
 static int sparx5_dcb_setapptrust(struct net_device *dev, u8 *selectors,
                                  int nselectors)
 {
index 59fb0583cc080530af616167dd56375b4c8f351b..0cc026b0aefd47d33f665b43e64ccd731cccc9af 100644 (file)
@@ -324,14 +324,15 @@ netdev_tx_t nfp_nfd3_tx(struct sk_buff *skb, struct net_device *netdev)
 
        /* Do not reorder - tso may adjust pkt cnt, vlan may override fields */
        nfp_nfd3_tx_tso(r_vec, txbuf, txd, skb, md_bytes);
-       nfp_nfd3_tx_csum(dp, r_vec, txbuf, txd, skb);
+       if (ipsec)
+               nfp_nfd3_ipsec_tx(txd, skb);
+       else
+               nfp_nfd3_tx_csum(dp, r_vec, txbuf, txd, skb);
        if (skb_vlan_tag_present(skb) && dp->ctrl & NFP_NET_CFG_CTRL_TXVLAN) {
                txd->flags |= NFD3_DESC_TX_VLAN;
                txd->vlan = cpu_to_le16(skb_vlan_tag_get(skb));
        }
 
-       if (ipsec)
-               nfp_nfd3_ipsec_tx(txd, skb);
        /* Gather DMA */
        if (nr_frags > 0) {
                __le64 second_half;
index e90f8c975903bd3c2cb6c802c878b3131d8e43b3..51087693072c289671a40fb8930d037c4913d301 100644 (file)
 void nfp_nfd3_ipsec_tx(struct nfp_nfd3_tx_desc *txd, struct sk_buff *skb)
 {
        struct xfrm_state *x = xfrm_input_state(skb);
+       struct xfrm_offload *xo = xfrm_offload(skb);
+       struct iphdr *iph = ip_hdr(skb);
+       int l4_proto;
 
        if (x->xso.dev && (x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM)) {
-               txd->flags |= NFD3_DESC_TX_CSUM | NFD3_DESC_TX_IP4_CSUM |
-                             NFD3_DESC_TX_TCP_CSUM | NFD3_DESC_TX_UDP_CSUM;
+               txd->flags |= NFD3_DESC_TX_CSUM;
+
+               if (iph->version == 4)
+                       txd->flags |= NFD3_DESC_TX_IP4_CSUM;
+
+               if (x->props.mode == XFRM_MODE_TRANSPORT)
+                       l4_proto = xo->proto;
+               else if (x->props.mode == XFRM_MODE_TUNNEL)
+                       l4_proto = xo->inner_ipproto;
+               else
+                       return;
+
+               switch (l4_proto) {
+               case IPPROTO_UDP:
+                       txd->flags |= NFD3_DESC_TX_UDP_CSUM;
+                       return;
+               case IPPROTO_TCP:
+                       txd->flags |= NFD3_DESC_TX_TCP_CSUM;
+                       return;
+               }
        }
 }
index d60c0e991a91cf3503c44d41f3cfbdf4ed419ac6..33b6d74adb4b55a90b0d98895860de8c4cbacafa 100644 (file)
@@ -387,7 +387,8 @@ netdev_tx_t nfp_nfdk_tx(struct sk_buff *skb, struct net_device *netdev)
        if (!skb_is_gso(skb)) {
                real_len = skb->len;
                /* Metadata desc */
-               metadata = nfp_nfdk_tx_csum(dp, r_vec, 1, skb, metadata);
+               if (!ipsec)
+                       metadata = nfp_nfdk_tx_csum(dp, r_vec, 1, skb, metadata);
                txd->raw = cpu_to_le64(metadata);
                txd++;
        } else {
@@ -395,7 +396,8 @@ netdev_tx_t nfp_nfdk_tx(struct sk_buff *skb, struct net_device *netdev)
                (txd + 1)->raw = nfp_nfdk_tx_tso(r_vec, txbuf, skb);
                real_len = txbuf->real_len;
                /* Metadata desc */
-               metadata = nfp_nfdk_tx_csum(dp, r_vec, txbuf->pkt_cnt, skb, metadata);
+               if (!ipsec)
+                       metadata = nfp_nfdk_tx_csum(dp, r_vec, txbuf->pkt_cnt, skb, metadata);
                txd->raw = cpu_to_le64(metadata);
                txd += 2;
                txbuf++;
index 58d8f59eb88543491e3e3d146283c086465366b3..cec199f4c852ff33e1132d21a1c09e9877ae0bea 100644 (file)
@@ -9,9 +9,13 @@
 u64 nfp_nfdk_ipsec_tx(u64 flags, struct sk_buff *skb)
 {
        struct xfrm_state *x = xfrm_input_state(skb);
+       struct iphdr *iph = ip_hdr(skb);
 
-       if (x->xso.dev && (x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM))
-               flags |= NFDK_DESC_TX_L3_CSUM | NFDK_DESC_TX_L4_CSUM;
+       if (x->xso.dev && (x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM)) {
+               if (iph->version == 4)
+                       flags |= NFDK_DESC_TX_L3_CSUM;
+               flags |= NFDK_DESC_TX_L4_CSUM;
+       }
 
        return flags;
 }
index 81b7ca0ad222eb897f9ab9085cb2d3d1052416ed..62f0bf91d1e1e52d9686bc7f6fa5249fdefd86c5 100644 (file)
@@ -38,6 +38,7 @@
 #include <net/tls.h>
 #include <net/vxlan.h>
 #include <net/xdp_sock_drv.h>
+#include <net/xfrm.h>
 
 #include "nfpcore/nfp_dev.h"
 #include "nfpcore/nfp_nsp.h"
@@ -1897,6 +1898,9 @@ nfp_net_features_check(struct sk_buff *skb, struct net_device *dev,
                        features &= ~NETIF_F_GSO_MASK;
        }
 
+       if (xfrm_offload(skb))
+               return features;
+
        /* VXLAN/GRE check */
        switch (vlan_get_protocol(skb)) {
        case htons(ETH_P_IP):
index e4902a7bb61eddad5bc7cc32f50854e301168756..8f543c3ab5c564257fa3cca3327383323fd48c24 100644 (file)
@@ -1170,6 +1170,7 @@ static int stmmac_init_phy(struct net_device *dev)
 
                phylink_ethtool_get_wol(priv->phylink, &wol);
                device_set_wakeup_capable(priv->device, !!wol.supported);
+               device_set_wakeup_enable(priv->device, !!wol.wolopts);
        }
 
        return ret;
index e1a569b99e4a6a071acf0488070298134bd40aab..0b0c6c0764fe9cfab3247917f16a6cb6be93f06e 100644 (file)
@@ -1913,6 +1913,8 @@ static int ca8210_skb_tx(
         * packet
         */
        mac_len = ieee802154_hdr_peek_addrs(skb, &header);
+       if (mac_len < 0)
+               return mac_len;
 
        secspec.security_level = header.sec.level;
        secspec.key_id_mode = header.sec.key_id_mode;
index ccecee2524ce6216189cf7cabf5f7cded2205bf4..0b88635f4fbca98b7e2f9e553f69fa6f465dd770 100644 (file)
@@ -342,6 +342,37 @@ static int lan88xx_config_aneg(struct phy_device *phydev)
        return genphy_config_aneg(phydev);
 }
 
+static void lan88xx_link_change_notify(struct phy_device *phydev)
+{
+       int temp;
+
+       /* At forced 100 F/H mode, chip may fail to set mode correctly
+        * when cable is switched between long(~50+m) and short one.
+        * As workaround, set to 10 before setting to 100
+        * at forced 100 F/H mode.
+        */
+       if (!phydev->autoneg && phydev->speed == 100) {
+               /* disable phy interrupt */
+               temp = phy_read(phydev, LAN88XX_INT_MASK);
+               temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN_;
+               phy_write(phydev, LAN88XX_INT_MASK, temp);
+
+               temp = phy_read(phydev, MII_BMCR);
+               temp &= ~(BMCR_SPEED100 | BMCR_SPEED1000);
+               phy_write(phydev, MII_BMCR, temp); /* set to 10 first */
+               temp |= BMCR_SPEED100;
+               phy_write(phydev, MII_BMCR, temp); /* set to 100 later */
+
+               /* clear pending interrupt generated while workaround */
+               temp = phy_read(phydev, LAN88XX_INT_STS);
+
+               /* enable phy interrupt back */
+               temp = phy_read(phydev, LAN88XX_INT_MASK);
+               temp |= LAN88XX_INT_MASK_MDINTPIN_EN_;
+               phy_write(phydev, LAN88XX_INT_MASK, temp);
+       }
+}
+
 static struct phy_driver microchip_phy_driver[] = {
 {
        .phy_id         = 0x0007c132,
@@ -359,6 +390,7 @@ static struct phy_driver microchip_phy_driver[] = {
 
        .config_init    = lan88xx_config_init,
        .config_aneg    = lan88xx_config_aneg,
+       .link_change_notify = lan88xx_link_change_notify,
 
        .config_intr    = lan88xx_phy_config_intr,
        .handle_interrupt = lan88xx_handle_interrupt,
index 3f8a64fb9d71284092f2877608214817bfdf38a0..1785f1cead97103bf58357eb04a34327336229a2 100644 (file)
@@ -3098,8 +3098,6 @@ static int phy_probe(struct device *dev)
        if (phydrv->flags & PHY_IS_INTERNAL)
                phydev->is_internal = true;
 
-       mutex_lock(&phydev->lock);
-
        /* Deassert the reset signal */
        phy_device_reset(phydev, 0);
 
@@ -3146,7 +3144,7 @@ static int phy_probe(struct device *dev)
         */
        err = genphy_c45_read_eee_adv(phydev, phydev->advertising_eee);
        if (err)
-               return err;
+               goto out;
 
        /* There is no "enabled" flag. If PHY is advertising, assume it is
         * kind of enabled.
@@ -3188,12 +3186,10 @@ static int phy_probe(struct device *dev)
        phydev->state = PHY_READY;
 
 out:
-       /* Assert the reset signal */
+       /* Re-assert the reset signal on error */
        if (err)
                phy_device_reset(phydev, 1);
 
-       mutex_unlock(&phydev->lock);
-
        return err;
 }
 
@@ -3203,9 +3199,7 @@ static int phy_remove(struct device *dev)
 
        cancel_delayed_work_sync(&phydev->state_queue);
 
-       mutex_lock(&phydev->lock);
        phydev->state = PHY_DOWN;
-       mutex_unlock(&phydev->lock);
 
        sfp_bus_del_upstream(phydev->sfp_bus);
        phydev->sfp_bus = NULL;
index ac7481ce2fc16c1a68d964396cb43d861f32cc4b..00d9eff91dcfaf34c4fae700e6d7dbcbc97f22cd 100644 (file)
@@ -44,7 +44,6 @@ static struct smsc_hw_stat smsc_hw_stats[] = {
 };
 
 struct smsc_phy_priv {
-       u16 intmask;
        bool energy_enable;
 };
 
@@ -57,7 +56,6 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
 
 static int smsc_phy_config_intr(struct phy_device *phydev)
 {
-       struct smsc_phy_priv *priv = phydev->priv;
        int rc;
 
        if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
@@ -65,14 +63,9 @@ static int smsc_phy_config_intr(struct phy_device *phydev)
                if (rc)
                        return rc;
 
-               priv->intmask = MII_LAN83C185_ISF_INT4 | MII_LAN83C185_ISF_INT6;
-               if (priv->energy_enable)
-                       priv->intmask |= MII_LAN83C185_ISF_INT7;
-
-               rc = phy_write(phydev, MII_LAN83C185_IM, priv->intmask);
+               rc = phy_write(phydev, MII_LAN83C185_IM,
+                              MII_LAN83C185_ISF_INT_PHYLIB_EVENTS);
        } else {
-               priv->intmask = 0;
-
                rc = phy_write(phydev, MII_LAN83C185_IM, 0);
                if (rc)
                        return rc;
@@ -85,7 +78,6 @@ static int smsc_phy_config_intr(struct phy_device *phydev)
 
 static irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev)
 {
-       struct smsc_phy_priv *priv = phydev->priv;
        int irq_status;
 
        irq_status = phy_read(phydev, MII_LAN83C185_ISF);
@@ -96,7 +88,7 @@ static irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev)
                return IRQ_NONE;
        }
 
-       if (!(irq_status & priv->intmask))
+       if (!(irq_status & MII_LAN83C185_ISF_INT_PHYLIB_EVENTS))
                return IRQ_NONE;
 
        phy_trigger_machine(phydev);
index c89639381eca3e847387834d64fcb5d5a803c063..cd4083e0b3b9e6bf8c8fa08ce5b6006d33d9bedd 100644 (file)
@@ -665,6 +665,11 @@ static const struct usb_device_id mbim_devs[] = {
          .driver_info = (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
        },
 
+       /* Telit FE990 */
+       { USB_DEVICE_AND_INTERFACE_INFO(0x1bc7, 0x1081, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
+         .driver_info = (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
+       },
+
        /* default entry */
        { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
          .driver_info = (unsigned long)&cdc_mbim_info_zlp,
index f18ab8e220db72787bffef62c598e7c65e1e1c6e..068488890d57be2f4a1c31ae72ecef518775f110 100644 (file)
@@ -2115,33 +2115,8 @@ static void lan78xx_remove_mdio(struct lan78xx_net *dev)
 static void lan78xx_link_status_change(struct net_device *net)
 {
        struct phy_device *phydev = net->phydev;
-       int temp;
-
-       /* At forced 100 F/H mode, chip may fail to set mode correctly
-        * when cable is switched between long(~50+m) and short one.
-        * As workaround, set to 10 before setting to 100
-        * at forced 100 F/H mode.
-        */
-       if (!phydev->autoneg && (phydev->speed == 100)) {
-               /* disable phy interrupt */
-               temp = phy_read(phydev, LAN88XX_INT_MASK);
-               temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN_;
-               phy_write(phydev, LAN88XX_INT_MASK, temp);
 
-               temp = phy_read(phydev, MII_BMCR);
-               temp &= ~(BMCR_SPEED100 | BMCR_SPEED1000);
-               phy_write(phydev, MII_BMCR, temp); /* set to 10 first */
-               temp |= BMCR_SPEED100;
-               phy_write(phydev, MII_BMCR, temp); /* set to 100 later */
-
-               /* clear pending interrupt generated while workaround */
-               temp = phy_read(phydev, LAN88XX_INT_STS);
-
-               /* enable phy interrupt back */
-               temp = phy_read(phydev, LAN88XX_INT_MASK);
-               temp |= LAN88XX_INT_MASK_MDINTPIN_EN_;
-               phy_write(phydev, LAN88XX_INT_MASK, temp);
-       }
+       phy_print_status(phydev);
 }
 
 static int irq_map(struct irq_domain *d, unsigned int irq,
index a808d718c0123ca76fbf152e22cf845bdb0bd647..571e37e67f9ce1706de16d3f4a4f9c883a6e8992 100644 (file)
@@ -1364,6 +1364,7 @@ static const struct usb_device_id products[] = {
        {QMI_QUIRK_SET_DTR(0x1bc7, 0x1057, 2)}, /* Telit FN980 */
        {QMI_QUIRK_SET_DTR(0x1bc7, 0x1060, 2)}, /* Telit LN920 */
        {QMI_QUIRK_SET_DTR(0x1bc7, 0x1070, 2)}, /* Telit FN990 */
+       {QMI_QUIRK_SET_DTR(0x1bc7, 0x1080, 2)}, /* Telit FE990 */
        {QMI_FIXED_INTF(0x1bc7, 0x1100, 3)},    /* Telit ME910 */
        {QMI_FIXED_INTF(0x1bc7, 0x1101, 3)},    /* Telit ME910 dual modem */
        {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},    /* Telit LE920 */
index 583adb37ee1e31e6f03858f6893b631e0d26d147..125284b346a7765f264c9e8ebaaeb0885c4bad91 100644 (file)
@@ -106,7 +106,7 @@ static inline int wg_cpumask_choose_online(int *stored_cpu, unsigned int id)
 {
        unsigned int cpu = *stored_cpu, cpu_index, i;
 
-       if (unlikely(cpu == nr_cpumask_bits ||
+       if (unlikely(cpu >= nr_cpu_ids ||
                     !cpumask_test_cpu(cpu, cpu_online_mask))) {
                cpu_index = id % cpumask_weight(cpu_online_mask);
                cpu = cpumask_first(cpu_online_mask);
index 2d53e0f88d2f95a6cf0f781285ba499279f9f33c..1e0f2297f9c665820aabb2093ebd3c71fc8325aa 100644 (file)
@@ -247,6 +247,9 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev,
                                           len, sizeof(**fw_vsc_cfg),
                                           GFP_KERNEL);
 
+               if (!*fw_vsc_cfg)
+                       goto alloc_err;
+
                r = device_property_read_u8_array(dev, FDP_DP_FW_VSC_CFG_NAME,
                                                  *fw_vsc_cfg, len);
 
@@ -260,6 +263,7 @@ vsc_read_err:
                *fw_vsc_cfg = NULL;
        }
 
+alloc_err:
        dev_dbg(dev, "Clock type: %d, clock frequency: %d, VSC: %s",
                *clock_type, *clock_freq, *fw_vsc_cfg != NULL ? "yes" : "no");
 }
index 09c7829e95c4b037947f573ff2045cf6cebbdd81..382793e73a60a8b3f4ade16b00768fc368eb50e2 100644 (file)
@@ -16,17 +16,17 @@ if MELLANOX_PLATFORM
 
 config MLXREG_HOTPLUG
        tristate "Mellanox platform hotplug driver support"
-       depends on REGMAP
        depends on HWMON
        depends on I2C
+       select REGMAP
        help
          This driver handles hot-plug events for the power suppliers, power
          cables and fans on the wide range Mellanox IB and Ethernet systems.
 
 config MLXREG_IO
        tristate "Mellanox platform register access driver support"
-       depends on REGMAP
        depends on HWMON
+       select REGMAP
        help
          This driver allows access to Mellanox programmable device register
          space through sysfs interface. The sets of registers for sysfs access
@@ -36,9 +36,9 @@ config MLXREG_IO
 
 config MLXREG_LC
        tristate "Mellanox line card platform driver support"
-       depends on REGMAP
        depends on HWMON
        depends on I2C
+       select REGMAP
        help
          This driver provides support for the Mellanox MSN4800-XX line cards,
          which are the part of MSN4800 Ethernet modular switch systems
@@ -80,10 +80,9 @@ config MLXBF_PMC
 
 config NVSW_SN2201
        tristate "Nvidia SN2201 platform driver support"
-       depends on REGMAP
        depends on HWMON
        depends on I2C
-       depends on REGMAP_I2C
+       select REGMAP_I2C
        help
          This driver provides support for the Nvidia SN2201 platform.
          The SN2201 is a highly integrated for one rack unit system with
index ec7c2b4e1721cd14cc000bd8bf3cd7d9587220b6..4a01b315e0a91ed5c6517407b4eb6250a42809b3 100644 (file)
@@ -955,7 +955,8 @@ config SERIAL_MULTI_INSTANTIATE
 
 config MLX_PLATFORM
        tristate "Mellanox Technologies platform support"
-       depends on I2C && REGMAP
+       depends on I2C
+       select REGMAP
        help
          This option enables system support for the Mellanox Technologies
          platform. The Mellanox systems provide data center networking
index ab05b9ee6655aa63a3ddf1023bd2f8a70047b635..2edaae04a6912a4bf6a2d377f1698dd5f9509584 100644 (file)
@@ -171,9 +171,7 @@ MODULE_PARM_DESC(disable_workarounds, "Disable workarounds for platform bugs");
 static struct amd_pmc_dev pmc;
 static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, bool ret);
 static int amd_pmc_read_stb(struct amd_pmc_dev *dev, u32 *buf);
-#ifdef CONFIG_SUSPEND
 static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data);
-#endif
 
 static inline u32 amd_pmc_reg_read(struct amd_pmc_dev *dev, int reg_offset)
 {
@@ -386,7 +384,6 @@ static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table
        return 0;
 }
 
-#ifdef CONFIG_SUSPEND
 static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)
 {
        struct smu_metrics table;
@@ -400,7 +397,6 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)
                dev_dbg(pdev->dev, "Last suspend in deepest state for %lluus\n",
                         table.timein_s0i3_lastcapture);
 }
-#endif
 
 static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev)
 {
@@ -673,7 +669,6 @@ out_unlock:
        return rc;
 }
 
-#ifdef CONFIG_SUSPEND
 static int amd_pmc_get_os_hint(struct amd_pmc_dev *dev)
 {
        switch (dev->cpu_id) {
@@ -861,9 +856,7 @@ static int __maybe_unused amd_pmc_suspend_handler(struct device *dev)
        return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(amd_pmc_pm, amd_pmc_suspend_handler, NULL);
-
-#endif
+static DEFINE_SIMPLE_DEV_PM_OPS(amd_pmc_pm, amd_pmc_suspend_handler, NULL);
 
 static const struct pci_device_id pmc_pci_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PS) },
@@ -905,7 +898,6 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
        return 0;
 }
 
-#ifdef CONFIG_SUSPEND
 static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data)
 {
        int err;
@@ -926,7 +918,6 @@ static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data)
 
        return 0;
 }
-#endif
 
 static int amd_pmc_read_stb(struct amd_pmc_dev *dev, u32 *buf)
 {
@@ -1017,11 +1008,11 @@ static int amd_pmc_probe(struct platform_device *pdev)
        }
 
        platform_set_drvdata(pdev, dev);
-#ifdef CONFIG_SUSPEND
-       err = acpi_register_lps0_dev(&amd_pmc_s2idle_dev_ops);
-       if (err)
-               dev_warn(dev->dev, "failed to register LPS0 sleep handler, expect increased power consumption\n");
-#endif
+       if (IS_ENABLED(CONFIG_SUSPEND)) {
+               err = acpi_register_lps0_dev(&amd_pmc_s2idle_dev_ops);
+               if (err)
+                       dev_warn(dev->dev, "failed to register LPS0 sleep handler, expect increased power consumption\n");
+       }
 
        amd_pmc_dbgfs_register(dev);
        return 0;
@@ -1035,9 +1026,8 @@ static int amd_pmc_remove(struct platform_device *pdev)
 {
        struct amd_pmc_dev *dev = platform_get_drvdata(pdev);
 
-#ifdef CONFIG_SUSPEND
-       acpi_unregister_lps0_dev(&amd_pmc_s2idle_dev_ops);
-#endif
+       if (IS_ENABLED(CONFIG_SUSPEND))
+               acpi_unregister_lps0_dev(&amd_pmc_s2idle_dev_ops);
        amd_pmc_dbgfs_unregister(dev);
        pci_dev_put(dev->rdev);
        mutex_destroy(&dev->lock);
@@ -1061,9 +1051,7 @@ static struct platform_driver amd_pmc_driver = {
                .name = "amd_pmc",
                .acpi_match_table = amd_pmc_acpi_ids,
                .dev_groups = pmc_groups,
-#ifdef CONFIG_SUSPEND
-               .pm = &amd_pmc_pm,
-#endif
+               .pm = pm_sleep_ptr(&amd_pmc_pm),
        },
        .probe = amd_pmc_probe,
        .remove = amd_pmc_remove,
index d547c9d097256f61ceffd52d15718b8d62157876..2750dee99c3e255a8821b591139775c1d4c641cf 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/kernel.h>
 #include <linux/hwmon.h>
 #include <linux/kstrtox.h>
-#include <linux/math.h>
 #include <linux/math64.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
@@ -96,6 +95,7 @@ struct combined_chip_info {
 };
 
 struct dell_wmi_ddv_sensors {
+       bool active;
        struct mutex lock;      /* protect caching */
        unsigned long timestamp;
        union acpi_object *obj;
@@ -520,6 +520,9 @@ static struct hwmon_channel_info *dell_wmi_ddv_channel_create(struct device *dev
 
 static void dell_wmi_ddv_hwmon_cache_invalidate(struct dell_wmi_ddv_sensors *sensors)
 {
+       if (!sensors->active)
+               return;
+
        mutex_lock(&sensors->lock);
        kfree(sensors->obj);
        sensors->obj = NULL;
@@ -530,6 +533,7 @@ static void dell_wmi_ddv_hwmon_cache_destroy(void *data)
 {
        struct dell_wmi_ddv_sensors *sensors = data;
 
+       sensors->active = false;
        mutex_destroy(&sensors->lock);
        kfree(sensors->obj);
 }
@@ -549,6 +553,7 @@ static struct hwmon_channel_info *dell_wmi_ddv_channel_init(struct wmi_device *w
                return ERR_PTR(ret);
 
        mutex_init(&sensors->lock);
+       sensors->active = true;
 
        ret = devm_add_action_or_reset(&wdev->dev, dell_wmi_ddv_hwmon_cache_destroy, sensors);
        if (ret < 0)
@@ -659,7 +664,8 @@ static ssize_t temp_show(struct device *dev, struct device_attribute *attr, char
        if (ret < 0)
                return ret;
 
-       return sysfs_emit(buf, "%d\n", DIV_ROUND_CLOSEST(value, 10));
+       /* Use 2731 instead of 2731.5 to avoid unnecessary rounding */
+       return sysfs_emit(buf, "%d\n", value - 2731);
 }
 
 static ssize_t eppid_show(struct device *dev, struct device_attribute *attr, char *buf)
@@ -852,7 +858,7 @@ static int dell_wmi_ddv_resume(struct device *dev)
 {
        struct dell_wmi_ddv_data *data = dev_get_drvdata(dev);
 
-       /* Force re-reading of all sensors */
+       /* Force re-reading of all active sensors */
        dell_wmi_ddv_hwmon_cache_invalidate(&data->fans);
        dell_wmi_ddv_hwmon_cache_invalidate(&data->temps);
 
index 309eab9c055888a7affde7ed898a131f072c5f9c..322237e056f32e585e342bf8c27934c39c6fce84 100644 (file)
@@ -159,9 +159,10 @@ static const struct int3472_tps68470_board_data surface_go_tps68470_board_data =
 static const struct int3472_tps68470_board_data surface_go3_tps68470_board_data = {
        .dev_name = "i2c-INT3472:01",
        .tps68470_regulator_pdata = &surface_go_tps68470_pdata,
-       .n_gpiod_lookups = 1,
+       .n_gpiod_lookups = 2,
        .tps68470_gpio_lookup_tables = {
-               &surface_go_int347a_gpios
+               &surface_go_int347a_gpios,
+               &surface_go_int347e_gpios,
        },
 };
 
index a7e02b24a87ad7dc02c1533f1555d8362f49501d..0954a04623edfff38d91cde7f22d7d2d3464e7f2 100644 (file)
@@ -47,7 +47,7 @@ struct isst_cmd_set_req_type {
 
 static const struct isst_valid_cmd_ranges isst_valid_cmds[] = {
        {0xD0, 0x00, 0x03},
-       {0x7F, 0x00, 0x0B},
+       {0x7F, 0x00, 0x0C},
        {0x7F, 0x10, 0x12},
        {0x7F, 0x20, 0x23},
        {0x94, 0x03, 0x03},
@@ -112,6 +112,7 @@ static void isst_delete_hash(void)
  * isst_store_cmd() - Store command to a hash table
  * @cmd: Mailbox command.
  * @sub_cmd: Mailbox sub-command or MSR id.
+ * @cpu: Target CPU for the command
  * @mbox_cmd_type: Mailbox or MSR command.
  * @param: Mailbox parameter.
  * @data: Mailbox request data or MSR data.
@@ -363,7 +364,7 @@ static struct pci_dev *_isst_if_get_pci_dev(int cpu, int bus_no, int dev, int fn
 /**
  * isst_if_get_pci_dev() - Get the PCI device instance for a CPU
  * @cpu: Logical CPU number.
- * @bus_number: The bus number assigned by the hardware.
+ * @bus_no: The bus number assigned by the hardware.
  * @dev: The device number assigned by the hardware.
  * @fn: The function number assigned by the hardware.
  *
index fdecdae248d7787200c3e09077b4df74d3f70a67..35ff506b402e1110b31274a9df09b704ad521d47 100644 (file)
@@ -40,6 +40,7 @@
  * @offset:    Offset to the first valid member in command structure.
  *             This will be the offset of the start of the command
  *             after command count field
+ * @owner:     Registered module owner
  * @cmd_callback: Callback function to handle IOCTL. The callback has the
  *             command pointer with data for command. There is a pointer
  *             called write_only, which when set, will not copy the
index c60733261c89c9cf106088814126aca6cb70f438..c999732b0f1e5d3faf8c74bac78829efb82a14e1 100644 (file)
@@ -209,14 +209,14 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
        if (!name)
                return -EOPNOTSUPP;
 
-       feature_vsec_dev = kzalloc(sizeof(*feature_vsec_dev), GFP_KERNEL);
-       if (!feature_vsec_dev)
+       res = kcalloc(pfs->pfs_header.num_entries, sizeof(*res), GFP_KERNEL);
+       if (!res)
                return -ENOMEM;
 
-       res = kcalloc(pfs->pfs_header.num_entries, sizeof(*res), GFP_KERNEL);
-       if (!res) {
+       feature_vsec_dev = kzalloc(sizeof(*feature_vsec_dev), GFP_KERNEL);
+       if (!feature_vsec_dev) {
                ret = -ENOMEM;
-               goto free_vsec;
+               goto free_res;
        }
 
        snprintf(feature_id_name, sizeof(feature_id_name), "tpmi-%s", name);
@@ -239,6 +239,8 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
        /*
         * intel_vsec_add_aux() is resource managed, no explicit
         * delete is required on error or on module unload.
+        * feature_vsec_dev memory is also freed as part of device
+        * delete.
         */
        ret = intel_vsec_add_aux(vsec_dev->pcidev, &vsec_dev->auxdev.dev,
                                 feature_vsec_dev, feature_id_name);
@@ -249,8 +251,6 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
 
 free_res:
        kfree(res);
-free_vsec:
-       kfree(feature_vsec_dev);
 
        return ret;
 }
index 7b6779cdb13493887474f7fea868feda8d2f24ab..67367f010139e21fbde7b3a345c80c36ab1bc31a 100644 (file)
@@ -5980,7 +5980,7 @@ MODULE_DEVICE_TABLE(dmi, mlxplat_dmi_table);
 static int mlxplat_mlxcpld_verify_bus_topology(int *nr)
 {
        struct i2c_adapter *search_adap;
-       int shift, i;
+       int i, shift = 0;
 
        /* Scan adapters from expected id to verify it is free. */
        *nr = MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR;
index 2a52c990d4fecbe7d6044388bfc430e24b66fb3f..6aa8f243b30c66b3afb11e0d453e6d29ff73081c 100644 (file)
@@ -232,13 +232,6 @@ config RESET_SOCFPGA
          This enables the reset driver for the SoCFPGA ARMv7 platforms. This
          driver gets initialized early during platform init calls.
 
-config RESET_STARFIVE_JH7100
-       bool "StarFive JH7100 Reset Driver"
-       depends on SOC_STARFIVE || COMPILE_TEST
-       default SOC_STARFIVE
-       help
-         This enables the reset controller driver for the StarFive JH7100 SoC.
-
 config RESET_SUNPLUS
        bool "Sunplus SoCs Reset Driver" if COMPILE_TEST
        default ARCH_SUNPLUS
@@ -320,6 +313,7 @@ config RESET_ZYNQ
        help
          This enables the reset controller driver for Xilinx Zynq SoCs.
 
+source "drivers/reset/starfive/Kconfig"
 source "drivers/reset/sti/Kconfig"
 source "drivers/reset/hisilicon/Kconfig"
 source "drivers/reset/tegra/Kconfig"
index 3e7e5fd633a8e99787dea9505e495cd65bfbd013..7fec5af6c9645011654b2ff0b61de759c1722c6e 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-y += core.o
 obj-y += hisilicon/
+obj-y += starfive/
 obj-$(CONFIG_ARCH_STI) += sti/
 obj-$(CONFIG_ARCH_TEGRA) += tegra/
 obj-$(CONFIG_RESET_A10SR) += reset-a10sr.o
@@ -30,7 +31,6 @@ obj-$(CONFIG_RESET_RZG2L_USBPHY_CTRL) += reset-rzg2l-usbphy-ctrl.o
 obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
 obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o
 obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
-obj-$(CONFIG_RESET_STARFIVE_JH7100) += reset-starfive-jh7100.o
 obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o
 obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
 obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.o
diff --git a/drivers/reset/reset-starfive-jh7100.c b/drivers/reset/reset-starfive-jh7100.c
deleted file mode 100644 (file)
index fc44b2f..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Reset driver for the StarFive JH7100 SoC
- *
- * Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>
- */
-
-#include <linux/bitmap.h>
-#include <linux/io.h>
-#include <linux/io-64-nonatomic-lo-hi.h>
-#include <linux/iopoll.h>
-#include <linux/mod_devicetable.h>
-#include <linux/platform_device.h>
-#include <linux/reset-controller.h>
-#include <linux/spinlock.h>
-
-#include <dt-bindings/reset/starfive-jh7100.h>
-
-/* register offsets */
-#define JH7100_RESET_ASSERT0   0x00
-#define JH7100_RESET_ASSERT1   0x04
-#define JH7100_RESET_ASSERT2   0x08
-#define JH7100_RESET_ASSERT3   0x0c
-#define JH7100_RESET_STATUS0   0x10
-#define JH7100_RESET_STATUS1   0x14
-#define JH7100_RESET_STATUS2   0x18
-#define JH7100_RESET_STATUS3   0x1c
-
-/*
- * Writing a 1 to the n'th bit of the m'th ASSERT register asserts
- * line 32m + n, and writing a 0 deasserts the same line.
- * Most reset lines have their status inverted so a 0 bit in the STATUS
- * register means the line is asserted and a 1 means it's deasserted. A few
- * lines don't though, so store the expected value of the status registers when
- * all lines are asserted.
- */
-static const u64 jh7100_reset_asserted[2] = {
-       /* STATUS0 */
-       BIT_ULL_MASK(JH7100_RST_U74) |
-       BIT_ULL_MASK(JH7100_RST_VP6_DRESET) |
-       BIT_ULL_MASK(JH7100_RST_VP6_BRESET) |
-       /* STATUS1 */
-       BIT_ULL_MASK(JH7100_RST_HIFI4_DRESET) |
-       BIT_ULL_MASK(JH7100_RST_HIFI4_BRESET),
-       /* STATUS2 */
-       BIT_ULL_MASK(JH7100_RST_E24) |
-       /* STATUS3 */
-       0,
-};
-
-struct jh7100_reset {
-       struct reset_controller_dev rcdev;
-       /* protect registers against concurrent read-modify-write */
-       spinlock_t lock;
-       void __iomem *base;
-};
-
-static inline struct jh7100_reset *
-jh7100_reset_from(struct reset_controller_dev *rcdev)
-{
-       return container_of(rcdev, struct jh7100_reset, rcdev);
-}
-
-static int jh7100_reset_update(struct reset_controller_dev *rcdev,
-                              unsigned long id, bool assert)
-{
-       struct jh7100_reset *data = jh7100_reset_from(rcdev);
-       unsigned long offset = BIT_ULL_WORD(id);
-       u64 mask = BIT_ULL_MASK(id);
-       void __iomem *reg_assert = data->base + JH7100_RESET_ASSERT0 + offset * sizeof(u64);
-       void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + offset * sizeof(u64);
-       u64 done = jh7100_reset_asserted[offset] & mask;
-       u64 value;
-       unsigned long flags;
-       int ret;
-
-       if (!assert)
-               done ^= mask;
-
-       spin_lock_irqsave(&data->lock, flags);
-
-       value = readq(reg_assert);
-       if (assert)
-               value |= mask;
-       else
-               value &= ~mask;
-       writeq(value, reg_assert);
-
-       /* if the associated clock is gated, deasserting might otherwise hang forever */
-       ret = readq_poll_timeout_atomic(reg_status, value, (value & mask) == done, 0, 1000);
-
-       spin_unlock_irqrestore(&data->lock, flags);
-       return ret;
-}
-
-static int jh7100_reset_assert(struct reset_controller_dev *rcdev,
-                              unsigned long id)
-{
-       return jh7100_reset_update(rcdev, id, true);
-}
-
-static int jh7100_reset_deassert(struct reset_controller_dev *rcdev,
-                                unsigned long id)
-{
-       return jh7100_reset_update(rcdev, id, false);
-}
-
-static int jh7100_reset_reset(struct reset_controller_dev *rcdev,
-                             unsigned long id)
-{
-       int ret;
-
-       ret = jh7100_reset_assert(rcdev, id);
-       if (ret)
-               return ret;
-
-       return jh7100_reset_deassert(rcdev, id);
-}
-
-static int jh7100_reset_status(struct reset_controller_dev *rcdev,
-                              unsigned long id)
-{
-       struct jh7100_reset *data = jh7100_reset_from(rcdev);
-       unsigned long offset = BIT_ULL_WORD(id);
-       u64 mask = BIT_ULL_MASK(id);
-       void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + offset * sizeof(u64);
-       u64 value = readq(reg_status);
-
-       return !((value ^ jh7100_reset_asserted[offset]) & mask);
-}
-
-static const struct reset_control_ops jh7100_reset_ops = {
-       .assert         = jh7100_reset_assert,
-       .deassert       = jh7100_reset_deassert,
-       .reset          = jh7100_reset_reset,
-       .status         = jh7100_reset_status,
-};
-
-static int __init jh7100_reset_probe(struct platform_device *pdev)
-{
-       struct jh7100_reset *data;
-
-       data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
-       if (!data)
-               return -ENOMEM;
-
-       data->base = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(data->base))
-               return PTR_ERR(data->base);
-
-       data->rcdev.ops = &jh7100_reset_ops;
-       data->rcdev.owner = THIS_MODULE;
-       data->rcdev.nr_resets = JH7100_RSTN_END;
-       data->rcdev.dev = &pdev->dev;
-       data->rcdev.of_node = pdev->dev.of_node;
-       spin_lock_init(&data->lock);
-
-       return devm_reset_controller_register(&pdev->dev, &data->rcdev);
-}
-
-static const struct of_device_id jh7100_reset_dt_ids[] = {
-       { .compatible = "starfive,jh7100-reset" },
-       { /* sentinel */ }
-};
-
-static struct platform_driver jh7100_reset_driver = {
-       .driver = {
-               .name = "jh7100-reset",
-               .of_match_table = jh7100_reset_dt_ids,
-               .suppress_bind_attrs = true,
-       },
-};
-builtin_platform_driver_probe(jh7100_reset_driver, jh7100_reset_probe);
diff --git a/drivers/reset/starfive/Kconfig b/drivers/reset/starfive/Kconfig
new file mode 100644 (file)
index 0000000..1fa706a
--- /dev/null
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config RESET_STARFIVE_JH71X0
+       bool
+
+config RESET_STARFIVE_JH7100
+       bool "StarFive JH7100 Reset Driver"
+       depends on ARCH_STARFIVE || COMPILE_TEST
+       select RESET_STARFIVE_JH71X0
+       default ARCH_STARFIVE
+       help
+         This enables the reset controller driver for the StarFive JH7100 SoC.
+
+config RESET_STARFIVE_JH7110
+       bool "StarFive JH7110 Reset Driver"
+       depends on AUXILIARY_BUS && CLK_STARFIVE_JH7110_SYS
+       select RESET_STARFIVE_JH71X0
+       default ARCH_STARFIVE
+       help
+         This enables the reset controller driver for the StarFive JH7110 SoC.
diff --git a/drivers/reset/starfive/Makefile b/drivers/reset/starfive/Makefile
new file mode 100644 (file)
index 0000000..7a44b66
--- /dev/null
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_RESET_STARFIVE_JH71X0)            += reset-starfive-jh71x0.o
+
+obj-$(CONFIG_RESET_STARFIVE_JH7100)            += reset-starfive-jh7100.o
+obj-$(CONFIG_RESET_STARFIVE_JH7110)            += reset-starfive-jh7110.o
diff --git a/drivers/reset/starfive/reset-starfive-jh7100.c b/drivers/reset/starfive/reset-starfive-jh7100.c
new file mode 100644 (file)
index 0000000..2a56f7f
--- /dev/null
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Reset driver for the StarFive JH7100 SoC
+ *
+ * Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>
+ */
+
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+
+#include "reset-starfive-jh71x0.h"
+
+#include <dt-bindings/reset/starfive-jh7100.h>
+
+/* register offsets */
+#define JH7100_RESET_ASSERT0   0x00
+#define JH7100_RESET_ASSERT1   0x04
+#define JH7100_RESET_ASSERT2   0x08
+#define JH7100_RESET_ASSERT3   0x0c
+#define JH7100_RESET_STATUS0   0x10
+#define JH7100_RESET_STATUS1   0x14
+#define JH7100_RESET_STATUS2   0x18
+#define JH7100_RESET_STATUS3   0x1c
+
+/*
+ * Writing a 1 to the n'th bit of the m'th ASSERT register asserts
+ * line 32m + n, and writing a 0 deasserts the same line.
+ * Most reset lines have their status inverted so a 0 bit in the STATUS
+ * register means the line is asserted and a 1 means it's deasserted. A few
+ * lines don't though, so store the expected value of the status registers when
+ * all lines are asserted.
+ */
+static const u32 jh7100_reset_asserted[4] = {
+       /* STATUS0 */
+       BIT(JH7100_RST_U74 % 32) |
+       BIT(JH7100_RST_VP6_DRESET % 32) |
+       BIT(JH7100_RST_VP6_BRESET % 32),
+       /* STATUS1 */
+       BIT(JH7100_RST_HIFI4_DRESET % 32) |
+       BIT(JH7100_RST_HIFI4_BRESET % 32),
+       /* STATUS2 */
+       BIT(JH7100_RST_E24 % 32),
+       /* STATUS3 */
+       0,
+};
+
+static int __init jh7100_reset_probe(struct platform_device *pdev)
+{
+       void __iomem *base = devm_platform_ioremap_resource(pdev, 0);
+
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       return reset_starfive_jh71x0_register(&pdev->dev, pdev->dev.of_node,
+                                             base + JH7100_RESET_ASSERT0,
+                                             base + JH7100_RESET_STATUS0,
+                                             jh7100_reset_asserted,
+                                             JH7100_RSTN_END,
+                                             THIS_MODULE);
+}
+
+static const struct of_device_id jh7100_reset_dt_ids[] = {
+       { .compatible = "starfive,jh7100-reset" },
+       { /* sentinel */ }
+};
+
+static struct platform_driver jh7100_reset_driver = {
+       .driver = {
+               .name = "jh7100-reset",
+               .of_match_table = jh7100_reset_dt_ids,
+               .suppress_bind_attrs = true,
+       },
+};
+builtin_platform_driver_probe(jh7100_reset_driver, jh7100_reset_probe);
diff --git a/drivers/reset/starfive/reset-starfive-jh7110.c b/drivers/reset/starfive/reset-starfive-jh7110.c
new file mode 100644 (file)
index 0000000..2d26ae9
--- /dev/null
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Reset driver for the StarFive JH7110 SoC
+ *
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ */
+
+#include <linux/auxiliary_bus.h>
+
+#include <soc/starfive/reset-starfive-jh71x0.h>
+
+#include "reset-starfive-jh71x0.h"
+
+#include <dt-bindings/reset/starfive,jh7110-crg.h>
+
+struct jh7110_reset_info {
+       unsigned int nr_resets;
+       unsigned int assert_offset;
+       unsigned int status_offset;
+};
+
+static const struct jh7110_reset_info jh7110_sys_info = {
+       .nr_resets = JH7110_SYSRST_END,
+       .assert_offset = 0x2F8,
+       .status_offset = 0x308,
+};
+
+static const struct jh7110_reset_info jh7110_aon_info = {
+       .nr_resets = JH7110_AONRST_END,
+       .assert_offset = 0x38,
+       .status_offset = 0x3C,
+};
+
+static int jh7110_reset_probe(struct auxiliary_device *adev,
+                             const struct auxiliary_device_id *id)
+{
+       struct jh7110_reset_info *info = (struct jh7110_reset_info *)(id->driver_data);
+       struct jh71x0_reset_adev *rdev = to_jh71x0_reset_adev(adev);
+       void __iomem *base = rdev->base;
+
+       if (!info || !base)
+               return -ENODEV;
+
+       return reset_starfive_jh71x0_register(&adev->dev, adev->dev.parent->of_node,
+                                             base + info->assert_offset,
+                                             base + info->status_offset,
+                                             NULL,
+                                             info->nr_resets,
+                                             NULL);
+}
+
+static const struct auxiliary_device_id jh7110_reset_ids[] = {
+       {
+               .name = "clk_starfive_jh7110_sys.rst-sys",
+               .driver_data = (kernel_ulong_t)&jh7110_sys_info,
+       },
+       {
+               .name = "clk_starfive_jh7110_sys.rst-aon",
+               .driver_data = (kernel_ulong_t)&jh7110_aon_info,
+       },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(auxiliary, jh7110_reset_ids);
+
+static struct auxiliary_driver jh7110_reset_driver = {
+       .probe          = jh7110_reset_probe,
+       .id_table       = jh7110_reset_ids,
+};
+module_auxiliary_driver(jh7110_reset_driver);
+
+MODULE_AUTHOR("Hal Feng <hal.feng@starfivetech.com>");
+MODULE_DESCRIPTION("StarFive JH7110 reset driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/reset/starfive/reset-starfive-jh71x0.c b/drivers/reset/starfive/reset-starfive-jh71x0.c
new file mode 100644 (file)
index 0000000..55bbbd2
--- /dev/null
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Reset driver for the StarFive JH71X0 SoCs
+ *
+ * Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>
+ */
+
+#include <linux/bitmap.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/reset-controller.h>
+#include <linux/spinlock.h>
+
+#include "reset-starfive-jh71x0.h"
+
+struct jh71x0_reset {
+       struct reset_controller_dev rcdev;
+       /* protect registers against concurrent read-modify-write */
+       spinlock_t lock;
+       void __iomem *assert;
+       void __iomem *status;
+       const u32 *asserted;
+};
+
+static inline struct jh71x0_reset *
+jh71x0_reset_from(struct reset_controller_dev *rcdev)
+{
+       return container_of(rcdev, struct jh71x0_reset, rcdev);
+}
+
+static int jh71x0_reset_update(struct reset_controller_dev *rcdev,
+                              unsigned long id, bool assert)
+{
+       struct jh71x0_reset *data = jh71x0_reset_from(rcdev);
+       unsigned long offset = id / 32;
+       u32 mask = BIT(id % 32);
+       void __iomem *reg_assert = data->assert + offset * sizeof(u32);
+       void __iomem *reg_status = data->status + offset * sizeof(u32);
+       u32 done = data->asserted ? data->asserted[offset] & mask : 0;
+       u32 value;
+       unsigned long flags;
+       int ret;
+
+       if (!assert)
+               done ^= mask;
+
+       spin_lock_irqsave(&data->lock, flags);
+
+       value = readl(reg_assert);
+       if (assert)
+               value |= mask;
+       else
+               value &= ~mask;
+       writel(value, reg_assert);
+
+       /* if the associated clock is gated, deasserting might otherwise hang forever */
+       ret = readl_poll_timeout_atomic(reg_status, value, (value & mask) == done, 0, 1000);
+
+       spin_unlock_irqrestore(&data->lock, flags);
+       return ret;
+}
+
+static int jh71x0_reset_assert(struct reset_controller_dev *rcdev,
+                              unsigned long id)
+{
+       return jh71x0_reset_update(rcdev, id, true);
+}
+
+static int jh71x0_reset_deassert(struct reset_controller_dev *rcdev,
+                                unsigned long id)
+{
+       return jh71x0_reset_update(rcdev, id, false);
+}
+
+static int jh71x0_reset_reset(struct reset_controller_dev *rcdev,
+                             unsigned long id)
+{
+       int ret;
+
+       ret = jh71x0_reset_assert(rcdev, id);
+       if (ret)
+               return ret;
+
+       return jh71x0_reset_deassert(rcdev, id);
+}
+
+static int jh71x0_reset_status(struct reset_controller_dev *rcdev,
+                              unsigned long id)
+{
+       struct jh71x0_reset *data = jh71x0_reset_from(rcdev);
+       unsigned long offset = id / 32;
+       u32 mask = BIT(id % 32);
+       void __iomem *reg_status = data->status + offset * sizeof(u32);
+       u32 value = readl(reg_status);
+
+       return !((value ^ data->asserted[offset]) & mask);
+}
+
+static const struct reset_control_ops jh71x0_reset_ops = {
+       .assert         = jh71x0_reset_assert,
+       .deassert       = jh71x0_reset_deassert,
+       .reset          = jh71x0_reset_reset,
+       .status         = jh71x0_reset_status,
+};
+
+int reset_starfive_jh71x0_register(struct device *dev, struct device_node *of_node,
+                                  void __iomem *assert, void __iomem *status,
+                                  const u32 *asserted, unsigned int nr_resets,
+                                  struct module *owner)
+{
+       struct jh71x0_reset *data;
+
+       data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+       if (!data)
+               return -ENOMEM;
+
+       data->rcdev.ops = &jh71x0_reset_ops;
+       data->rcdev.owner = owner;
+       data->rcdev.nr_resets = nr_resets;
+       data->rcdev.dev = dev;
+       data->rcdev.of_node = of_node;
+
+       spin_lock_init(&data->lock);
+       data->assert = assert;
+       data->status = status;
+       data->asserted = asserted;
+
+       return devm_reset_controller_register(dev, &data->rcdev);
+}
+EXPORT_SYMBOL_GPL(reset_starfive_jh71x0_register);
diff --git a/drivers/reset/starfive/reset-starfive-jh71x0.h b/drivers/reset/starfive/reset-starfive-jh71x0.h
new file mode 100644 (file)
index 0000000..db7d39a
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>
+ */
+
+#ifndef __RESET_STARFIVE_JH71X0_H
+#define __RESET_STARFIVE_JH71X0_H
+
+int reset_starfive_jh71x0_register(struct device *dev, struct device_node *of_node,
+                                  void __iomem *assert, void __iomem *status,
+                                  const u32 *asserted, unsigned int nr_resets,
+                                  struct module *owner);
+
+#endif /* __RESET_STARFIVE_JH71X0_H */
index 0c3fcb8078062b9ad7e44c7a987076042adfabb6..a63279f55d09607488d7784d2d8666375de62c3e 100644 (file)
@@ -2495,8 +2495,7 @@ static int interrupt_preinit_v3_hw(struct hisi_hba *hisi_hba)
        hisi_hba->cq_nvecs = vectors - BASE_VECTORS_V3_HW;
        shost->nr_hw_queues = hisi_hba->cq_nvecs;
 
-       devm_add_action(&pdev->dev, hisi_sas_v3_free_vectors, pdev);
-       return 0;
+       return devm_add_action(&pdev->dev, hisi_sas_v3_free_vectors, pdev);
 }
 
 static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba)
index 61958a24a43d9f765bef60d9f2af17bc2e20634b..4f7485958c49af72b22c88a4feb4445c1771a954 100644 (file)
@@ -7291,6 +7291,8 @@ lpfc_sli4_cgn_params_read(struct lpfc_hba *phba)
        /* Find out if the FW has a new set of congestion parameters. */
        len = sizeof(struct lpfc_cgn_param);
        pdata = kzalloc(len, GFP_KERNEL);
+       if (!pdata)
+               return -ENOMEM;
        ret = lpfc_read_object(phba, (char *)LPFC_PORT_CFG_NAME,
                               pdata, len);
 
@@ -12563,7 +12565,7 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors)
                                        goto found_same;
                                new_cpu = cpumask_next(
                                        new_cpu, cpu_present_mask);
-                               if (new_cpu == nr_cpumask_bits)
+                               if (new_cpu >= nr_cpu_ids)
                                        new_cpu = first_cpu;
                        }
                        /* At this point, we leave the CPU as unassigned */
@@ -12577,7 +12579,7 @@ found_same:
                         * selecting the same IRQ.
                         */
                        start_cpu = cpumask_next(new_cpu, cpu_present_mask);
-                       if (start_cpu == nr_cpumask_bits)
+                       if (start_cpu >= nr_cpu_ids)
                                start_cpu = first_cpu;
 
                        lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
@@ -12613,7 +12615,7 @@ found_same:
                                        goto found_any;
                                new_cpu = cpumask_next(
                                        new_cpu, cpu_present_mask);
-                               if (new_cpu == nr_cpumask_bits)
+                               if (new_cpu >= nr_cpu_ids)
                                        new_cpu = first_cpu;
                        }
                        /* We should never leave an entry unassigned */
@@ -12631,7 +12633,7 @@ found_any:
                         * selecting the same IRQ.
                         */
                        start_cpu = cpumask_next(new_cpu, cpu_present_mask);
-                       if (start_cpu == nr_cpumask_bits)
+                       if (start_cpu >= nr_cpu_ids)
                                start_cpu = first_cpu;
 
                        lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
@@ -12704,7 +12706,7 @@ found_any:
                                goto found_hdwq;
                        }
                        new_cpu = cpumask_next(new_cpu, cpu_present_mask);
-                       if (new_cpu == nr_cpumask_bits)
+                       if (new_cpu >= nr_cpu_ids)
                                new_cpu = first_cpu;
                }
 
@@ -12719,7 +12721,7 @@ found_any:
                                goto found_hdwq;
 
                        new_cpu = cpumask_next(new_cpu, cpu_present_mask);
-                       if (new_cpu == nr_cpumask_bits)
+                       if (new_cpu >= nr_cpu_ids)
                                new_cpu = first_cpu;
                }
 
@@ -12730,7 +12732,7 @@ found_any:
  found_hdwq:
                /* We found an available entry, copy the IRQ info */
                start_cpu = cpumask_next(new_cpu, cpu_present_mask);
-               if (start_cpu == nr_cpumask_bits)
+               if (start_cpu >= nr_cpu_ids)
                        start_cpu = first_cpu;
                cpup->hdwq = new_cpup->hdwq;
  logit:
index c5b69f313af365694f77f83fb569e427f084acd4..cf630aa6734eb60fb9c9ce9de53bc3fe411e1719 100644 (file)
@@ -21899,20 +21899,20 @@ lpfc_get_io_buf_from_private_pool(struct lpfc_hba *phba,
 static struct lpfc_io_buf *
 lpfc_get_io_buf_from_expedite_pool(struct lpfc_hba *phba)
 {
-       struct lpfc_io_buf *lpfc_ncmd;
+       struct lpfc_io_buf *lpfc_ncmd = NULL, *iter;
        struct lpfc_io_buf *lpfc_ncmd_next;
        unsigned long iflag;
        struct lpfc_epd_pool *epd_pool;
 
        epd_pool = &phba->epd_pool;
-       lpfc_ncmd = NULL;
 
        spin_lock_irqsave(&epd_pool->lock, iflag);
        if (epd_pool->count > 0) {
-               list_for_each_entry_safe(lpfc_ncmd, lpfc_ncmd_next,
+               list_for_each_entry_safe(iter, lpfc_ncmd_next,
                                         &epd_pool->list, list) {
-                       list_del(&lpfc_ncmd->list);
+                       list_del(&iter->list);
                        epd_pool->count--;
+                       lpfc_ncmd = iter;
                        break;
                }
        }
@@ -22109,10 +22109,6 @@ lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap,
        struct lpfc_dmabuf *pcmd;
        u32 rd_object_name[LPFC_MBX_OBJECT_NAME_LEN_DW] = {0};
 
-       /* sanity check on queue memory */
-       if (!datap)
-               return -ENODEV;
-
        mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
        if (!mbox)
                return -ENOMEM;
index 4919ea54b8277b9c847d40107b501a759fa02037..63bac3684c197ddf7b20a3844d429cb77c838a8c 100644 (file)
@@ -23,8 +23,8 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION                                "07.719.03.00-rc1"
-#define MEGASAS_RELDATE                                "Sep 29, 2021"
+#define MEGASAS_VERSION                                "07.725.01.00-rc1"
+#define MEGASAS_RELDATE                                "Mar 2, 2023"
 
 #define MEGASAS_MSIX_NAME_LEN                  32
 
@@ -1519,6 +1519,8 @@ struct megasas_ctrl_info {
 #define MEGASAS_MAX_LD_IDS                     (MEGASAS_MAX_LD_CHANNELS * \
                                                MEGASAS_MAX_DEV_PER_CHANNEL)
 
+#define MEGASAS_MAX_SUPPORTED_LD_IDS           240
+
 #define MEGASAS_MAX_SECTORS                    (2*1024)
 #define MEGASAS_MAX_SECTORS_IEEE               (2*128)
 #define MEGASAS_DBG_LVL                                1
@@ -1758,7 +1760,8 @@ union megasas_sgl_frame {
 typedef union _MFI_CAPABILITIES {
        struct {
 #if   defined(__BIG_ENDIAN_BITFIELD)
-       u32     reserved:16;
+       u32     reserved:15;
+       u32     support_memdump:1;
        u32     support_fw_exposed_dev_list:1;
        u32     support_nvme_passthru:1;
        u32     support_64bit_mode:1;
@@ -1792,7 +1795,8 @@ typedef union _MFI_CAPABILITIES {
        u32     support_64bit_mode:1;
        u32     support_nvme_passthru:1;
        u32     support_fw_exposed_dev_list:1;
-       u32     reserved:16;
+       u32     support_memdump:1;
+       u32     reserved:15;
 #endif
        } mfi_capabilities;
        __le32          reg;
index da1cad1ee12389053fec297e2f9da723d2145fb6..4463a538102ad6d7fb1b1d266ae8a3273d38a173 100644 (file)
@@ -358,7 +358,7 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance, u64 map_id)
                ld = MR_TargetIdToLdGet(i, drv_map);
 
                /* For non existing VDs, iterate to next VD*/
-               if (ld >= (MAX_LOGICAL_DRIVES_EXT - 1))
+               if (ld >= MEGASAS_MAX_SUPPORTED_LD_IDS)
                        continue;
 
                raid = MR_LdRaidGet(ld, drv_map);
index 6597e118c805af60de2155266b00391f470e4539..84c9a55a5794c814c9bf8960d503130f2f3b451b 100644 (file)
@@ -1201,6 +1201,9 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
        drv_ops->mfi_capabilities.support_nvme_passthru = 1;
        drv_ops->mfi_capabilities.support_fw_exposed_dev_list = 1;
 
+       if (reset_devices)
+               drv_ops->mfi_capabilities.support_memdump = 1;
+
        if (instance->consistent_mask_64bit)
                drv_ops->mfi_capabilities.support_64bit_mode = 1;
 
index 23de2603e71fdd3736ceef7ca1d5fb1b91d35240..40f238fa80cc18341b329a7e5eb1a2060a5e70d8 100644 (file)
@@ -902,6 +902,7 @@ struct scmd_priv {
  * @admin_reply_ephase:Admin reply queue expected phase
  * @admin_reply_base: Admin reply queue base virtual address
  * @admin_reply_dma: Admin reply queue base dma address
+ * @admin_reply_q_in_use: Queue is handled by poll/ISR
  * @ready_timeout: Controller ready timeout
  * @intr_info: Interrupt cookie pointer
  * @intr_info_count: Number of interrupt cookies
@@ -1055,6 +1056,7 @@ struct mpi3mr_ioc {
        u8 admin_reply_ephase;
        void *admin_reply_base;
        dma_addr_t admin_reply_dma;
+       atomic_t admin_reply_q_in_use;
 
        u32 ready_timeout;
 
@@ -1390,4 +1392,5 @@ void mpi3mr_add_event_wait_for_device_refresh(struct mpi3mr_ioc *mrioc);
 void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc);
 void mpi3mr_flush_cmds_for_unrecovered_controller(struct mpi3mr_ioc *mrioc);
 void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc);
+int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc);
 #endif /*MPI3MR_H_INCLUDED*/
index bff63770239797ce2e9a5e6be4c3d82281d42c14..d10c6afb7f9cdafdd7f2120f552597b88161014f 100644 (file)
@@ -886,7 +886,7 @@ static int mpi3mr_build_nvme_prp(struct mpi3mr_ioc *mrioc,
                         * each time through the loop.
                         */
                        *prp_entry = cpu_to_le64(dma_addr);
-                       if (*prp1_entry & sgemod_mask) {
+                       if (*prp_entry & sgemod_mask) {
                                dprint_bsg_err(mrioc,
                                    "%s: PRP address collides with SGE modifier\n",
                                    __func__);
@@ -895,7 +895,7 @@ static int mpi3mr_build_nvme_prp(struct mpi3mr_ioc *mrioc,
                        *prp_entry &= ~sgemod_mask;
                        *prp_entry |= sgemod_val;
                        prp_entry++;
-                       prp_entry_dma++;
+                       prp_entry_dma += prp_size;
                }
 
                /*
index 758f7ca9e0ee803bad899d35fef7bbd04b222f69..29acf6111db302d3a0e9dba2c48aaa046b8f97ba 100644 (file)
@@ -415,7 +415,7 @@ out:
                    le64_to_cpu(scsi_reply->sense_data_buffer_address));
 }
 
-static int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc)
+int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc)
 {
        u32 exp_phase = mrioc->admin_reply_ephase;
        u32 admin_reply_ci = mrioc->admin_reply_ci;
@@ -423,12 +423,17 @@ static int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc)
        u64 reply_dma = 0;
        struct mpi3_default_reply_descriptor *reply_desc;
 
+       if (!atomic_add_unless(&mrioc->admin_reply_q_in_use, 1, 1))
+               return 0;
+
        reply_desc = (struct mpi3_default_reply_descriptor *)mrioc->admin_reply_base +
            admin_reply_ci;
 
        if ((le16_to_cpu(reply_desc->reply_flags) &
-           MPI3_REPLY_DESCRIPT_FLAGS_PHASE_MASK) != exp_phase)
+           MPI3_REPLY_DESCRIPT_FLAGS_PHASE_MASK) != exp_phase) {
+               atomic_dec(&mrioc->admin_reply_q_in_use);
                return 0;
+       }
 
        do {
                if (mrioc->unrecoverable)
@@ -454,6 +459,7 @@ static int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc)
        writel(admin_reply_ci, &mrioc->sysif_regs->admin_reply_queue_ci);
        mrioc->admin_reply_ci = admin_reply_ci;
        mrioc->admin_reply_ephase = exp_phase;
+       atomic_dec(&mrioc->admin_reply_q_in_use);
 
        return num_admin_replies;
 }
@@ -1192,7 +1198,7 @@ mpi3mr_revalidate_factsdata(struct mpi3mr_ioc *mrioc)
  */
 static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc)
 {
-       u32 ioc_config, ioc_status, timeout;
+       u32 ioc_config, ioc_status, timeout, host_diagnostic;
        int retval = 0;
        enum mpi3mr_iocstate ioc_state;
        u64 base_info;
@@ -1246,6 +1252,23 @@ static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc)
                            retval, mpi3mr_iocstate_name(ioc_state));
        }
        if (ioc_state != MRIOC_STATE_RESET) {
+               if (ioc_state == MRIOC_STATE_FAULT) {
+                       timeout = MPI3_SYSIF_DIAG_SAVE_TIMEOUT * 10;
+                       mpi3mr_print_fault_info(mrioc);
+                       do {
+                               host_diagnostic =
+                                       readl(&mrioc->sysif_regs->host_diagnostic);
+                               if (!(host_diagnostic &
+                                     MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS))
+                                       break;
+                               if (!pci_device_is_present(mrioc->pdev)) {
+                                       mrioc->unrecoverable = 1;
+                                       ioc_err(mrioc, "controller is not present at the bringup\n");
+                                       goto out_device_not_present;
+                               }
+                               msleep(100);
+                       } while (--timeout);
+               }
                mpi3mr_print_fault_info(mrioc);
                ioc_info(mrioc, "issuing soft reset to bring to reset state\n");
                retval = mpi3mr_issue_reset(mrioc,
@@ -2605,6 +2628,7 @@ static int mpi3mr_setup_admin_qpair(struct mpi3mr_ioc *mrioc)
        mrioc->admin_reply_ci = 0;
        mrioc->admin_reply_ephase = 1;
        mrioc->admin_reply_base = NULL;
+       atomic_set(&mrioc->admin_reply_q_in_use, 0);
 
        if (!mrioc->admin_req_base) {
                mrioc->admin_req_base = dma_alloc_coherent(&mrioc->pdev->dev,
@@ -3816,8 +3840,10 @@ retry_init:
        dprint_init(mrioc, "allocating config page buffers\n");
        mrioc->cfg_page = dma_alloc_coherent(&mrioc->pdev->dev,
            MPI3MR_DEFAULT_CFG_PAGE_SZ, &mrioc->cfg_page_dma, GFP_KERNEL);
-       if (!mrioc->cfg_page)
+       if (!mrioc->cfg_page) {
+               retval = -1;
                goto out_failed_noretry;
+       }
 
        mrioc->cfg_page_sz = MPI3MR_DEFAULT_CFG_PAGE_SZ;
 
@@ -3879,8 +3905,10 @@ retry_init:
                dprint_init(mrioc, "allocating memory for throttle groups\n");
                sz = sizeof(struct mpi3mr_throttle_group_info);
                mrioc->throttle_groups = kcalloc(mrioc->num_io_throttle_group, sz, GFP_KERNEL);
-               if (!mrioc->throttle_groups)
+               if (!mrioc->throttle_groups) {
+                       retval = -1;
                        goto out_failed_noretry;
+               }
        }
 
        retval = mpi3mr_enable_events(mrioc);
@@ -3900,6 +3928,7 @@ out_failed:
                mpi3mr_memset_buffers(mrioc);
                goto retry_init;
        }
+       retval = -1;
 out_failed_noretry:
        ioc_err(mrioc, "controller initialization failed\n");
        mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
@@ -4012,6 +4041,7 @@ retry_init:
                ioc_err(mrioc,
                    "cannot create minimum number of operational queues expected:%d created:%d\n",
                    mrioc->shost->nr_hw_queues, mrioc->num_op_reply_q);
+               retval = -1;
                goto out_failed_noretry;
        }
 
@@ -4078,6 +4108,7 @@ out_failed:
                mpi3mr_memset_buffers(mrioc);
                goto retry_init;
        }
+       retval = -1;
 out_failed_noretry:
        ioc_err(mrioc, "controller %s is failed\n",
            (is_resume)?"resume":"re-initialization");
@@ -4155,6 +4186,7 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc)
                memset(mrioc->admin_req_base, 0, mrioc->admin_req_q_sz);
        if (mrioc->admin_reply_base)
                memset(mrioc->admin_reply_base, 0, mrioc->admin_reply_q_sz);
+       atomic_set(&mrioc->admin_reply_q_in_use, 0);
 
        if (mrioc->init_cmds.reply) {
                memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply));
index 6eaeba41072cb53e4ff2354fa4241815b2c7a24c..a794cc8a1c0b137697624d2e90f3a257e8e7983d 100644 (file)
@@ -3720,6 +3720,7 @@ int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
                mpi3mr_poll_pend_io_completions(mrioc);
                mpi3mr_ioc_enable_intr(mrioc);
                mpi3mr_poll_pend_io_completions(mrioc);
+               mpi3mr_process_admin_reply_q(mrioc);
        }
        switch (tm_type) {
        case MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET:
index 3b61815979dabe5c9a1113a410f34e3333905229..be25f242fa79495f796bc21180105927440e4011 100644 (file)
@@ -1552,7 +1552,8 @@ static void mpi3mr_sas_port_remove(struct mpi3mr_ioc *mrioc, u64 sas_address,
 
        list_for_each_entry_safe(mr_sas_phy, next_phy,
            &mr_sas_port->phy_list, port_siblings) {
-               if ((mrioc->logging_level & MPI3_DEBUG_TRANSPORT_INFO))
+               if ((!mrioc->stop_drv_processing) &&
+                   (mrioc->logging_level & MPI3_DEBUG_TRANSPORT_INFO))
                        dev_info(&mr_sas_port->port->dev,
                            "remove: sas_address(0x%016llx), phy(%d)\n",
                            (unsigned long long)
@@ -2357,15 +2358,16 @@ int mpi3mr_report_tgtdev_to_sas_transport(struct mpi3mr_ioc *mrioc,
        tgtdev->host_exposed = 1;
        if (!mpi3mr_sas_port_add(mrioc, tgtdev->dev_handle,
            sas_address_parent, hba_port)) {
-               tgtdev->host_exposed = 0;
                retval = -1;
-       } else if ((!tgtdev->starget)) {
-               if (!mrioc->is_driver_loading)
+               } else if ((!tgtdev->starget) && (!mrioc->is_driver_loading)) {
                        mpi3mr_sas_port_remove(mrioc, sas_address,
                            sas_address_parent, hba_port);
-               tgtdev->host_exposed = 0;
                retval = -1;
        }
+       if (retval) {
+               tgtdev->dev_spec.sas_sata_inf.hba_port = NULL;
+               tgtdev->host_exposed = 0;
+       }
        return retval;
 }
 
@@ -2394,6 +2396,7 @@ void mpi3mr_remove_tgtdev_from_sas_transport(struct mpi3mr_ioc *mrioc,
        mpi3mr_sas_port_remove(mrioc, sas_address, sas_address_parent,
            hba_port);
        tgtdev->host_exposed = 0;
+       tgtdev->dev_spec.sas_sata_inf.hba_port = NULL;
 }
 
 /**
@@ -2450,7 +2453,7 @@ static u8 mpi3mr_get_port_id_by_rphy(struct mpi3mr_ioc *mrioc, struct sas_rphy *
 
                tgtdev = __mpi3mr_get_tgtdev_by_addr_and_rphy(mrioc,
                            rphy->identify.sas_address, rphy);
-               if (tgtdev) {
+               if (tgtdev && tgtdev->dev_spec.sas_sata_inf.hba_port) {
                        port_id =
                                tgtdev->dev_spec.sas_sata_inf.hba_port->port_id;
                        mpi3mr_tgtdev_put(tgtdev);
index 9142df876c733451dd62a2d06723f4b8ffc8705a..9aba07c7bde4b142a0ab1f91fa5c9369daec0804 100644 (file)
@@ -192,6 +192,7 @@ extern int ql2xsecenable;
 extern int ql2xenforce_iocb_limit;
 extern int ql2xabts_wait_nvme;
 extern u32 ql2xnvme_queues;
+extern int ql2xfc2target;
 
 extern int qla2x00_loop_reset(scsi_qla_host_t *);
 extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int);
index 1dbc1496ebeddf9cf1458e5e30b79ba07954b858..ec0423ec66817c1a54ea00d508aeaccc02def258 100644 (file)
@@ -1840,7 +1840,8 @@ void qla2x00_handle_rscn(scsi_qla_host_t *vha, struct event_arg *ea)
        case RSCN_PORT_ADDR:
                fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1);
                if (fcport) {
-                       if (fcport->flags & FCF_FCP2_DEVICE &&
+                       if (ql2xfc2target &&
+                           fcport->flags & FCF_FCP2_DEVICE &&
                            atomic_read(&fcport->state) == FCS_ONLINE) {
                                ql_dbg(ql_dbg_disc, vha, 0x2115,
                                       "Delaying session delete for FCP2 portid=%06x %8phC ",
index 545167627e48e9fd171adaf54cbbd716fc0e68e3..80c4ee9df2a4ff86fe6243c9201cb29e2f54899b 100644 (file)
@@ -360,6 +360,13 @@ MODULE_PARM_DESC(ql2xnvme_queues,
        "1 - Minimum number of queues supported\n"
        "8 - Default value");
 
+int ql2xfc2target = 1;
+module_param(ql2xfc2target, int, 0444);
+MODULE_PARM_DESC(qla2xfc2target,
+                 "Enables FC2 Target support. "
+                 "0 - FC2 Target support is disabled. "
+                 "1 - FC2 Target support is enabled (default).");
+
 static struct scsi_transport_template *qla2xxx_transport_template = NULL;
 struct scsi_transport_template *qla2xxx_transport_vport_template = NULL;
 
@@ -4085,7 +4092,8 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha)
            "Mark all dev lost\n");
 
        list_for_each_entry(fcport, &vha->vp_fcports, list) {
-               if (fcport->loop_id != FC_NO_LOOP_ID &&
+               if (ql2xfc2target &&
+                   fcport->loop_id != FC_NO_LOOP_ID &&
                    (fcport->flags & FCF_FCP2_DEVICE) &&
                    fcport->port_type == FCT_TARGET &&
                    !qla2x00_reset_active(vha)) {
index 4f28dd617ecadaa5636adde4b892834df7cfb1a1..4bb87043e6dba2bd477b34f35a43602c13fe575f 100644 (file)
@@ -2988,8 +2988,13 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
        }
 
        if (sdkp->device->type == TYPE_ZBC) {
-               /* Host-managed */
+               /*
+                * Host-managed: Per ZBC and ZAC specifications, writes in
+                * sequential write required zones of host-managed devices must
+                * be aligned to the device physical block size.
+                */
                disk_set_zoned(sdkp->disk, BLK_ZONED_HM);
+               blk_queue_zone_write_granularity(q, sdkp->physical_block_size);
        } else {
                sdkp->zoned = zoned;
                if (sdkp->zoned == 1) {
index 6b3a02d4406c08614ea2fbcbe508a43c4de7ed54..22801c24ea193c795a014a168d0df213a993fdad 100644 (file)
@@ -965,14 +965,6 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
        disk_set_max_active_zones(disk, 0);
        nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
 
-       /*
-        * Per ZBC and ZAC specifications, writes in sequential write required
-        * zones of host-managed devices must be aligned to the device physical
-        * block size.
-        */
-       if (blk_queue_zoned_model(q) == BLK_ZONED_HM)
-               blk_queue_zone_write_granularity(q, sdkp->physical_block_size);
-
        sdkp->early_zone_info.nr_zones = nr_zones;
        sdkp->early_zone_info.zone_blocks = zone_blocks;
 
index 33f568b7f54dee409a06238502e73e77553b034c..d9ce379c4d2e836476a04a724622d80a0a85a36a 100644 (file)
@@ -987,6 +987,22 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb,
                                goto do_work;
                        }
 
+                       /*
+                        * Check for "Operating parameters have changed"
+                        * due to Hyper-V changing the VHD/VHDX BlockSize
+                        * when adding/removing a differencing disk. This
+                        * causes discard_granularity to change, so do a
+                        * rescan to pick up the new granularity. We don't
+                        * want scsi_report_sense() to output a message
+                        * that a sysadmin wouldn't know what to do with.
+                        */
+                       if ((asc == 0x3f) && (ascq != 0x03) &&
+                                       (ascq != 0x0e)) {
+                               process_err_fn = storvsc_device_scan;
+                               set_host_byte(scmnd, DID_REQUEUE);
+                               goto do_work;
+                       }
+
                        /*
                         * Otherwise, let upper layer deal with the
                         * error when sense message is present
index 5cfabd5376cc233ab154c43c29a3278d709e4220..f9aef39cac2e93dbb488b62f44236c49eecbf338 100644 (file)
@@ -36,8 +36,6 @@ source "drivers/staging/rtl8723bs/Kconfig"
 
 source "drivers/staging/rtl8712/Kconfig"
 
-source "drivers/staging/r8188eu/Kconfig"
-
 source "drivers/staging/rts5208/Kconfig"
 
 source "drivers/staging/octeon/Kconfig"
index f8c3aa9c241820d0f52f06c1851b042a0db154dc..ffa70dda481d36c526a11275a2b7896957a4edc3 100644 (file)
@@ -8,7 +8,6 @@ obj-$(CONFIG_RTL8192U)          += rtl8192u/
 obj-$(CONFIG_RTL8192E)         += rtl8192e/
 obj-$(CONFIG_RTL8723BS)                += rtl8723bs/
 obj-$(CONFIG_R8712U)           += rtl8712/
-obj-$(CONFIG_R8188EU)          += r8188eu/
 obj-$(CONFIG_RTS5208)          += rts5208/
 obj-$(CONFIG_OCTEON_ETHERNET)  += octeon/
 obj-$(CONFIG_VT6655)           += vt6655/
diff --git a/drivers/staging/r8188eu/Kconfig b/drivers/staging/r8188eu/Kconfig
deleted file mode 100644 (file)
index f5fe423..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-config R8188EU
-       tristate "Realtek RTL8188EU Wireless LAN NIC driver"
-       depends on WLAN && USB && CFG80211
-       depends on m
-       select WIRELESS_EXT
-       select WEXT_PRIV
-       select LIB80211
-       select LIB80211_CRYPT_WEP
-       select LIB80211_CRYPT_CCMP
-       help
-       This option adds support for the Realtek RTL8188EU chipset, used in USB
-       devices such as the ASUS USB-N10 Nano. This newer driver is based on GitHub
-       sources for version v4.1.4_6773.20130222, and contains modifications for
-       newer kernel features. If built as a module, it will be called r8188eu.
-
diff --git a/drivers/staging/r8188eu/Makefile b/drivers/staging/r8188eu/Makefile
deleted file mode 100644 (file)
index fd494c2..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-
-r8188eu-y = \
-               hal/HalHWImg8188E_MAC.o \
-               hal/HalHWImg8188E_BB.o \
-               hal/HalHWImg8188E_RF.o \
-               hal/HalPhyRf_8188e.o \
-               hal/HalPwrSeqCmd.o \
-               hal/Hal8188ERateAdaptive.o \
-               hal/hal_intf.o \
-               hal/hal_com.o \
-               hal/odm.o \
-               hal/odm_HWConfig.o \
-               hal/odm_RTL8188E.o \
-               hal/rtl8188e_cmd.o \
-               hal/rtl8188e_dm.o \
-               hal/rtl8188e_hal_init.o \
-               hal/rtl8188e_phycfg.o \
-               hal/rtl8188e_rf6052.o \
-               hal/rtl8188e_rxdesc.o \
-               hal/rtl8188eu_xmit.o \
-               hal/usb_halinit.o \
-               hal/usb_ops_linux.o \
-               os_dep/ioctl_linux.o \
-               os_dep/os_intfs.o \
-               os_dep/osdep_service.o \
-               os_dep/usb_intf.o \
-               os_dep/usb_ops_linux.o \
-               core/rtw_ap.o \
-               core/rtw_br_ext.o \
-               core/rtw_cmd.o \
-               core/rtw_efuse.o \
-               core/rtw_fw.o \
-               core/rtw_ieee80211.o \
-               core/rtw_ioctl_set.o \
-               core/rtw_iol.o \
-               core/rtw_led.o \
-               core/rtw_mlme.o \
-               core/rtw_mlme_ext.o \
-               core/rtw_pwrctrl.o \
-               core/rtw_p2p.o \
-               core/rtw_recv.o \
-               core/rtw_rf.o \
-               core/rtw_security.o \
-               core/rtw_sta_mgt.o \
-               core/rtw_wlan_util.o \
-               core/rtw_xmit.o
-
-obj-$(CONFIG_R8188EU) := r8188eu.o
diff --git a/drivers/staging/r8188eu/TODO b/drivers/staging/r8188eu/TODO
deleted file mode 100644 (file)
index ab9d5d1..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-To-do list:
-
-* Correct the coding style according to Linux guidelines; please read the document
-  at https://www.kernel.org/doc/html/latest/process/coding-style.html.
-* Remove unnecessary debugging/printing macros; for those that are still needed
-  use the proper kernel API (pr_debug(), dev_dbg(), netdev_dbg()).
-* Remove dead code such as unusued functions, variables, fields, etc..
-* Use in-kernel API and remove unnecessary wrappers where possible.
-* Fix bugs due to code that sleeps in atomic context.
-* Remove the HAL layer and migrate its functionality into the relevant parts of
-  the driver.
-* Switch to use LIB80211.
-* Switch to use MAC80211.
-* Switch to use CFG80211.
-* Improve the error handling of various functions, particularly those that use
-  existing kernel APIs.
diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c
deleted file mode 100644 (file)
index e0ca4b6..0000000
+++ /dev/null
@@ -1,1181 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _RTW_AP_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/wifi.h"
-#include "../include/ieee80211.h"
-#include "../include/rtl8188e_cmd.h"
-
-void init_mlme_ap_info(struct adapter *padapter)
-{
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
-
-       spin_lock_init(&pmlmepriv->bcn_update_lock);
-
-       /* for ACL */
-       rtw_init_queue(&pacl_list->acl_node_q);
-
-       start_ap_mode(padapter);
-}
-
-void free_mlme_ap_info(struct adapter *padapter)
-{
-       struct sta_info *psta = NULL;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       pmlmepriv->update_bcn = false;
-       pmlmeext->bstart_bss = false;
-
-       rtw_sta_flush(padapter);
-
-       pmlmeinfo->state = _HW_STATE_NOLINK_;
-
-       /* free_assoc_sta_resources */
-       rtw_free_all_stainfo(padapter);
-
-       /* free bc/mc sta_info */
-       psta = rtw_get_bcmc_stainfo(padapter);
-       spin_lock_bh(&pstapriv->sta_hash_lock);
-       rtw_free_stainfo(padapter, psta);
-       spin_unlock_bh(&pstapriv->sta_hash_lock);
-}
-
-static void update_BCNTIM(struct adapter *padapter)
-{
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network;
-       unsigned char *pie = pnetwork_mlmeext->IEs;
-       u8 *p, *dst_ie, *premainder_ie = NULL;
-       u8 *pbackup_remainder_ie = NULL;
-       __le16 tim_bitmap_le;
-       uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;
-
-       /* update TIM IE */
-
-       p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen,
-                      pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_);
-       if (p && tim_ielen > 0) {
-               tim_ielen += 2;
-               premainder_ie = p + tim_ielen;
-               tim_ie_offset = (int)(p - pie);
-               remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen;
-               /* append TIM IE from dst_ie offset */
-               dst_ie = p;
-       } else {
-               tim_ielen = 0;
-
-               /* calculate head_len */
-               offset = _FIXED_IE_LENGTH_;
-               offset += pnetwork_mlmeext->Ssid.SsidLength + 2;
-
-               /*  get supported rates len */
-               p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_,
-                              &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_));
-               if (p)
-                       offset += tmp_len + 2;
-
-               /* DS Parameter Set IE, len = 3 */
-               offset += 3;
-
-               premainder_ie = pie + offset;
-
-               remainder_ielen = pnetwork_mlmeext->IELength - offset - tim_ielen;
-
-               /* append TIM IE from offset */
-               dst_ie = pie + offset;
-       }
-
-       if (remainder_ielen > 0) {
-               pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_ATOMIC);
-               if (pbackup_remainder_ie && premainder_ie)
-                       memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
-       }
-       *dst_ie++ = _TIM_IE_;
-
-       if ((pstapriv->tim_bitmap & 0xff00) && (pstapriv->tim_bitmap & 0x00fc))
-               tim_ielen = 5;
-       else
-               tim_ielen = 4;
-
-       *dst_ie++ = tim_ielen;
-
-       *dst_ie++ = 0;/* DTIM count */
-       *dst_ie++ = 1;/* DTIM period */
-
-       if (pstapriv->tim_bitmap & BIT(0))/* for bc/mc frames */
-               *dst_ie++ = BIT(0);/* bitmap ctrl */
-       else
-               *dst_ie++ = 0;
-
-       tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap);
-
-       if (tim_ielen == 4) {
-               *dst_ie++ = *(u8 *)&tim_bitmap_le;
-       } else if (tim_ielen == 5) {
-               memcpy(dst_ie, &tim_bitmap_le, 2);
-               dst_ie += 2;
-       }
-
-       /* copy remainder IE */
-       if (pbackup_remainder_ie) {
-               memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen);
-
-               kfree(pbackup_remainder_ie);
-       }
-       offset =  (uint)(dst_ie - pie);
-       pnetwork_mlmeext->IELength = offset + remainder_ielen;
-
-       set_tx_beacon_cmd(padapter);
-}
-
-static u8 chk_sta_is_alive(struct sta_info *psta)
-{
-       u8 ret = false;
-
-       if ((psta->sta_stats.last_rx_data_pkts + psta->sta_stats.last_rx_ctrl_pkts) ==
-           (psta->sta_stats.rx_data_pkts + psta->sta_stats.rx_ctrl_pkts))
-               ;
-       else
-               ret = true;
-
-       sta_update_last_rx_pkts(psta);
-
-       return ret;
-}
-
-void   expire_timeout_chk(struct adapter *padapter)
-{
-       struct list_head *phead, *plist;
-       u8 updated = 0;
-       struct sta_info *psta = NULL;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       u8 chk_alive_num = 0;
-       char chk_alive_list[NUM_STA];
-       int i;
-
-       spin_lock_bh(&pstapriv->auth_list_lock);
-
-       phead = &pstapriv->auth_list;
-       plist = phead->next;
-
-       /* check auth_queue */
-       while (phead != plist) {
-               psta = container_of(plist, struct sta_info, auth_list);
-               plist = plist->next;
-
-               if (psta->expire_to > 0) {
-                       psta->expire_to--;
-                       if (psta->expire_to == 0) {
-                               list_del_init(&psta->auth_list);
-                               pstapriv->auth_list_cnt--;
-
-                               spin_unlock_bh(&pstapriv->auth_list_lock);
-
-                               spin_lock_bh(&pstapriv->sta_hash_lock);
-                               rtw_free_stainfo(padapter, psta);
-                               spin_unlock_bh(&pstapriv->sta_hash_lock);
-
-                               spin_lock_bh(&pstapriv->auth_list_lock);
-                       }
-               }
-       }
-       spin_unlock_bh(&pstapriv->auth_list_lock);
-
-       psta = NULL;
-
-       spin_lock_bh(&pstapriv->asoc_list_lock);
-
-       phead = &pstapriv->asoc_list;
-       plist = phead->next;
-
-       /* check asoc_queue */
-       while (phead != plist) {
-               psta = container_of(plist, struct sta_info, asoc_list);
-               plist = plist->next;
-
-               if (chk_sta_is_alive(psta) || !psta->expire_to) {
-                       psta->expire_to = pstapriv->expire_to;
-                       psta->keep_alive_trycnt = 0;
-                       psta->under_exist_checking = 0;
-               } else {
-                       psta->expire_to--;
-               }
-
-               if (psta->expire_to <= 0) {
-                       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-
-                       if (padapter->registrypriv.wifi_spec == 1) {
-                               psta->expire_to = pstapriv->expire_to;
-                               continue;
-                       }
-
-                       if (psta->state & WIFI_SLEEP_STATE) {
-                               if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) {
-                                       /* to check if alive by another methods if station is at ps mode. */
-                                       psta->expire_to = pstapriv->expire_to;
-                                       psta->state |= WIFI_STA_ALIVE_CHK_STATE;
-
-                                       /* to update bcn with tim_bitmap for this station */
-                                       pstapriv->tim_bitmap |= BIT(psta->aid);
-                                       update_beacon(padapter, _TIM_IE_, NULL, false);
-
-                                       if (!pmlmeext->active_keep_alive_check)
-                                               continue;
-                               }
-                       }
-                       if (pmlmeext->active_keep_alive_check) {
-                               int stainfo_offset;
-
-                               stainfo_offset = rtw_stainfo_offset(pstapriv, psta);
-                               if (stainfo_offset_valid(stainfo_offset))
-                                       chk_alive_list[chk_alive_num++] = stainfo_offset;
-                               continue;
-                       }
-
-                       list_del_init(&psta->asoc_list);
-                       pstapriv->asoc_list_cnt--;
-
-                       updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING);
-               } else {
-                       /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */
-                       if (psta->sleepq_len > (NR_XMITFRAME / pstapriv->asoc_list_cnt) &&
-                           padapter->xmitpriv.free_xmitframe_cnt < (NR_XMITFRAME / pstapriv->asoc_list_cnt / 2)) {
-                               wakeup_sta_to_xmit(padapter, psta);
-                       }
-               }
-       }
-
-       spin_unlock_bh(&pstapriv->asoc_list_lock);
-
-       if (chk_alive_num) {
-               u8 backup_oper_channel = 0;
-               struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-               /* switch to correct channel of current network  before issue keep-alive frames */
-               if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) {
-                       backup_oper_channel = rtw_get_oper_ch(padapter);
-                       SelectChannel(padapter, pmlmeext->cur_channel);
-               }
-
-               /* issue null data to check sta alive*/
-               for (i = 0; i < chk_alive_num; i++) {
-                       int ret = _FAIL;
-
-                       psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
-
-                       if (psta->state & WIFI_SLEEP_STATE)
-                               ret = issue_nulldata(padapter, psta->hwaddr, 0, 1, 50);
-                       else
-                               ret = issue_nulldata(padapter, psta->hwaddr, 0, 3, 50);
-
-                       psta->keep_alive_trycnt++;
-                       if (ret == _SUCCESS) {
-                               psta->expire_to = pstapriv->expire_to;
-                               psta->keep_alive_trycnt = 0;
-                               continue;
-                       } else if (psta->keep_alive_trycnt <= 3) {
-                               psta->expire_to = 1;
-                               continue;
-                       }
-
-                       psta->keep_alive_trycnt = 0;
-
-                       spin_lock_bh(&pstapriv->asoc_list_lock);
-                       list_del_init(&psta->asoc_list);
-                       pstapriv->asoc_list_cnt--;
-                       updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING);
-                       spin_unlock_bh(&pstapriv->asoc_list_lock);
-               }
-
-               if (backup_oper_channel > 0) /* back to the original operation channel */
-                       SelectChannel(padapter, backup_oper_channel);
-       }
-
-       associated_clients_update(padapter, updated);
-}
-
-void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level)
-{
-       int i;
-       u32 init_rate = 0;
-       unsigned char sta_band = 0, raid, shortGIrate = false;
-       unsigned char limit;
-       unsigned int tx_ra_bitmap = 0;
-       struct ht_priv  *psta_ht = NULL;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
-
-       if (psta)
-               psta_ht = &psta->htpriv;
-       else
-               return;
-
-       if (!(psta->state & _FW_LINKED))
-               return;
-
-       /* b/g mode ra_bitmap */
-       for (i = 0; i < sizeof(psta->bssrateset); i++) {
-               if (psta->bssrateset[i])
-                       tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i] & 0x7f);
-       }
-       /* n mode ra_bitmap */
-       if (psta_ht->ht_option) {
-               limit = 8; /* 1R */
-
-               for (i = 0; i < limit; i++) {
-                       if (psta_ht->ht_cap.mcs.rx_mask[i / 8] & BIT(i % 8))
-                               tx_ra_bitmap |= BIT(i + 12);
-               }
-
-               /* max short GI rate */
-               shortGIrate = psta_ht->sgi;
-       }
-
-       if (pcur_network->Configuration.DSConfig > 14) {
-               sta_band |= WIRELESS_INVALID;
-       } else {
-               if (tx_ra_bitmap & 0xffff000)
-                       sta_band |= WIRELESS_11_24N | WIRELESS_11G | WIRELESS_11B;
-               else if (tx_ra_bitmap & 0xff0)
-                       sta_band |= WIRELESS_11G | WIRELESS_11B;
-               else
-                       sta_band |= WIRELESS_11B;
-       }
-
-       psta->wireless_mode = sta_band;
-
-       raid = networktype_to_raid(sta_band);
-       init_rate = get_highest_rate_idx(tx_ra_bitmap & 0x0fffffff) & 0x3f;
-
-       if (psta->aid < NUM_STA) {
-               u8 arg = 0;
-
-               arg = psta->mac_id & 0x1f;
-
-               arg |= BIT(7);/* support entry 2~31 */
-
-               if (shortGIrate)
-                       arg |= BIT(5);
-
-               tx_ra_bitmap |= ((raid << 28) & 0xf0000000);
-
-               /* bitmap[0:27] = tx_rate_bitmap */
-               /* bitmap[28:31]= Rate Adaptive id */
-               /* arg[0:4] = macid */
-               /* arg[5] = Short GI */
-               rtl8188e_Add_RateATid(padapter, tx_ra_bitmap, arg, rssi_level);
-
-               if (shortGIrate)
-                       init_rate |= BIT(6);
-
-               /* set ra_id, init_rate */
-               psta->raid = raid;
-               psta->init_rate = init_rate;
-       }
-}
-
-void update_bmc_sta(struct adapter *padapter)
-{
-       u32 init_rate = 0;
-       unsigned char   network_type, raid;
-       int i, supportRateNum = 0;
-       unsigned int tx_ra_bitmap = 0;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
-       struct sta_info *psta = rtw_get_bcmc_stainfo(padapter);
-
-       if (psta) {
-               psta->aid = 0;/* default set to 0 */
-               psta->mac_id = psta->aid + 1;
-
-               psta->qos_option = 0;
-               psta->htpriv.ht_option = false;
-
-               psta->ieee8021x_blocked = 0;
-
-               memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats));
-
-               /* prepare for add_RATid */
-               supportRateNum = rtw_get_rateset_len((u8 *)&pcur_network->SupportedRates);
-               network_type = rtw_check_network_type((u8 *)&pcur_network->SupportedRates, supportRateNum, 1);
-
-               memcpy(psta->bssrateset, &pcur_network->SupportedRates, supportRateNum);
-               psta->bssratelen = supportRateNum;
-
-               /* b/g mode ra_bitmap */
-               for (i = 0; i < supportRateNum; i++) {
-                       if (psta->bssrateset[i])
-                               tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i] & 0x7f);
-               }
-
-               if (pcur_network->Configuration.DSConfig > 14) {
-                       network_type = WIRELESS_INVALID;
-               } else {
-                       /* force to b mode */
-                       network_type = WIRELESS_11B;
-                       tx_ra_bitmap = 0xf;
-               }
-
-               raid = networktype_to_raid(network_type);
-               init_rate = get_highest_rate_idx(tx_ra_bitmap & 0x0fffffff) & 0x3f;
-
-               /* ap mode */
-               rtl8188e_SetHalODMVar(padapter, psta, true);
-
-               {
-                       u8 arg = 0;
-
-                       arg = psta->mac_id & 0x1f;
-                       arg |= BIT(7);
-                       tx_ra_bitmap |= ((raid << 28) & 0xf0000000);
-
-                       /* bitmap[0:27] = tx_rate_bitmap */
-                       /* bitmap[28:31]= Rate Adaptive id */
-                       /* arg[0:4] = macid */
-                       /* arg[5] = Short GI */
-                       rtl8188e_Add_RateATid(padapter, tx_ra_bitmap, arg, 0);
-               }
-               /* set ra_id, init_rate */
-               psta->raid = raid;
-               psta->init_rate = init_rate;
-
-               rtw_sta_media_status_rpt(padapter, psta, 1);
-
-               spin_lock_bh(&psta->lock);
-               psta->state = _FW_LINKED;
-               spin_unlock_bh(&psta->lock);
-       }
-}
-
-/* notes: */
-/* AID: 1~MAX for sta and 0 for bc/mc in ap/adhoc mode */
-/* MAC_ID = AID+1 for sta in ap/adhoc mode */
-/* MAC_ID = 1 for bc/mc for sta/ap/adhoc */
-/* MAC_ID = 0 for bssid for sta/ap/adhoc */
-/* CAM_ID = 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */
-
-void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta)
-{
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct ht_priv  *phtpriv_ap = &pmlmepriv->htpriv;
-       struct ht_priv  *phtpriv_sta = &psta->htpriv;
-       u16 sta_cap_info;
-       u16 ap_cap_info;
-
-       psta->mac_id = psta->aid + 1;
-
-       /* ap mode */
-       rtl8188e_SetHalODMVar(padapter, psta, true);
-
-       if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)
-               psta->ieee8021x_blocked = true;
-       else
-               psta->ieee8021x_blocked = false;
-
-       /* update sta's cap */
-
-       /* ERP */
-       VCS_update(padapter, psta);
-       /* HT related cap */
-       if (phtpriv_sta->ht_option) {
-               /* check if sta supports rx ampdu */
-               phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable;
-               sta_cap_info = le16_to_cpu(phtpriv_sta->ht_cap.cap_info);
-               ap_cap_info = le16_to_cpu(phtpriv_ap->ht_cap.cap_info);
-
-               /* check if sta support s Short GI */
-               if ((sta_cap_info & ap_cap_info) &
-                   (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40))
-                       phtpriv_sta->sgi = true;
-
-               /*  bwmode */
-               if ((sta_cap_info & ap_cap_info) & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
-                       phtpriv_sta->bwmode = pmlmeext->cur_bwmode;
-                       phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset;
-               }
-               psta->qos_option = true;
-       } else {
-               phtpriv_sta->ampdu_enable = false;
-               phtpriv_sta->sgi = false;
-               phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20;
-               phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-       }
-
-       /* Rx AMPDU */
-       send_delba(padapter, 0, psta->hwaddr);/*  recipient */
-
-       /* TX AMPDU */
-       send_delba(padapter, 1, psta->hwaddr);/* originator */
-       phtpriv_sta->agg_enable_bitmap = 0x0;/* reset */
-       phtpriv_sta->candidate_tid_bitmap = 0x0;/* reset */
-
-       /* todo: init other variables */
-
-       memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats));
-
-       spin_lock_bh(&psta->lock);
-       psta->state |= _FW_LINKED;
-       spin_unlock_bh(&psta->lock);
-}
-
-static void update_bcn_erpinfo_ie(struct adapter *padapter)
-{
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
-       unsigned char *p, *ie = pnetwork->IEs;
-       u32 len = 0;
-
-       if (!pmlmeinfo->ERP_enable)
-               return;
-
-       /* parsing ERP_IE */
-       p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &len,
-                      (pnetwork->IELength - _BEACON_IE_OFFSET_));
-       if (p && len > 0) {
-               struct ndis_802_11_var_ie *pIE = (struct ndis_802_11_var_ie *)p;
-
-               if (pmlmepriv->num_sta_non_erp == 1)
-                       pIE->data[0] |= RTW_ERP_INFO_NON_ERP_PRESENT | RTW_ERP_INFO_USE_PROTECTION;
-               else
-                       pIE->data[0] &= ~(RTW_ERP_INFO_NON_ERP_PRESENT | RTW_ERP_INFO_USE_PROTECTION);
-
-               if (pmlmepriv->num_sta_no_short_preamble > 0)
-                       pIE->data[0] |= RTW_ERP_INFO_BARKER_PREAMBLE_MODE;
-               else
-                       pIE->data[0] &= ~(RTW_ERP_INFO_BARKER_PREAMBLE_MODE);
-
-               ERP_IE_handler(padapter, pIE);
-       }
-}
-
-static void update_bcn_wps_ie(struct adapter *padapter)
-{
-       u8 *pwps_ie = NULL, *pwps_ie_src;
-       u8 *premainder_ie, *pbackup_remainder_ie = NULL;
-       uint wps_ielen = 0, wps_offset, remainder_ielen;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
-       unsigned char *ie = pnetwork->IEs;
-       u32 ielen = pnetwork->IELength;
-
-       pwps_ie = rtw_get_wps_ie(ie + _FIXED_IE_LENGTH_, ielen - _FIXED_IE_LENGTH_, NULL, &wps_ielen);
-
-       if (!pwps_ie || wps_ielen == 0)
-               return;
-
-       wps_offset = (uint)(pwps_ie - ie);
-
-       premainder_ie = pwps_ie + wps_ielen;
-
-       remainder_ielen = ielen - wps_offset - wps_ielen;
-
-       if (remainder_ielen > 0) {
-               pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_ATOMIC);
-               if (pbackup_remainder_ie)
-                       memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
-       }
-
-       pwps_ie_src = pmlmepriv->wps_beacon_ie;
-       if (!pwps_ie_src)
-               goto exit;
-
-       wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */
-       if ((wps_offset + wps_ielen + 2 + remainder_ielen) <= MAX_IE_SZ) {
-               memcpy(pwps_ie, pwps_ie_src, wps_ielen + 2);
-               pwps_ie += (wps_ielen + 2);
-
-               if (pbackup_remainder_ie)
-                       memcpy(pwps_ie, pbackup_remainder_ie, remainder_ielen);
-
-               /* update IELength */
-               pnetwork->IELength = wps_offset + (wps_ielen + 2) + remainder_ielen;
-       }
-
-exit:
-       kfree(pbackup_remainder_ie);
-}
-
-static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui)
-{
-       if (!memcmp(WPS_OUI, oui, 4))
-               update_bcn_wps_ie(padapter);
-}
-
-void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
-{
-       struct mlme_priv *pmlmepriv;
-       struct mlme_ext_priv    *pmlmeext;
-
-       if (!padapter)
-               return;
-
-       pmlmepriv = &padapter->mlmepriv;
-       pmlmeext = &padapter->mlmeextpriv;
-
-       if (!pmlmeext->bstart_bss)
-               return;
-
-       spin_lock_bh(&pmlmepriv->bcn_update_lock);
-
-       switch (ie_id) {
-       case _TIM_IE_:
-               update_BCNTIM(padapter);
-               break;
-       case _ERPINFO_IE_:
-               update_bcn_erpinfo_ie(padapter);
-               break;
-       case _VENDOR_SPECIFIC_IE_:
-               update_bcn_vendor_spec_ie(padapter, oui);
-               break;
-       default:
-               break;
-       }
-
-       pmlmepriv->update_bcn = true;
-
-       spin_unlock_bh(&pmlmepriv->bcn_update_lock);
-
-       if (tx)
-               set_tx_beacon_cmd(padapter);
-}
-
-/* op_mode
- * Set to 0 (HT pure) under the following conditions
- *     - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
- *     - all STAs in the BSS are 20 MHz HT in 20 MHz BSS
- * Set to 1 (HT non-member protection) if there may be non-HT STAs
- *     in both the primary and the secondary channel
- * Set to 2 if only HT STAs are associated in BSS,
- *     however and at least one 20 MHz HT STA is associated
- * Set to 3 (HT mixed mode) when one or more non-HT STAs are associated
- *     (currently non-GF HT station is considered as non-HT STA also)
- */
-static int rtw_ht_operation_update(struct adapter *padapter)
-{
-       u16 cur_op_mode, new_op_mode;
-       int op_mode_changes = 0;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct ht_priv  *phtpriv_ap = &pmlmepriv->htpriv;
-
-       if (pmlmepriv->htpriv.ht_option)
-               return 0;
-
-       if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) &&
-           pmlmepriv->num_sta_ht_no_gf) {
-               pmlmepriv->ht_op_mode |=
-                       HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT;
-               op_mode_changes++;
-       } else if ((pmlmepriv->ht_op_mode &
-                  HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) &&
-                  pmlmepriv->num_sta_ht_no_gf == 0) {
-               pmlmepriv->ht_op_mode &=
-                       ~HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT;
-               op_mode_changes++;
-       }
-
-       if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) &&
-           (pmlmepriv->num_sta_no_ht || pmlmepriv->olbc_ht)) {
-               pmlmepriv->ht_op_mode |= HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT;
-               op_mode_changes++;
-       } else if ((pmlmepriv->ht_op_mode &
-                   HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) &&
-                  (pmlmepriv->num_sta_no_ht == 0 && !pmlmepriv->olbc_ht)) {
-               pmlmepriv->ht_op_mode &=
-                       ~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT;
-               op_mode_changes++;
-       }
-
-       /* Note: currently we switch to the MIXED op mode if HT non-greenfield
-        * station is associated. Probably it's a theoretical case, since
-        * it looks like all known HT STAs support greenfield.
-        */
-       new_op_mode = 0;
-       if (pmlmepriv->num_sta_no_ht ||
-           (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT))
-               new_op_mode = OP_MODE_MIXED;
-       else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) &
-                 IEEE80211_HT_CAP_SUP_WIDTH_20_40) &&
-                pmlmepriv->num_sta_ht_20mhz)
-               new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED;
-       else if (pmlmepriv->olbc_ht)
-               new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS;
-       else
-               new_op_mode = OP_MODE_PURE;
-
-       cur_op_mode = pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_OP_MODE_MASK;
-       if (cur_op_mode != new_op_mode) {
-               pmlmepriv->ht_op_mode &= ~HT_INFO_OPERATION_MODE_OP_MODE_MASK;
-               pmlmepriv->ht_op_mode |= new_op_mode;
-               op_mode_changes++;
-       }
-
-       return op_mode_changes;
-}
-
-void associated_clients_update(struct adapter *padapter, u8 updated)
-{
-       /* update associated stations cap. */
-       if (updated) {
-               struct list_head *phead, *plist;
-               struct sta_info *psta = NULL;
-               struct sta_priv *pstapriv = &padapter->stapriv;
-
-               spin_lock_bh(&pstapriv->asoc_list_lock);
-
-               phead = &pstapriv->asoc_list;
-               plist = phead->next;
-
-               /* check asoc_queue */
-               while (phead != plist) {
-                       psta = container_of(plist, struct sta_info, asoc_list);
-
-                       plist = plist->next;
-
-                       VCS_update(padapter, psta);
-               }
-               spin_unlock_bh(&pstapriv->asoc_list_lock);
-       }
-}
-
-/* called > TSR LEVEL for USB or SDIO Interface*/
-void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
-{
-       u8 beacon_updated = false;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-
-       if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) {
-               if (!psta->no_short_preamble_set) {
-                       psta->no_short_preamble_set = 1;
-
-                       pmlmepriv->num_sta_no_short_preamble++;
-
-                       if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
-                           (pmlmepriv->num_sta_no_short_preamble == 1)) {
-                               beacon_updated = true;
-                               update_beacon(padapter, 0xFF, NULL, true);
-                       }
-               }
-       } else {
-               if (psta->no_short_preamble_set) {
-                       psta->no_short_preamble_set = 0;
-
-                       pmlmepriv->num_sta_no_short_preamble--;
-
-                       if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
-                           (pmlmepriv->num_sta_no_short_preamble == 0)) {
-                               beacon_updated = true;
-                               update_beacon(padapter, 0xFF, NULL, true);
-                       }
-               }
-       }
-
-       if (psta->flags & WLAN_STA_NONERP) {
-               if (!psta->nonerp_set) {
-                       psta->nonerp_set = 1;
-
-                       pmlmepriv->num_sta_non_erp++;
-
-                       if (pmlmepriv->num_sta_non_erp == 1) {
-                               beacon_updated = true;
-                               update_beacon(padapter, _ERPINFO_IE_, NULL, true);
-                       }
-               }
-       } else {
-               if (psta->nonerp_set) {
-                       psta->nonerp_set = 0;
-
-                       pmlmepriv->num_sta_non_erp--;
-
-                       if (pmlmepriv->num_sta_non_erp == 0) {
-                               beacon_updated = true;
-                               update_beacon(padapter, _ERPINFO_IE_, NULL, true);
-                       }
-               }
-       }
-
-       if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT)) {
-               if (!psta->no_short_slot_time_set) {
-                       psta->no_short_slot_time_set = 1;
-
-                       pmlmepriv->num_sta_no_short_slot_time++;
-
-                       if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
-                           (pmlmepriv->num_sta_no_short_slot_time == 1)) {
-                               beacon_updated = true;
-                               update_beacon(padapter, 0xFF, NULL, true);
-                       }
-               }
-       } else {
-               if (psta->no_short_slot_time_set) {
-                       psta->no_short_slot_time_set = 0;
-
-                       pmlmepriv->num_sta_no_short_slot_time--;
-
-                       if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
-                           (pmlmepriv->num_sta_no_short_slot_time == 0)) {
-                               beacon_updated = true;
-                               update_beacon(padapter, 0xFF, NULL, true);
-                       }
-               }
-       }
-
-       if (psta->flags & WLAN_STA_HT) {
-               u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info);
-
-               if (psta->no_ht_set) {
-                       psta->no_ht_set = 0;
-                       pmlmepriv->num_sta_no_ht--;
-               }
-
-               if ((ht_capab & IEEE80211_HT_CAP_GRN_FLD) == 0) {
-                       if (!psta->no_ht_gf_set) {
-                               psta->no_ht_gf_set = 1;
-                               pmlmepriv->num_sta_ht_no_gf++;
-                       }
-               }
-
-               if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH_20_40) == 0) {
-                       if (!psta->ht_20mhz_set) {
-                               psta->ht_20mhz_set = 1;
-                               pmlmepriv->num_sta_ht_20mhz++;
-                       }
-               }
-       } else {
-               if (!psta->no_ht_set) {
-                       psta->no_ht_set = 1;
-                       pmlmepriv->num_sta_no_ht++;
-               }
-       }
-
-       if (rtw_ht_operation_update(padapter) > 0) {
-               update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false);
-               update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true);
-       }
-
-       /* update associated stations cap. */
-       associated_clients_update(padapter,  beacon_updated);
-}
-
-u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta)
-{
-       u8 beacon_updated = false;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-
-       if (!psta)
-               return beacon_updated;
-
-       if (psta->no_short_preamble_set) {
-               psta->no_short_preamble_set = 0;
-               pmlmepriv->num_sta_no_short_preamble--;
-               if (pmlmeext->cur_wireless_mode > WIRELESS_11B &&
-                   pmlmepriv->num_sta_no_short_preamble == 0) {
-                       beacon_updated = true;
-                       update_beacon(padapter, 0xFF, NULL, true);
-               }
-       }
-
-       if (psta->nonerp_set) {
-               psta->nonerp_set = 0;
-               pmlmepriv->num_sta_non_erp--;
-               if (pmlmepriv->num_sta_non_erp == 0) {
-                       beacon_updated = true;
-                       update_beacon(padapter, _ERPINFO_IE_, NULL, true);
-               }
-       }
-
-       if (psta->no_short_slot_time_set) {
-               psta->no_short_slot_time_set = 0;
-               pmlmepriv->num_sta_no_short_slot_time--;
-               if (pmlmeext->cur_wireless_mode > WIRELESS_11B &&
-                   pmlmepriv->num_sta_no_short_slot_time == 0) {
-                       beacon_updated = true;
-                       update_beacon(padapter, 0xFF, NULL, true);
-               }
-       }
-
-       if (psta->no_ht_gf_set) {
-               psta->no_ht_gf_set = 0;
-               pmlmepriv->num_sta_ht_no_gf--;
-       }
-
-       if (psta->no_ht_set) {
-               psta->no_ht_set = 0;
-               pmlmepriv->num_sta_no_ht--;
-       }
-
-       if (psta->ht_20mhz_set) {
-               psta->ht_20mhz_set = 0;
-               pmlmepriv->num_sta_ht_20mhz--;
-       }
-
-       if (rtw_ht_operation_update(padapter) > 0) {
-               update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false);
-               update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true);
-       }
-
-       /* update associated stations cap. */
-
-       return beacon_updated;
-}
-
-void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta)
-{
-       union iwreq_data wrqu;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       if (!psta)
-               return;
-
-       if (psta->aid > NUM_STA)
-               return;
-
-       if (pstapriv->sta_aid[psta->aid - 1] != psta)
-               return;
-
-       wrqu.addr.sa_family = ARPHRD_ETHER;
-
-       memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
-
-       wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL);
-}
-
-static void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta)
-{
-       union iwreq_data wrqu;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       if (!psta)
-               return;
-
-       if (psta->aid > NUM_STA)
-               return;
-
-       if (pstapriv->sta_aid[psta->aid - 1] != psta)
-               return;
-
-       wrqu.addr.sa_family = ARPHRD_ETHER;
-
-       memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
-
-       wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL);
-}
-
-u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta,
-              bool active, u16 reason)
-{
-       u8 beacon_updated = false;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       if (!psta)
-               return beacon_updated;
-
-       /* tear down Rx AMPDU */
-       send_delba(padapter, 0, psta->hwaddr);/*  recipient */
-
-       /* tear down TX AMPDU */
-       send_delba(padapter, 1, psta->hwaddr);/*  originator */
-       psta->htpriv.agg_enable_bitmap = 0x0;/* reset */
-       psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */
-
-       if (active)
-               issue_deauth(padapter, psta->hwaddr, reason);
-
-       /* clear cam entry / key */
-       rtw_clearstakey_cmd(padapter, (u8 *)psta, (u8)(psta->mac_id + 3), true);
-
-       spin_lock_bh(&psta->lock);
-       psta->state &= ~_FW_LINKED;
-       spin_unlock_bh(&psta->lock);
-
-       rtw_indicate_sta_disassoc_event(padapter, psta);
-
-       report_del_sta_event(padapter, psta->hwaddr, reason);
-
-       beacon_updated = bss_cap_update_on_sta_leave(padapter, psta);
-
-       spin_lock_bh(&pstapriv->sta_hash_lock);
-       rtw_free_stainfo(padapter, psta);
-       spin_unlock_bh(&pstapriv->sta_hash_lock);
-
-       return beacon_updated;
-}
-
-void rtw_sta_flush(struct adapter *padapter)
-{
-       struct list_head *phead, *plist;
-       struct sta_info *psta = NULL;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
-       if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
-               return;
-
-       spin_lock_bh(&pstapriv->asoc_list_lock);
-       phead = &pstapriv->asoc_list;
-       plist = phead->next;
-
-       /* free sta asoc_queue */
-       while (phead != plist) {
-               psta = container_of(plist, struct sta_info, asoc_list);
-
-               plist = plist->next;
-
-               list_del_init(&psta->asoc_list);
-               pstapriv->asoc_list_cnt--;
-
-               ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING);
-       }
-       spin_unlock_bh(&pstapriv->asoc_list_lock);
-
-       issue_deauth(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING);
-
-       associated_clients_update(padapter, true);
-}
-
-/* called > TSR LEVEL for USB or SDIO Interface*/
-void sta_info_update(struct adapter *padapter, struct sta_info *psta)
-{
-       int flags = psta->flags;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       /* update wmm cap. */
-       if (WLAN_STA_WME & flags)
-               psta->qos_option = 1;
-       else
-               psta->qos_option = 0;
-
-       if (pmlmepriv->qospriv.qos_option == 0)
-               psta->qos_option = 0;
-
-       /* update 802.11n ht cap. */
-       if (WLAN_STA_HT & flags) {
-               psta->htpriv.ht_option = true;
-               psta->qos_option = 1;
-       } else {
-               psta->htpriv.ht_option = false;
-       }
-
-       if (!pmlmepriv->htpriv.ht_option)
-               psta->htpriv.ht_option = false;
-
-       update_sta_info_apmode(padapter, psta);
-}
-
-void start_ap_mode(struct adapter *padapter)
-{
-       int i;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
-
-       pmlmepriv->update_bcn = false;
-
-       pmlmeext->bstart_bss = false;
-
-       pmlmepriv->num_sta_non_erp = 0;
-
-       pmlmepriv->num_sta_no_short_slot_time = 0;
-
-       pmlmepriv->num_sta_no_short_preamble = 0;
-
-       pmlmepriv->num_sta_ht_no_gf = 0;
-       pmlmepriv->num_sta_no_ht = 0;
-       pmlmepriv->num_sta_ht_20mhz = 0;
-
-       pmlmepriv->olbc = false;
-
-       pmlmepriv->olbc_ht = false;
-
-       pmlmepriv->ht_op_mode = 0;
-
-       for (i = 0; i < NUM_STA; i++)
-               pstapriv->sta_aid[i] = NULL;
-
-       pmlmepriv->wps_beacon_ie = NULL;
-       pmlmepriv->wps_probe_resp_ie = NULL;
-       pmlmepriv->wps_assoc_resp_ie = NULL;
-
-       pmlmepriv->p2p_beacon_ie = NULL;
-       pmlmepriv->p2p_probe_resp_ie = NULL;
-
-       /* for ACL */
-       INIT_LIST_HEAD(&pacl_list->acl_node_q.queue);
-       pacl_list->num = 0;
-       pacl_list->mode = 0;
-       for (i = 0; i < NUM_ACL; i++) {
-               INIT_LIST_HEAD(&pacl_list->aclnode[i].list);
-               pacl_list->aclnode[i].valid = false;
-       }
-}
-
-void stop_ap_mode(struct adapter *padapter)
-{
-       struct list_head *phead, *plist;
-       struct rtw_wlan_acl_node *paclnode;
-       struct sta_info *psta = NULL;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
-       struct __queue *pacl_node_q = &pacl_list->acl_node_q;
-
-       pmlmepriv->update_bcn = false;
-       pmlmeext->bstart_bss = false;
-
-       /* reset and init security priv , this can refine with rtw_reset_securitypriv */
-       memset((unsigned char *)&padapter->securitypriv, 0, sizeof(struct security_priv));
-       padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
-       padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
-
-       /* for ACL */
-       spin_lock_bh(&pacl_node_q->lock);
-       phead = get_list_head(pacl_node_q);
-       plist = phead->next;
-       while (phead != plist) {
-               paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
-               plist = plist->next;
-
-               if (paclnode->valid) {
-                       paclnode->valid = false;
-
-                       list_del_init(&paclnode->list);
-
-                       pacl_list->num--;
-               }
-       }
-       spin_unlock_bh(&pacl_node_q->lock);
-
-       rtw_sta_flush(padapter);
-
-       /* free_assoc_sta_resources */
-       rtw_free_all_stainfo(padapter);
-
-       psta = rtw_get_bcmc_stainfo(padapter);
-       spin_lock_bh(&pstapriv->sta_hash_lock);
-       rtw_free_stainfo(padapter, psta);
-       spin_unlock_bh(&pstapriv->sta_hash_lock);
-
-       rtw_init_bcmc_stainfo(padapter);
-
-       rtw_free_mlme_priv_ie_data(pmlmepriv);
-}
diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c
deleted file mode 100644 (file)
index a7c6701..0000000
+++ /dev/null
@@ -1,658 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. i*/
-
-#define _RTW_BR_EXT_C_
-
-#include "../include/linux/if_arp.h"
-#include "../include/net/ip.h"
-#include "../include/linux/atalk.h"
-#include "../include/linux/udp.h"
-#include "../include/linux/if_pppox.h"
-
-#include "../include/drv_types.h"
-#include "../include/rtw_br_ext.h"
-#include "../include/usb_osintf.h"
-
-#ifndef csum_ipv6_magic
-#include "../include/net/ip6_checksum.h"
-#endif
-
-#include "../include/linux/ipv6.h"
-#include "../include/linux/icmpv6.h"
-#include "../include/net/ndisc.h"
-#include "../include/net/checksum.h"
-
-#define NAT25_IPV4             01
-#define NAT25_IPV6             02
-#define NAT25_IPX              03
-#define NAT25_APPLE            04
-#define NAT25_PPPOE            05
-
-#define RTL_RELAY_TAG_LEN (ETH_ALEN)
-#define TAG_HDR_LEN            4
-
-#define MAGIC_CODE             0x8186
-#define MAGIC_CODE_LEN 2
-#define WAIT_TIME_PPPOE        5       /*  waiting time for pppoe server in sec */
-
-/*-----------------------------------------------------------------
-  How database records network address:
-          0    1    2    3    4    5    6    7    8    9   10
-       |----|----|----|----|----|----|----|----|----|----|----|
-  IPv4  |type|                             |      IP addr      |
-  IPX   |type|      Net addr     |          Node addr          |
-  IPX   |type|      Net addr     |Sckt addr|
-  Apple |type| Network |node|
-  PPPoE |type|   SID   |           AC MAC            |
------------------------------------------------------------------*/
-
-/* Find a tag in pppoe frame and return the pointer */
-static unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type)
-{
-       unsigned char *cur_ptr, *start_ptr;
-       unsigned short tag_len, tag_type;
-
-       start_ptr = (unsigned char *)ph->tag;
-       cur_ptr = (unsigned char *)ph->tag;
-       while ((cur_ptr - start_ptr) < ntohs(ph->length)) {
-               /*  prevent un-alignment access */
-               tag_type = (unsigned short)((cur_ptr[0] << 8) + cur_ptr[1]);
-               tag_len  = (unsigned short)((cur_ptr[2] << 8) + cur_ptr[3]);
-               if (tag_type == type)
-                       return cur_ptr;
-               cur_ptr = cur_ptr + TAG_HDR_LEN + tag_len;
-       }
-       return NULL;
-}
-
-static int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag)
-{
-       struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
-       int data_len;
-
-       data_len = be16_to_cpu(tag->tag_len) + TAG_HDR_LEN;
-       if (skb_tailroom(skb) < data_len)
-               return -1;
-
-       skb_put(skb, data_len);
-       /*  have a room for new tag */
-       memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length));
-       ph->length = htons(ntohs(ph->length) + data_len);
-       memcpy((unsigned char *)ph->tag, tag, data_len);
-       return data_len;
-}
-
-static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len)
-{
-       int tail_len;
-       unsigned long end, tail;
-
-       if ((src + len) > skb_tail_pointer(skb) || skb->len < len)
-               return -1;
-
-       tail = (unsigned long)skb_tail_pointer(skb);
-       end = (unsigned long)src + len;
-       if (tail < end)
-               return -1;
-
-       tail_len = (int)(tail - end);
-       if (tail_len > 0)
-               memmove(src, src + len, tail_len);
-
-       skb_trim(skb, skb->len - len);
-       return 0;
-}
-
-static int  __nat25_has_expired(struct nat25_network_db_entry *fdb)
-{
-       if (time_before_eq(fdb->ageing_timer, jiffies - NAT25_AGEING_TIME * HZ))
-               return 1;
-
-       return 0;
-}
-
-static void __nat25_generate_ipv4_network_addr(unsigned char *addr,
-                               unsigned int *ip_addr)
-{
-       memset(addr, 0, MAX_NETWORK_ADDR_LEN);
-
-       addr[0] = NAT25_IPV4;
-       memcpy(addr + 7, (unsigned char *)ip_addr, 4);
-}
-
-static void __nat25_generate_pppoe_network_addr(unsigned char *addr,
-                               unsigned char *ac_mac, __be16 *sid)
-{
-       memset(addr, 0, MAX_NETWORK_ADDR_LEN);
-
-       addr[0] = NAT25_PPPOE;
-       memcpy(addr + 1, (unsigned char *)sid, 2);
-       memcpy(addr + 3, (unsigned char *)ac_mac, 6);
-}
-
-static  void __nat25_generate_ipv6_network_addr(unsigned char *addr,
-                               unsigned int *ip_addr)
-{
-       memset(addr, 0, MAX_NETWORK_ADDR_LEN);
-
-       addr[0] = NAT25_IPV6;
-       memcpy(addr + 1, (unsigned char *)ip_addr, 16);
-}
-
-static unsigned char *scan_tlv(unsigned char *data, int len, unsigned char tag, unsigned char len8b)
-{
-       while (len > 0) {
-               if (*data == tag && *(data + 1) == len8b && len >= len8b * 8)
-                       return data + 2;
-
-               len -= (*(data + 1)) * 8;
-               data += (*(data + 1)) * 8;
-       }
-       return NULL;
-}
-
-static int update_nd_link_layer_addr(unsigned char *data, int len, unsigned char *replace_mac)
-{
-       struct icmp6hdr *icmphdr = (struct icmp6hdr *)data;
-       unsigned char *mac;
-
-       if (icmphdr->icmp6_type == NDISC_ROUTER_SOLICITATION) {
-               if (len >= 8) {
-                       mac = scan_tlv(&data[8], len - 8, 1, 1);
-                       if (mac) {
-                               memcpy(mac, replace_mac, 6);
-                               return 1;
-                       }
-               }
-       } else if (icmphdr->icmp6_type == NDISC_ROUTER_ADVERTISEMENT) {
-               if (len >= 16) {
-                       mac = scan_tlv(&data[16], len - 16, 1, 1);
-                       if (mac) {
-                               memcpy(mac, replace_mac, 6);
-                               return 1;
-                       }
-               }
-       } else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) {
-               if (len >= 24) {
-                       mac = scan_tlv(&data[24], len - 24, 1, 1);
-                       if (mac) {
-                               memcpy(mac, replace_mac, 6);
-                               return 1;
-                       }
-               }
-       } else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT) {
-               if (len >= 24) {
-                       mac = scan_tlv(&data[24], len - 24, 2, 1);
-                       if (mac) {
-                               memcpy(mac, replace_mac, 6);
-                               return 1;
-                       }
-               }
-       } else if (icmphdr->icmp6_type == NDISC_REDIRECT) {
-               if (len >= 40) {
-                       mac = scan_tlv(&data[40], len - 40, 2, 1);
-                       if (mac) {
-                               memcpy(mac, replace_mac, 6);
-                               return 1;
-                       }
-               }
-       }
-       return 0;
-}
-
-static int __nat25_network_hash(unsigned char *addr)
-{
-       if (addr[0] == NAT25_IPV4) {
-               unsigned long x;
-
-               x = addr[7] ^ addr[8] ^ addr[9] ^ addr[10];
-
-               return x & (NAT25_HASH_SIZE - 1);
-       } else if (addr[0] == NAT25_IPX) {
-               unsigned long x;
-
-               x = addr[1] ^ addr[2] ^ addr[3] ^ addr[4] ^ addr[5] ^
-                   addr[6] ^ addr[7] ^ addr[8] ^ addr[9] ^ addr[10];
-
-               return x & (NAT25_HASH_SIZE - 1);
-       } else if (addr[0] == NAT25_APPLE) {
-               unsigned long x;
-
-               x = addr[1] ^ addr[2] ^ addr[3];
-
-               return x & (NAT25_HASH_SIZE - 1);
-       } else if (addr[0] == NAT25_PPPOE) {
-               unsigned long x;
-
-               x = addr[0] ^ addr[1] ^ addr[2] ^ addr[3] ^ addr[4] ^
-                   addr[5] ^ addr[6] ^ addr[7] ^ addr[8];
-
-               return x & (NAT25_HASH_SIZE - 1);
-       } else if (addr[0] == NAT25_IPV6) {
-               unsigned long x;
-
-               x = addr[1] ^ addr[2] ^ addr[3] ^ addr[4] ^ addr[5] ^ addr[6] ^
-                   addr[7] ^ addr[8] ^ addr[9] ^ addr[10] ^ addr[11] ^ addr[12] ^
-                   addr[13] ^ addr[14] ^ addr[15] ^ addr[16];
-
-               return x & (NAT25_HASH_SIZE - 1);
-       } else {
-               unsigned long x = 0;
-               int i;
-
-               for (i = 0; i < MAX_NETWORK_ADDR_LEN; i++)
-                       x ^= addr[i];
-
-               return x & (NAT25_HASH_SIZE - 1);
-       }
-}
-
-static void __network_hash_link(struct adapter *priv,
-                               struct nat25_network_db_entry *ent, int hash)
-{
-       /*  Caller must spin_lock already! */
-       ent->next_hash = priv->nethash[hash];
-       if (ent->next_hash)
-               ent->next_hash->pprev_hash = &ent->next_hash;
-       priv->nethash[hash] = ent;
-       ent->pprev_hash = &priv->nethash[hash];
-}
-
-static void __network_hash_unlink(struct nat25_network_db_entry *ent)
-{
-       /*  Caller must spin_lock already! */
-       *ent->pprev_hash = ent->next_hash;
-       if (ent->next_hash)
-               ent->next_hash->pprev_hash = ent->pprev_hash;
-       ent->next_hash = NULL;
-       ent->pprev_hash = NULL;
-}
-
-static void __nat25_db_network_insert(struct adapter *priv,
-                               unsigned char *mac_addr, unsigned char *addr)
-{
-       struct nat25_network_db_entry *db;
-       int hash;
-
-       spin_lock_bh(&priv->br_ext_lock);
-       hash = __nat25_network_hash(addr);
-       db = priv->nethash[hash];
-       while (db) {
-               if (!memcmp(db->networkAddr, addr, MAX_NETWORK_ADDR_LEN)) {
-                       memcpy(db->macAddr, mac_addr, ETH_ALEN);
-                       db->ageing_timer = jiffies;
-                       spin_unlock_bh(&priv->br_ext_lock);
-                       return;
-               }
-               db = db->next_hash;
-       }
-       db = kmalloc(sizeof(*db), GFP_ATOMIC);
-       if (!db) {
-               spin_unlock_bh(&priv->br_ext_lock);
-               return;
-       }
-       memcpy(db->networkAddr, addr, MAX_NETWORK_ADDR_LEN);
-       memcpy(db->macAddr, mac_addr, ETH_ALEN);
-       atomic_set(&db->use_count, 1);
-       db->ageing_timer = jiffies;
-
-       __network_hash_link(priv, db, hash);
-
-       spin_unlock_bh(&priv->br_ext_lock);
-}
-
-/*
- *     NAT2.5 interface
- */
-
-void nat25_db_cleanup(struct adapter *priv)
-{
-       int i;
-
-       spin_lock_bh(&priv->br_ext_lock);
-
-       for (i = 0; i < NAT25_HASH_SIZE; i++) {
-               struct nat25_network_db_entry *f;
-
-               f = priv->nethash[i];
-               while (f) {
-                       struct nat25_network_db_entry *g;
-
-                       g = f->next_hash;
-                       if (priv->scdb_entry == f) {
-                               memset(priv->scdb_mac, 0, ETH_ALEN);
-                               memset(priv->scdb_ip, 0, 4);
-                               priv->scdb_entry = NULL;
-                       }
-                       __network_hash_unlink(f);
-                       kfree(f);
-                       f = g;
-               }
-       }
-       spin_unlock_bh(&priv->br_ext_lock);
-}
-
-void nat25_db_expire(struct adapter *priv)
-{
-       int i;
-
-       spin_lock_bh(&priv->br_ext_lock);
-
-       for (i = 0; i < NAT25_HASH_SIZE; i++) {
-               struct nat25_network_db_entry *f;
-
-               f = priv->nethash[i];
-               while (f) {
-                       struct nat25_network_db_entry *g;
-
-                       g = f->next_hash;
-                       if (__nat25_has_expired(f)) {
-                               if (atomic_dec_and_test(&f->use_count)) {
-                                       if (priv->scdb_entry == f) {
-                                               memset(priv->scdb_mac, 0, ETH_ALEN);
-                                               memset(priv->scdb_ip, 0, 4);
-                                               priv->scdb_entry = NULL;
-                                       }
-                                       __network_hash_unlink(f);
-                                       kfree(f);
-                               }
-                       }
-                       f = g;
-               }
-       }
-       spin_unlock_bh(&priv->br_ext_lock);
-}
-
-int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method)
-{
-       unsigned short protocol;
-       unsigned char addr[MAX_NETWORK_ADDR_LEN];
-       unsigned int tmp;
-
-       if (!skb)
-               return -1;
-
-       if ((method <= NAT25_MIN) || (method >= NAT25_MAX))
-               return -1;
-
-       protocol = be16_to_cpu(*((__be16 *)(skb->data + 2 * ETH_ALEN)));
-
-       /*---------------------------------------------------*/
-       /*                 Handle IP frame                   */
-       /*---------------------------------------------------*/
-       if (protocol == ETH_P_IP) {
-               struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN);
-
-               if (((unsigned char *)(iph) + (iph->ihl << 2)) >= (skb->data + ETH_HLEN + skb->len))
-                       return -1;
-
-               switch (method) {
-               case NAT25_CHECK:
-                       return -1;
-               case NAT25_INSERT:
-                       /* some multicast with source IP is all zero, maybe other case is illegal */
-                       /* in class A, B, C, host address is all zero or all one is illegal */
-                       if (iph->saddr == 0)
-                               return 0;
-                       tmp = be32_to_cpu(iph->saddr);
-                       __nat25_generate_ipv4_network_addr(addr, &tmp);
-                       /* record source IP address and , source mac address into db */
-                       __nat25_db_network_insert(priv, skb->data + ETH_ALEN, addr);
-                       return 0;
-               default:
-                       return -1;
-               }
-       } else if (protocol == ETH_P_ARP) {
-               /*---------------------------------------------------*/
-               /*                 Handle ARP frame                  */
-               /*---------------------------------------------------*/
-               struct arphdr *arp = (struct arphdr *)(skb->data + ETH_HLEN);
-               unsigned char *arp_ptr = (unsigned char *)(arp + 1);
-               unsigned int *sender;
-
-               if (arp->ar_pro != htons(ETH_P_IP))
-                       return -1;
-
-               switch (method) {
-               case NAT25_CHECK:
-                       return 0;       /*  skb_copy for all ARP frame */
-               case NAT25_INSERT:
-                       /*  change to ARP sender mac address to wlan STA address */
-                       memcpy(arp_ptr, GET_MY_HWADDR(priv), ETH_ALEN);
-                       arp_ptr += arp->ar_hln;
-                       sender = (unsigned int *)arp_ptr;
-                       __nat25_generate_ipv4_network_addr(addr, sender);
-                       __nat25_db_network_insert(priv, skb->data + ETH_ALEN, addr);
-                       return 0;
-               default:
-                       return -1;
-               }
-       } else if ((protocol == ETH_P_PPP_DISC) ||
-                  (protocol == ETH_P_PPP_SES)) {
-               /*---------------------------------------------------*/
-               /*                Handle PPPoE frame                 */
-               /*---------------------------------------------------*/
-               struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
-               __be16 *pMagic;
-
-               switch (method) {
-               case NAT25_CHECK:
-                       if (ph->sid == 0)
-                               return 0;
-                       return 1;
-               case NAT25_INSERT:
-                       if (ph->sid == 0) {     /*  Discovery phase according to tag */
-                               if (ph->code == PADI_CODE || ph->code == PADR_CODE) {
-                                       if (priv->ethBrExtInfo.addPPPoETag) {
-                                               struct pppoe_tag *tag, *pOldTag;
-                                               unsigned char tag_buf[40];
-                                               int old_tag_len = 0;
-
-                                               tag = (struct pppoe_tag *)tag_buf;
-                                               pOldTag = (struct pppoe_tag *)__nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID));
-                                               if (pOldTag) { /*  if SID existed, copy old value and delete it */
-                                                       old_tag_len = ntohs(pOldTag->tag_len);
-                                                       if (old_tag_len +
-                                                           TAG_HDR_LEN +
-                                                           MAGIC_CODE_LEN +
-                                                           RTL_RELAY_TAG_LEN >
-                                                           sizeof(tag_buf))
-                                                               return -1;
-
-                                                       memcpy(tag->tag_data + MAGIC_CODE_LEN + RTL_RELAY_TAG_LEN,
-                                                               pOldTag->tag_data, old_tag_len);
-
-                                                       if (skb_pull_and_merge(skb, (unsigned char *)pOldTag, TAG_HDR_LEN + old_tag_len) < 0)
-                                                               return -1;
-
-                                                       ph->length = htons(ntohs(ph->length) - TAG_HDR_LEN - old_tag_len);
-                                               }
-
-                                               tag->tag_type = PTT_RELAY_SID;
-                                               tag->tag_len = htons(MAGIC_CODE_LEN + RTL_RELAY_TAG_LEN + old_tag_len);
-
-                                               /*  insert the magic_code+client mac in relay tag */
-                                               pMagic = (__be16 *)tag->tag_data;
-                                               *pMagic = htons(MAGIC_CODE);
-                                               memcpy(tag->tag_data + MAGIC_CODE_LEN, skb->data + ETH_ALEN, ETH_ALEN);
-
-                                               /* Add relay tag */
-                                               if (__nat25_add_pppoe_tag(skb, tag) < 0)
-                                                       return -1;
-                                       } else { /*  not add relay tag */
-                                               if (priv->pppoe_connection_in_progress &&
-                                                   memcmp(skb->data + ETH_ALEN,
-                                                          priv->pppoe_addr,
-                                                          ETH_ALEN))
-                                                       return -2;
-
-                                               if (priv->pppoe_connection_in_progress == 0)
-                                                       memcpy(priv->pppoe_addr, skb->data + ETH_ALEN, ETH_ALEN);
-
-                                               priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE;
-                                       }
-                               } else {
-                                       return -1;
-                               }
-                       } else {        /*  session phase */
-                               __nat25_generate_pppoe_network_addr(addr, skb->data, &ph->sid);
-
-                               __nat25_db_network_insert(priv, skb->data + ETH_ALEN, addr);
-
-                               if (!priv->ethBrExtInfo.addPPPoETag &&
-                                   priv->pppoe_connection_in_progress &&
-                                   !memcmp(skb->data + ETH_ALEN, priv->pppoe_addr, ETH_ALEN))
-                                       priv->pppoe_connection_in_progress = 0;
-                       }
-                       return 0;
-               default:
-                       return -1;
-               }
-       } else if (protocol == 0x888e) {
-               /*---------------------------------------------------*/
-               /*                 Handle EAP frame                  */
-               /*---------------------------------------------------*/
-               switch (method) {
-               case NAT25_CHECK:
-                       return -1;
-               case NAT25_INSERT:
-                       return 0;
-               default:
-                       return -1;
-               }
-       } else if ((protocol == 0xe2ae) || (protocol == 0xe2af)) {
-               /*---------------------------------------------------*/
-               /*         Handle C-Media proprietary frame          */
-               /*---------------------------------------------------*/
-               switch (method) {
-               case NAT25_CHECK:
-                       return -1;
-               case NAT25_INSERT:
-                       return 0;
-               default:
-                       return -1;
-               }
-       } else if (protocol == ETH_P_IPV6) {
-               /*------------------------------------------------*/
-               /*         Handle IPV6 frame                      */
-               /*------------------------------------------------*/
-               struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
-
-               if (sizeof(*iph) >= (skb->len - ETH_HLEN))
-                       return -1;
-
-               switch (method) {
-               case NAT25_CHECK:
-                       if (skb->data[0] & 1)
-                               return 0;
-                       return -1;
-               case NAT25_INSERT:
-                       if (memcmp(&iph->saddr, "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0", 16)) {
-                               __nat25_generate_ipv6_network_addr(addr, (unsigned int *)&iph->saddr);
-                               __nat25_db_network_insert(priv, skb->data + ETH_ALEN, addr);
-
-                               if (iph->nexthdr == IPPROTO_ICMPV6 &&
-                                               skb->len > (ETH_HLEN +  sizeof(*iph) + 4)) {
-                                       if (update_nd_link_layer_addr(skb->data + ETH_HLEN + sizeof(*iph),
-                                                                     skb->len - ETH_HLEN - sizeof(*iph), GET_MY_HWADDR(priv))) {
-                                               struct icmp6hdr  *hdr = (struct icmp6hdr *)(skb->data + ETH_HLEN + sizeof(*iph));
-                                               hdr->icmp6_cksum = 0;
-                                               hdr->icmp6_cksum = csum_ipv6_magic(&iph->saddr, &iph->daddr,
-                                                                               be16_to_cpu(iph->payload_len),
-                                                                               IPPROTO_ICMPV6,
-                                                                               csum_partial((__u8 *)hdr,
-                                                                               be16_to_cpu(iph->payload_len),
-                                                                               0));
-                                       }
-                               }
-                       }
-                       return 0;
-               default:
-                       return -1;
-               }
-       }
-       return -1;
-}
-
-#define SERVER_PORT                    67
-#define CLIENT_PORT                    68
-#define DHCP_MAGIC                     0x63825363
-#define BROADCAST_FLAG         0x8000
-
-struct dhcpMessage {
-       u_int8_t op;
-       u_int8_t htype;
-       u_int8_t hlen;
-       u_int8_t hops;
-       u_int32_t xid;
-       __be16 secs;
-       __be16 flags;
-       __be32 ciaddr;
-       __be32 yiaddr;
-       __be32 siaddr;
-       __be32 giaddr;
-       u_int8_t chaddr[16];
-       u_int8_t sname[64];
-       u_int8_t file[128];
-       __be32 cookie;
-       u_int8_t options[308]; /* 312 - cookie */
-};
-
-void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb)
-{
-       if (!skb)
-               return;
-
-       if (!priv->ethBrExtInfo.dhcp_bcst_disable) {
-               __be16 protocol = *((__be16 *)(skb->data + 2 * ETH_ALEN));
-
-               if (protocol == htons(ETH_P_IP)) { /*  IP */
-                       struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN);
-
-                       if (iph->protocol == IPPROTO_UDP) { /*  UDP */
-                               struct udphdr *udph = (void *)iph + (iph->ihl << 2);
-
-                               if ((udph->source == htons(CLIENT_PORT)) &&
-                                   (udph->dest == htons(SERVER_PORT))) { /*  DHCP request */
-                                       struct dhcpMessage *dhcph = (void *)udph + sizeof(struct udphdr);
-                                       u32 cookie = be32_to_cpu(dhcph->cookie);
-
-                                       if (cookie == DHCP_MAGIC) { /*  match magic word */
-                                               if (!(dhcph->flags & htons(BROADCAST_FLAG))) {
-                                                       /*  if not broadcast */
-                                                       register int sum = 0;
-
-                                                       /*  or BROADCAST flag */
-                                                       dhcph->flags |= htons(BROADCAST_FLAG);
-                                                       /*  recalculate checksum */
-                                                       sum = ~(udph->check) & 0xffff;
-                                                       sum += be16_to_cpu(dhcph->flags);
-                                                       while (sum >> 16)
-                                                               sum = (sum & 0xffff) + (sum >> 16);
-                                                       udph->check = ~sum;
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-}
-
-void *scdb_findEntry(struct adapter *priv, unsigned char *ip_addr)
-{
-       unsigned char addr[MAX_NETWORK_ADDR_LEN];
-       struct nat25_network_db_entry *db;
-       int hash;
-
-       __nat25_generate_ipv4_network_addr(addr, (unsigned int *)ip_addr);
-       hash = __nat25_network_hash(addr);
-       db = priv->nethash[hash];
-       while (db) {
-               if (!memcmp(db->networkAddr, addr, MAX_NETWORK_ADDR_LEN))
-                       return (void *)db;
-
-               db = db->next_hash;
-       }
-
-       return NULL;
-}
diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c
deleted file mode 100644 (file)
index ca9e3d4..0000000
+++ /dev/null
@@ -1,1529 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _RTW_CMD_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/rtw_br_ext.h"
-#include "../include/rtw_mlme_ext.h"
-#include "../include/rtl8188e_dm.h"
-
-/* Caller and the rtw_cmd_thread can protect cmd_q by spin_lock.
- * No irqsave is necessary.
- */
-
-static void c2h_wk_callback(struct work_struct *work);
-
-void rtw_free_evt_priv(struct  evt_priv *pevtpriv)
-{
-       cancel_work_sync(&pevtpriv->c2h_wk);
-       while (pevtpriv->c2h_wk_alive)
-               msleep(10);
-
-       while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) {
-               void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue);
-               if (c2h && c2h != (void *)pevtpriv)
-                       kfree(c2h);
-       }
-}
-
-int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
-{
-       init_completion(&pcmdpriv->enqueue_cmd);
-       /* sema_init(&(pcmdpriv->cmd_done_sema), 0); */
-       init_completion(&pcmdpriv->start_cmd_thread);
-       init_completion(&pcmdpriv->stop_cmd_thread);
-
-       rtw_init_queue(&pcmdpriv->cmd_queue);
-
-       /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
-
-       pcmdpriv->cmd_allocated_buf = kzalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ,
-                                             GFP_KERNEL);
-
-       if (!pcmdpriv->cmd_allocated_buf)
-               return -ENOMEM;
-
-       pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf  +  CMDBUFF_ALIGN_SZ - ((size_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ - 1));
-
-       pcmdpriv->rsp_allocated_buf = kzalloc(MAX_RSPSZ + 4, GFP_KERNEL);
-
-       if (!pcmdpriv->rsp_allocated_buf) {
-               kfree(pcmdpriv->cmd_allocated_buf);
-               return -ENOMEM;
-       }
-
-       pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf  +  4 - ((size_t)(pcmdpriv->rsp_allocated_buf) & 3);
-
-       pcmdpriv->cmd_done_cnt = 0;
-       pcmdpriv->rsp_cnt = 0;
-
-       return 0;
-}
-
-int rtw_init_evt_priv(struct evt_priv *pevtpriv)
-{
-       /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
-       atomic_set(&pevtpriv->event_seq, 0);
-
-       INIT_WORK(&pevtpriv->c2h_wk, c2h_wk_callback);
-       pevtpriv->c2h_wk_alive = false;
-       pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN + 1);
-       if (!pevtpriv->c2h_queue)
-               return -ENOMEM;
-
-       return 0;
-}
-
-void rtw_free_cmd_priv(struct  cmd_priv *pcmdpriv)
-{
-       if (pcmdpriv) {
-               kfree(pcmdpriv->cmd_allocated_buf);
-               kfree(pcmdpriv->rsp_allocated_buf);
-       }
-}
-
-static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
-{
-       u8 bAllow = false; /* set to true to allow enqueuing cmd when hw_init_completed is false */
-
-       if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan))
-               bAllow = true;
-
-       if ((!pcmdpriv->padapter->hw_init_completed && !bAllow) ||
-           !pcmdpriv->cmdthd_running)  /* com_thread not running */
-               return _FAIL;
-       return _SUCCESS;
-}
-
-u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
-{
-       unsigned long flags;
-       struct adapter *padapter = pcmdpriv->padapter;
-
-       if (!cmd_obj)
-               return _FAIL;
-
-       cmd_obj->padapter = padapter;
-
-       if (rtw_cmd_filter(pcmdpriv, cmd_obj) == _FAIL) {
-               rtw_free_cmd_obj(cmd_obj);
-               return _FAIL;
-       }
-
-       spin_lock_irqsave(&pcmdpriv->cmd_queue.lock, flags);
-       list_add_tail(&cmd_obj->list, &pcmdpriv->cmd_queue.queue);
-       spin_unlock_irqrestore(&pcmdpriv->cmd_queue.lock, flags);
-
-       complete(&pcmdpriv->enqueue_cmd);
-       return _SUCCESS;
-}
-
-struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv)
-{
-       struct cmd_obj *obj;
-       struct __queue *queue = &pcmdpriv->cmd_queue;
-       unsigned long flags;
-
-       spin_lock_irqsave(&queue->lock, flags);
-       if (list_empty(&queue->queue)) {
-               obj = NULL;
-       } else {
-               obj = container_of((&queue->queue)->next, struct cmd_obj, list);
-               list_del_init(&obj->list);
-       }
-
-       spin_unlock_irqrestore(&queue->lock, flags);
-
-       return obj;
-}
-
-void rtw_free_cmd_obj(struct cmd_obj *pcmd)
-{
-
-       if ((pcmd->cmdcode != _JoinBss_CMD_) && (pcmd->cmdcode != _CreateBss_CMD_)) {
-               /* free parmbuf in cmd_obj */
-               kfree(pcmd->parmbuf);
-       }
-
-       if (pcmd->rsp) {
-               if (pcmd->rspsz != 0) {
-                       /* free rsp in cmd_obj */
-                       kfree(pcmd->rsp);
-               }
-       }
-
-       /* free cmd_obj */
-       kfree(pcmd);
-
-}
-
-int rtw_cmd_thread(void *context)
-{
-       u8 ret;
-       struct cmd_obj *pcmd;
-       u8 *pcmdbuf;
-       u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf);
-       void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd);
-       struct adapter *padapter = (struct adapter *)context;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-
-       pcmdbuf = pcmdpriv->cmd_buf;
-
-       pcmdpriv->cmdthd_running = true;
-       complete(&pcmdpriv->start_cmd_thread);
-
-       while (1) {
-               wait_for_completion(&pcmdpriv->enqueue_cmd);
-
-_next:
-               if (padapter->bDriverStopped ||
-                   padapter->bSurpriseRemoved)
-                       break;
-
-               pcmd = rtw_dequeue_cmd(pcmdpriv);
-               if (!pcmd)
-                       continue;
-
-               if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) {
-                       pcmd->res = H2C_DROPPED;
-                       goto post_process;
-               }
-
-               pcmd->cmdsz = round_up(pcmd->cmdsz, 4);
-
-               memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
-
-               if (pcmd->cmdcode < ARRAY_SIZE(wlancmds)) {
-                       cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns;
-
-                       if (cmd_hdl) {
-                               ret = cmd_hdl(pcmd->padapter, pcmdbuf);
-                               pcmd->res = ret;
-                       }
-               } else {
-                       pcmd->res = H2C_PARAMETERS_ERROR;
-               }
-
-               cmd_hdl = NULL;
-
-post_process:
-
-               /* call callback function for post-processed */
-               if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) {
-                       pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback;
-                       if (!pcmd_callback)
-                               rtw_free_cmd_obj(pcmd);
-                       else
-                               /* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */
-                               pcmd_callback(pcmd->padapter, pcmd);/* need consider that free cmd_obj in rtw_cmd_callback */
-               } else {
-                       rtw_free_cmd_obj(pcmd);
-               }
-
-               flush_signals_thread();
-
-               goto _next;
-       }
-       pcmdpriv->cmdthd_running = false;
-
-       /*  free all cmd_obj resources */
-       do {
-               pcmd = rtw_dequeue_cmd(pcmdpriv);
-               if (!pcmd)
-                       break;
-
-               rtw_free_cmd_obj(pcmd);
-       } while (1);
-
-       complete(&pcmdpriv->stop_cmd_thread);
-
-       return 0;
-}
-
-/* rtw_sitesurvey_cmd(~)
- *     ### NOTE:#### (!!!!)
- *     MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
- */
-u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct ndis_802_11_ssid *ssid, int ssid_num)
-{
-       u8 res = _FAIL;
-       struct cmd_obj          *ph2c;
-       struct sitesurvey_parm  *psurveyPara;
-       struct cmd_priv         *pcmdpriv = &padapter->cmdpriv;
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED))
-               rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1);
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED))
-               p2p_ps_wk_cmd(padapter, P2P_PS_SCAN, 1);
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-       if (!ph2c)
-               return _FAIL;
-
-       psurveyPara = kzalloc(sizeof(*psurveyPara), GFP_ATOMIC);
-       if (!psurveyPara) {
-               kfree(ph2c);
-               return _FAIL;
-       }
-
-       rtw_free_network_queue(padapter, false);
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey));
-
-       /* psurveyPara->bsslimit = 48; */
-       psurveyPara->scan_mode = pmlmepriv->scan_mode;
-
-       /* prepare ssid list */
-       if (ssid) {
-               int i;
-               for (i = 0; i < ssid_num && i < RTW_SSID_SCAN_AMOUNT; i++) {
-                       if (ssid[i].SsidLength) {
-                               memcpy(&psurveyPara->ssid[i], &ssid[i], sizeof(struct ndis_802_11_ssid));
-                               psurveyPara->ssid_num++;
-                       }
-               }
-       }
-
-       set_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
-
-       res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-
-       if (res == _SUCCESS) {
-               pmlmepriv->scan_start_time = jiffies;
-
-               _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT);
-
-               rtw_led_control(padapter, LED_CTL_SITE_SURVEY);
-
-               pmlmepriv->scan_interval = SCAN_INTERVAL;/*  30*2 sec = 60sec */
-       } else {
-               _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
-       }
-
-       return res;
-}
-
-int rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset)
-{
-       struct cmd_obj *ph2c;
-       struct setdatarate_parm *pbsetdataratepara;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-       if (!ph2c)
-               return -ENOMEM;
-
-       pbsetdataratepara = kzalloc(sizeof(*pbsetdataratepara), GFP_ATOMIC);
-       if (!pbsetdataratepara) {
-               kfree(ph2c);
-               return -ENOMEM;
-       }
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, GEN_CMD_CODE(_SetDataRate));
-       pbsetdataratepara->mac_id = 5;
-       memcpy(pbsetdataratepara->datarates, rateset, NumRates);
-       if (rtw_enqueue_cmd(pcmdpriv, ph2c) == _FAIL)
-               return -EPERM;
-
-       return 0;
-}
-
-void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
-{
-
-
-       kfree(pcmd->parmbuf);
-       kfree(pcmd);
-}
-
-u8 rtw_createbss_cmd(struct adapter  *padapter)
-{
-       struct cmd_obj *pcmd;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network;
-       u8      res = _SUCCESS;
-
-       rtw_led_control(padapter, LED_CTL_START_TO_LINK);
-
-       pcmd = kzalloc(sizeof(*pcmd), GFP_ATOMIC);
-       if (!pcmd) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       INIT_LIST_HEAD(&pcmd->list);
-       pcmd->cmdcode = _CreateBss_CMD_;
-       pcmd->parmbuf = (unsigned char *)pdev_network;
-       pcmd->cmdsz = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network);
-       pcmd->rsp = NULL;
-       pcmd->rspsz = 0;
-       pdev_network->Length = pcmd->cmdsz;
-       res = rtw_enqueue_cmd(pcmdpriv, pcmd);
-exit:
-
-       return res;
-}
-
-u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)
-{
-       u8      res = _SUCCESS;
-       uint    t_len = 0;
-       struct wlan_bssid_ex            *psecnetwork;
-       struct cmd_obj          *pcmd;
-       struct cmd_priv         *pcmdpriv = &padapter->cmdpriv;
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct qos_priv         *pqospriv = &pmlmepriv->qospriv;
-       struct security_priv    *psecuritypriv = &padapter->securitypriv;
-       struct registry_priv    *pregistrypriv = &padapter->registrypriv;
-       struct ht_priv          *phtpriv = &pmlmepriv->htpriv;
-       enum ndis_802_11_network_infra ndis_network_mode = pnetwork->network.InfrastructureMode;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       rtw_led_control(padapter, LED_CTL_START_TO_LINK);
-
-       pcmd = kzalloc(sizeof(*pcmd), GFP_ATOMIC);
-       if (!pcmd) {
-               res = _FAIL;
-               goto exit;
-       }
-       /* for IEs is fix buf size */
-       t_len = sizeof(struct wlan_bssid_ex);
-
-       /* for hidden ap to set fw_state here */
-       if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) {
-               switch (ndis_network_mode) {
-               case Ndis802_11IBSS:
-                       set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
-                       break;
-               case Ndis802_11Infrastructure:
-                       set_fwstate(pmlmepriv, WIFI_STATION_STATE);
-                       break;
-               case Ndis802_11APMode:
-               case Ndis802_11AutoUnknown:
-               case Ndis802_11InfrastructureMax:
-                       break;
-               }
-       }
-
-       psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
-       if (!psecnetwork) {
-               kfree(pcmd);
-               res = _FAIL;
-               goto exit;
-       }
-
-       memset(psecnetwork, 0, t_len);
-
-       memcpy(psecnetwork, &pnetwork->network, get_wlan_bssid_ex_sz(&pnetwork->network));
-
-       psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength;
-
-       if (psecnetwork->IELength - 12 < 255)
-               memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength - 12);
-       else
-               memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], 255);
-
-       psecnetwork->IELength = 0;
-       /*  Added by Albert 2009/02/18 */
-       /*  If the driver wants to use the bssid to create the connection. */
-       /*  If not,  we have to copy the connecting AP's MAC address to it so that */
-       /*  the driver just has the bssid information for PMKIDList searching. */
-
-       if (!pmlmepriv->assoc_by_bssid)
-               memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.MacAddress[0], ETH_ALEN);
-
-       psecnetwork->IELength = rtw_restruct_sec_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength);
-
-       pqospriv->qos_option = 0;
-
-       if (pregistrypriv->wmm_enable) {
-               u32 tmp_len;
-
-               tmp_len = rtw_restruct_wmm_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength, psecnetwork->IELength);
-
-               if (psecnetwork->IELength != tmp_len) {
-                       psecnetwork->IELength = tmp_len;
-                       pqospriv->qos_option = 1; /* There is WMM IE in this corresp. beacon */
-               } else {
-                       pqospriv->qos_option = 0;/* There is no WMM IE in this corresp. beacon */
-               }
-       }
-
-       phtpriv->ht_option = false;
-       if (pregistrypriv->ht_enable) {
-               /*      Added by Albert 2010/06/23 */
-               /*      For the WEP mode, we will use the bg mode to do the connection to avoid some IOT issue. */
-               /*      Especially for Realtek 8192u SoftAP. */
-               if ((padapter->securitypriv.dot11PrivacyAlgrthm != _WEP40_) &&
-                   (padapter->securitypriv.dot11PrivacyAlgrthm != _WEP104_) &&
-                   (padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) {
-                       /* rtw_restructure_ht_ie */
-                       rtw_restructure_ht_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0],
-                                                                       pnetwork->network.IELength, &psecnetwork->IELength);
-               }
-       }
-
-       pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pnetwork->network.IEs, pnetwork->network.IELength);
-
-       if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_TENDA)
-               padapter->pwrctrlpriv.smart_ps = 0;
-       else
-               padapter->pwrctrlpriv.smart_ps = padapter->registrypriv.smart_ps;
-
-       pcmd->cmdsz = get_wlan_bssid_ex_sz(psecnetwork);/* get cmdsz before endian conversion */
-
-       INIT_LIST_HEAD(&pcmd->list);
-       pcmd->cmdcode = _JoinBss_CMD_;/* GEN_CMD_CODE(_JoinBss) */
-       pcmd->parmbuf = (unsigned char *)psecnetwork;
-       pcmd->rsp = NULL;
-       pcmd->rspsz = 0;
-
-       res = rtw_enqueue_cmd(pcmdpriv, pcmd);
-
-exit:
-
-       return res;
-}
-
-u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue) /* for sta_mode */
-{
-       struct cmd_obj *cmdobj = NULL;
-       struct disconnect_parm *param = NULL;
-       struct cmd_priv *cmdpriv = &padapter->cmdpriv;
-       u8 res = _SUCCESS;
-
-       /* prepare cmd parameter */
-       param = kzalloc(sizeof(*param), GFP_ATOMIC);
-       if (!param) {
-               res = _FAIL;
-               goto exit;
-       }
-       param->deauth_timeout_ms = deauth_timeout_ms;
-
-       if (enqueue) {
-               /* need enqueue, prepare cmd_obj and enqueue */
-               cmdobj = kzalloc(sizeof(*cmdobj), GFP_ATOMIC);
-               if (!cmdobj) {
-                       res = _FAIL;
-                       kfree(param);
-                       goto exit;
-               }
-               init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
-               res = rtw_enqueue_cmd(cmdpriv, cmdobj);
-       } else {
-               /* no need to enqueue, do the cmd hdl directly and free cmd parameter */
-               if (disconnect_hdl(padapter, (u8 *)param) != H2C_SUCCESS)
-                       res = _FAIL;
-               kfree(param);
-       }
-
-exit:
-
-       return res;
-}
-
-u8 rtw_setopmode_cmd(struct adapter  *padapter, enum ndis_802_11_network_infra networktype)
-{
-       struct  cmd_obj *ph2c;
-       struct  setopmode_parm *psetop;
-
-       struct  cmd_priv   *pcmdpriv = &padapter->cmdpriv;
-       u8      res = _SUCCESS;
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_KERNEL);
-       if (!ph2c) {
-               res = false;
-               goto exit;
-       }
-       psetop = kzalloc(sizeof(*psetop), GFP_KERNEL);
-
-       if (!psetop) {
-               kfree(ph2c);
-               res = false;
-               goto exit;
-       }
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_);
-       psetop->mode = (u8)networktype;
-
-       res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-
-exit:
-
-       return res;
-}
-
-u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key)
-{
-       struct cmd_obj *ph2c;
-       struct set_stakey_parm *psetstakey_para;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       struct set_stakey_rsp *psetstakey_rsp = NULL;
-
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct sta_info *sta = (struct sta_info *)psta;
-       u8      res = _SUCCESS;
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_KERNEL);
-       if (!ph2c) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       psetstakey_para = kzalloc(sizeof(*psetstakey_para), GFP_KERNEL);
-       if (!psetstakey_para) {
-               kfree(ph2c);
-               res = _FAIL;
-               goto exit;
-       }
-
-       psetstakey_rsp = kzalloc(sizeof(*psetstakey_rsp), GFP_KERNEL);
-       if (!psetstakey_rsp) {
-               kfree(ph2c);
-               kfree(psetstakey_para);
-               res = _FAIL;
-               goto exit;
-       }
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_);
-       ph2c->rsp = (u8 *)psetstakey_rsp;
-       ph2c->rspsz = sizeof(struct set_stakey_rsp);
-
-       memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN);
-
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
-               psetstakey_para->algorithm = (unsigned char)psecuritypriv->dot11PrivacyAlgrthm;
-       else
-               GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false);
-
-       if (unicast_key)
-               memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16);
-       else
-               memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16);
-
-       /* jeff: set this because at least sw key is ready */
-       padapter->securitypriv.busetkipkey = true;
-
-       res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-
-exit:
-
-       return res;
-}
-
-u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue)
-{
-       struct cmd_obj *ph2c;
-       struct set_stakey_parm  *psetstakey_para;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       struct set_stakey_rsp *psetstakey_rsp = NULL;
-       struct sta_info *sta = (struct sta_info *)psta;
-       u8      res = _SUCCESS;
-
-       if (!enqueue) {
-               clear_cam_entry(padapter, entry);
-       } else {
-               ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-               if (!ph2c) {
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               psetstakey_para = kzalloc(sizeof(*psetstakey_para),
-                                         GFP_ATOMIC);
-               if (!psetstakey_para) {
-                       kfree(ph2c);
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               psetstakey_rsp = kzalloc(sizeof(*psetstakey_rsp),
-                                        GFP_ATOMIC);
-               if (!psetstakey_rsp) {
-                       kfree(ph2c);
-                       kfree(psetstakey_para);
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_);
-               ph2c->rsp = (u8 *)psetstakey_rsp;
-               ph2c->rspsz = sizeof(struct set_stakey_rsp);
-
-               memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN);
-
-               psetstakey_para->algorithm = _NO_PRIVACY_;
-
-               psetstakey_para->id = entry;
-
-               res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-       }
-exit:
-
-       return res;
-}
-
-u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
-{
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       struct cmd_obj *ph2c;
-       struct addBaReq_parm *paddbareq_parm;
-       u8      res = _SUCCESS;
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-       if (!ph2c) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       paddbareq_parm = kzalloc(sizeof(*paddbareq_parm), GFP_ATOMIC);
-       if (!paddbareq_parm) {
-               kfree(ph2c);
-               res = _FAIL;
-               goto exit;
-       }
-
-       paddbareq_parm->tid = tid;
-       memcpy(paddbareq_parm->addr, addr, ETH_ALEN);
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, GEN_CMD_CODE(_AddBAReq));
-
-       /* rtw_enqueue_cmd(pcmdpriv, ph2c); */
-       res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-
-exit:
-
-       return res;
-}
-
-u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
-{
-       struct cmd_obj *ph2c;
-       struct drvextra_cmd_parm *pdrvextra_cmd_parm;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       u8      res = _SUCCESS;
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-       if (!ph2c) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC);
-       if (!pdrvextra_cmd_parm) {
-               kfree(ph2c);
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm->ec_id = DYNAMIC_CHK_WK_CID;
-       pdrvextra_cmd_parm->type_size = 0;
-       pdrvextra_cmd_parm->pbuf = (u8 *)padapter;
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
-
-       /* rtw_enqueue_cmd(pcmdpriv, ph2c); */
-       res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-exit:
-
-       return res;
-}
-
-u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan)
-{
-       struct  cmd_obj *pcmdobj;
-       struct  SetChannelPlan_param *setChannelPlan_param;
-       struct  cmd_priv   *pcmdpriv = &padapter->cmdpriv;
-
-       u8      res = _SUCCESS;
-
-       /* check input parameter */
-       if (!rtw_is_channel_plan_valid(chplan)) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       /* prepare cmd parameter */
-       setChannelPlan_param = kzalloc(sizeof(*setChannelPlan_param),
-                                      GFP_KERNEL);
-       if (!setChannelPlan_param) {
-               res = _FAIL;
-               goto exit;
-       }
-       setChannelPlan_param->channel_plan = chplan;
-
-       /* need enqueue, prepare cmd_obj and enqueue */
-       pcmdobj = kzalloc(sizeof(*pcmdobj), GFP_KERNEL);
-       if (!pcmdobj) {
-               kfree(setChannelPlan_param);
-               res = _FAIL;
-               goto exit;
-       }
-
-       init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelPlan_param, GEN_CMD_CODE(_SetChannelPlan));
-       res = rtw_enqueue_cmd(pcmdpriv, pcmdobj);
-
-       /* do something based on res... */
-       if (res == _SUCCESS)
-               padapter->mlmepriv.ChannelPlan = chplan;
-
-exit:
-
-       return res;
-}
-
-static void traffic_status_watchdog(struct adapter *padapter)
-{
-       u8      bEnterPS;
-       u8      bBusyTraffic = false, bTxBusyTraffic = false, bRxBusyTraffic = false;
-       u8      bHigherBusyTraffic = false, bHigherBusyRxTraffic = false, bHigherBusyTxTraffic = false;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-
-       /*  */
-       /*  Determine if our traffic is busy now */
-       /*  */
-       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-               if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 100 ||
-                   pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 100) {
-                       bBusyTraffic = true;
-
-                       if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > pmlmepriv->LinkDetectInfo.NumTxOkInPeriod)
-                               bRxBusyTraffic = true;
-                       else
-                               bTxBusyTraffic = true;
-               }
-
-               /*  Higher Tx/Rx data. */
-               if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 4000 ||
-                   pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 4000) {
-                       bHigherBusyTraffic = true;
-
-                       if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > pmlmepriv->LinkDetectInfo.NumTxOkInPeriod)
-                               bHigherBusyRxTraffic = true;
-                       else
-                               bHigherBusyTxTraffic = true;
-               }
-
-               /*  check traffic for  powersaving. */
-               if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
-                   (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2))
-                       bEnterPS = false;
-               else
-                       bEnterPS = true;
-
-               /*  LeisurePS only work in infra mode. */
-               if (bEnterPS)
-                       LPS_Enter(padapter);
-               else
-                       LPS_Leave(padapter);
-       } else {
-               LPS_Leave(padapter);
-       }
-
-       pmlmepriv->LinkDetectInfo.NumRxOkInPeriod = 0;
-       pmlmepriv->LinkDetectInfo.NumTxOkInPeriod = 0;
-       pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod = 0;
-       pmlmepriv->LinkDetectInfo.bBusyTraffic = bBusyTraffic;
-       pmlmepriv->LinkDetectInfo.bTxBusyTraffic = bTxBusyTraffic;
-       pmlmepriv->LinkDetectInfo.bRxBusyTraffic = bRxBusyTraffic;
-       pmlmepriv->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic;
-       pmlmepriv->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic;
-       pmlmepriv->LinkDetectInfo.bHigherBusyTxTraffic = bHigherBusyTxTraffic;
-}
-
-static void rtl8188e_sreset_xmit_status_check(struct adapter *padapter)
-{
-       u32 txdma_status;
-       int res;
-
-       res = rtw_read32(padapter, REG_TXDMA_STATUS, &txdma_status);
-       if (res)
-               return;
-
-       if (txdma_status != 0x00)
-               rtw_write32(padapter, REG_TXDMA_STATUS, txdma_status);
-       /* total xmit irp = 4 */
-}
-
-static void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf)
-{
-       struct mlme_priv *pmlmepriv;
-
-       padapter = (struct adapter *)pbuf;
-       pmlmepriv = &padapter->mlmepriv;
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
-               expire_timeout_chk(padapter);
-
-       rtl8188e_sreset_xmit_status_check(padapter);
-
-       linked_status_chk(padapter);
-       traffic_status_watchdog(padapter);
-
-       rtl8188e_HalDmWatchDog(padapter);
-}
-
-static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
-{
-       struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       u8      mstatus;
-
-       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
-           check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))
-               return;
-
-       switch (lps_ctrl_type) {
-       case LPS_CTRL_SCAN:
-               if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-                       /* connect */
-                       LPS_Leave(padapter);
-               }
-               break;
-       case LPS_CTRL_JOINBSS:
-               LPS_Leave(padapter);
-               break;
-       case LPS_CTRL_CONNECT:
-               mstatus = 1;/* connect */
-               /*  Reset LPS Setting */
-               padapter->pwrctrlpriv.LpsIdleCount = 0;
-               rtl8188e_set_FwJoinBssReport_cmd(padapter, mstatus);
-               break;
-       case LPS_CTRL_DISCONNECT:
-               mstatus = 0;/* disconnect */
-               LPS_Leave(padapter);
-               rtl8188e_set_FwJoinBssReport_cmd(padapter, mstatus);
-               break;
-       case LPS_CTRL_SPECIAL_PACKET:
-               pwrpriv->DelayLPSLastTimeStamp = jiffies;
-               LPS_Leave(padapter);
-               break;
-       case LPS_CTRL_LEAVE:
-               LPS_Leave(padapter);
-               break;
-       default:
-               break;
-       }
-
-}
-
-u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
-{
-       struct cmd_obj  *ph2c;
-       struct drvextra_cmd_parm        *pdrvextra_cmd_parm;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       /* struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; */
-       u8      res = _SUCCESS;
-
-       /* if (!pwrctrlpriv->bLeisurePs) */
-       /*      return res; */
-
-       if (enqueue) {
-               ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-               if (!ph2c) {
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm),
-                                            GFP_ATOMIC);
-               if (!pdrvextra_cmd_parm) {
-                       kfree(ph2c);
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               pdrvextra_cmd_parm->ec_id = LPS_CTRL_WK_CID;
-               pdrvextra_cmd_parm->type_size = lps_ctrl_type;
-               pdrvextra_cmd_parm->pbuf = NULL;
-
-               init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
-
-               res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-       } else {
-               lps_ctrl_wk_hdl(padapter, lps_ctrl_type);
-       }
-
-exit:
-
-       return res;
-}
-
-static void rpt_timer_setting_wk_hdl(struct adapter *padapter, u16 min_time)
-{
-       struct hal_data_8188e *haldata = &padapter->haldata;
-       struct odm_dm_struct *odmpriv = &haldata->odmpriv;
-
-       ODM_RA_Set_TxRPT_Time(odmpriv, min_time);
-}
-
-u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time)
-{
-       struct cmd_obj          *ph2c;
-       struct drvextra_cmd_parm        *pdrvextra_cmd_parm;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-
-       u8      res = _SUCCESS;
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-       if (!ph2c) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm),
-                                    GFP_ATOMIC);
-       if (!pdrvextra_cmd_parm) {
-               kfree(ph2c);
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm->ec_id = RTP_TIMER_CFG_WK_CID;
-       pdrvextra_cmd_parm->type_size = min_time;
-       pdrvextra_cmd_parm->pbuf = NULL;
-       init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
-       res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-exit:
-
-       return res;
-}
-
-static void antenna_select_wk_hdl(struct adapter *padapter, u8 antenna)
-{
-       struct hal_data_8188e *haldata = &padapter->haldata;
-
-       /* switch current antenna to optimum antenna */
-       if (haldata->CurAntenna != antenna) {
-               ODM_UpdateRxIdleAnt_88E(&haldata->odmpriv, antenna == 2 ? MAIN_ANT : AUX_ANT);
-               haldata->CurAntenna = antenna;
-       }
-}
-
-static bool rtw_antenna_diversity(struct adapter *adapter)
-{
-       struct hal_data_8188e *haldata = &adapter->haldata;
-
-       return haldata->AntDivCfg != 0;
-}
-
-u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue)
-{
-       struct cmd_obj          *ph2c;
-       struct drvextra_cmd_parm        *pdrvextra_cmd_parm;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       u8      res = _SUCCESS;
-
-       if (!rtw_antenna_diversity(padapter))
-               return res;
-
-       if (enqueue) {
-               ph2c = kzalloc(sizeof(*ph2c), GFP_KERNEL);
-               if (!ph2c) {
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm),
-                                            GFP_KERNEL);
-               if (!pdrvextra_cmd_parm) {
-                       kfree(ph2c);
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               pdrvextra_cmd_parm->ec_id = ANT_SELECT_WK_CID;
-               pdrvextra_cmd_parm->type_size = antenna;
-               pdrvextra_cmd_parm->pbuf = NULL;
-               init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
-
-               res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-       } else {
-               antenna_select_wk_hdl(padapter, antenna);
-       }
-exit:
-
-       return res;
-}
-
-u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType)
-{
-       struct cmd_obj  *ph2c;
-       struct drvextra_cmd_parm        *pdrvextra_cmd_parm;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       u8      res = _SUCCESS;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return res;
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-       if (!ph2c) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC);
-       if (!pdrvextra_cmd_parm) {
-               kfree(ph2c);
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm->ec_id = P2P_PROTO_WK_CID;
-       pdrvextra_cmd_parm->type_size = intCmdType;     /*      As the command type. */
-       pdrvextra_cmd_parm->pbuf = NULL;                /*      Must be NULL here */
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
-
-       res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-
-exit:
-
-       return res;
-}
-
-u8 rtw_ps_cmd(struct adapter *padapter)
-{
-       struct cmd_obj          *ppscmd;
-       struct drvextra_cmd_parm        *pdrvextra_cmd_parm;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-
-       u8      res = _SUCCESS;
-
-       ppscmd = kzalloc(sizeof(*ppscmd), GFP_ATOMIC);
-       if (!ppscmd) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC);
-       if (!pdrvextra_cmd_parm) {
-               kfree(ppscmd);
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm->ec_id = POWER_SAVING_CTRL_WK_CID;
-       pdrvextra_cmd_parm->pbuf = NULL;
-       init_h2fwcmd_w_parm_no_rsp(ppscmd, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
-
-       res = rtw_enqueue_cmd(pcmdpriv, ppscmd);
-
-exit:
-
-       return res;
-}
-
-static bool rtw_is_hi_queue_empty(struct adapter *adapter)
-{
-       int res;
-       u32 reg;
-
-       res = rtw_read32(adapter, REG_HGQ_INFORMATION, &reg);
-       if (res)
-               return false;
-
-       return (reg & 0x0000ff00) == 0;
-}
-
-static void rtw_chk_hi_queue_hdl(struct adapter *padapter)
-{
-       int cnt = 0;
-       struct sta_info *psta_bmc;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       psta_bmc = rtw_get_bcmc_stainfo(padapter);
-       if (!psta_bmc)
-               return;
-
-       if (psta_bmc->sleepq_len == 0) {
-               bool val = rtw_is_hi_queue_empty(padapter);
-
-               while (!val) {
-                       msleep(100);
-
-                       cnt++;
-
-                       if (cnt > 10)
-                               break;
-
-                       val = rtw_is_hi_queue_empty(padapter);
-               }
-
-               if (cnt <= 10) {
-                       pstapriv->tim_bitmap &= ~BIT(0);
-                       pstapriv->sta_dz_bitmap &= ~BIT(0);
-
-                       update_beacon(padapter, _TIM_IE_, NULL, false);
-               } else { /* re check again */
-                       rtw_chk_hi_queue_cmd(padapter);
-               }
-       }
-}
-
-void rtw_chk_hi_queue_cmd(struct adapter *padapter)
-{
-       struct cmd_obj  *ph2c;
-       struct drvextra_cmd_parm        *pdrvextra_cmd_parm;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-       if (!ph2c)
-               return;
-
-       pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC);
-       if (!pdrvextra_cmd_parm) {
-               kfree(ph2c);
-               return;
-       }
-
-       pdrvextra_cmd_parm->ec_id = CHECK_HIQ_WK_CID;
-       pdrvextra_cmd_parm->type_size = 0;
-       pdrvextra_cmd_parm->pbuf = NULL;
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
-
-       rtw_enqueue_cmd(pcmdpriv, ph2c);
-}
-
-u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt)
-{
-       struct cmd_obj *ph2c;
-       struct drvextra_cmd_parm *pdrvextra_cmd_parm;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       u8      res = _SUCCESS;
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-       if (!ph2c) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC);
-       if (!pdrvextra_cmd_parm) {
-               kfree(ph2c);
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm->ec_id = C2H_WK_CID;
-       pdrvextra_cmd_parm->type_size = c2h_evt ? 16 : 0;
-       pdrvextra_cmd_parm->pbuf = c2h_evt;
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
-
-       res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-
-exit:
-
-       return res;
-}
-
-/* C2H event format:
- * Field    TRIGGER      CONTENT     CMD_SEQ    CMD_LEN    CMD_ID
- * BITS     [127:120]    [119:16]    [15:8]     [7:4]      [3:0]
- */
-static s32 c2h_evt_read(struct adapter *adapter, u8 *buf)
-{
-       s32 ret = _FAIL;
-       struct c2h_evt_hdr *c2h_evt;
-       int i;
-       u8 trigger;
-
-       if (!buf)
-               goto exit;
-
-       ret = rtw_read8(adapter, REG_C2HEVT_CLEAR, &trigger);
-       if (ret)
-               return _FAIL;
-
-       if (trigger == C2H_EVT_HOST_CLOSE)
-               goto exit; /* Not ready */
-       else if (trigger != C2H_EVT_FW_CLOSE)
-               goto clear_evt; /* Not a valid value */
-
-       c2h_evt = (struct c2h_evt_hdr *)buf;
-
-       memset(c2h_evt, 0, 16);
-
-       ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL, buf);
-       if (ret) {
-               ret = _FAIL;
-               goto clear_evt;
-       }
-
-       ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1, buf + 1);
-       if (ret) {
-               ret = _FAIL;
-               goto clear_evt;
-       }
-       /* Read the content */
-       for (i = 0; i < c2h_evt->plen; i++) {
-               ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL +
-                               sizeof(*c2h_evt) + i, c2h_evt->payload + i);
-               if (ret) {
-                       ret = _FAIL;
-                       goto clear_evt;
-               }
-       }
-
-       ret = _SUCCESS;
-
-clear_evt:
-       /* Clear event to notify FW we have read the command.
-        * If this field isn't clear, the FW won't update the next
-        * command message.
-        */
-       rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE);
-exit:
-       return ret;
-}
-
-static void c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter)
-{
-       u8 buf[16];
-
-       if (!c2h_evt)
-               c2h_evt_read(adapter, buf);
-}
-
-static void c2h_wk_callback(struct work_struct *work)
-{
-       struct evt_priv *evtpriv = container_of(work, struct evt_priv, c2h_wk);
-       struct adapter *adapter = container_of(evtpriv, struct adapter, evtpriv);
-       struct c2h_evt_hdr *c2h_evt;
-
-       evtpriv->c2h_wk_alive = true;
-
-       while (!rtw_cbuf_empty(evtpriv->c2h_queue)) {
-               c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue);
-               if (c2h_evt) {
-                       /* This C2H event is read, clear it */
-                       rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE);
-               } else {
-                       c2h_evt = kmalloc(16, GFP_KERNEL);
-                       if (c2h_evt) {
-                               /* This C2H event is not read, read & clear now */
-                               if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) {
-                                       kfree(c2h_evt);
-                                       continue;
-                               }
-                       } else {
-                               return;
-                       }
-               }
-
-               /* Special pointer to trigger c2h_evt_clear only */
-               if ((void *)c2h_evt == (void *)evtpriv)
-                       continue;
-
-               if (!c2h_evt_exist(c2h_evt)) {
-                       kfree(c2h_evt);
-                       continue;
-               }
-
-               /* Enqueue into cmd_thread for others */
-               rtw_c2h_wk_cmd(adapter, (u8 *)c2h_evt);
-       }
-
-       evtpriv->c2h_wk_alive = false;
-}
-
-u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       struct drvextra_cmd_parm *pdrvextra_cmd;
-
-       if (!pbuf)
-               return H2C_PARAMETERS_ERROR;
-
-       pdrvextra_cmd = (struct drvextra_cmd_parm *)pbuf;
-
-       switch (pdrvextra_cmd->ec_id) {
-       case DYNAMIC_CHK_WK_CID:
-               dynamic_chk_wk_hdl(padapter, pdrvextra_cmd->pbuf);
-               break;
-       case POWER_SAVING_CTRL_WK_CID:
-               rtw_ps_processor(padapter);
-               break;
-       case LPS_CTRL_WK_CID:
-               lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size);
-               break;
-       case RTP_TIMER_CFG_WK_CID:
-               rpt_timer_setting_wk_hdl(padapter, pdrvextra_cmd->type_size);
-               break;
-       case ANT_SELECT_WK_CID:
-               antenna_select_wk_hdl(padapter, pdrvextra_cmd->type_size);
-               break;
-       case P2P_PS_WK_CID:
-               p2p_ps_wk_hdl(padapter, pdrvextra_cmd->type_size);
-               break;
-       case P2P_PROTO_WK_CID:
-               /*      Commented by Albert 2011/07/01 */
-               /*      I used the type_size as the type command */
-               p2p_protocol_wk_hdl(padapter, pdrvextra_cmd->type_size);
-               break;
-       case CHECK_HIQ_WK_CID:
-               rtw_chk_hi_queue_hdl(padapter);
-               break;
-       case C2H_WK_CID:
-               c2h_evt_hdl(padapter, (struct c2h_evt_hdr *)pdrvextra_cmd->pbuf, NULL);
-               break;
-       default:
-               break;
-       }
-
-       if (pdrvextra_cmd->pbuf && pdrvextra_cmd->type_size > 0)
-               kfree(pdrvextra_cmd->pbuf);
-
-       return H2C_SUCCESS;
-}
-
-void rtw_survey_cmd_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
-{
-       struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       if (pcmd->res != H2C_SUCCESS) {
-               /* TODO: cancel timer and do timeout handler directly... */
-               _set_timer(&pmlmepriv->scan_to_timer, 1);
-       }
-
-       /*  free cmd */
-       rtw_free_cmd_obj(pcmd);
-
-}
-
-void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
-{
-       struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       if (pcmd->res != H2C_SUCCESS) {
-               spin_lock_bh(&pmlmepriv->lock);
-               set_fwstate(pmlmepriv, _FW_LINKED);
-               spin_unlock_bh(&pmlmepriv->lock);
-
-               return;
-       }
-
-       /* clear bridge database */
-       nat25_db_cleanup(padapter);
-
-       /*  free cmd */
-       rtw_free_cmd_obj(pcmd);
-}
-
-void rtw_joinbss_cmd_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
-{
-       struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       if (pcmd->res != H2C_SUCCESS) {
-               /* TODO: cancel timer and do timeout handler directly... */
-               _set_timer(&pmlmepriv->assoc_timer, 1);
-       }
-
-       rtw_free_cmd_obj(pcmd);
-}
-
-void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
-{
-       struct sta_info *psta = NULL;
-       struct wlan_network *pwlan = NULL;
-       struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf;
-       struct wlan_network *tgt_network = &pmlmepriv->cur_network;
-
-       if (pcmd->res != H2C_SUCCESS)
-               _set_timer(&pmlmepriv->assoc_timer, 1);
-
-       del_timer_sync(&pmlmepriv->assoc_timer);
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress);
-               if (!psta) {
-                       psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress);
-                       if (!psta)
-                               goto createbss_cmd_fail;
-               }
-
-               rtw_indicate_connect(padapter);
-       } else {
-
-               pwlan = rtw_alloc_network(pmlmepriv);
-               spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-               if (!pwlan) {
-                       pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue);
-                       if (!pwlan) {
-                               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-                               goto createbss_cmd_fail;
-                       }
-                       pwlan->last_scanned = jiffies;
-               } else {
-                       list_add_tail(&pwlan->list, &pmlmepriv->scanned_queue.queue);
-               }
-
-               pnetwork->Length = get_wlan_bssid_ex_sz(pnetwork);
-               memcpy(&pwlan->network, pnetwork, pnetwork->Length);
-
-               memcpy(&tgt_network->network, pnetwork, (get_wlan_bssid_ex_sz(pnetwork)));
-
-               _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
-
-               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-               /*  we will set _FW_LINKED when there is one more sat to join us (rtw_stassoc_event_callback) */
-       }
-
-createbss_cmd_fail:
-
-       spin_unlock_bh(&pmlmepriv->lock);
-
-       rtw_free_cmd_obj(pcmd);
-
-}
-
-void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
-{
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *)(pcmd->rsp);
-       struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr);
-
-       if (!psta)
-               goto exit;
-exit:
-       rtw_free_cmd_obj(pcmd);
-
-}
-
-void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
-{
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct set_assocsta_parm *passocsta_parm = (struct set_assocsta_parm *)(pcmd->parmbuf);
-       struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *)(pcmd->rsp);
-       struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr);
-
-       if (!psta)
-               goto exit;
-
-       psta->aid = passocsta_rsp->cam_id;
-       psta->mac_id = passocsta_rsp->cam_id;
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
-               _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
-
-       set_fwstate(pmlmepriv, _FW_LINKED);
-       spin_unlock_bh(&pmlmepriv->lock);
-
-exit:
-       rtw_free_cmd_obj(pcmd);
-
-}
diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c
deleted file mode 100644 (file)
index df9534d..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _RTW_EFUSE_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/rtw_efuse.h"
-#include "../include/rtl8188e_hal.h"
-
-/*  */
-/*     Description: */
-/*             Execute E-Fuse read byte operation. */
-/*             Referred from SD1 Richard. */
-/*  */
-/*     Assumption: */
-/*             1. Boot from E-Fuse and successfully auto-load. */
-/*             2. PASSIVE_LEVEL (USB interface) */
-/*  */
-/*     Created by Roger, 2008.10.21. */
-/*  */
-void
-ReadEFuseByte(
-               struct adapter *Adapter,
-               u16 _offset,
-               u8 *pbuf)
-{
-       u32 value32;
-       u8 readbyte;
-       u16 retry;
-       int res;
-
-       /* Write Address */
-       rtw_write8(Adapter, EFUSE_CTRL + 1, (_offset & 0xff));
-       res = rtw_read8(Adapter, EFUSE_CTRL + 2, &readbyte);
-       if (res)
-               return;
-
-       rtw_write8(Adapter, EFUSE_CTRL + 2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc));
-
-       /* Write bit 32 0 */
-       res = rtw_read8(Adapter, EFUSE_CTRL + 3, &readbyte);
-       if (res)
-               return;
-
-       rtw_write8(Adapter, EFUSE_CTRL + 3, (readbyte & 0x7f));
-
-       /* Check bit 32 read-ready */
-       res = rtw_read32(Adapter, EFUSE_CTRL, &value32);
-       if (res)
-               return;
-
-       for (retry = 0; retry < 10000; retry++) {
-               res = rtw_read32(Adapter, EFUSE_CTRL, &value32);
-               if (res)
-                       continue;
-
-               if (((value32 >> 24) & 0xff) & 0x80)
-                       break;
-       }
-
-       /*  20100205 Joseph: Add delay suggested by SD1 Victor. */
-       /*  This fix the problem that Efuse read error in high temperature condition. */
-       /*  Designer says that there shall be some delay after ready bit is set, or the */
-       /*  result will always stay on last data we read. */
-       udelay(50);
-       res = rtw_read32(Adapter, EFUSE_CTRL, &value32);
-       if (res)
-               return;
-
-       *pbuf = (u8)(value32 & 0xff);
-
-       /* FIXME: return an error to caller */
-}
diff --git a/drivers/staging/r8188eu/core/rtw_fw.c b/drivers/staging/r8188eu/core/rtw_fw.c
deleted file mode 100644 (file)
index 1e4baf7..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include <linux/firmware.h>
-#include "../include/rtw_fw.h"
-
-#define MAX_REG_BLOCK_SIZE     196
-#define FW_8188E_START_ADDRESS 0x1000
-#define MAX_PAGE_SIZE          4096
-
-#define IS_FW_HEADER_EXIST(_fwhdr)                             \
-       ((le16_to_cpu(_fwhdr->signature) & 0xFFF0) == 0x92C0 || \
-       (le16_to_cpu(_fwhdr->signature) & 0xFFF0) == 0x88C0 ||  \
-       (le16_to_cpu(_fwhdr->signature) & 0xFFF0) == 0x2300 ||  \
-       (le16_to_cpu(_fwhdr->signature) & 0xFFF0) == 0x88E0)
-
-struct rt_firmware_hdr {
-       __le16  signature;      /* 92C0: test chip; 92C,
-                                * 88C0: test chip; 88C1: MP A-cut;
-                                * 92C1: MP A-cut */
-       u8      category;       /* AP/NIC and USB/PCI */
-       u8      function;       /* Reserved for different FW function
-                                * indcation, for further use when
-                                * driver needs to download different
-                                * FW for different conditions */
-       __le16  version;        /* FW Version */
-       u8      subversion;     /* FW Subversion, default 0x00 */
-       u8      rsvd1;
-       u8      month;          /* Release time Month field */
-       u8      date;           /* Release time Date field */
-       u8      hour;           /* Release time Hour field */
-       u8      minute;         /* Release time Minute field */
-       __le16  ramcodesize;    /* The size of RAM code */
-       u8      foundry;
-       u8      rsvd2;
-       __le32  svnidx;         /* The SVN entry index */
-       __le32  rsvd3;
-       __le32  rsvd4;
-       __le32  rsvd5;
-};
-
-static_assert(sizeof(struct rt_firmware_hdr) == 32);
-
-static void fw_download_enable(struct adapter *padapter, bool enable)
-{
-       u8 tmp;
-       int res;
-
-       if (enable) {
-               /*  MCU firmware download enable. */
-               res = rtw_read8(padapter, REG_MCUFWDL, &tmp);
-               if (res)
-                       return;
-
-               rtw_write8(padapter, REG_MCUFWDL, tmp | 0x01);
-
-               /*  8051 reset */
-               res = rtw_read8(padapter, REG_MCUFWDL + 2, &tmp);
-               if (res)
-                       return;
-
-               rtw_write8(padapter, REG_MCUFWDL + 2, tmp & 0xf7);
-       } else {
-               /*  MCU firmware download disable. */
-               res = rtw_read8(padapter, REG_MCUFWDL, &tmp);
-               if (res)
-                       return;
-
-               rtw_write8(padapter, REG_MCUFWDL, tmp & 0xfe);
-
-               /*  Reserved for fw extension. */
-               rtw_write8(padapter, REG_MCUFWDL + 1, 0x00);
-       }
-}
-
-static int block_write(struct adapter *padapter, u8 *buffer, u32 size)
-{
-       int ret = _SUCCESS;
-       u32 blocks, block_size, remain;
-       u32 i, offset, addr;
-       u8 *data;
-
-       block_size = MAX_REG_BLOCK_SIZE;
-
-       blocks = size / block_size;
-       remain = size % block_size;
-
-       for (i = 0; i < blocks; i++) {
-               addr = FW_8188E_START_ADDRESS + i * block_size;
-               data = buffer + i * block_size;
-
-               if (rtw_writeN(padapter, addr, block_size, data))
-                       return _FAIL;
-       }
-
-       if (remain) {
-               offset = blocks * block_size;
-               block_size = 8;
-
-               blocks = remain / block_size;
-               remain = remain % block_size;
-
-               for (i = 0; i < blocks; i++) {
-                       addr = FW_8188E_START_ADDRESS + offset + i * block_size;
-                       data = buffer + offset + i * block_size;
-
-                       if (rtw_writeN(padapter, addr, block_size, data))
-                               return _FAIL;
-               }
-       }
-
-       if (remain) {
-               offset += blocks * block_size;
-
-               /* block size 1 */
-               blocks = remain;
-
-               for (i = 0; i < blocks; i++) {
-                       addr = FW_8188E_START_ADDRESS + offset + i;
-                       data = buffer + offset + i;
-
-                       ret = rtw_write8(padapter, addr, *data);
-                       if (ret == _FAIL)
-                               goto exit;
-               }
-       }
-
-exit:
-       return ret;
-}
-
-static int page_write(struct adapter *padapter, u32 page, u8 *buffer, u32 size)
-{
-       u8 value8;
-       u8 u8Page = (u8)(page & 0x07);
-       int res;
-
-       res = rtw_read8(padapter, REG_MCUFWDL + 2, &value8);
-       if (res)
-               return _FAIL;
-
-       value8 = (value8 & 0xF8) | u8Page;
-       rtw_write8(padapter, REG_MCUFWDL + 2, value8);
-
-       return block_write(padapter, buffer, size);
-}
-
-static int write_fw(struct adapter *padapter, u8 *buffer, u32 size)
-{
-       /*  Since we need dynamic decide method of dwonload fw, so we call this function to get chip version. */
-       /*  We can remove _ReadChipVersion from ReadpadapterInfo8192C later. */
-       int ret = _SUCCESS;
-       u32     pageNums, remainSize;
-       u32     page, offset;
-
-       pageNums = size / MAX_PAGE_SIZE;
-       remainSize = size % MAX_PAGE_SIZE;
-
-       for (page = 0; page < pageNums; page++) {
-               offset = page * MAX_PAGE_SIZE;
-               ret = page_write(padapter, page, buffer + offset, MAX_PAGE_SIZE);
-
-               if (ret == _FAIL)
-                       goto exit;
-       }
-       if (remainSize) {
-               offset = pageNums * MAX_PAGE_SIZE;
-               page = pageNums;
-               ret = page_write(padapter, page, buffer + offset, remainSize);
-
-               if (ret == _FAIL)
-                       goto exit;
-       }
-exit:
-       return ret;
-}
-
-void rtw_reset_8051(struct adapter *padapter)
-{
-       u8 val8;
-       int res;
-
-       res = rtw_read8(padapter, REG_SYS_FUNC_EN + 1, &val8);
-       if (res)
-               return;
-
-       rtw_write8(padapter, REG_SYS_FUNC_EN + 1, val8 & (~BIT(2)));
-       rtw_write8(padapter, REG_SYS_FUNC_EN + 1, val8 | (BIT(2)));
-}
-
-static int fw_free_to_go(struct adapter *padapter)
-{
-       u32     counter = 0;
-       u32     value32;
-       int res;
-
-       /*  polling CheckSum report */
-       do {
-               res = rtw_read32(padapter, REG_MCUFWDL, &value32);
-               if (res)
-                       continue;
-
-               if (value32 & FWDL_CHKSUM_RPT)
-                       break;
-       } while (counter++ < POLLING_READY_TIMEOUT_COUNT);
-
-       if (counter >= POLLING_READY_TIMEOUT_COUNT)
-               return _FAIL;
-
-       res = rtw_read32(padapter, REG_MCUFWDL, &value32);
-       if (res)
-               return _FAIL;
-
-       value32 |= MCUFWDL_RDY;
-       value32 &= ~WINTINI_RDY;
-       rtw_write32(padapter, REG_MCUFWDL, value32);
-
-       rtw_reset_8051(padapter);
-
-       /*  polling for FW ready */
-       counter = 0;
-       do {
-               res = rtw_read32(padapter, REG_MCUFWDL, &value32);
-               if (!res && value32 & WINTINI_RDY)
-                       return _SUCCESS;
-
-               udelay(5);
-       } while (counter++ < POLLING_READY_TIMEOUT_COUNT);
-
-       return _FAIL;
-}
-
-static int load_firmware(struct rt_firmware *rtfw, struct device *device)
-{
-       int ret = _SUCCESS;
-       const struct firmware *fw;
-       const char *fw_name = FW_RTL8188EU;
-       int err = request_firmware(&fw, fw_name, device);
-
-       if (err) {
-               pr_err("Request firmware failed with error 0x%x\n", err);
-               ret = _FAIL;
-               goto exit;
-       }
-       if (!fw) {
-               pr_err("Firmware %s not available\n", fw_name);
-               ret = _FAIL;
-               goto exit;
-       }
-
-       rtfw->data = kmemdup(fw->data, fw->size, GFP_KERNEL);
-       if (!rtfw->data) {
-               pr_err("Failed to allocate rtfw->data\n");
-               ret = _FAIL;
-               goto exit;
-       }
-       rtfw->size = fw->size;
-
-exit:
-       release_firmware(fw);
-       return ret;
-}
-
-int rtl8188e_firmware_download(struct adapter *padapter)
-{
-       int ret = _SUCCESS;
-       u8 reg;
-       unsigned long fwdl_timeout;
-       struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
-       struct device *device = dvobj_to_dev(dvobj);
-       struct rt_firmware_hdr *fwhdr = NULL;
-       u8 *fw_data;
-       u32 fw_size;
-
-       if (!dvobj->firmware.data)
-               ret = load_firmware(&dvobj->firmware, device);
-       if (ret == _FAIL) {
-               dvobj->firmware.data = NULL;
-               goto exit;
-       }
-       fw_data = dvobj->firmware.data;
-       fw_size = dvobj->firmware.size;
-
-       fwhdr = (struct rt_firmware_hdr *)dvobj->firmware.data;
-
-       if (IS_FW_HEADER_EXIST(fwhdr)) {
-               dev_info_once(device, "Firmware Version %d, SubVersion %d, Signature 0x%x\n",
-                             le16_to_cpu(fwhdr->version), fwhdr->subversion,
-                             le16_to_cpu(fwhdr->signature));
-
-               fw_data = fw_data + sizeof(struct rt_firmware_hdr);
-               fw_size = fw_size - sizeof(struct rt_firmware_hdr);
-       }
-
-       /*  Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */
-       /*  or it will cause download Fw fail. 2010.02.01. by tynli. */
-       ret = rtw_read8(padapter, REG_MCUFWDL, &reg);
-       if (ret) {
-               ret = _FAIL;
-               goto exit;
-       }
-
-       if (reg & RAM_DL_SEL) { /* 8051 RAM code */
-               rtw_write8(padapter, REG_MCUFWDL, 0x00);
-               rtw_reset_8051(padapter);
-       }
-
-       fw_download_enable(padapter, true);
-       fwdl_timeout = jiffies + msecs_to_jiffies(500);
-       do {
-               /* reset the FWDL chksum */
-               ret = rtw_read8(padapter, REG_MCUFWDL, &reg);
-               if (ret) {
-                       ret = _FAIL;
-                       continue;
-               }
-
-               rtw_write8(padapter, REG_MCUFWDL, reg | FWDL_CHKSUM_RPT);
-
-               ret = write_fw(padapter, fw_data, fw_size);
-               if (ret == _SUCCESS)
-                       break;
-       } while (!time_after(jiffies, fwdl_timeout));
-
-       fw_download_enable(padapter, false);
-       if (ret != _SUCCESS)
-               goto exit;
-
-       ret = fw_free_to_go(padapter);
-       if (ret != _SUCCESS)
-               goto exit;
-
-exit:
-       return ret;
-}
diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c
deleted file mode 100644 (file)
index bc8543e..0000000
+++ /dev/null
@@ -1,1150 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _IEEE80211_C
-
-#include "../include/drv_types.h"
-#include "../include/ieee80211.h"
-#include "../include/wifi.h"
-#include "../include/osdep_service.h"
-#include "../include/wlan_bssdef.h"
-#include "../include/usb_osintf.h"
-
-u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 };
-u16 RTW_WPA_VERSION = 1;
-u8 WPA_AUTH_KEY_MGMT_NONE[] = { 0x00, 0x50, 0xf2, 0 };
-u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x50, 0xf2, 1 };
-u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x50, 0xf2, 2 };
-u8 WPA_CIPHER_SUITE_NONE[] = { 0x00, 0x50, 0xf2, 0 };
-u8 WPA_CIPHER_SUITE_WEP40[] = { 0x00, 0x50, 0xf2, 1 };
-u8 WPA_CIPHER_SUITE_TKIP[] = { 0x00, 0x50, 0xf2, 2 };
-u8 WPA_CIPHER_SUITE_WRAP[] = { 0x00, 0x50, 0xf2, 3 };
-u8 WPA_CIPHER_SUITE_CCMP[] = { 0x00, 0x50, 0xf2, 4 };
-u8 WPA_CIPHER_SUITE_WEP104[] = { 0x00, 0x50, 0xf2, 5 };
-
-u16 RSN_VERSION_BSD = 1;
-u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x0f, 0xac, 1 };
-u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x0f, 0xac, 2 };
-u8 RSN_CIPHER_SUITE_NONE[] = { 0x00, 0x0f, 0xac, 0 };
-u8 RSN_CIPHER_SUITE_WEP40[] = { 0x00, 0x0f, 0xac, 1 };
-u8 RSN_CIPHER_SUITE_TKIP[] = { 0x00, 0x0f, 0xac, 2 };
-u8 RSN_CIPHER_SUITE_WRAP[] = { 0x00, 0x0f, 0xac, 3 };
-u8 RSN_CIPHER_SUITE_CCMP[] = { 0x00, 0x0f, 0xac, 4 };
-u8 RSN_CIPHER_SUITE_WEP104[] = { 0x00, 0x0f, 0xac, 5 };
-/*  */
-/*  for adhoc-master to generate ie and provide supported-rate to fw */
-/*  */
-
-static u8      WIFI_CCKRATES[] = {
-       (IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK),
-       (IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK),
-       (IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK),
-       (IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK)
-       };
-
-static u8      WIFI_OFDMRATES[] = {
-        (IEEE80211_OFDM_RATE_6MB),
-        (IEEE80211_OFDM_RATE_9MB),
-        (IEEE80211_OFDM_RATE_12MB),
-        (IEEE80211_OFDM_RATE_18MB),
-        (IEEE80211_OFDM_RATE_24MB),
-        IEEE80211_OFDM_RATE_36MB,
-        IEEE80211_OFDM_RATE_48MB,
-        IEEE80211_OFDM_RATE_54MB
-       };
-
-int rtw_get_bit_value_from_ieee_value(u8 val)
-{
-       unsigned char dot11_rate_table[] = {
-               2, 4, 11, 22, 12, 18, 24, 36, 48,
-               72, 96, 108, 0}; /*  last element must be zero!! */
-
-       int i = 0;
-       while (dot11_rate_table[i] != 0) {
-               if (dot11_rate_table[i] == val)
-                       return BIT(i);
-               i++;
-       }
-       return 0;
-}
-
-bool   rtw_is_cckrates_included(u8 *rate)
-{
-       u32     i = 0;
-
-       while (rate[i] != 0) {
-               if  ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
-                    (((rate[i]) & 0x7f) == 11)  || (((rate[i]) & 0x7f) == 22))
-                       return true;
-               i++;
-       }
-       return false;
-}
-
-bool   rtw_is_cckratesonly_included(u8 *rate)
-{
-       u32 i = 0;
-
-       while (rate[i] != 0) {
-               if  ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
-                    (((rate[i]) & 0x7f) != 11)  && (((rate[i]) & 0x7f) != 22))
-                       return false;
-               i++;
-       }
-
-       return true;
-}
-
-int rtw_check_network_type(unsigned char *rate, int ratelen, int channel)
-{
-       if (channel > 14)
-               return WIRELESS_INVALID;
-       /*  could be pure B, pure G, or B/G */
-       if (rtw_is_cckratesonly_included(rate))
-               return WIRELESS_11B;
-       else if (rtw_is_cckrates_included(rate))
-               return  WIRELESS_11BG;
-       else
-               return WIRELESS_11G;
-}
-
-u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source,
-                               unsigned int *frlen)
-{
-       memcpy((void *)pbuf, (void *)source, len);
-       *frlen = *frlen + len;
-       return pbuf + len;
-}
-
-/*  rtw_set_ie will update frame length */
-u8 *rtw_set_ie
-(
-       u8 *pbuf,
-       int index,
-       uint len,
-       u8 *source,
-       uint *frlen /* frame length */
-)
-{
-
-       *pbuf = (u8)index;
-
-       *(pbuf + 1) = (u8)len;
-
-       if (len > 0)
-               memcpy((void *)(pbuf + 2), (void *)source, len);
-
-       *frlen = *frlen + (len + 2);
-
-       return pbuf + len + 2;
-}
-
-/*----------------------------------------------------------------------------
-index: the information element id index, limit is the limit for search
------------------------------------------------------------------------------*/
-u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit)
-{
-       int tmp, i;
-       u8 *p;
-
-       if (limit < 1) {
-
-               return NULL;
-       }
-
-       p = pbuf;
-       i = 0;
-       *len = 0;
-       while (1) {
-               if (*p == index) {
-                       *len = *(p + 1);
-                       return p;
-               }
-               tmp = *(p + 1);
-               p += (tmp + 2);
-               i += (tmp + 2);
-               if (i >= limit)
-                       break;
-       }
-
-       return NULL;
-}
-
-void rtw_set_supported_rate(u8 *SupportedRates, uint mode)
-{
-
-       memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX);
-
-       switch (mode) {
-       case WIRELESS_11B:
-               memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
-               break;
-       case WIRELESS_11G:
-               memcpy(SupportedRates, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN);
-               break;
-       case WIRELESS_11BG:
-       case WIRELESS_11G_24N:
-       case WIRELESS_11_24N:
-       case WIRELESS_11BG_24N:
-               memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
-               memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN);
-               break;
-       }
-
-}
-
-uint   rtw_get_rateset_len(u8  *rateset)
-{
-       uint i = 0;
-
-       while (1) {
-               if ((rateset[i]) == 0)
-                       break;
-               if (i > 12)
-                       break;
-               i++;
-       }
-
-       return i;
-}
-
-int rtw_generate_ie(struct registry_priv *pregistrypriv)
-{
-       u8      wireless_mode;
-       int     sz = 0, rateLen;
-       struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network;
-       u8 *ie = pdev_network->IEs;
-
-       /* timestamp will be inserted by hardware */
-       sz += 8;
-       ie += sz;
-
-       /* beacon interval : 2bytes */
-       *(__le16 *)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);/* BCN_INTERVAL; */
-       sz += 2;
-       ie += 2;
-
-       /* capability info */
-       *(u16 *)ie = 0;
-
-       *(__le16 *)ie |= cpu_to_le16(cap_IBSS);
-
-       if (pregistrypriv->preamble == PREAMBLE_SHORT)
-               *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble);
-
-       if (pdev_network->Privacy)
-               *(__le16 *)ie |= cpu_to_le16(cap_Privacy);
-
-       sz += 2;
-       ie += 2;
-
-       /* SSID */
-       ie = rtw_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength, pdev_network->Ssid.Ssid, &sz);
-
-       /* supported rates */
-       wireless_mode = pregistrypriv->wireless_mode;
-
-       rtw_set_supported_rate(pdev_network->SupportedRates, wireless_mode);
-
-       rateLen = rtw_get_rateset_len(pdev_network->SupportedRates);
-
-       if (rateLen > 8) {
-               ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, pdev_network->SupportedRates, &sz);
-               /* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */
-       } else {
-               ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, pdev_network->SupportedRates, &sz);
-       }
-
-       /* DS parameter set */
-       ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&pdev_network->Configuration.DSConfig, &sz);
-
-       /* IBSS Parameter Set */
-
-       ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&pdev_network->Configuration.ATIMWindow, &sz);
-
-       if (rateLen > 8)
-               ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz);
-
-       return sz;
-}
-
-unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
-{
-       int len;
-       u16 val16;
-       __le16 le_tmp;
-       unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01};
-       u8 *pbuf = pie;
-       int limit_new = limit;
-
-       while (1) {
-               pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new);
-
-               if (pbuf) {
-                       /* check if oui matches... */
-                       if (memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type)))
-                               goto check_next_ie;
-
-                       /* check version... */
-                       memcpy((u8 *)&le_tmp, (pbuf + 6), sizeof(val16));
-
-                       val16 = le16_to_cpu(le_tmp);
-                       if (val16 != 0x0001)
-                               goto check_next_ie;
-                       *wpa_ie_len = *(pbuf + 1);
-                       return pbuf;
-               }
-               *wpa_ie_len = 0;
-               return NULL;
-
-check_next_ie:
-               limit_new = limit - (pbuf - pie) - 2 - len;
-               if (limit_new <= 0)
-                       break;
-               pbuf += (2 + len);
-       }
-       *wpa_ie_len = 0;
-       return NULL;
-}
-
-unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit)
-{
-
-       return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit);
-}
-
-int rtw_get_wpa_cipher_suite(u8 *s)
-{
-       if (!memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN))
-               return WPA_CIPHER_NONE;
-       if (!memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN))
-               return WPA_CIPHER_WEP40;
-       if (!memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN))
-               return WPA_CIPHER_TKIP;
-       if (!memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN))
-               return WPA_CIPHER_CCMP;
-       if (!memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN))
-               return WPA_CIPHER_WEP104;
-
-       return 0;
-}
-
-int rtw_get_wpa2_cipher_suite(u8 *s)
-{
-       if (!memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN))
-               return WPA_CIPHER_NONE;
-       if (!memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN))
-               return WPA_CIPHER_WEP40;
-       if (!memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN))
-               return WPA_CIPHER_TKIP;
-       if (!memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN))
-               return WPA_CIPHER_CCMP;
-       if (!memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN))
-               return WPA_CIPHER_WEP104;
-
-       return 0;
-}
-
-int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x)
-{
-       int i, ret = _SUCCESS;
-       int left, count;
-       u8 *pos;
-       u8 SUITE_1X[4] = {0x00, 0x50, 0xf2, 1};
-
-       if (wpa_ie_len <= 0) {
-               /* No WPA IE - fail silently */
-               return _FAIL;
-       }
-
-       if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) ||
-           (memcmp(wpa_ie + 2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN)))
-               return _FAIL;
-
-       pos = wpa_ie;
-
-       pos += 8;
-       left = wpa_ie_len - 8;
-
-       /* group_cipher */
-       if (left >= WPA_SELECTOR_LEN) {
-               *group_cipher = rtw_get_wpa_cipher_suite(pos);
-               pos += WPA_SELECTOR_LEN;
-               left -= WPA_SELECTOR_LEN;
-       } else if (left > 0) {
-               return _FAIL;
-       }
-
-       /* pairwise_cipher */
-       if (left >= 2) {
-               count = get_unaligned_le16(pos);
-               pos += 2;
-               left -= 2;
-
-               if (count == 0 || left < count * WPA_SELECTOR_LEN)
-                       return _FAIL;
-
-               for (i = 0; i < count; i++) {
-                       *pairwise_cipher |= rtw_get_wpa_cipher_suite(pos);
-
-                       pos += WPA_SELECTOR_LEN;
-                       left -= WPA_SELECTOR_LEN;
-               }
-       } else if (left == 1) {
-               return _FAIL;
-       }
-
-       if (is_8021x) {
-               if (left >= 6) {
-                       pos += 2;
-                       if (!memcmp(pos, SUITE_1X, 4))
-                               *is_8021x = 1;
-               }
-       }
-
-       return ret;
-}
-
-int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x)
-{
-       int i, ret = _SUCCESS;
-       int left, count;
-       u8 *pos;
-       u8 SUITE_1X[4] = {0x00, 0x0f, 0xac, 0x01};
-
-       if (rsn_ie_len <= 0) {
-               /* No RSN IE - fail silently */
-               return _FAIL;
-       }
-
-       if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie + 1) != (u8)(rsn_ie_len - 2)))
-               return _FAIL;
-
-       pos = rsn_ie;
-       pos += 4;
-       left = rsn_ie_len - 4;
-
-       /* group_cipher */
-       if (left >= RSN_SELECTOR_LEN) {
-               *group_cipher = rtw_get_wpa2_cipher_suite(pos);
-
-               pos += RSN_SELECTOR_LEN;
-               left -= RSN_SELECTOR_LEN;
-
-       } else if (left > 0) {
-               return _FAIL;
-       }
-
-       /* pairwise_cipher */
-       if (left >= 2) {
-               count = get_unaligned_le16(pos);
-               pos += 2;
-               left -= 2;
-
-               if (count == 0 || left < count * RSN_SELECTOR_LEN)
-                       return _FAIL;
-
-               for (i = 0; i < count; i++) {
-                       *pairwise_cipher |= rtw_get_wpa2_cipher_suite(pos);
-
-                       pos += RSN_SELECTOR_LEN;
-                       left -= RSN_SELECTOR_LEN;
-               }
-
-       } else if (left == 1) {
-               return _FAIL;
-       }
-
-       if (is_8021x) {
-               if (left >= 6) {
-                       pos += 2;
-                       if (!memcmp(pos, SUITE_1X, 4))
-                               *is_8021x = 1;
-               }
-       }
-       return ret;
-}
-
-int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len)
-{
-       u8 authmode;
-       u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01};
-       uint    cnt;
-
-       /* Search required WPA or WPA2 IE and copy to sec_ie[] */
-
-       cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
-
-       while (cnt < in_len) {
-               authmode = in_ie[cnt];
-
-               if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) {
-                               if (wpa_ie)
-                                       memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
-
-                               *wpa_len = in_ie[cnt + 1] + 2;
-                               cnt += in_ie[cnt + 1] + 2;  /* get next */
-               } else {
-                       if (authmode == _WPA2_IE_ID_) {
-                               if (rsn_ie)
-                                       memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
-
-                               *rsn_len = in_ie[cnt + 1] + 2;
-                               cnt += in_ie[cnt + 1] + 2;  /* get next */
-                       } else {
-                               cnt += in_ie[cnt + 1] + 2;   /* get next */
-                       }
-               }
-       }
-
-       return *rsn_len + *wpa_len;
-}
-
-u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen)
-{
-       u8 match = false;
-       u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
-
-       if (!ie_ptr)
-               return match;
-
-       eid = ie_ptr[0];
-
-       if ((eid == _WPA_IE_ID_) && (!memcmp(&ie_ptr[2], wps_oui, 4))) {
-               *wps_ielen = ie_ptr[1] + 2;
-               match = true;
-       }
-       return match;
-}
-
-/**
- * rtw_get_wps_ie - Search WPS IE from a series of IEs
- * @in_ie: Address of IEs to search
- * @in_len: Length limit from in_ie
- * @wps_ie: If not NULL and WPS IE is found, WPS IE will be copied to the buf starting from wps_ie
- * @wps_ielen: If not NULL and WPS IE is found, will set to the length of the entire WPS IE
- *
- * Returns: The address of the WPS IE found, or NULL
- */
-u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
-{
-       uint cnt;
-       u8 *wpsie_ptr = NULL;
-       u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
-
-       if (wps_ielen)
-               *wps_ielen = 0;
-
-       if (!in_ie || in_len <= 0)
-               return wpsie_ptr;
-
-       cnt = 0;
-
-       while (cnt < in_len) {
-               eid = in_ie[cnt];
-
-               if ((eid == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) {
-                       wpsie_ptr = &in_ie[cnt];
-
-                       if (wps_ie)
-                               memcpy(wps_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
-
-                       if (wps_ielen)
-                               *wps_ielen = in_ie[cnt + 1] + 2;
-
-                       cnt += in_ie[cnt + 1] + 2;
-
-                       break;
-               }
-               cnt += in_ie[cnt + 1] + 2; /* goto next */
-       }
-       return wpsie_ptr;
-}
-
-/**
- * rtw_get_wps_attr - Search a specific WPS attribute from a given WPS IE
- * @wps_ie: Address of WPS IE to search
- * @wps_ielen: Length limit from wps_ie
- * @target_attr_id: The attribute ID of WPS attribute to search
- * @buf_attr: If not NULL and the WPS attribute is found, WPS attribute will be copied to the buf starting from buf_attr
- * @len_attr: If not NULL and the WPS attribute is found, will set to the length of the entire WPS attribute
- *
- * Returns: the address of the specific WPS attribute found, or NULL
- */
-u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_attr, u32 *len_attr)
-{
-       u8 *attr_ptr = NULL;
-       u8 *target_attr_ptr = NULL;
-       u8 wps_oui[4] = {0x00, 0x50, 0xF2, 0x04};
-
-       if (len_attr)
-               *len_attr = 0;
-
-       if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) ||
-           (memcmp(wps_ie + 2, wps_oui, 4)))
-               return attr_ptr;
-
-       /*  6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */
-       attr_ptr = wps_ie + 6; /* goto first attr */
-
-       while (attr_ptr - wps_ie < wps_ielen) {
-               /*  4 = 2(Attribute ID) + 2(Length) */
-               u16 attr_id = RTW_GET_BE16(attr_ptr);
-               u16 attr_data_len = RTW_GET_BE16(attr_ptr + 2);
-               u16 attr_len = attr_data_len + 4;
-
-               if (attr_id == target_attr_id) {
-                       target_attr_ptr = attr_ptr;
-                       if (buf_attr)
-                               memcpy(buf_attr, attr_ptr, attr_len);
-                       if (len_attr)
-                               *len_attr = attr_len;
-                       break;
-               }
-               attr_ptr += attr_len; /* goto next */
-       }
-       return target_attr_ptr;
-}
-
-/**
- * rtw_get_wps_attr_content - Search a specific WPS attribute content from a given WPS IE
- * @wps_ie: Address of WPS IE to search
- * @wps_ielen: Length limit from wps_ie
- * @target_attr_id: The attribute ID of WPS attribute to search
- * @buf_content: If not NULL and the WPS attribute is found, WPS attribute content will be copied to the buf starting from buf_content
- * @len_content: If not NULL and the WPS attribute is found, will set to the length of the WPS attribute content
- *
- * Returns: the address of the specific WPS attribute content found, or NULL
- */
-u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_content, uint *len_content)
-{
-       u8 *attr_ptr;
-       u32 attr_len;
-
-       if (len_content)
-               *len_content = 0;
-
-       attr_ptr = rtw_get_wps_attr(wps_ie, wps_ielen, target_attr_id, NULL, &attr_len);
-
-       if (attr_ptr && attr_len) {
-               if (buf_content)
-                       memcpy(buf_content, attr_ptr + 4, attr_len - 4);
-
-               if (len_content)
-                       *len_content = attr_len - 4;
-
-               return attr_ptr + 4;
-       }
-
-       return NULL;
-}
-
-static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
-                                           struct rtw_ieee802_11_elems *elems,
-                                           int show_errors)
-{
-       unsigned int oui;
-
-       /* first 3 bytes in vendor specific information element are the IEEE
-        * OUI of the vendor. The following byte is used a vendor specific
-        * sub-type. */
-       if (elen < 4)
-               return -1;
-
-       oui = RTW_GET_BE24(pos);
-       switch (oui) {
-       case OUI_MICROSOFT:
-               /* Microsoft/Wi-Fi information elements are further typed and
-                * subtyped */
-               switch (pos[3]) {
-               case 1:
-                       /* Microsoft OUI (00:50:F2) with OUI Type 1:
-                        * real WPA information element */
-                       elems->wpa_ie = pos;
-                       elems->wpa_ie_len = elen;
-                       break;
-               case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */
-                       if (elen < 5)
-                               return -1;
-                       switch (pos[4]) {
-                       case WME_OUI_SUBTYPE_INFORMATION_ELEMENT:
-                       case WME_OUI_SUBTYPE_PARAMETER_ELEMENT:
-                               elems->wme = pos;
-                               elems->wme_len = elen;
-                               break;
-                       case WME_OUI_SUBTYPE_TSPEC_ELEMENT:
-                               elems->wme_tspec = pos;
-                               elems->wme_tspec_len = elen;
-                               break;
-                       default:
-                               return -1;
-                       }
-                       break;
-               case 4:
-                       /* Wi-Fi Protected Setup (WPS) IE */
-                       elems->wps_ie = pos;
-                       elems->wps_ie_len = elen;
-                       break;
-               default:
-                       return -1;
-               }
-               break;
-
-       case OUI_BROADCOM:
-               switch (pos[3]) {
-               case VENDOR_HT_CAPAB_OUI_TYPE:
-                       elems->vendor_ht_cap = pos;
-                       elems->vendor_ht_cap_len = elen;
-                       break;
-               default:
-                       return -1;
-               }
-               break;
-       default:
-               return -1;
-       }
-       return 0;
-}
-
-/**
- * ieee802_11_parse_elems - Parse information elements in management frames
- * @start: Pointer to the start of IEs
- * @len: Length of IE buffer in octets
- * @elems: Data structure for parsed elements
- * @show_errors: Whether to show parsing errors in debug log
- * Returns: Parsing result
- */
-enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len,
-                               struct rtw_ieee802_11_elems *elems,
-                               int show_errors)
-{
-       uint left = len;
-       u8 *pos = start;
-       int unknown = 0;
-
-       memset(elems, 0, sizeof(*elems));
-
-       while (left >= 2) {
-               u8 id, elen;
-
-               id = *pos++;
-               elen = *pos++;
-               left -= 2;
-
-               if (elen > left)
-                       return ParseFailed;
-
-               switch (id) {
-               case WLAN_EID_SSID:
-                       elems->ssid = pos;
-                       elems->ssid_len = elen;
-                       break;
-               case WLAN_EID_SUPP_RATES:
-                       elems->supp_rates = pos;
-                       elems->supp_rates_len = elen;
-                       break;
-               case WLAN_EID_FH_PARAMS:
-                       elems->fh_params = pos;
-                       elems->fh_params_len = elen;
-                       break;
-               case WLAN_EID_DS_PARAMS:
-                       elems->ds_params = pos;
-                       elems->ds_params_len = elen;
-                       break;
-               case WLAN_EID_CF_PARAMS:
-                       elems->cf_params = pos;
-                       elems->cf_params_len = elen;
-                       break;
-               case WLAN_EID_TIM:
-                       elems->tim = pos;
-                       elems->tim_len = elen;
-                       break;
-               case WLAN_EID_IBSS_PARAMS:
-                       elems->ibss_params = pos;
-                       elems->ibss_params_len = elen;
-                       break;
-               case WLAN_EID_CHALLENGE:
-                       elems->challenge = pos;
-                       elems->challenge_len = elen;
-                       break;
-               case WLAN_EID_ERP_INFO:
-                       elems->erp_info = pos;
-                       elems->erp_info_len = elen;
-                       break;
-               case WLAN_EID_EXT_SUPP_RATES:
-                       elems->ext_supp_rates = pos;
-                       elems->ext_supp_rates_len = elen;
-                       break;
-               case WLAN_EID_VENDOR_SPECIFIC:
-                       if (rtw_ieee802_11_parse_vendor_specific(pos, elen, elems, show_errors))
-                               unknown++;
-                       break;
-               case WLAN_EID_RSN:
-                       elems->rsn_ie = pos;
-                       elems->rsn_ie_len = elen;
-                       break;
-               case WLAN_EID_PWR_CAPABILITY:
-                       elems->power_cap = pos;
-                       elems->power_cap_len = elen;
-                       break;
-               case WLAN_EID_SUPPORTED_CHANNELS:
-                       elems->supp_channels = pos;
-                       elems->supp_channels_len = elen;
-                       break;
-               case WLAN_EID_MOBILITY_DOMAIN:
-                       elems->mdie = pos;
-                       elems->mdie_len = elen;
-                       break;
-               case WLAN_EID_FAST_BSS_TRANSITION:
-                       elems->ftie = pos;
-                       elems->ftie_len = elen;
-                       break;
-               case WLAN_EID_TIMEOUT_INTERVAL:
-                       elems->timeout_int = pos;
-                       elems->timeout_int_len = elen;
-                       break;
-               case WLAN_EID_HT_CAP:
-                       elems->ht_capabilities = pos;
-                       elems->ht_capabilities_len = elen;
-                       break;
-               case WLAN_EID_HT_OPERATION:
-                       elems->ht_operation = pos;
-                       elems->ht_operation_len = elen;
-                       break;
-               default:
-                       unknown++;
-                       break;
-               }
-               left -= elen;
-               pos += elen;
-       }
-       if (left)
-               return ParseFailed;
-       return unknown ? ParseUnknown : ParseOK;
-}
-
-u8 key_char2num(u8 ch)
-{
-       if ((ch >= '0') && (ch <= '9'))
-               return ch - '0';
-       else if ((ch >= 'a') && (ch <= 'f'))
-               return ch - 'a' + 10;
-       else if ((ch >= 'A') && (ch <= 'F'))
-               return ch - 'A' + 10;
-       else
-               return 0xff;
-}
-
-u8 str_2char2num(u8 hch, u8 lch)
-{
-    return (key_char2num(hch) * 10) + key_char2num(lch);
-}
-
-u8 key_2char2num(u8 hch, u8 lch)
-{
-    return (key_char2num(hch) << 4) | key_char2num(lch);
-}
-
-void rtw_macaddr_cfg(u8 *mac_addr)
-{
-       u8 mac[ETH_ALEN];
-
-       if (!mac_addr)
-               return;
-
-       if (rtw_initmac && mac_pton(rtw_initmac, mac)) {
-               /* Users specify the mac address */
-               ether_addr_copy(mac_addr, mac);
-       } else {
-               /* Use the mac address stored in the Efuse */
-               ether_addr_copy(mac, mac_addr);
-       }
-
-       if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac))
-               eth_random_addr(mac_addr);
-}
-
-/**
- * rtw_get_p2p_ie - Search P2P IE from a series of IEs
- * @in_ie: Address of IEs to search
- * @in_len: Length limit from in_ie
- * @p2p_ie: If not NULL and P2P IE is found, P2P IE will be copied to the buf starting from p2p_ie
- * @p2p_ielen: If not NULL and P2P IE is found, will set to the length of the entire P2P IE
- *
- * Returns: The address of the P2P IE found, or NULL
- */
-u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen)
-{
-       uint cnt = 0;
-       u8 *p2p_ie_ptr;
-       u8 eid, p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09};
-
-       if (p2p_ielen)
-               *p2p_ielen = 0;
-
-       while (cnt < in_len) {
-               eid = in_ie[cnt];
-               if ((in_len < 0) || (cnt > MAX_IE_SZ)) {
-                       dump_stack();
-                       return NULL;
-               }
-               if ((eid == _VENDOR_SPECIFIC_IE_) && !memcmp(&in_ie[cnt + 2], p2p_oui, 4)) {
-                       p2p_ie_ptr = in_ie + cnt;
-
-                       if (p2p_ie)
-                               memcpy(p2p_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
-                       if (p2p_ielen)
-                               *p2p_ielen = in_ie[cnt + 1] + 2;
-                       return p2p_ie_ptr;
-               }
-               cnt += in_ie[cnt + 1] + 2; /* goto next */
-       }
-       return NULL;
-}
-
-/**
- * rtw_get_p2p_attr - Search a specific P2P attribute from a given P2P IE
- * @p2p_ie: Address of P2P IE to search
- * @p2p_ielen: Length limit from p2p_ie
- * @target_attr_id: The attribute ID of P2P attribute to search
- * @buf_attr: If not NULL and the P2P attribute is found, P2P attribute will be copied to the buf starting from buf_attr
- * @len_attr: If not NULL and the P2P attribute is found, will set to the length of the entire P2P attribute
- *
- * Returns: the address of the specific WPS attribute found, or NULL
- */
-u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 *buf_attr, u32 *len_attr)
-{
-       u8 *attr_ptr = NULL;
-       u8 *target_attr_ptr = NULL;
-       u8 p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09};
-
-       if (len_attr)
-               *len_attr = 0;
-
-       if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) ||
-           memcmp(p2p_ie + 2, p2p_oui, 4))
-               return attr_ptr;
-
-       /*  6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */
-       attr_ptr = p2p_ie + 6; /* goto first attr */
-
-       while (attr_ptr - p2p_ie < p2p_ielen) {
-               /*  3 = 1(Attribute ID) + 2(Length) */
-               u8 attr_id = *attr_ptr;
-               u16 attr_data_len = get_unaligned_le16(attr_ptr + 1);
-               u16 attr_len = attr_data_len + 3;
-
-               if (attr_id == target_attr_id) {
-                       target_attr_ptr = attr_ptr;
-
-                       if (buf_attr)
-                               memcpy(buf_attr, attr_ptr, attr_len);
-                       if (len_attr)
-                               *len_attr = attr_len;
-                       break;
-               }
-               attr_ptr += attr_len; /* goto next */
-       }
-       return target_attr_ptr;
-}
-
-/**
- * rtw_get_p2p_attr_content - Search a specific P2P attribute content from a given P2P IE
- * @p2p_ie: Address of P2P IE to search
- * @p2p_ielen: Length limit from p2p_ie
- * @target_attr_id: The attribute ID of P2P attribute to search
- * @buf_content: If not NULL and the P2P attribute is found, P2P attribute content will be copied to the buf starting from buf_content
- * @len_content: If not NULL and the P2P attribute is found, will set to the length of the P2P attribute content
- *
- * Returns: the address of the specific P2P attribute content found, or NULL
- */
-u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 *buf_content, uint *len_content)
-{
-       u8 *attr_ptr;
-       u32 attr_len;
-
-       if (len_content)
-               *len_content = 0;
-
-       attr_ptr = rtw_get_p2p_attr(p2p_ie, p2p_ielen, target_attr_id, NULL, &attr_len);
-
-       if (attr_ptr && attr_len) {
-               if (buf_content)
-                       memcpy(buf_content, attr_ptr + 3, attr_len - 3);
-
-               if (len_content)
-                       *len_content = attr_len - 3;
-
-               return attr_ptr + 3;
-       }
-
-       return NULL;
-}
-
-u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr)
-{
-       u32 a_len;
-
-       *pbuf = attr_id;
-
-       /* u16*)(pbuf + 1) = cpu_to_le16(attr_len); */
-       RTW_PUT_LE16(pbuf + 1, attr_len);
-
-       if (pdata_attr)
-               memcpy(pbuf + 3, pdata_attr, attr_len);
-
-       a_len = attr_len + 3;
-
-       return a_len;
-}
-
-static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id)
-{
-       u8 *target_attr;
-       u32 target_attr_len;
-       uint ielen = ielen_ori;
-
-       while (1) {
-               target_attr = rtw_get_p2p_attr(ie, ielen, attr_id, NULL, &target_attr_len);
-               if (target_attr && target_attr_len) {
-                       u8 *next_attr = target_attr + target_attr_len;
-                       uint remain_len = ielen - (next_attr - ie);
-
-                       memset(target_attr, 0, target_attr_len);
-                       memcpy(target_attr, next_attr, remain_len);
-                       memset(target_attr + remain_len, 0, target_attr_len);
-                       *(ie + 1) -= target_attr_len;
-                       ielen -= target_attr_len;
-               } else {
-                       break;
-               }
-       }
-       return ielen;
-}
-
-void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex, u8 attr_id)
-{
-       u8 *p2p_ie;
-       uint p2p_ielen, p2p_ielen_ori;
-
-       p2p_ie = rtw_get_p2p_ie(bss_ex->IEs + _FIXED_IE_LENGTH_, bss_ex->IELength - _FIXED_IE_LENGTH_, NULL, &p2p_ielen_ori);
-       if (p2p_ie) {
-               p2p_ielen = rtw_p2p_attr_remove(p2p_ie, p2p_ielen_ori, attr_id);
-               if (p2p_ielen != p2p_ielen_ori) {
-                       u8 *next_ie_ori = p2p_ie + p2p_ielen_ori;
-                       u8 *next_ie = p2p_ie + p2p_ielen;
-                       uint remain_len = bss_ex->IELength - (next_ie_ori - bss_ex->IEs);
-
-                       memcpy(next_ie, next_ie_ori, remain_len);
-                       memset(next_ie + remain_len, 0, p2p_ielen_ori - p2p_ielen);
-                       bss_ex->IELength -= p2p_ielen_ori - p2p_ielen;
-               }
-       }
-}
-
-static int rtw_get_cipher_info(struct wlan_network *pnetwork)
-{
-       u32 wpa_ielen;
-       unsigned char *pbuf;
-       int group_cipher = 0, pairwise_cipher = 0, is8021x = 0;
-       int ret = _FAIL;
-
-       pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength - 12);
-
-       if (pbuf && (wpa_ielen > 0)) {
-               if (rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is8021x) == _SUCCESS) {
-                       pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher;
-                       pnetwork->BcnInfo.group_cipher = group_cipher;
-                       pnetwork->BcnInfo.is_8021x = is8021x;
-                       ret = _SUCCESS;
-               }
-       } else {
-               pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength - 12);
-
-               if (pbuf && (wpa_ielen > 0)) {
-                       if (rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is8021x) == _SUCCESS) {
-                               pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher;
-                               pnetwork->BcnInfo.group_cipher = group_cipher;
-                               pnetwork->BcnInfo.is_8021x = is8021x;
-                               ret = _SUCCESS;
-                       }
-               }
-       }
-
-       return ret;
-}
-
-void rtw_get_bcn_info(struct wlan_network *pnetwork)
-{
-       unsigned short cap = 0;
-       u8 bencrypt = 0;
-       __le16 le_tmp;
-       u16 wpa_len = 0, rsn_len = 0;
-       struct HT_info_element *pht_info = NULL;
-       struct ieee80211_ht_cap *pht_cap = NULL;
-       unsigned int            len;
-       unsigned char           *p;
-
-       memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.IEs), 2);
-       cap = le16_to_cpu(le_tmp);
-       if (cap & WLAN_CAPABILITY_PRIVACY) {
-               bencrypt = 1;
-               pnetwork->network.Privacy = 1;
-       } else {
-               pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS;
-       }
-       rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len);
-
-       if (rsn_len > 0) {
-               pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA2;
-       } else if (wpa_len > 0) {
-               pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA;
-       } else {
-               if (bencrypt)
-                       pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP;
-       }
-       rtw_get_cipher_info(pnetwork);
-
-       /* get bwmode and ch_offset */
-       /* parsing HT_CAP_IE */
-       p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_);
-       if (p && len > 0) {
-                       pht_cap = (struct ieee80211_ht_cap *)(p + 2);
-                       pnetwork->BcnInfo.ht_cap_info = le16_to_cpu(pht_cap->cap_info);
-       } else {
-                       pnetwork->BcnInfo.ht_cap_info = 0;
-       }
-       /* parsing HT_INFO_IE */
-       p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_);
-       if (p && len > 0) {
-                       pht_info = (struct HT_info_element *)(p + 2);
-                       pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0];
-       } else {
-                       pnetwork->BcnInfo.ht_info_infos_0 = 0;
-       }
-}
-
-/* show MCS rate, unit: 100Kbps */
-u16 rtw_mcs_rate(u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsigned char *MCS_rate)
-{
-       u16 max_rate = 0;
-
-       if (MCS_rate[0] & BIT(7))
-               max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) : ((short_GI_20) ? 722 : 650);
-       else if (MCS_rate[0] & BIT(6))
-               max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) : ((short_GI_20) ? 650 : 585);
-       else if (MCS_rate[0] & BIT(5))
-               max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) : ((short_GI_20) ? 578 : 520);
-       else if (MCS_rate[0] & BIT(4))
-               max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) : ((short_GI_20) ? 433 : 390);
-       else if (MCS_rate[0] & BIT(3))
-               max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260);
-       else if (MCS_rate[0] & BIT(2))
-               max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) : ((short_GI_20) ? 217 : 195);
-       else if (MCS_rate[0] & BIT(1))
-               max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130);
-       else if (MCS_rate[0] & BIT(0))
-               max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) : ((short_GI_20) ? 72 : 65);
-
-       return max_rate;
-}
diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c
deleted file mode 100644 (file)
index 785c0db..0000000
+++ /dev/null
@@ -1,479 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _RTW_IOCTL_SET_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/rtw_ioctl_set.h"
-#include "../include/hal_intf.h"
-
-#include "../include/usb_osintf.h"
-#include "../include/usb_ops.h"
-
-u8 rtw_do_join(struct adapter *padapter)
-{
-       struct list_head *plist, *phead;
-       u8 *pibss = NULL;
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       u8 ret = _SUCCESS;
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       pmlmepriv->cur_network.join_res = -2;
-
-       set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
-
-       pmlmepriv->pscanned = plist;
-
-       pmlmepriv->to_join = true;
-
-       if (list_empty(&queue->queue)) {
-               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-               _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
-
-               /* when set_ssid/set_bssid for rtw_do_join(), but scanning queue is empty */
-               /* we try to issue sitesurvey firstly */
-
-               if (!pmlmepriv->LinkDetectInfo.bBusyTraffic ||
-                   pmlmepriv->to_roaming > 0) {
-                       /*  submit site_survey_cmd */
-                       ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1);
-                       if (ret != _SUCCESS)
-                               pmlmepriv->to_join = false;
-               } else {
-                       pmlmepriv->to_join = false;
-                       ret = _FAIL;
-               }
-
-               return ret;
-       } else {
-               int select_ret;
-
-               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-               select_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv);
-               if (select_ret == _SUCCESS) {
-                       pmlmepriv->to_join = false;
-                       _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
-               } else {
-                       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-                               /*  submit createbss_cmd to change to a ADHOC_MASTER */
-
-                               /* pmlmepriv->lock has been acquired by caller... */
-                               struct wlan_bssid_ex    *pdev_network = &padapter->registrypriv.dev_network;
-
-                               pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
-
-                               pibss = padapter->registrypriv.dev_network.MacAddress;
-
-                               memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid));
-
-                               rtw_update_registrypriv_dev_network(padapter);
-
-                               rtw_generate_random_ibss(pibss);
-
-                               if (rtw_createbss_cmd(padapter) != _SUCCESS)
-                                       return false;
-
-                               pmlmepriv->to_join = false;
-                       } else {
-                               /*  can't associate ; reset under-linking */
-                               _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
-
-                               /* when set_ssid/set_bssid for rtw_do_join(), but there are no desired bss in scanning queue */
-                               /* we try to issue sitesurvey firstly */
-                               if (!pmlmepriv->LinkDetectInfo.bBusyTraffic ||
-                                   pmlmepriv->to_roaming > 0) {
-                                       ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1);
-                                       if (ret != _SUCCESS)
-                                               pmlmepriv->to_join = false;
-                               } else {
-                                       ret = _FAIL;
-                                       pmlmepriv->to_join = false;
-                               }
-                       }
-               }
-       }
-
-       return ret;
-}
-
-u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid)
-{
-       u8 status = _SUCCESS;
-       u32 cur_time = 0;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 &&
-            bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) ||
-           (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF &&
-            bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) {
-               status = _FAIL;
-               goto exit;
-       }
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
-               goto handle_tkip_countermeasure;
-       else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
-               goto release_mlme_lock;
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) {
-               if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) {
-                       if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE))
-                               goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */
-               } else {
-                       rtw_disassoc_cmd(padapter, 0, true);
-
-                       if (check_fwstate(pmlmepriv, _FW_LINKED))
-                               rtw_indicate_disconnect(padapter);
-
-                       rtw_free_assoc_resources(padapter, 1);
-
-                       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
-                               _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
-                               set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
-                       }
-               }
-       }
-
-handle_tkip_countermeasure:
-       /* should we add something here...? */
-
-       if (padapter->securitypriv.btkip_countermeasure) {
-               cur_time = jiffies;
-
-               if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) {
-                       padapter->securitypriv.btkip_countermeasure = false;
-                       padapter->securitypriv.btkip_countermeasure_time = 0;
-               } else {
-                       status = _FAIL;
-                       goto release_mlme_lock;
-               }
-       }
-
-       memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN);
-       pmlmepriv->assoc_by_bssid = true;
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
-               pmlmepriv->to_join = true;
-       else
-               status = rtw_do_join(padapter);
-
-release_mlme_lock:
-       spin_unlock_bh(&pmlmepriv->lock);
-
-exit:
-       return status;
-}
-
-u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid)
-{
-       u8 status = _SUCCESS;
-       u32 cur_time = 0;
-
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_network *pnetwork = &pmlmepriv->cur_network;
-
-       if (!padapter->hw_init_completed) {
-               status = _FAIL;
-               goto exit;
-       }
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
-               goto handle_tkip_countermeasure;
-       } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
-               goto release_mlme_lock;
-       }
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) {
-               if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) &&
-                   (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) {
-                       if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-                               if (!rtw_is_same_ibss(padapter, pnetwork)) {
-                                       /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */
-                                       rtw_disassoc_cmd(padapter, 0, true);
-
-                                       if (check_fwstate(pmlmepriv, _FW_LINKED))
-                                               rtw_indicate_disconnect(padapter);
-
-                                       rtw_free_assoc_resources(padapter, 1);
-
-                                       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
-                                               _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
-                                               set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
-                                       }
-                               } else {
-                                       goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */
-                               }
-                       } else {
-                               rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1);
-                       }
-               } else {
-                       rtw_disassoc_cmd(padapter, 0, true);
-
-                       if (check_fwstate(pmlmepriv, _FW_LINKED))
-                               rtw_indicate_disconnect(padapter);
-
-                       rtw_free_assoc_resources(padapter, 1);
-
-                       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
-                               _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
-                               set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
-                       }
-               }
-       }
-
-handle_tkip_countermeasure:
-
-       if (padapter->securitypriv.btkip_countermeasure) {
-               cur_time = jiffies;
-
-               if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) {
-                       padapter->securitypriv.btkip_countermeasure = false;
-                       padapter->securitypriv.btkip_countermeasure_time = 0;
-               } else {
-                       status = _FAIL;
-                       goto release_mlme_lock;
-               }
-       }
-
-       memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid));
-       pmlmepriv->assoc_by_bssid = false;
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
-               pmlmepriv->to_join = true;
-       } else {
-               status = rtw_do_join(padapter);
-       }
-
-release_mlme_lock:
-       spin_unlock_bh(&pmlmepriv->lock);
-
-exit:
-       return status;
-}
-
-u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter,
-       enum ndis_802_11_network_infra networktype)
-{
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-       struct  wlan_network    *cur_network = &pmlmepriv->cur_network;
-       enum ndis_802_11_network_infra *pold_state = &cur_network->network.InfrastructureMode;
-
-       if (*pold_state != networktype) {
-               spin_lock_bh(&pmlmepriv->lock);
-
-               if (*pold_state == Ndis802_11APMode) {
-                       /* change to other mode from Ndis802_11APMode */
-                       cur_network->join_res = -1;
-
-                       stop_ap_mode(padapter);
-               }
-
-               if ((check_fwstate(pmlmepriv, _FW_LINKED)) ||
-                   (*pold_state == Ndis802_11IBSS))
-                       rtw_disassoc_cmd(padapter, 0, true);
-
-               if ((check_fwstate(pmlmepriv, _FW_LINKED)) ||
-                   (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)))
-                       rtw_free_assoc_resources(padapter, 1);
-
-               if ((*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) {
-                       if (check_fwstate(pmlmepriv, _FW_LINKED))
-                               rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have checked whether issue dis-assoc_cmd or not */
-              }
-
-               *pold_state = networktype;
-
-               _clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE);
-
-               switch (networktype) {
-               case Ndis802_11IBSS:
-                       set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
-                       break;
-               case Ndis802_11Infrastructure:
-                       set_fwstate(pmlmepriv, WIFI_STATION_STATE);
-                       break;
-               case Ndis802_11APMode:
-                       set_fwstate(pmlmepriv, WIFI_AP_STATE);
-                       break;
-               case Ndis802_11AutoUnknown:
-               case Ndis802_11InfrastructureMax:
-                       break;
-               }
-               spin_unlock_bh(&pmlmepriv->lock);
-       }
-
-       return true;
-}
-
-void rtw_set_802_11_disassociate(struct adapter *padapter)
-{
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-               rtw_disassoc_cmd(padapter, 0, true);
-               rtw_indicate_disconnect(padapter);
-               rtw_free_assoc_resources(padapter, 1);
-               rtw_pwr_wakeup(padapter);
-       }
-
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-
-u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int ssid_max_num)
-{
-       struct  mlme_priv               *pmlmepriv = &padapter->mlmepriv;
-       u8      res = true;
-
-       if (!padapter) {
-               res = false;
-               goto exit;
-       }
-       if (!padapter->hw_init_completed) {
-               res = false;
-               goto exit;
-       }
-
-       if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) ||
-           (pmlmepriv->LinkDetectInfo.bBusyTraffic)) {
-               /*  Scan or linking is in progress, do nothing. */
-               res = true;
-       } else {
-               spin_lock_bh(&pmlmepriv->lock);
-
-               res = rtw_sitesurvey_cmd(padapter, pssid, ssid_max_num);
-
-               spin_unlock_bh(&pmlmepriv->lock);
-       }
-exit:
-
-       return res;
-}
-
-u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11_auth_mode authmode)
-{
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       int res;
-       u8 ret;
-
-       psecuritypriv->ndisauthtype = authmode;
-
-       if (psecuritypriv->ndisauthtype > 3)
-               psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
-
-       res = rtw_set_auth(padapter, psecuritypriv);
-
-       if (res == _SUCCESS)
-               ret = true;
-       else
-               ret = false;
-
-       return ret;
-}
-
-u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep)
-{
-       int             keyid, res;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       u8              ret = _SUCCESS;
-
-       keyid = wep->KeyIndex & 0x3fffffff;
-
-       if (keyid >= 4) {
-               ret = false;
-               goto exit;
-       }
-
-       switch (wep->KeyLength) {
-       case 5:
-               psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
-               break;
-       case 13:
-               psecuritypriv->dot11PrivacyAlgrthm = _WEP104_;
-               break;
-       default:
-               psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
-               break;
-       }
-
-       memcpy(&psecuritypriv->dot11DefKey[keyid].skey[0], &wep->KeyMaterial, wep->KeyLength);
-
-       psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength;
-
-       psecuritypriv->dot11PrivacyKeyIndex = keyid;
-
-       res = rtw_set_key(padapter, psecuritypriv, keyid, 1);
-
-       if (res == _FAIL)
-               ret = false;
-exit:
-
-       return ret;
-}
-
-/*
-* rtw_get_cur_max_rate -
-* @adapter: pointer to struct adapter structure
-*
-* Return 0 or 100Kbps
-*/
-u16 rtw_get_cur_max_rate(struct adapter *adapter)
-{
-       int     i = 0;
-       u8      *p;
-       u16     rate = 0, max_rate = 0;
-       struct mlme_ext_priv    *pmlmeext = &adapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct registry_priv *pregistrypriv = &adapter->registrypriv;
-       struct mlme_priv        *pmlmepriv = &adapter->mlmepriv;
-       struct wlan_bssid_ex  *pcur_bss = &pmlmepriv->cur_network.network;
-       struct ieee80211_ht_cap *pht_capie;
-       u8      bw_40MHz = 0, short_GI_20 = 0, short_GI_40 = 0;
-       u16     mcs_rate = 0;
-       u32     ht_ielen = 0;
-
-       if ((!check_fwstate(pmlmepriv, _FW_LINKED)) &&
-           (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)))
-               return 0;
-
-       if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N)) {
-               p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength - 12);
-               if (p && ht_ielen > 0) {
-                       pht_capie = (struct ieee80211_ht_cap *)(p + 2);
-
-                       memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2);
-
-                       /* cur_bwmod is updated by beacon, pmlmeinfo is updated by association response */
-                       bw_40MHz = (pmlmeext->cur_bwmode && (HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH & pmlmeinfo->HT_info.infos[0])) ? 1 : 0;
-
-                       short_GI_20 = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & IEEE80211_HT_CAP_SGI_20) ? 1 : 0;
-                       short_GI_40 = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & IEEE80211_HT_CAP_SGI_40) ? 1 : 0;
-
-                       max_rate = rtw_mcs_rate(bw_40MHz & (pregistrypriv->cbw40_enable),
-                                               short_GI_20,
-                                               short_GI_40,
-                                               pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate);
-               }
-       } else {
-               while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) {
-                       rate = pcur_bss->SupportedRates[i] & 0x7F;
-                       if (rate > max_rate)
-                               max_rate = rate;
-                       i++;
-               }
-
-               max_rate *= 5;
-       }
-
-       return max_rate;
-}
diff --git a/drivers/staging/r8188eu/core/rtw_iol.c b/drivers/staging/r8188eu/core/rtw_iol.c
deleted file mode 100644 (file)
index 31e196c..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/rtw_iol.h"
-
-struct xmit_frame      *rtw_IOL_accquire_xmit_frame(struct adapter  *adapter)
-{
-       struct xmit_frame       *xmit_frame;
-       struct xmit_buf *xmitbuf;
-       struct pkt_attrib       *pattrib;
-       struct xmit_priv        *pxmitpriv = &adapter->xmitpriv;
-
-       xmit_frame = rtw_alloc_xmitframe(pxmitpriv);
-       if (!xmit_frame)
-               return NULL;
-
-       xmitbuf = rtw_alloc_xmitbuf(pxmitpriv);
-       if (!xmitbuf) {
-               rtw_free_xmitframe(pxmitpriv, xmit_frame);
-               return NULL;
-       }
-
-       xmit_frame->frame_tag = MGNT_FRAMETAG;
-       xmit_frame->pxmitbuf = xmitbuf;
-       xmit_frame->buf_addr = xmitbuf->pbuf;
-       xmitbuf->priv_data = xmit_frame;
-
-       pattrib = &xmit_frame->attrib;
-       update_mgntframe_attrib(adapter, pattrib);
-       pattrib->qsel = 0x10;/* Beacon */
-       pattrib->subtype = WIFI_BEACON;
-       pattrib->pktlen = 0;
-       pattrib->last_txcmdsz = 0;
-
-       return xmit_frame;
-}
-
-int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, u32 cmd_len)
-{
-       struct pkt_attrib       *pattrib = &xmit_frame->attrib;
-       u16 buf_offset;
-       u32 ori_len;
-
-       buf_offset = TXDESC_OFFSET;
-       ori_len = buf_offset + pattrib->pktlen;
-
-       /* check if the io_buf can accommodate new cmds */
-       if (ori_len + cmd_len + 8 > MAX_XMITBUF_SZ)
-               return _FAIL;
-
-       memcpy(xmit_frame->buf_addr + buf_offset + pattrib->pktlen, IOL_cmds, cmd_len);
-       pattrib->pktlen += cmd_len;
-       pattrib->last_txcmdsz += cmd_len;
-
-       return _SUCCESS;
-}
-
-bool rtw_IOL_applied(struct adapter  *adapter)
-{
-       if (adapter->registrypriv.fw_iol == 1)
-               return true;
-
-       if ((adapter->registrypriv.fw_iol == 2) &&
-           (adapter_to_dvobj(adapter)->pusbdev->speed != USB_SPEED_HIGH))
-               return true;
-
-       return false;
-}
-
-int rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value, u8 mask)
-{
-       struct ioreg_cfg cmd = {8, IOREG_CMD_WB_REG, 0x0, 0x0, 0x0};
-
-       cmd.address = cpu_to_le16(addr);
-       cmd.data = cpu_to_le32(value);
-
-       if (mask != 0xFF) {
-               cmd.length = 12;
-               cmd.mask = cpu_to_le32(mask);
-       }
-       return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
-}
-
-int rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value, u16 mask)
-{
-       struct ioreg_cfg cmd = {8, IOREG_CMD_WW_REG, 0x0, 0x0, 0x0};
-
-       cmd.address = cpu_to_le16(addr);
-       cmd.data = cpu_to_le32(value);
-
-       if (mask != 0xFFFF) {
-               cmd.length = 12;
-               cmd.mask =  cpu_to_le32(mask);
-       }
-       return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
-}
-
-int rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value, u32 mask)
-{
-       struct ioreg_cfg cmd = {8, IOREG_CMD_WD_REG, 0x0, 0x0, 0x0};
-
-       cmd.address = cpu_to_le16(addr);
-       cmd.data = cpu_to_le32(value);
-
-       if (mask != 0xFFFFFFFF) {
-               cmd.length = 12;
-               cmd.mask =  cpu_to_le32(mask);
-       }
-       return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
-}
-
-int rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, u16 addr, u32 value, u32 mask)
-{
-       struct ioreg_cfg cmd = {8, IOREG_CMD_W_RF, 0x0, 0x0, 0x0};
-
-       cmd.address = cpu_to_le16((rf_path << 8) | ((addr) & 0xFF));
-       cmd.data = cpu_to_le32(value);
-
-       if (mask != 0x000FFFFF) {
-               cmd.length = 12;
-               cmd.mask =  cpu_to_le32(mask);
-       }
-       return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
-}
-
-int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us)
-{
-       struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0};
-       cmd.address = cpu_to_le16(us);
-
-       return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4);
-}
-
-int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms)
-{
-       struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0};
-
-       cmd.address = cpu_to_le16(ms);
-       return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4);
-}
-
-int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame)
-{
-       struct ioreg_cfg cmd = {4, IOREG_CMD_END, cpu_to_le16(0xFFFF), cpu_to_le32(0xFF), 0x0};
-
-       return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4);
-}
-
-u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame)
-{
-       u8 is_cmd_bndy = false;
-       if (((pxmit_frame->attrib.pktlen + 32) % 256) + 8 >= 256) {
-               rtw_IOL_append_END_cmd(pxmit_frame);
-               pxmit_frame->attrib.pktlen = ((((pxmit_frame->attrib.pktlen + 32) / 256) + 1) * 256);
-
-               pxmit_frame->attrib.last_txcmdsz = pxmit_frame->attrib.pktlen;
-               is_cmd_bndy = true;
-       }
-       return is_cmd_bndy;
-}
diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c
deleted file mode 100644 (file)
index 48725ce..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#include "../include/drv_types.h"
-#include "../include/rtw_led.h"
-#include "../include/rtl8188e_spec.h"
-
-#define LED_BLINK_NO_LINK_INTVL                        msecs_to_jiffies(1000)
-#define LED_BLINK_LINK_INTVL                   msecs_to_jiffies(500)
-#define LED_BLINK_SCAN_INTVL                   msecs_to_jiffies(180)
-#define LED_BLINK_FASTER_INTVL                 msecs_to_jiffies(50)
-#define LED_BLINK_WPS_SUCESS_INTVL             msecs_to_jiffies(5000)
-
-#define IS_LED_WPS_BLINKING(l) \
-       ((l)->CurrLedState == LED_BLINK_WPS || \
-       (l)->CurrLedState == LED_BLINK_WPS_STOP || \
-       (l)->bLedWPSBlinkInProgress)
-
-static void ResetLedStatus(struct led_priv *pLed)
-{
-       pLed->CurrLedState = RTW_LED_OFF; /*  Current LED state. */
-       pLed->bLedOn = false; /*  true if LED is ON, false if LED is OFF. */
-
-       pLed->bLedBlinkInProgress = false; /*  true if it is blinking, false o.w.. */
-       pLed->bLedWPSBlinkInProgress = false;
-
-       pLed->BlinkTimes = 0; /*  Number of times to toggle led state for blinking. */
-
-       pLed->bLedScanBlinkInProgress = false;
-}
-
-static void SwLedOn(struct led_priv *pLed)
-{
-       struct adapter *padapter = container_of(pLed, struct adapter, ledpriv);
-
-       if (padapter->bDriverStopped)
-               return;
-
-       if (rtw_write8(padapter, REG_LEDCFG2, BIT(5)) != _SUCCESS)
-               return;
-
-       pLed->bLedOn = true;
-}
-
-static void SwLedOff(struct led_priv *pLed)
-{
-       struct adapter *padapter = container_of(pLed, struct adapter, ledpriv);
-
-       if (padapter->bDriverStopped)
-               return;
-
-       if (rtw_write8(padapter, REG_LEDCFG2, BIT(5) | BIT(3)) != _SUCCESS)
-               return;
-
-       pLed->bLedOn = false;
-}
-
-static void blink_work(struct work_struct *work)
-{
-       struct delayed_work *dwork = to_delayed_work(work);
-       struct led_priv *pLed = container_of(dwork, struct led_priv, blink_work);
-       struct adapter *padapter = container_of(pLed, struct adapter, ledpriv);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-               SwLedOff(pLed);
-               ResetLedStatus(pLed);
-               return;
-       }
-
-       if (pLed->bLedOn)
-               SwLedOff(pLed);
-       else
-               SwLedOn(pLed);
-
-       switch (pLed->CurrLedState) {
-       case LED_BLINK_SLOWLY:
-               schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL);
-               break;
-       case LED_BLINK_NORMAL:
-               schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL);
-               break;
-       case LED_BLINK_SCAN:
-       case LED_BLINK_TXRX:
-               pLed->BlinkTimes--;
-               if (pLed->BlinkTimes == 0) {
-                       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               pLed->CurrLedState = LED_BLINK_NORMAL;
-                               schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL);
-                       } else {
-                               pLed->CurrLedState = LED_BLINK_SLOWLY;
-                               schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL);
-                       }
-                       pLed->bLedBlinkInProgress = false;
-                       pLed->bLedScanBlinkInProgress = false;
-               } else {
-                       schedule_delayed_work(&pLed->blink_work,
-                                             pLed->CurrLedState == LED_BLINK_SCAN ?
-                                             LED_BLINK_SCAN_INTVL : LED_BLINK_FASTER_INTVL);
-               }
-               break;
-       case LED_BLINK_WPS:
-               schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL);
-               break;
-       case LED_BLINK_WPS_STOP:        /* WPS success */
-               if (!pLed->bLedOn) {
-                       pLed->CurrLedState = LED_BLINK_NORMAL;
-                       schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL);
-
-                       pLed->bLedWPSBlinkInProgress = false;
-               } else {
-                       schedule_delayed_work(&pLed->blink_work, LED_BLINK_WPS_SUCESS_INTVL);
-               }
-               break;
-       default:
-               break;
-       }
-}
-
-void rtl8188eu_InitSwLeds(struct adapter *padapter)
-{
-       struct led_priv *pledpriv = &padapter->ledpriv;
-
-       ResetLedStatus(pledpriv);
-       INIT_DELAYED_WORK(&pledpriv->blink_work, blink_work);
-}
-
-void rtl8188eu_DeInitSwLeds(struct adapter *padapter)
-{
-       struct led_priv *ledpriv = &padapter->ledpriv;
-
-       cancel_delayed_work_sync(&ledpriv->blink_work);
-       ResetLedStatus(ledpriv);
-       SwLedOff(ledpriv);
-}
-
-void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
-{
-       struct led_priv *pLed = &padapter->ledpriv;
-       struct registry_priv *registry_par;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       if (!padapter->hw_init_completed)
-               return;
-
-       if (!pLed->bRegUseLed)
-               return;
-
-       registry_par = &padapter->registrypriv;
-       if (!registry_par->led_enable)
-               return;
-
-       switch (LedAction) {
-       case LED_CTL_START_TO_LINK:
-       case LED_CTL_NO_LINK:
-               if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                       return;
-
-               cancel_delayed_work(&pLed->blink_work);
-
-               pLed->bLedBlinkInProgress = false;
-
-               pLed->CurrLedState = LED_BLINK_SLOWLY;
-               schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL);
-               break;
-       case LED_CTL_LINK:
-               if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                       return;
-
-               cancel_delayed_work(&pLed->blink_work);
-
-               pLed->bLedBlinkInProgress = false;
-
-               pLed->CurrLedState = LED_BLINK_NORMAL;
-               schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL);
-               break;
-       case LED_CTL_SITE_SURVEY:
-               if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED)))
-                       return;
-
-               if (pLed->bLedScanBlinkInProgress)
-                       return;
-
-               if (IS_LED_WPS_BLINKING(pLed))
-                       return;
-
-               cancel_delayed_work(&pLed->blink_work);
-
-               pLed->bLedBlinkInProgress = false;
-               pLed->bLedScanBlinkInProgress = true;
-
-               pLed->CurrLedState = LED_BLINK_SCAN;
-               pLed->BlinkTimes = 24;
-               schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL);
-               break;
-       case LED_CTL_TX:
-       case LED_CTL_RX:
-               if (pLed->bLedBlinkInProgress)
-                       return;
-
-               if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                       return;
-
-               cancel_delayed_work(&pLed->blink_work);
-
-               pLed->bLedBlinkInProgress = true;
-
-               pLed->CurrLedState = LED_BLINK_TXRX;
-               pLed->BlinkTimes = 2;
-               schedule_delayed_work(&pLed->blink_work, LED_BLINK_FASTER_INTVL);
-               break;
-       case LED_CTL_START_WPS: /* wait until xinpin finish */
-               if (pLed->bLedWPSBlinkInProgress)
-                       return;
-
-               cancel_delayed_work(&pLed->blink_work);
-
-               pLed->bLedBlinkInProgress = false;
-               pLed->bLedScanBlinkInProgress = false;
-               pLed->bLedWPSBlinkInProgress = true;
-               pLed->CurrLedState = LED_BLINK_WPS;
-               schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL);
-               break;
-       case LED_CTL_STOP_WPS:
-               cancel_delayed_work(&pLed->blink_work);
-
-               pLed->bLedBlinkInProgress = false;
-               pLed->bLedScanBlinkInProgress = false;
-               pLed->bLedWPSBlinkInProgress = true;
-
-               pLed->CurrLedState = LED_BLINK_WPS_STOP;
-               if (pLed->bLedOn) {
-                       schedule_delayed_work(&pLed->blink_work, LED_BLINK_WPS_SUCESS_INTVL);
-               } else {
-                       schedule_delayed_work(&pLed->blink_work, 0);
-               }
-               break;
-       case LED_CTL_STOP_WPS_FAIL:
-               cancel_delayed_work(&pLed->blink_work);
-               pLed->bLedWPSBlinkInProgress = false;
-               pLed->CurrLedState = LED_BLINK_SLOWLY;
-               schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL);
-               break;
-       case LED_CTL_POWER_OFF:
-               pLed->CurrLedState = RTW_LED_OFF;
-               pLed->bLedBlinkInProgress = false;
-               pLed->bLedWPSBlinkInProgress = false;
-               pLed->bLedScanBlinkInProgress = false;
-               cancel_delayed_work(&pLed->blink_work);
-               SwLedOff(pLed);
-               break;
-       default:
-               break;
-       }
-}
diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c
deleted file mode 100644 (file)
index fb7d0e1..0000000
+++ /dev/null
@@ -1,2067 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _RTW_MLME_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/hal_intf.h"
-#include "../include/sta_info.h"
-#include "../include/wifi.h"
-#include "../include/wlan_bssdef.h"
-#include "../include/rtw_ioctl_set.h"
-#include "../include/usb_osintf.h"
-#include "../include/rtl8188e_dm.h"
-
-extern unsigned char   MCS_rate_1R[16];
-
-void rtw_set_roaming(struct adapter *adapter, u8 to_roaming)
-{
-       if (to_roaming == 0)
-               adapter->mlmepriv.to_join = false;
-       adapter->mlmepriv.to_roaming = to_roaming;
-}
-
-u8 rtw_to_roaming(struct adapter *adapter)
-{
-       return adapter->mlmepriv.to_roaming;
-}
-
-static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen)
-{
-       kfree(*ppie);
-       *plen = 0;
-       *ppie = NULL;
-}
-
-void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv)
-{
-       kfree(pmlmepriv->assoc_req);
-       rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, &pmlmepriv->wps_assoc_resp_ie_len);
-
-       rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, &pmlmepriv->p2p_beacon_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, &pmlmepriv->p2p_probe_req_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, &pmlmepriv->p2p_probe_resp_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len);
-}
-
-void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall)
-{
-       u32 curr_time, delta_time;
-       u32 lifetime = SCANQUEUE_LIFETIME;
-       struct __queue *free_queue = &pmlmepriv->free_bss_pool;
-
-       if (!pnetwork)
-               return;
-
-       if (pnetwork->fixed)
-               return;
-       curr_time = jiffies;
-       if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) ||
-           (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)))
-               lifetime = 1;
-       if (!isfreeall) {
-               delta_time = (curr_time - pnetwork->last_scanned) / HZ;
-               if (delta_time < lifetime)/*  unit:sec */
-                       return;
-       }
-       spin_lock_bh(&free_queue->lock);
-       list_del_init(&pnetwork->list);
-       list_add_tail(&pnetwork->list, &free_queue->queue);
-       pmlmepriv->num_of_scanned--;
-       spin_unlock_bh(&free_queue->lock);
-}
-
-/*
-       return the wlan_network with the matching addr
-
-       Shall be called under atomic context... to avoid possible racing condition...
-*/
-struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr)
-{
-       struct list_head *phead, *plist;
-       struct  wlan_network *pnetwork = NULL;
-       u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
-
-       if (!memcmp(zero_addr, addr, ETH_ALEN)) {
-               pnetwork = NULL;
-               goto exit;
-       }
-       phead = get_list_head(scanned_queue);
-       plist = phead->next;
-
-       while (plist != phead) {
-               pnetwork = container_of(plist, struct wlan_network, list);
-               if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
-                       break;
-               plist = plist->next;
-       }
-       if (plist == phead)
-               pnetwork = NULL;
-exit:
-
-       return pnetwork;
-}
-
-void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall)
-{
-       struct list_head *phead, *plist;
-       struct wlan_network *pnetwork;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct __queue *scanned_queue = &pmlmepriv->scanned_queue;
-
-       spin_lock_bh(&scanned_queue->lock);
-
-       phead = get_list_head(scanned_queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               pnetwork = container_of(plist, struct wlan_network, list);
-
-               plist = plist->next;
-
-               _rtw_free_network(pmlmepriv, pnetwork, isfreeall);
-       }
-       spin_unlock_bh(&scanned_queue->lock);
-
-}
-
-int rtw_if_up(struct adapter *padapter)
-{
-       int res;
-
-       if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
-           !check_fwstate(&padapter->mlmepriv, _FW_LINKED))
-               res = false;
-       else
-               res =  true;
-
-       return res;
-}
-
-void rtw_generate_random_ibss(u8 *pibss)
-{
-       u32     curtime = jiffies;
-
-       pibss[0] = 0x02;  /* in ad-hoc mode bit1 must set to 1 */
-       pibss[1] = 0x11;
-       pibss[2] = 0x87;
-       pibss[3] = (u8)(curtime & 0xff);/* p[0]; */
-       pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */
-       pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */
-}
-
-u8 *rtw_get_capability_from_ie(u8 *ie)
-{
-       return ie + 8 + 2;
-}
-
-u16 rtw_get_capability(struct wlan_bssid_ex *bss)
-{
-       __le16  val;
-
-       memcpy((u8 *)&val, rtw_get_capability_from_ie(bss->IEs), 2);
-
-       return le16_to_cpu(val);
-}
-
-u8 *rtw_get_beacon_interval_from_ie(u8 *ie)
-{
-       return ie + 8;
-}
-
-static void rtw_join_timeout_handler(struct timer_list *t)
-{
-       struct adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer);
-
-       _rtw_join_timeout_handler(adapter);
-}
-
-static void _rtw_scan_timeout_handler(struct timer_list *t)
-{
-       struct adapter *adapter = from_timer(adapter, t, mlmepriv.scan_to_timer);
-
-       rtw_scan_timeout_handler(adapter);
-}
-
-static void _dynamic_check_timer_handlder(struct timer_list *t)
-{
-       struct adapter *adapter = from_timer(adapter, t, mlmepriv.dynamic_chk_timer);
-
-       rtw_dynamic_check_timer_handlder(adapter);
-       _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000);
-}
-
-static void rtw_init_mlme_timer(struct adapter *padapter)
-{
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       timer_setup(&pmlmepriv->assoc_timer, rtw_join_timeout_handler, 0);
-       timer_setup(&pmlmepriv->scan_to_timer, _rtw_scan_timeout_handler, 0);
-       timer_setup(&pmlmepriv->dynamic_chk_timer, _dynamic_check_timer_handlder, 0);
-}
-
-int rtw_init_mlme_priv(struct adapter *padapter)/* struct      mlme_priv *pmlmepriv) */
-{
-       int     i;
-       u8      *pbuf;
-       struct wlan_network     *pnetwork;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-
-       /*  We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
-
-       pmlmepriv->nic_hdl = (u8 *)padapter;
-
-       pmlmepriv->pscanned = NULL;
-       pmlmepriv->fw_state = 0;
-       pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown;
-       pmlmepriv->scan_mode = SCAN_ACTIVE;/*  1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */
-
-       spin_lock_init(&pmlmepriv->lock);
-       rtw_init_queue(&pmlmepriv->free_bss_pool);
-       rtw_init_queue(&pmlmepriv->scanned_queue);
-
-       set_scanned_network_val(pmlmepriv, 0);
-
-       memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
-
-       pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network)));
-
-       if (!pbuf)
-               return -ENOMEM;
-
-       pmlmepriv->free_bss_buf = pbuf;
-
-       pnetwork = (struct wlan_network *)pbuf;
-
-       for (i = 0; i < MAX_BSS_CNT; i++) {
-               INIT_LIST_HEAD(&pnetwork->list);
-
-               list_add_tail(&pnetwork->list, &pmlmepriv->free_bss_pool.queue);
-
-               pnetwork++;
-       }
-
-       /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
-
-       rtw_init_mlme_timer(padapter);
-
-       return 0;
-}
-
-void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
-{
-       rtw_free_mlme_priv_ie_data(pmlmepriv);
-       vfree(pmlmepriv->free_bss_buf);
-}
-
-struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv)
-{
-       struct  wlan_network    *pnetwork;
-       struct __queue *free_queue = &pmlmepriv->free_bss_pool;
-       struct list_head *plist = NULL;
-
-       spin_lock_bh(&free_queue->lock);
-
-       if (list_empty(&free_queue->queue)) {
-               pnetwork = NULL;
-               goto exit;
-       }
-       plist = (&free_queue->queue)->next;
-
-       pnetwork = container_of(plist, struct wlan_network, list);
-
-       list_del_init(&pnetwork->list);
-
-       pnetwork->network_type = 0;
-       pnetwork->fixed = false;
-       pnetwork->last_scanned = jiffies;
-       pnetwork->aid = 0;
-       pnetwork->join_res = 0;
-
-       pmlmepriv->num_of_scanned++;
-
-exit:
-       spin_unlock_bh(&free_queue->lock);
-
-       return pnetwork;
-}
-
-static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv,
-                                   struct wlan_network *pnetwork)
-{
-       struct __queue *free_queue = &pmlmepriv->free_bss_pool;
-
-       if (!pnetwork)
-               return;
-       if (pnetwork->fixed)
-               return;
-       list_del_init(&pnetwork->list);
-       list_add_tail(&pnetwork->list, get_list_head(free_queue));
-       pmlmepriv->num_of_scanned--;
-}
-
-void rtw_free_network_queue(struct adapter *dev, u8 isfreeall)
-{
-
-       _rtw_free_network_queue(dev, isfreeall);
-
-}
-
-/*
-       return the wlan_network with the matching addr
-
-       Shall be called under atomic context... to avoid possible racing condition...
-*/
-struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr)
-{
-       struct  wlan_network *pnetwork = _rtw_find_network(scanned_queue, addr);
-
-       return pnetwork;
-}
-
-int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork)
-{
-       int ret = true;
-       struct security_priv *psecuritypriv = &adapter->securitypriv;
-
-       if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) &&
-           (pnetwork->network.Privacy == 0))
-               ret = false;
-       else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) &&
-                (pnetwork->network.Privacy == 1))
-               ret = false;
-       else
-               ret = true;
-       return ret;
-}
-
-static int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b)
-{
-       return (a->Ssid.SsidLength == b->Ssid.SsidLength) &&
-              !memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength);
-}
-
-int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst)
-{
-       u16 s_cap, d_cap;
-       __le16 le_scap, le_dcap;
-
-       memcpy((u8 *)&le_scap, rtw_get_capability_from_ie(src->IEs), 2);
-       memcpy((u8 *)&le_dcap, rtw_get_capability_from_ie(dst->IEs), 2);
-
-       s_cap = le16_to_cpu(le_scap);
-       d_cap = le16_to_cpu(le_dcap);
-
-       return ((src->Ssid.SsidLength == dst->Ssid.SsidLength) &&
-               ((!memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN))) &&
-               ((!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength))) &&
-               ((s_cap & WLAN_CAPABILITY_IBSS) ==
-               (d_cap & WLAN_CAPABILITY_IBSS)) &&
-               ((s_cap & WLAN_CAPABILITY_BSS) ==
-               (d_cap & WLAN_CAPABILITY_BSS)));
-}
-
-struct wlan_network    *rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
-{
-       struct list_head *plist, *phead;
-       struct  wlan_network    *pwlan = NULL;
-       struct  wlan_network    *oldest = NULL;
-
-       phead = get_list_head(scanned_queue);
-
-       plist = phead->next;
-
-       while (1) {
-               if (phead == plist)
-                       break;
-
-               pwlan = container_of(plist, struct wlan_network, list);
-
-               if (!pwlan->fixed) {
-                       if (!oldest || time_after(oldest->last_scanned, pwlan->last_scanned))
-                               oldest = pwlan;
-               }
-
-               plist = plist->next;
-       }
-
-       return oldest;
-}
-
-void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
-       struct adapter *padapter, bool update_ie)
-{
-       long rssi_ori = dst->Rssi;
-       u8 sq_smp = src->PhyInfo.SignalQuality;
-       u8 ss_final;
-       u8 sq_final;
-       long rssi_final;
-
-       AntDivCompare8188E(padapter, dst, src); /* this will update src.Rssi, need consider again */
-
-       /* The rule below is 1/5 for sample value, 4/5 for history value */
-       if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network(&padapter->mlmepriv.cur_network.network, src)) {
-               /* Take the recvpriv's value for the connected AP*/
-               ss_final = padapter->recvpriv.signal_strength;
-               sq_final = padapter->recvpriv.signal_qual;
-               /* the rssi value here is undecorated, and will be used for antenna diversity */
-               if (sq_smp != 101) /* from the right channel */
-                       rssi_final = dst->Rssi; //(src->Rssi+dst->Rssi*4)/5;
-               else
-                       rssi_final = rssi_ori;
-       } else {
-//             if (sq_smp != 101) { /* from the right channel */
-                       ss_final = (u32)dst->PhyInfo.SignalStrength; //((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5;
-                       sq_final = (u32)dst->PhyInfo.SignalQuality; //((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5;
-                       rssi_final = dst->Rssi; //(src->Rssi+dst->Rssi*4)/5;
-//             } else {
-//                     /* bss info not receiving from the right channel, use the original RX signal infos */
-//                     ss_final = dst->PhyInfo.SignalStrength;
-//                     sq_final = dst->PhyInfo.SignalQuality;
-//                     rssi_final = dst->Rssi;
-//             }
-       }
-       if (update_ie) {
-               dst->Reserved[0] = src->Reserved[0];
-               dst->Reserved[1] = src->Reserved[1];
-               memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src));
-       }
-       dst->PhyInfo.SignalStrength = ss_final;
-       dst->PhyInfo.SignalQuality = sq_final;
-       dst->Rssi = rssi_final;
-
-}
-
-static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork)
-{
-       struct  mlme_priv       *pmlmepriv = &adapter->mlmepriv;
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED) &&
-           is_same_network(&pmlmepriv->cur_network.network, pnetwork)) {
-               update_network(&pmlmepriv->cur_network.network, pnetwork, adapter, true);
-       }
-
-}
-
-u8 rtw_current_antenna(struct adapter *adapter)
-{
-       struct hal_data_8188e *haldata = &adapter->haldata;
-
-       return haldata->CurAntenna;
-}
-
-/*
-Caller must hold pmlmepriv->lock first.
-*/
-void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *target)
-{
-       struct list_head *plist, *phead;
-       u32     bssid_ex_sz;
-       struct mlme_priv        *pmlmepriv = &adapter->mlmepriv;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct wlan_network     *pnetwork = NULL;
-       struct wlan_network     *oldest = NULL;
-
-       spin_lock_bh(&queue->lock);
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               pnetwork        = container_of(plist, struct wlan_network, list);
-
-               if (is_same_network(&pnetwork->network, target))
-                       break;
-               if ((oldest == ((struct wlan_network *)0)) ||
-                   time_after(oldest->last_scanned, pnetwork->last_scanned))
-                       oldest = pnetwork;
-               plist = plist->next;
-       }
-       /* If we didn't find a match, then get a new network slot to initialize
-        * with this beacon's information */
-       if (phead == plist) {
-               if (list_empty(&pmlmepriv->free_bss_pool.queue)) {
-                       /* If there are no more slots, expire the oldest */
-                       pnetwork = oldest;
-
-                       target->PhyInfo.Optimum_antenna = rtw_current_antenna(adapter);
-
-                       memcpy(&pnetwork->network, target,  get_wlan_bssid_ex_sz(target));
-                       /*  variable initialize */
-                       pnetwork->fixed = false;
-                       pnetwork->last_scanned = jiffies;
-
-                       pnetwork->network_type = 0;
-                       pnetwork->aid = 0;
-                       pnetwork->join_res = 0;
-
-                       /* bss info not receiving from the right channel */
-                       if (pnetwork->network.PhyInfo.SignalQuality == 101)
-                               pnetwork->network.PhyInfo.SignalQuality = 0;
-               } else {
-                       /* Otherwise just pull from the free list */
-
-                       pnetwork = rtw_alloc_network(pmlmepriv); /*  will update scan_time */
-
-                       if (!pnetwork)
-                               goto exit;
-
-                       bssid_ex_sz = get_wlan_bssid_ex_sz(target);
-                       target->Length = bssid_ex_sz;
-                       target->PhyInfo.Optimum_antenna = rtw_current_antenna(adapter);
-                       memcpy(&pnetwork->network, target, bssid_ex_sz);
-
-                       pnetwork->last_scanned = jiffies;
-
-                       /* bss info not receiving from the right channel */
-                       if (pnetwork->network.PhyInfo.SignalQuality == 101)
-                               pnetwork->network.PhyInfo.SignalQuality = 0;
-                       list_add_tail(&pnetwork->list, &queue->queue);
-               }
-       } else {
-               /* we have an entry and we are going to update it. But this entry may
-                * be already expired. In this case we do the same as we found a new
-                * net and call the new_net handler
-                */
-               bool update_ie = true;
-
-               pnetwork->last_scanned = jiffies;
-
-               /* target.Reserved[0]== 1, means that scanned network is a bcn frame. */
-               /* probe resp(3) > beacon(1) > probe req(2) */
-               if ((target->Reserved[0] != 2) &&
-                   (target->Reserved[0] >= pnetwork->network.Reserved[0]))
-                       update_ie = true;
-               else
-                       update_ie = false;
-               update_network(&pnetwork->network, target, adapter, update_ie);
-       }
-
-exit:
-       spin_unlock_bh(&queue->lock);
-
-}
-
-static void rtw_add_network(struct adapter *adapter,
-                           struct wlan_bssid_ex *pnetwork)
-{
-
-       rtw_wlan_bssid_ex_remove_p2p_attr(pnetwork, P2P_ATTR_GROUP_INFO);
-       update_current_network(adapter, pnetwork);
-       rtw_update_scanned_network(adapter, pnetwork);
-
-}
-
-/* select the desired network based on the capability of the (i)bss. */
-/*  check items:       (1) security */
-/*                     (2) network_type */
-/*                     (3) WMM */
-/*                     (4) HT */
-/*                     (5) others */
-static bool rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwork)
-{
-       struct security_priv *psecuritypriv = &adapter->securitypriv;
-       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       u32 desired_encmode;
-       u32 privacy;
-
-       /* u8 wps_ie[512]; */
-       uint wps_ielen;
-
-       int bselected = true;
-
-       desired_encmode = psecuritypriv->ndisencryptstatus;
-       privacy = pnetwork->network.Privacy;
-
-       if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
-               if (rtw_get_wps_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, pnetwork->network.IELength - _FIXED_IE_LENGTH_, NULL, &wps_ielen))
-                       return true;
-               else
-                       return false;
-       }
-       if (adapter->registrypriv.wifi_spec == 1) { /* for  correct flow of 8021X  to do.... */
-               u8 *p = NULL;
-               uint ie_len = 0;
-
-               if ((desired_encmode == Ndis802_11EncryptionDisabled) && (privacy != 0))
-                       bselected = false;
-               if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) {
-                       p = rtw_get_ie(pnetwork->network.IEs + _BEACON_IE_OFFSET_,
-                                      _RSN_IE_2_, &ie_len,
-                                      (pnetwork->network.IELength -
-                                      _BEACON_IE_OFFSET_));
-                       if (p && ie_len > 0)
-                               bselected = true;
-                       else
-                               bselected = false;
-               }
-       }
-
-       if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0))
-               bselected = false;
-
-       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-               if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode)
-                       bselected = false;
-       }
-
-       return bselected;
-}
-
-void rtw_survey_event_callback(struct adapter  *adapter, u8 *pbuf)
-{
-       u32 len;
-       struct wlan_bssid_ex *pnetwork;
-       struct  mlme_priv       *pmlmepriv = &adapter->mlmepriv;
-
-       pnetwork = (struct wlan_bssid_ex *)pbuf;
-
-       len = get_wlan_bssid_ex_sz(pnetwork);
-       if (len > (sizeof(struct wlan_bssid_ex)))
-               return;
-       spin_lock_bh(&pmlmepriv->lock);
-
-       /*  update IBSS_network 's timestamp */
-       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
-               if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, pnetwork->MacAddress, ETH_ALEN)) {
-                       struct wlan_network *ibss_wlan = NULL;
-
-                       memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8);
-                       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-                       ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue,  pnetwork->MacAddress);
-                       if (ibss_wlan) {
-                               memcpy(ibss_wlan->network.IEs, pnetwork->IEs, 8);
-                               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-                               goto exit;
-                       }
-                       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-               }
-       }
-
-       /*  lock pmlmepriv->lock when you accessing network_q */
-       if (!check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
-               if (pnetwork->Ssid.Ssid[0] == 0)
-                       pnetwork->Ssid.SsidLength = 0;
-               rtw_add_network(adapter, pnetwork);
-       }
-
-exit:
-
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-
-static void rtw_xmit_schedule(struct adapter *padapter)
-{
-       struct xmit_priv *pxmitpriv;
-
-       if (!padapter)
-               return;
-
-       pxmitpriv = &padapter->xmitpriv;
-
-       spin_lock_bh(&pxmitpriv->lock);
-
-       if (rtw_txframes_pending(padapter))
-               tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
-
-       spin_unlock_bh(&pxmitpriv->lock);
-}
-
-void rtw_surveydone_event_callback(struct adapter      *adapter, u8 *pbuf)
-{
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       if (pmlmepriv->wps_probe_req_ie) {
-               pmlmepriv->wps_probe_req_ie_len = 0;
-               kfree(pmlmepriv->wps_probe_req_ie);
-               pmlmepriv->wps_probe_req_ie = NULL;
-       }
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
-               _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
-
-       spin_unlock_bh(&pmlmepriv->lock);
-
-       del_timer_sync(&pmlmepriv->scan_to_timer);
-
-       spin_lock_bh(&pmlmepriv->lock);
-       rtw_set_signal_stat_timer(&adapter->recvpriv);
-
-       if (pmlmepriv->to_join) {
-               if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-                       if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
-
-                               if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) {
-                                       _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
-                               } else {
-                                       struct wlan_bssid_ex    *pdev_network = &adapter->registrypriv.dev_network;
-                                       u8 *pibss = adapter->registrypriv.dev_network.MacAddress;
-
-                                       _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
-
-                                       memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid));
-
-                                       rtw_update_registrypriv_dev_network(adapter);
-                                       rtw_generate_random_ibss(pibss);
-
-                                       pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
-
-                                       rtw_createbss_cmd(adapter);
-                                       pmlmepriv->to_join = false;
-                               }
-                       }
-               } else {
-                       int s_ret;
-                       set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
-                       pmlmepriv->to_join = false;
-                       s_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv);
-                       if (s_ret == _SUCCESS) {
-                               _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
-                       } else {
-                               if (rtw_to_roaming(adapter) != 0) {
-                                       if (--pmlmepriv->to_roaming == 0 ||
-                                           rtw_sitesurvey_cmd(adapter, &pmlmepriv->assoc_ssid, 1) != _SUCCESS) {
-                                               rtw_set_roaming(adapter, 0);
-                                               rtw_free_assoc_resources(adapter, 1);
-                                               rtw_indicate_disconnect(adapter);
-                                       } else {
-                                               pmlmepriv->to_join = true;
-                                       }
-                               } else {
-                                       rtw_indicate_disconnect(adapter);
-                               }
-                               _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
-                       }
-               }
-       }
-
-       indicate_wx_scan_complete_event(adapter);
-
-       spin_unlock_bh(&pmlmepriv->lock);
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED))
-               p2p_ps_wk_cmd(adapter, P2P_PS_SCAN_DONE, 0);
-
-       rtw_xmit_schedule(adapter);
-}
-
-static void free_scanqueue(struct      mlme_priv *pmlmepriv)
-{
-       struct __queue *free_queue = &pmlmepriv->free_bss_pool;
-       struct __queue *scan_queue = &pmlmepriv->scanned_queue;
-       struct list_head *plist, *phead, *ptemp;
-
-       spin_lock_bh(&scan_queue->lock);
-       spin_lock_bh(&free_queue->lock);
-
-       phead = get_list_head(scan_queue);
-       plist = phead->next;
-
-       while (plist != phead) {
-               ptemp = plist->next;
-               list_del_init(plist);
-               list_add_tail(plist, &free_queue->queue);
-               plist = ptemp;
-               pmlmepriv->num_of_scanned--;
-       }
-
-       spin_unlock_bh(&free_queue->lock);
-       spin_unlock_bh(&scan_queue->lock);
-}
-
-/*
-*rtw_free_assoc_resources: the caller has to lock pmlmepriv->lock
-*/
-void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue)
-{
-       struct wlan_network *pwlan = NULL;
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       struct  sta_priv *pstapriv = &adapter->stapriv;
-       struct wlan_network *tgt_network = &pmlmepriv->cur_network;
-
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_AP_STATE)) {
-               struct sta_info *psta;
-
-               psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.MacAddress);
-
-               spin_lock_bh(&pstapriv->sta_hash_lock);
-               rtw_free_stainfo(adapter,  psta);
-               spin_unlock_bh(&pstapriv->sta_hash_lock);
-       }
-
-       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) {
-               struct sta_info *psta;
-
-               rtw_free_all_stainfo(adapter);
-
-               psta = rtw_get_bcmc_stainfo(adapter);
-               spin_lock_bh(&pstapriv->sta_hash_lock);
-               rtw_free_stainfo(adapter, psta);
-               spin_unlock_bh(&pstapriv->sta_hash_lock);
-
-               rtw_init_bcmc_stainfo(adapter);
-       }
-
-       if (lock_scanned_queue)
-               spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress);
-       if (pwlan)
-               pwlan->fixed = false;
-
-       if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1)))
-               rtw_free_network_nolock(pmlmepriv, pwlan);
-
-       if (lock_scanned_queue)
-               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-       pmlmepriv->key_mask = 0;
-
-}
-
-static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE];
-
-static void rtw_reset_securitypriv(struct adapter *adapter)
-{
-       u8 backup_index;
-       u8 backup_counter;
-       u32 backup_time;
-
-       if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
-               /* 802.1x */
-               /*  We have to backup the PMK information for WiFi PMK Caching test item. */
-               /*  Backup the btkip_countermeasure information. */
-               /*  When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */
-               memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
-               backup_index = adapter->securitypriv.PMKIDIndex;
-               backup_counter = adapter->securitypriv.btkip_countermeasure;
-               backup_time = adapter->securitypriv.btkip_countermeasure_time;
-               memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
-
-               /*  Restore the PMK information to securitypriv structure for the following connection. */
-               memcpy(&adapter->securitypriv.PMKIDList[0],
-                           &backup_pmkid[0],
-                           sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
-               adapter->securitypriv.PMKIDIndex = backup_index;
-               adapter->securitypriv.btkip_countermeasure = backup_counter;
-               adapter->securitypriv.btkip_countermeasure_time = backup_time;
-               adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
-               adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
-       } else {
-               /* reset values in securitypriv */
-               struct security_priv *psec_priv = &adapter->securitypriv;
-
-               psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;  /* open system */
-               psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
-               psec_priv->dot11PrivacyKeyIndex = 0;
-               psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_;
-               psec_priv->dot118021XGrpKeyid = 1;
-               psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
-               psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
-       }
-}
-
-/*
-*rtw_indicate_connect: the caller has to lock pmlmepriv->lock
-*/
-void rtw_indicate_connect(struct adapter *padapter)
-{
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-
-       pmlmepriv->to_join = false;
-
-       if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
-               set_fwstate(pmlmepriv, _FW_LINKED);
-
-               rtw_led_control(padapter, LED_CTL_LINK);
-
-               rtw_indicate_wx_assoc_event(padapter);
-               netif_carrier_on(padapter->pnetdev);
-               if (padapter->pid[2] != 0)
-                       rtw_signal_process(padapter->pid[2], SIGALRM);
-       }
-
-       pmlmepriv->to_roaming = 0;
-}
-
-/*
-*rtw_indicate_disconnect: the caller has to lock pmlmepriv->lock
-*/
-void rtw_indicate_disconnect(struct adapter *padapter)
-{
-       struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING | WIFI_UNDER_WPS);
-
-       if (pmlmepriv->to_roaming > 0)
-               _clr_fwstate_(pmlmepriv, _FW_LINKED);
-
-       if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) ||
-           (pmlmepriv->to_roaming <= 0)) {
-               /*  Do it first for tx broadcast pkt after disconnection issue! */
-               netif_carrier_off(padapter->pnetdev);
-
-               rtw_indicate_wx_disassoc_event(padapter);
-               rtw_reset_securitypriv(padapter);
-
-               _clr_fwstate_(pmlmepriv, _FW_LINKED);
-               rtw_led_control(padapter, LED_CTL_NO_LINK);
-       }
-       p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1);
-
-       rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 1);
-
-}
-
-inline void rtw_indicate_scan_done(struct adapter *padapter)
-{
-       indicate_wx_scan_complete_event(padapter);
-}
-
-static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, struct wlan_network *pnetwork)
-{
-       int i;
-       struct sta_info *bmc_sta, *psta = NULL;
-       struct recv_reorder_ctrl *preorder_ctrl;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
-       if (!psta)
-               psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress);
-
-       if (psta) { /* update ptarget_sta */
-               psta->aid  = pnetwork->join_res;
-               psta->mac_id = 0;
-               /* sta mode */
-               rtl8188e_SetHalODMVar(padapter, psta, true);
-               /* security related */
-               if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
-                       padapter->securitypriv.binstallGrpkey = false;
-                       padapter->securitypriv.busetkipkey = false;
-                       padapter->securitypriv.bgrpkey_handshake = false;
-                       psta->ieee8021x_blocked = true;
-                       psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
-                       memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof(union Keytype));
-                       memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof(union Keytype));
-                       memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof(union Keytype));
-                       memset((u8 *)&psta->dot11txpn, 0, sizeof(union pn48));
-                       memset((u8 *)&psta->dot11rxpn, 0, sizeof(union pn48));
-               }
-               /*      When doing the WPS, the wps_ie_len won't equal to 0 */
-               /*      And the Wi-Fi driver shouldn't allow the data packet to be transmitted. */
-               if (padapter->securitypriv.wps_ie_len != 0) {
-                       psta->ieee8021x_blocked = true;
-                       padapter->securitypriv.wps_ie_len = 0;
-               }
-               /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */
-               /* if A-MPDU Rx is enabled, resetting  rx_ordering_ctrl wstart_b(indicate_seq) to default value = 0xffff */
-               /* todo: check if AP can send A-MPDU packets */
-               for (i = 0; i < 16; i++) {
-                       /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */
-                       preorder_ctrl = &psta->recvreorder_ctrl[i];
-                       preorder_ctrl->enable = false;
-                       preorder_ctrl->indicate_seq = 0xffff;
-                       preorder_ctrl->wend_b = 0xffff;
-                       preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */
-               }
-               bmc_sta = rtw_get_bcmc_stainfo(padapter);
-               if (bmc_sta) {
-                       for (i = 0; i < 16; i++) {
-                               /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */
-                               preorder_ctrl = &bmc_sta->recvreorder_ctrl[i];
-                               preorder_ctrl->enable = false;
-                               preorder_ctrl->indicate_seq = 0xffff;
-                               preorder_ctrl->wend_b = 0xffff;
-                               preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */
-                       }
-               }
-               /* misc. */
-               update_sta_info(padapter, psta);
-       }
-       return psta;
-}
-
-/* pnetwork: returns from rtw_joinbss_event_callback */
-/* ptarget_wlan: found from scanned_queue */
-static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network  *pnetwork)
-{
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_network  *cur_network = &pmlmepriv->cur_network;
-
-       /*  why not use ptarget_wlan?? */
-       memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length);
-       /*  some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */
-       cur_network->network.IELength = ptarget_wlan->network.IELength;
-       memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], MAX_IE_SZ);
-
-       cur_network->aid = pnetwork->join_res;
-
-       rtw_set_signal_stat_timer(&padapter->recvpriv);
-       padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength;
-       padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality;
-       /* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */
-       padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength);
-       rtw_set_signal_stat_timer(&padapter->recvpriv);
-
-       /* update fw_state will clr _FW_UNDER_LINKING here indirectly */
-       switch (pnetwork->network.InfrastructureMode) {
-       case Ndis802_11Infrastructure:
-               if (pmlmepriv->fw_state & WIFI_UNDER_WPS)
-                       pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS;
-               else
-                       pmlmepriv->fw_state = WIFI_STATION_STATE;
-               break;
-       case Ndis802_11IBSS:
-               pmlmepriv->fw_state = WIFI_ADHOC_STATE;
-               break;
-       default:
-               pmlmepriv->fw_state = WIFI_NULL_STATE;
-               break;
-       }
-
-       rtw_update_ht_cap(padapter, cur_network->network.IEs, cur_network->network.IELength);
-}
-
-/* Notes: the function could be > passive_level (the same context as Rx tasklet) */
-/* pnetwork: returns from rtw_joinbss_event_callback */
-/* ptarget_wlan: found from scanned_queue */
-/* if join_res > 0, for (fw_state == WIFI_STATION_STATE), we check if  "ptarget_sta" & "ptarget_wlan" exist. */
-/* if join_res > 0, for (fw_state == WIFI_ADHOC_STATE), we only check if "ptarget_wlan" exist. */
-/* if join_res > 0, update "cur_network->network" from "pnetwork->network" if (ptarget_wlan != NULL). */
-
-void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
-{
-       struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL;
-       struct  sta_priv *pstapriv = &adapter->stapriv;
-       struct  mlme_priv       *pmlmepriv = &adapter->mlmepriv;
-       struct wlan_network     *pnetwork       = (struct wlan_network *)pbuf;
-       struct wlan_network     *cur_network = &pmlmepriv->cur_network;
-       struct wlan_network     *pcur_wlan = NULL, *ptarget_wlan = NULL;
-       unsigned int            the_same_macaddr = false;
-
-       the_same_macaddr = !memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN);
-
-       pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network);
-       if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex))
-               return;
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       if (pnetwork->join_res > 0) {
-               spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-               if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
-                       /* s1. find ptarget_wlan */
-                       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               if (the_same_macaddr) {
-                                       ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
-                               } else {
-                                       pcur_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
-                                       if (pcur_wlan)
-                                               pcur_wlan->fixed = false;
-
-                                       pcur_sta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress);
-                                       if (pcur_sta) {
-                                               spin_lock_bh(&pstapriv->sta_hash_lock);
-                                               rtw_free_stainfo(adapter,  pcur_sta);
-                                               spin_unlock_bh(&pstapriv->sta_hash_lock);
-                                       }
-
-                                       ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress);
-                                       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-                                               if (ptarget_wlan)
-                                                       ptarget_wlan->fixed = true;
-                                       }
-                               }
-                       } else {
-                               ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress);
-                               if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-                                       if (ptarget_wlan)
-                                               ptarget_wlan->fixed = true;
-                               }
-                       }
-
-                       /* s2. update cur_network */
-                       if (ptarget_wlan) {
-                               rtw_joinbss_update_network(adapter, ptarget_wlan, pnetwork);
-                       } else {
-                               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-                               goto ignore_joinbss_callback;
-                       }
-
-                       /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */
-                       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-                               ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork);
-                               if (!ptarget_sta) {
-                                       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-                                       goto ignore_joinbss_callback;
-                               }
-                       }
-
-                       /* s4. indicate connect */
-                       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-                               pmlmepriv->cur_network_scanned = ptarget_wlan;
-                               rtw_indicate_connect(adapter);
-                       }
-
-                       spin_unlock_bh(&pmlmepriv->lock);
-                       /* s5. Cancel assoc_timer */
-                       del_timer_sync(&pmlmepriv->assoc_timer);
-                       spin_lock_bh(&pmlmepriv->lock);
-               } else {
-                       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-                       goto ignore_joinbss_callback;
-               }
-
-               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       } else if (pnetwork->join_res == -4) {
-               rtw_reset_securitypriv(adapter);
-               _set_timer(&pmlmepriv->assoc_timer, 1);
-
-               if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
-                       _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
-       } else { /* if join_res < 0 (join fails), then try again */
-               _set_timer(&pmlmepriv->assoc_timer, 1);
-               _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
-       }
-
-ignore_joinbss_callback:
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-
-void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf)
-{
-       struct wlan_network     *pnetwork       = (struct wlan_network *)pbuf;
-
-       mlmeext_joinbss_event_callback(adapter, pnetwork->join_res);
-
-       rtw_xmit_schedule(adapter);
-}
-
-void rtw_set_max_rpt_macid(struct adapter *adapter, u8 macid)
-{
-       rtw_write8(adapter, REG_TX_RPT_CTRL + 1, macid + 1);
-}
-
-static u8 search_max_mac_id(struct adapter *padapter)
-{
-       u8 mac_id;
-       u8 aid;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               for (aid = (pstapriv->max_num_sta); aid > 0; aid--) {
-                       if (pstapriv->sta_aid[aid - 1])
-                               break;
-               }
-               mac_id = aid + 1;
-       } else {
-               /* adhoc  id =  31~2 */
-               for (mac_id = (NUM_STA - 1); mac_id >= IBSS_START_MAC_ID; mac_id--) {
-                       if (pmlmeinfo->FW_sta_info[mac_id].status == 1)
-                               break;
-               }
-       }
-       return mac_id;
-}
-
-/* FOR AP , AD-HOC mode */
-void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta,
-                             u32 mstatus)
-{
-       u16 media_status_rpt;
-       u8 macid;
-
-       if (!psta)
-               return;
-
-       macid = search_max_mac_id(adapter);
-       rtw_set_max_rpt_macid(adapter, macid);
-
-       /* MACID|OPMODE:1 connect */
-       media_status_rpt = (u16)((psta->mac_id << 8) | mstatus);
-       rtl8188e_set_FwMediaStatus_cmd(adapter, media_status_rpt);
-}
-
-void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf)
-{
-       struct sta_info *psta;
-       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       struct stassoc_event    *pstassoc = (struct stassoc_event *)pbuf;
-       struct wlan_network     *cur_network = &pmlmepriv->cur_network;
-       struct wlan_network     *ptarget_wlan = NULL;
-
-       if (!rtw_access_ctrl(adapter, pstassoc->macaddr))
-               return;
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr);
-               if (psta)
-                       rtw_indicate_sta_assoc_event(adapter, psta);
-               return;
-       }
-       /* for AD-HOC mode */
-       psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr);
-       if (psta)
-               /* the sta have been in sta_info_queue => do nothing */
-               return; /* between drv has received this event before and  fw have not yet to set key to CAM_ENTRY) */
-       psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr);
-       if (!psta)
-               return;
-       /* to do: init sta_info variable */
-       psta->qos_option = 0;
-       psta->mac_id = (uint)pstassoc->cam_id;
-
-       /* for ad-hoc mode */
-       rtl8188e_SetHalODMVar(adapter, psta, true);
-       rtw_sta_media_status_rpt(adapter, psta, 1);
-       if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)
-               psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm;
-       psta->ieee8021x_blocked = false;
-       spin_lock_bh(&pmlmepriv->lock);
-       if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) ||
-           (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) {
-               if (adapter->stapriv.asoc_sta_count == 2) {
-                       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-                       ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
-                       pmlmepriv->cur_network_scanned = ptarget_wlan;
-                       if (ptarget_wlan)
-                               ptarget_wlan->fixed = true;
-                       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-                       /*  a sta + bc/mc_stainfo (not Ibss_stainfo) */
-                       rtw_indicate_connect(adapter);
-               }
-       }
-       spin_unlock_bh(&pmlmepriv->lock);
-       mlmeext_sta_add_event_callback(adapter, psta);
-}
-
-void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf)
-{
-       int mac_id = -1;
-       struct sta_info *psta;
-       struct wlan_network *pwlan = NULL;
-       struct wlan_bssid_ex *pdev_network = NULL;
-       u8 *pibss = NULL;
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       struct  stadel_event *pstadel = (struct stadel_event *)pbuf;
-       struct  sta_priv *pstapriv = &adapter->stapriv;
-       struct wlan_network *tgt_network = &pmlmepriv->cur_network;
-
-       psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr);
-       if (psta)
-               mac_id = psta->mac_id;
-       else
-               mac_id = pstadel->mac_id;
-
-       if (mac_id >= 0) {
-               u16 media_status;
-               media_status = (mac_id << 8) | 0; /*   MACID|OPMODE:0 means disconnect */
-               /* for STA, AP, ADHOC mode, report disconnect stauts to FW */
-               rtl8188e_set_FwMediaStatus_cmd(adapter, media_status);
-       }
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
-               return;
-
-       mlmeext_sta_del_event_callback(adapter);
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-               if (adapter->registrypriv.wifi_spec == 1)
-                       rtw_set_roaming(adapter, 0); /* don't roam */
-               else if (rtw_to_roaming(adapter) > 0)
-                       pmlmepriv->to_roaming--; /* this stadel_event is caused by roaming, decrease to_roaming */
-               else if (rtw_to_roaming(adapter) == 0)
-                       rtw_set_roaming(adapter,
-                                       adapter->registrypriv.max_roaming_times);
-
-               if (*((unsigned short *)(pstadel->rsvd)) != WLAN_REASON_EXPIRATION_CHK)
-                       rtw_set_roaming(adapter, 0); /* don't roam */
-
-               rtw_free_uc_swdec_pending_queue(adapter);
-
-               rtw_free_assoc_resources(adapter, 1);
-               rtw_indicate_disconnect(adapter);
-               spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-               /*  remove the network entry in scanned_queue */
-               pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress);
-               if (pwlan) {
-                       pwlan->fixed = false;
-                       rtw_free_network_nolock(pmlmepriv, pwlan);
-               }
-               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-               _rtw_roaming(adapter, tgt_network);
-       }
-       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
-           check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-               spin_lock_bh(&pstapriv->sta_hash_lock);
-               rtw_free_stainfo(adapter,  psta);
-               spin_unlock_bh(&pstapriv->sta_hash_lock);
-
-               if (adapter->stapriv.asoc_sta_count == 1) { /* a sta + bc/mc_stainfo (not Ibss_stainfo) */
-                       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-                       /* free old ibss network */
-                       pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress);
-                       if (pwlan) {
-                               pwlan->fixed = false;
-                               rtw_free_network_nolock(pmlmepriv, pwlan);
-                       }
-                       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-                       /* re-create ibss */
-                       pdev_network = &adapter->registrypriv.dev_network;
-                       pibss = adapter->registrypriv.dev_network.MacAddress;
-
-                       memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network));
-
-                       memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid));
-
-                       rtw_update_registrypriv_dev_network(adapter);
-
-                       rtw_generate_random_ibss(pibss);
-
-                       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-                               set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
-                               _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE);
-                       }
-
-                       rtw_createbss_cmd(adapter);
-               }
-       }
-       spin_unlock_bh(&pmlmepriv->lock);
-
-}
-
-/*
-* _rtw_join_timeout_handler - Timeout/failure handler for CMD JoinBss
-* @adapter: pointer to struct adapter structure
-*/
-void _rtw_join_timeout_handler (struct adapter *adapter)
-{
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       int do_join_r;
-
-       if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
-               return;
-
-       spin_lock_irq(&pmlmepriv->lock);
-
-       if (rtw_to_roaming(adapter) > 0) { /* join timeout caused by roaming */
-               while (1) {
-                       pmlmepriv->to_roaming--;
-                       if (rtw_to_roaming(adapter) != 0) { /* try another */
-                               do_join_r = rtw_do_join(adapter);
-                               if (do_join_r != _SUCCESS)
-                                       continue;
-                               break;
-                       } else {
-                               rtw_indicate_disconnect(adapter);
-                               break;
-                       }
-               }
-       } else {
-               rtw_indicate_disconnect(adapter);
-               free_scanqueue(pmlmepriv);/*  */
-       }
-       spin_unlock_irq(&pmlmepriv->lock);
-
-}
-
-/*
-* rtw_scan_timeout_handler - Timeout/Failure handler for CMD SiteSurvey
-* @adapter: pointer to struct adapter structure
-*/
-void rtw_scan_timeout_handler (struct adapter *adapter)
-{
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-
-       spin_lock_bh(&pmlmepriv->lock);
-       _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
-       spin_unlock_bh(&pmlmepriv->lock);
-       rtw_indicate_scan_done(adapter);
-}
-
-static void rtw_auto_scan_handler(struct adapter *padapter)
-{
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       /* auto site survey per 60sec */
-       if (pmlmepriv->scan_interval > 0) {
-               pmlmepriv->scan_interval--;
-               if (pmlmepriv->scan_interval == 0) {
-                       rtw_set_802_11_bssid_list_scan(padapter, NULL, 0);
-                       pmlmepriv->scan_interval = SCAN_INTERVAL;/*  30*2 sec = 60sec */
-               }
-       }
-}
-
-void rtw_dynamic_check_timer_handlder(struct adapter *adapter)
-{
-       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       struct registry_priv *pregistrypriv = &adapter->registrypriv;
-
-       if (!adapter)
-               return;
-       if (!adapter->hw_init_completed)
-               return;
-       if ((adapter->bDriverStopped) || (adapter->bSurpriseRemoved))
-               return;
-       if (adapter->net_closed)
-               return;
-       rtw_dynamic_chk_wk_cmd(adapter);
-
-       if (pregistrypriv->wifi_spec == 1) {
-               struct wifidirect_info *pwdinfo = &adapter->wdinfo;
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-                       /* auto site survey */
-                       rtw_auto_scan_handler(adapter);
-               }
-       }
-
-       rcu_read_lock();
-
-       if (rcu_dereference(adapter->pnetdev->rx_handler_data) &&
-           check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) {
-               /*  expire NAT2.5 entry */
-               nat25_db_expire(adapter);
-
-               if (adapter->pppoe_connection_in_progress > 0)
-                       adapter->pppoe_connection_in_progress--;
-
-               /*  due to rtw_dynamic_check_timer_handlder() is called every 2 seconds */
-               if (adapter->pppoe_connection_in_progress > 0)
-                       adapter->pppoe_connection_in_progress--;
-       }
-
-       rcu_read_unlock();
-}
-
-#define RTW_SCAN_RESULT_EXPIRE 2000
-
-/*
-* Select a new join candidate from the original @param candidate and @param competitor
-* @return true: candidate is updated
-* @return false: candidate is not updated
-*/
-static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv
-       , struct wlan_network **candidate, struct wlan_network *competitor)
-{
-       int updated = false;
-       struct adapter *adapter = container_of(pmlmepriv, struct adapter, mlmepriv);
-       unsigned long scan_res_expire;
-
-       /* check bssid, if needed */
-       if (pmlmepriv->assoc_by_bssid) {
-               if (memcmp(competitor->network.MacAddress, pmlmepriv->assoc_bssid, ETH_ALEN))
-                       goto exit;
-       }
-
-       /* check ssid, if needed */
-       if (pmlmepriv->assoc_ssid.SsidLength) {
-               if (competitor->network.Ssid.SsidLength != pmlmepriv->assoc_ssid.SsidLength ||
-                   memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength))
-                       goto exit;
-       }
-
-       if (!rtw_is_desired_network(adapter, competitor))
-               goto exit;
-
-       scan_res_expire = competitor->last_scanned + msecs_to_jiffies(RTW_SCAN_RESULT_EXPIRE);
-       if (rtw_to_roaming(adapter) > 0) {
-               if (time_after(jiffies, scan_res_expire) ||
-                   !is_same_ess(&competitor->network, &pmlmepriv->cur_network.network))
-                       goto exit;
-       }
-
-       if (!*candidate || (*candidate)->network.Rssi < competitor->network.Rssi) {
-               *candidate = competitor;
-               updated = true;
-       }
-
-exit:
-       return updated;
-}
-
-/*
-Calling context:
-The caller of the sub-routine will be in critical section...
-The caller must hold the following spinlock
-pmlmepriv->lock
-*/
-
-int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv)
-{
-       int ret;
-       struct list_head *phead;
-       struct adapter *adapter;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       struct  wlan_network    *candidate = NULL;
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-       phead = get_list_head(queue);
-       adapter = (struct adapter *)pmlmepriv->nic_hdl;
-       pmlmepriv->pscanned = phead->next;
-       while (phead != pmlmepriv->pscanned) {
-               pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list);
-               pmlmepriv->pscanned = pmlmepriv->pscanned->next;
-               rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork);
-       }
-       if (!candidate) {
-               ret = _FAIL;
-               goto exit;
-       }
-
-       /*  check for situation of  _FW_LINKED */
-       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-               rtw_disassoc_cmd(adapter, 0, true);
-               rtw_indicate_disconnect(adapter);
-               rtw_free_assoc_resources(adapter, 0);
-       }
-
-       ret = rtw_joinbss_cmd(adapter, candidate);
-
-exit:
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       return ret;
-}
-
-int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
-{
-       struct  cmd_obj *pcmd;
-       struct  setauth_parm *psetauthparm;
-       struct  cmd_priv *pcmdpriv = &adapter->cmdpriv;
-       int             res = _SUCCESS;
-
-       pcmd = kzalloc(sizeof(*pcmd), GFP_KERNEL);
-       if (!pcmd) {
-               res = _FAIL;  /* try again */
-               goto exit;
-       }
-
-       psetauthparm = kzalloc(sizeof(*psetauthparm), GFP_KERNEL);
-       if (!psetauthparm) {
-               kfree(pcmd);
-               res = _FAIL;
-               goto exit;
-       }
-       psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm;
-       pcmd->cmdcode = _SetAuth_CMD_;
-       pcmd->parmbuf = (unsigned char *)psetauthparm;
-       pcmd->cmdsz =  (sizeof(struct setauth_parm));
-       pcmd->rsp = NULL;
-       pcmd->rspsz = 0;
-       INIT_LIST_HEAD(&pcmd->list);
-       res = rtw_enqueue_cmd(pcmdpriv, pcmd);
-exit:
-
-       return res;
-}
-
-int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, int keyid, u8 set_tx)
-{
-       u8      keylen;
-       struct cmd_obj          *pcmd;
-       struct setkey_parm      *psetkeyparm;
-       struct cmd_priv         *pcmdpriv = &adapter->cmdpriv;
-       struct mlme_priv                *pmlmepriv = &adapter->mlmepriv;
-       int     res = _SUCCESS;
-
-       pcmd = kzalloc(sizeof(*pcmd), GFP_KERNEL);
-       if (!pcmd) {
-               res = _FAIL;  /* try again */
-               goto exit;
-       }
-       psetkeyparm = kzalloc(sizeof(*psetkeyparm), GFP_KERNEL);
-       if (!psetkeyparm) {
-               kfree(pcmd);
-               res = _FAIL;
-               goto exit;
-       }
-
-       if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)
-               psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy;
-       else
-               psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm;
-       psetkeyparm->keyid = (u8)keyid;/* 0~3 */
-       psetkeyparm->set_tx = set_tx;
-       pmlmepriv->key_mask |= BIT(psetkeyparm->keyid);
-
-       switch (psetkeyparm->algorithm) {
-       case _WEP40_:
-               keylen = 5;
-               memcpy(&psetkeyparm->key[0], &psecuritypriv->dot11DefKey[keyid].skey[0], keylen);
-               break;
-       case _WEP104_:
-               keylen = 13;
-               memcpy(&psetkeyparm->key[0], &psecuritypriv->dot11DefKey[keyid].skey[0], keylen);
-               break;
-       case _TKIP_:
-               keylen = 16;
-               memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen);
-               psetkeyparm->grpkey = 1;
-               break;
-       case _AES_:
-               keylen = 16;
-               memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen);
-               psetkeyparm->grpkey = 1;
-               break;
-       default:
-               kfree(psetkeyparm);
-               kfree(pcmd);
-               res = _FAIL;
-               goto exit;
-       }
-       pcmd->cmdcode = _SetKey_CMD_;
-       pcmd->parmbuf = (u8 *)psetkeyparm;
-       pcmd->cmdsz =  (sizeof(struct setkey_parm));
-       pcmd->rsp = NULL;
-       pcmd->rspsz = 0;
-       INIT_LIST_HEAD(&pcmd->list);
-       res = rtw_enqueue_cmd(pcmdpriv, pcmd);
-exit:
-       return res;
-}
-
-/* adjust IEs for rtw_joinbss_cmd in WMM */
-int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len)
-{
-       unsigned        int ielength = 0;
-       unsigned int i, j;
-
-       i = 12; /* after the fixed IE */
-       while (i < in_len) {
-               ielength = initial_out_len;
-
-               if (in_ie[i] == 0xDD && in_ie[i + 2] == 0x00 && in_ie[i + 3] == 0x50  && in_ie[i + 4] == 0xF2 && in_ie[i + 5] == 0x02 && i + 5 < in_len) {
-                       /* WMM element ID and OUI */
-                       /* Append WMM IE to the last index of out_ie */
-
-                       for (j = i; j < i + 9; j++) {
-                               out_ie[ielength] = in_ie[j];
-                               ielength++;
-                       }
-                       out_ie[initial_out_len + 1] = 0x07;
-                       out_ie[initial_out_len + 6] = 0x00;
-                       out_ie[initial_out_len + 8] = 0x00;
-                       break;
-               }
-               i += (in_ie[i + 1] + 2); /*  to the next IE element */
-       }
-       return ielength;
-}
-
-/*  */
-/*  Search by BSSID, */
-/*  Return Value: */
-/*             -1              :if there is no pre-auth key in the  table */
-/*             >= 0            :if there is pre-auth key, and   return the entry id */
-/*  */
-/*  */
-
-static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid)
-{
-       struct security_priv *p = &Adapter->securitypriv;
-       int i;
-
-       for (i = 0; i < NUM_PMKID_CACHE; i++)
-               if (p->PMKIDList[i].bUsed && !memcmp(p->PMKIDList[i].Bssid, bssid, ETH_ALEN))
-                       return i;
-       return -1;
-}
-
-/*  */
-/*  Check the RSN IE length */
-/*  If the RSN IE length <= 20, the RSN IE didn't include the PMKID information */
-/*  0-11th element in the array are the fixed IE */
-/*  12th element in the array is the IE */
-/*  13th element in the array is the IE length */
-/*  */
-
-static int rtw_append_pmkid(struct adapter *Adapter, int iEntry, u8 *ie, uint ie_len)
-{
-       struct security_priv *psecuritypriv = &Adapter->securitypriv;
-
-       if (ie[13] <= 20) {
-               /*  The RSN IE didn't include the PMK ID, append the PMK information */
-               ie[ie_len] = 1;
-               ie_len++;
-               ie[ie_len] = 0; /* PMKID count = 0x0100 */
-               ie_len++;
-               memcpy(&ie[ie_len], &psecuritypriv->PMKIDList[iEntry].PMKID, 16);
-
-               ie_len += 16;
-               ie[13] += 18;/* PMKID length = 2+16 */
-       }
-       return ie_len;
-}
-
-static void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
-{
-       uint len;
-       u8 *buff, *p, i;
-       union iwreq_data wrqu;
-
-       buff = NULL;
-       if (authmode == _WPA_IE_ID_) {
-               buff = kzalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
-               if (!buff)
-                       return;
-               p = buff;
-               p += sprintf(p, "ASSOCINFO(ReqIEs =");
-               len = sec_ie[1] + 2;
-               len =  (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
-               for (i = 0; i < len; i++)
-                       p += sprintf(p, "%02x", sec_ie[i]);
-               p += sprintf(p, ")");
-               memset(&wrqu, 0, sizeof(wrqu));
-               wrqu.data.length = p - buff;
-               wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
-                                  wrqu.data.length : IW_CUSTOM_MAX;
-               wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
-               kfree(buff);
-       }
-}
-
-int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len)
-{
-       u8 authmode = 0;
-       uint    ielength;
-       int iEntry;
-       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       struct security_priv *psecuritypriv = &adapter->securitypriv;
-       uint    ndisauthmode = psecuritypriv->ndisauthtype;
-
-       /* copy fixed ie only */
-       memcpy(out_ie, in_ie, 12);
-       ielength = 12;
-       if ((ndisauthmode == Ndis802_11AuthModeWPA) ||
-           (ndisauthmode == Ndis802_11AuthModeWPAPSK))
-                       authmode = _WPA_IE_ID_;
-       if ((ndisauthmode == Ndis802_11AuthModeWPA2) ||
-           (ndisauthmode == Ndis802_11AuthModeWPA2PSK))
-               authmode = _WPA2_IE_ID_;
-
-       if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
-               memcpy(out_ie + ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len);
-
-               ielength += psecuritypriv->wps_ie_len;
-       } else if ((authmode == _WPA_IE_ID_) || (authmode == _WPA2_IE_ID_)) {
-               /* copy RSN or SSN */
-               memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2);
-               ielength += psecuritypriv->supplicant_ie[1] + 2;
-               rtw_report_sec_ie(adapter, authmode, psecuritypriv->supplicant_ie);
-       }
-
-       iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid);
-       if (iEntry < 0) {
-               return ielength;
-       } else {
-               if (authmode == _WPA2_IE_ID_)
-                       ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength);
-       }
-
-       return ielength;
-}
-
-void rtw_init_registrypriv_dev_network(struct adapter *adapter)
-{
-       struct registry_priv *pregistrypriv = &adapter->registrypriv;
-       struct eeprom_priv *peepriv = &adapter->eeprompriv;
-       struct wlan_bssid_ex    *pdev_network = &pregistrypriv->dev_network;
-       u8 *myhwaddr = myid(peepriv);
-
-       memcpy(pdev_network->MacAddress, myhwaddr, ETH_ALEN);
-
-       memcpy(&pdev_network->Ssid, &pregistrypriv->ssid, sizeof(struct ndis_802_11_ssid));
-
-       pdev_network->Configuration.Length = sizeof(struct ndis_802_11_config);
-       pdev_network->Configuration.BeaconPeriod = 100;
-       pdev_network->Configuration.FHConfig.Length = 0;
-       pdev_network->Configuration.FHConfig.HopPattern = 0;
-       pdev_network->Configuration.FHConfig.HopSet = 0;
-       pdev_network->Configuration.FHConfig.DwellTime = 0;
-
-}
-
-void rtw_update_registrypriv_dev_network(struct adapter *adapter)
-{
-       int sz = 0;
-       struct registry_priv *pregistrypriv = &adapter->registrypriv;
-       struct wlan_bssid_ex    *pdev_network = &pregistrypriv->dev_network;
-       struct  security_priv *psecuritypriv = &adapter->securitypriv;
-       struct  wlan_network    *cur_network = &adapter->mlmepriv.cur_network;
-
-       pdev_network->Privacy = (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0); /*  adhoc no 802.1x */
-
-       pdev_network->Rssi = 0;
-
-       pdev_network->Configuration.DSConfig = (pregistrypriv->channel);
-
-       if (cur_network->network.InfrastructureMode == Ndis802_11IBSS)
-               pdev_network->Configuration.ATIMWindow = (0);
-
-       pdev_network->InfrastructureMode = (cur_network->network.InfrastructureMode);
-
-       /*  1. Supported rates */
-       /*  2. IE */
-
-       sz = rtw_generate_ie(pregistrypriv);
-       pdev_network->IELength = sz;
-       pdev_network->Length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex  *)pdev_network);
-
-       /* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */
-       /* pdev_network->IELength = cpu_to_le32(sz); */
-
-}
-
-static void rtw_set_threshold(struct adapter *adapter)
-{
-       struct mlme_priv *mlmepriv = &adapter->mlmepriv;
-       struct ht_priv *htpriv = &mlmepriv->htpriv;
-
-       if (htpriv->ht_option && adapter->registrypriv.wifi_spec != 1) {
-               /* validate usb rx aggregation, use init value. */
-               rtw_write8(adapter, REG_RXDMA_AGG_PG_TH, USB_RXAGG_PAGE_COUNT);
-       } else {
-               /* invalidate usb rx aggregation */
-               rtw_write8(adapter, REG_RXDMA_AGG_PG_TH, 1);
-       }
-}
-
-/* the function is at passive_level */
-void rtw_joinbss_reset(struct adapter *padapter)
-{
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct ht_priv          *phtpriv = &pmlmepriv->htpriv;
-
-       /* todo: if you want to do something io/reg/hw setting before join_bss, please add code here */
-       pmlmepriv->num_FortyMHzIntolerant = 0;
-
-       pmlmepriv->num_sta_no_ht = 0;
-
-       phtpriv->ampdu_enable = false;/* reset to disabled */
-
-       rtw_set_threshold(padapter);
-}
-
-/* the function is >= passive_level */
-unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len)
-{
-       u32 ielen, out_len;
-       unsigned char *p;
-       struct ieee80211_ht_cap ht_capie;
-       unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct qos_priv         *pqospriv = &pmlmepriv->qospriv;
-       struct ht_priv          *phtpriv = &pmlmepriv->htpriv;
-
-       phtpriv->ht_option = false;
-
-       p = rtw_get_ie(in_ie + 12, _HT_CAPABILITY_IE_, &ielen, in_len - 12);
-
-       if (p && ielen > 0) {
-               if (pqospriv->qos_option == 0) {
-                       out_len = *pout_len;
-                       rtw_set_ie(out_ie + out_len, _VENDOR_SPECIFIC_IE_,
-                                  _WMM_IE_Length_, WMM_IE, pout_len);
-
-                       pqospriv->qos_option = 1;
-               }
-
-               out_len = *pout_len;
-
-               memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap));
-
-               ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
-                                               IEEE80211_HT_CAP_SGI_20 |
-                                               IEEE80211_HT_CAP_SGI_40 |
-                                               IEEE80211_HT_CAP_TX_STBC |
-                                               IEEE80211_HT_CAP_DSSSCCK40);
-
-               /*
-               AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
-               AMPDU_para [4:2]:Min MPDU Start Spacing
-               */
-
-               ht_capie.ampdu_params_info = (MAX_AMPDU_FACTOR_64K & 0x03);
-
-               if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)
-                       ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07 << 2));
-               else
-                       ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00);
-
-               rtw_set_ie(out_ie + out_len, _HT_CAPABILITY_IE_,
-                          sizeof(struct ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len);
-
-               phtpriv->ht_option = true;
-
-               p = rtw_get_ie(in_ie + 12, _HT_ADD_INFO_IE_, &ielen, in_len - 12);
-               if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) {
-                       out_len = *pout_len;
-                       rtw_set_ie(out_ie + out_len, _HT_ADD_INFO_IE_, ielen, p + 2, pout_len);
-               }
-       }
-       return phtpriv->ht_option;
-}
-
-/* the function is > passive_level (in critical_section) */
-void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len)
-{
-       u8 *p, max_ampdu_sz;
-       int len;
-       struct ieee80211_ht_cap *pht_capie;
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct ht_priv          *phtpriv = &pmlmepriv->htpriv;
-       struct registry_priv *pregistrypriv = &padapter->registrypriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (!phtpriv->ht_option)
-               return;
-
-       if ((!pmlmeinfo->HT_info_enable) || (!pmlmeinfo->HT_caps_enable))
-               return;
-
-       /* maybe needs check if ap supports rx ampdu. */
-       if ((!phtpriv->ampdu_enable) && (pregistrypriv->ampdu_enable == 1)) {
-               if (pregistrypriv->wifi_spec == 1)
-                       phtpriv->ampdu_enable = false;
-               else
-                       phtpriv->ampdu_enable = true;
-       } else if (pregistrypriv->ampdu_enable == 2) {
-               phtpriv->ampdu_enable = true;
-       }
-
-       /* check Max Rx A-MPDU Size */
-       len = 0;
-       p = rtw_get_ie(pie + sizeof(struct ndis_802_11_fixed_ie), _HT_CAPABILITY_IE_, &len, ie_len - sizeof(struct ndis_802_11_fixed_ie));
-       if (p && len > 0) {
-               pht_capie = (struct ieee80211_ht_cap *)(p + 2);
-               max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR);
-               max_ampdu_sz = 1 << (max_ampdu_sz + 3); /*  max_ampdu_sz (kbytes); */
-               phtpriv->rx_ampdu_maxlen = max_ampdu_sz;
-       }
-       len = 0;
-       p = rtw_get_ie(pie + sizeof(struct ndis_802_11_fixed_ie), _HT_ADD_INFO_IE_, &len, ie_len - sizeof(struct ndis_802_11_fixed_ie));
-
-       /* update cur_bwmode & cur_ch_offset */
-       if ((pregistrypriv->cbw40_enable) &&
-           (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & BIT(1)) &&
-           (pmlmeinfo->HT_info.infos[0] & BIT(2))) {
-               int i;
-
-               /* update the MCS rates */
-               for (i = 0; i < 16; i++)
-                       pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R[i];
-
-               /* switch to the 40M Hz mode according to the AP */
-               pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40;
-               switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) {
-               case HT_EXTCHNL_OFFSET_UPPER:
-                       pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
-                       break;
-               case HT_EXTCHNL_OFFSET_LOWER:
-                       pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
-                       break;
-               default:
-                       pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-                       break;
-               }
-       }
-
-       /*  Config SM Power Save setting */
-       pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & 0x0C) >> 2;
-
-       /*  Config current HT Protection mode. */
-       pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3;
-}
-
-void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitframe)
-{
-       u8 issued;
-       int priority;
-       struct sta_info *psta = NULL;
-       struct ht_priv  *phtpriv;
-       struct pkt_attrib *pattrib = &pxmitframe->attrib;
-
-       if (is_multicast_ether_addr(pattrib->ra) ||
-           padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100)
-               return;
-
-       priority = pattrib->priority;
-
-       if (pattrib->psta)
-               psta = pattrib->psta;
-       else
-               psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
-
-       if (!psta)
-               return;
-
-       phtpriv = &psta->htpriv;
-
-       if ((phtpriv->ht_option) && (phtpriv->ampdu_enable)) {
-               issued = (phtpriv->agg_enable_bitmap >> priority) & 0x1;
-               issued |= (phtpriv->candidate_tid_bitmap >> priority) & 0x1;
-
-               if (issued == 0) {
-                       psta->htpriv.candidate_tid_bitmap |= BIT((u8)priority);
-                       rtw_addbareq_cmd(padapter, (u8)priority, pattrib->ra);
-               }
-       }
-}
-
-void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network)
-{
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-
-       spin_lock_bh(&pmlmepriv->lock);
-       _rtw_roaming(padapter, tgt_network);
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network)
-{
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       int do_join_r;
-
-       struct wlan_network *pnetwork;
-
-       if (tgt_network)
-               pnetwork = tgt_network;
-       else
-               pnetwork = &pmlmepriv->cur_network;
-
-       if (rtw_to_roaming(padapter) > 0) {
-               memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid, sizeof(struct ndis_802_11_ssid));
-
-               pmlmepriv->assoc_by_bssid = false;
-
-               while (1) {
-                       do_join_r = rtw_do_join(padapter);
-                       if (do_join_r == _SUCCESS) {
-                               break;
-                       } else {
-                               pmlmepriv->to_roaming--;
-
-                               if (pmlmepriv->to_roaming > 0) {
-                                       continue;
-                               } else {
-                                       rtw_indicate_disconnect(padapter);
-                                       break;
-                               }
-                       }
-               }
-       }
-}
diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
deleted file mode 100644 (file)
index dc181e4..0000000
+++ /dev/null
@@ -1,7817 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _RTW_MLME_EXT_C_
-
-#include <linux/ieee80211.h>
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/wifi.h"
-#include "../include/rtw_mlme_ext.h"
-#include "../include/wlan_bssdef.h"
-#include "../include/rtl8188e_xmit.h"
-#include "../include/rtl8188e_dm.h"
-
-static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
-
-/**************************************************
-OUI definitions for the vendor specific IE
-***************************************************/
-unsigned char  RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01};
-unsigned char WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02};
-unsigned char  WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04};
-unsigned char  P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09};
-unsigned char  WFD_OUI[] = {0x50, 0x6F, 0x9A, 0x0A};
-
-unsigned char  WMM_INFO_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01};
-unsigned char  WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01};
-
-unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02};
-unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02};
-
-extern unsigned char REALTEK_96B_IE[];
-
-/********************************************************
-MCS rate definitions
-*********************************************************/
-unsigned char  MCS_rate_1R[16] = {0xff, 0x00, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
-
-/********************************************************
-ChannelPlan definitions
-*********************************************************/
-static struct rt_channel_plan RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = {
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},              /*  0x00, RT_CHANNEL_DOMAIN_2G_WORLD , Passive scan CH 12, 13 */
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},              /*  0x01, RT_CHANNEL_DOMAIN_2G_ETSI1 */
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11},                      /*  0x02, RT_CHANNEL_DOMAIN_2G_FCC1 */
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14},  /*  0x03, RT_CHANNEL_DOMAIN_2G_MIKK1 */
-       {{10, 11, 12, 13}, 4},                                  /*  0x04, RT_CHANNEL_DOMAIN_2G_ETSI2 */
-       {{}, 0},                                                                        /*  0x05, RT_CHANNEL_DOMAIN_2G_NULL */
-};
-
-static struct rt_channel_plan_map      RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = {
-       /*  0x00 ~ 0x1F , Old Define ===== */
-       {0x02}, /* 0x00, RT_CHANNEL_DOMAIN_FCC */
-       {0x02}, /* 0x01, RT_CHANNEL_DOMAIN_IC */
-       {0x01}, /* 0x02, RT_CHANNEL_DOMAIN_ETSI */
-       {0x01}, /* 0x03, RT_CHANNEL_DOMAIN_SPAIN */
-       {0x01}, /* 0x04, RT_CHANNEL_DOMAIN_FRANCE */
-       {0x03}, /* 0x05, RT_CHANNEL_DOMAIN_MKK */
-       {0x03}, /* 0x06, RT_CHANNEL_DOMAIN_MKK1 */
-       {0x01}, /* 0x07, RT_CHANNEL_DOMAIN_ISRAEL */
-       {0x03}, /* 0x08, RT_CHANNEL_DOMAIN_TELEC */
-       {0x03}, /* 0x09, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN */
-       {0x00}, /* 0x0A, RT_CHANNEL_DOMAIN_WORLD_WIDE_13 */
-       {0x02}, /* 0x0B, RT_CHANNEL_DOMAIN_TAIWAN */
-       {0x01}, /* 0x0C, RT_CHANNEL_DOMAIN_CHINA */
-       {0x02}, /* 0x0D, RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO */
-       {0x02}, /* 0x0E, RT_CHANNEL_DOMAIN_KOREA */
-       {0x02}, /* 0x0F, RT_CHANNEL_DOMAIN_TURKEY */
-       {0x01}, /* 0x10, RT_CHANNEL_DOMAIN_JAPAN */
-       {0x02}, /* 0x11, RT_CHANNEL_DOMAIN_FCC_NO_DFS */
-       {0x01}, /* 0x12, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */
-       {0x00}, /* 0x13 */
-       {0x02}, /* 0x14, RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS */
-       {0x00}, /* 0x15, RT_CHANNEL_DOMAIN_ETSI_NO_DFS */
-       {0x00}, /* 0x16, RT_CHANNEL_DOMAIN_KOREA_NO_DFS */
-       {0x03}, /* 0x17, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */
-       {0x05}, /* 0x18, RT_CHANNEL_DOMAIN_PAKISTAN_NO_DFS */
-       {0x02}, /* 0x19, RT_CHANNEL_DOMAIN_TAIWAN2_NO_DFS */
-       {0x00}, /* 0x1A, */
-       {0x00}, /* 0x1B, */
-       {0x00}, /* 0x1C, */
-       {0x00}, /* 0x1D, */
-       {0x00}, /* 0x1E, */
-       {0x00}, /* 0x1F, */
-       /*  0x20 ~ 0x7F , New Define ===== */
-       {0x00}, /* 0x20, RT_CHANNEL_DOMAIN_WORLD_NULL */
-       {0x01}, /* 0x21, RT_CHANNEL_DOMAIN_ETSI1_NULL */
-       {0x02}, /* 0x22, RT_CHANNEL_DOMAIN_FCC1_NULL */
-       {0x03}, /* 0x23, RT_CHANNEL_DOMAIN_MKK1_NULL */
-       {0x04}, /* 0x24, RT_CHANNEL_DOMAIN_ETSI2_NULL */
-       {0x02}, /* 0x25, RT_CHANNEL_DOMAIN_FCC1_FCC1 */
-       {0x00}, /* 0x26, RT_CHANNEL_DOMAIN_WORLD_ETSI1 */
-       {0x03}, /* 0x27, RT_CHANNEL_DOMAIN_MKK1_MKK1 */
-       {0x00}, /* 0x28, RT_CHANNEL_DOMAIN_WORLD_KCC1 */
-       {0x00}, /* 0x29, RT_CHANNEL_DOMAIN_WORLD_FCC2 */
-       {0x00}, /* 0x2A, */
-       {0x00}, /* 0x2B, */
-       {0x00}, /* 0x2C, */
-       {0x00}, /* 0x2D, */
-       {0x00}, /* 0x2E, */
-       {0x00}, /* 0x2F, */
-       {0x00}, /* 0x30, RT_CHANNEL_DOMAIN_WORLD_FCC3 */
-       {0x00}, /* 0x31, RT_CHANNEL_DOMAIN_WORLD_FCC4 */
-       {0x00}, /* 0x32, RT_CHANNEL_DOMAIN_WORLD_FCC5 */
-       {0x00}, /* 0x33, RT_CHANNEL_DOMAIN_WORLD_FCC6 */
-       {0x02}, /* 0x34, RT_CHANNEL_DOMAIN_FCC1_FCC7 */
-       {0x00}, /* 0x35, RT_CHANNEL_DOMAIN_WORLD_ETSI2 */
-       {0x00}, /* 0x36, RT_CHANNEL_DOMAIN_WORLD_ETSI3 */
-       {0x03}, /* 0x37, RT_CHANNEL_DOMAIN_MKK1_MKK2 */
-       {0x03}, /* 0x38, RT_CHANNEL_DOMAIN_MKK1_MKK3 */
-       {0x02}, /* 0x39, RT_CHANNEL_DOMAIN_FCC1_NCC1 */
-       {0x00}, /* 0x3A, */
-       {0x00}, /* 0x3B, */
-       {0x00}, /* 0x3C, */
-       {0x00}, /* 0x3D, */
-       {0x00}, /* 0x3E, */
-       {0x00}, /* 0x3F, */
-       {0x02}, /* 0x40, RT_CHANNEL_DOMAIN_FCC1_NCC2 */
-       {0x03}, /* 0x41, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G */
-};
-
-static struct rt_channel_plan_map RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03}; /* use the combination for max channel numbers */
-
-/*
- * Search the @param channel_num in given @param channel_set
- * @ch_set: the given channel set
- * @ch: the given channel number
- *
- * return the index of channel_num in channel_set, -1 if not found
- */
-int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch)
-{
-       int i;
-       for (i = 0; ch_set[i].ChannelNum != 0; i++) {
-               if (ch == ch_set[i].ChannelNum)
-                       break;
-       }
-
-       if (i >= ch_set[i].ChannelNum)
-               return -1;
-       return i;
-}
-
-/****************************************************************************
-
-Following are the initialization functions for WiFi MLME
-
-*****************************************************************************/
-
-int init_hw_mlme_ext(struct adapter *padapter)
-{
-       struct  mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-
-       set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
-       return _SUCCESS;
-}
-
-static void init_mlme_ext_priv_value(struct adapter *padapter)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       unsigned char   mixed_datarate[NumRates] = {
-               _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_,
-               _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_,
-                _48M_RATE_, _54M_RATE_, 0xff
-       };
-       unsigned char   mixed_basicrate[NumRates] = {
-               _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_,
-               _12M_RATE_, _24M_RATE_, 0xff,
-       };
-
-       atomic_set(&pmlmeext->event_seq, 0);
-       pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */
-
-       pmlmeext->cur_channel = padapter->registrypriv.channel;
-       pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20;
-       pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-       pmlmeext->retry = 0;
-
-       pmlmeext->cur_wireless_mode = padapter->registrypriv.wireless_mode;
-
-       memcpy(pmlmeext->datarate, mixed_datarate, NumRates);
-       memcpy(pmlmeext->basicrate, mixed_basicrate, NumRates);
-
-       pmlmeext->tx_rate = IEEE80211_CCK_RATE_1MB;
-
-       pmlmeext->sitesurvey_res.state = SCAN_DISABLE;
-       pmlmeext->sitesurvey_res.channel_idx = 0;
-       pmlmeext->sitesurvey_res.bss_cnt = 0;
-       pmlmeext->scan_abort = false;
-
-       pmlmeinfo->state = WIFI_FW_NULL_STATE;
-       pmlmeinfo->reauth_count = 0;
-       pmlmeinfo->reassoc_count = 0;
-       pmlmeinfo->link_count = 0;
-       pmlmeinfo->auth_seq = 0;
-       pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open;
-       pmlmeinfo->key_index = 0;
-       pmlmeinfo->iv = 0;
-
-       pmlmeinfo->enc_algo = _NO_PRIVACY_;
-       pmlmeinfo->authModeToggle = 0;
-
-       memset(pmlmeinfo->chg_txt, 0, 128);
-
-       pmlmeinfo->slotTime = SHORT_SLOT_TIME;
-       pmlmeinfo->preamble_mode = PREAMBLE_AUTO;
-
-       pmlmeinfo->dialogToken = 0;
-
-       pmlmeext->action_public_rxseq = 0xffff;
-       pmlmeext->action_public_dialog_token = 0xff;
-}
-
-static int has_channel(struct rt_channel_info *channel_set,
-                                          u8 chanset_size,
-                                          u8 chan)
-{
-       int i;
-
-       for (i = 0; i < chanset_size; i++) {
-               if (channel_set[i].ChannelNum == chan)
-                       return 1;
-       }
-       return 0;
-}
-
-static void init_channel_list(struct adapter *padapter, struct rt_channel_info *channel_set,
-                                                         u8 chanset_size,
-                                                         struct p2p_channels *channel_list)
-{
-       struct p2p_oper_class_map op_class[] = {
-               { IEEE80211G,  81,   1,  13,  1, BW20 },
-               { IEEE80211G,  82,  14,  14,  1, BW20 },
-               { -1, 0, 0, 0, 0, BW20 }
-       };
-
-       int cla, op;
-
-       cla = 0;
-
-       for (op = 0; op_class[op].op_class; op++) {
-               u8 ch;
-               struct p2p_oper_class_map *o = &op_class[op];
-               struct p2p_reg_class *reg = NULL;
-
-               for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) {
-                       if (!has_channel(channel_set, chanset_size, ch)) {
-                               continue;
-                       }
-
-                       if ((padapter->registrypriv.ht_enable == 0) && (o->inc == 8))
-                               continue;
-
-                       if (((padapter->registrypriv.cbw40_enable & BIT(1)) == 0) &&
-                           ((o->bw == BW40MINUS) || (o->bw == BW40PLUS)))
-                               continue;
-
-                       if (!reg) {
-                               reg = &channel_list->reg_class[cla];
-                               cla++;
-                               reg->reg_class = o->op_class;
-                               reg->channels = 0;
-                       }
-                       reg->channel[reg->channels] = ch;
-                       reg->channels++;
-               }
-       }
-       channel_list->reg_classes = cla;
-}
-
-static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_channel_info *channel_set)
-{
-       u8 index, chanset_size = 0;
-       u8 b2_4GBand = false;
-       u8 Index2G = 0;
-
-       memset(channel_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM);
-
-       if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
-               return chanset_size;
-
-       if (padapter->registrypriv.wireless_mode & WIRELESS_11G) {
-               b2_4GBand = true;
-               if (ChannelPlan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
-                       Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G;
-               else
-                       Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G;
-       }
-
-       if (b2_4GBand) {
-               for (index = 0; index < RTW_ChannelPlan2G[Index2G].Len; index++) {
-                       channel_set[chanset_size].ChannelNum = RTW_ChannelPlan2G[Index2G].Channel[index];
-
-                       if ((ChannelPlan == RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN) ||/* Channel 1~11 is active, and 12~14 is passive */
-                           (ChannelPlan == RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G)) {
-                               if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11)
-                                       channel_set[chanset_size].ScanType = SCAN_ACTIVE;
-                               else if ((channel_set[chanset_size].ChannelNum  >= 12 && channel_set[chanset_size].ChannelNum  <= 14))
-                                       channel_set[chanset_size].ScanType  = SCAN_PASSIVE;
-                       } else if (ChannelPlan == RT_CHANNEL_DOMAIN_WORLD_WIDE_13 ||
-                                  Index2G == RT_CHANNEL_DOMAIN_2G_WORLD) {/*  channel 12~13, passive scan */
-                               if (channel_set[chanset_size].ChannelNum <= 11)
-                                       channel_set[chanset_size].ScanType = SCAN_ACTIVE;
-                               else
-                                       channel_set[chanset_size].ScanType = SCAN_PASSIVE;
-                       } else {
-                               channel_set[chanset_size].ScanType = SCAN_ACTIVE;
-                       }
-
-                       chanset_size++;
-               }
-       }
-       return chanset_size;
-}
-
-static void _survey_timer_hdl(struct timer_list *t)
-{
-       struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.survey_timer);
-
-       survey_timer_hdl(padapter);
-}
-
-static void _link_timer_hdl(struct timer_list *t)
-{
-       struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer);
-
-       link_timer_hdl(padapter);
-}
-
-static void init_mlme_ext_timer(struct adapter *padapter)
-{
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-
-       timer_setup(&pmlmeext->survey_timer, _survey_timer_hdl, 0);
-       timer_setup(&pmlmeext->link_timer, _link_timer_hdl, 0);
-}
-
-void init_mlme_ext_priv(struct adapter *padapter)
-{
-       struct registry_priv *pregistrypriv = &padapter->registrypriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       pmlmeext->padapter = padapter;
-
-       init_mlme_ext_priv_value(padapter);
-       pmlmeinfo->bAcceptAddbaReq = pregistrypriv->bAcceptAddbaReq;
-
-       init_mlme_ext_timer(padapter);
-
-       init_mlme_ap_info(padapter);
-
-       pmlmeext->max_chan_nums = init_channel_set(padapter, pmlmepriv->ChannelPlan, pmlmeext->channel_set);
-       init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list);
-
-       pmlmeext->chan_scan_time = SURVEY_TO;
-       pmlmeext->mlmeext_init = true;
-
-       pmlmeext->active_keep_alive_check = true;
-}
-
-void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext)
-{
-       struct adapter *padapter = pmlmeext->padapter;
-
-       if (!padapter)
-               return;
-
-       if (padapter->bDriverStopped) {
-               _cancel_timer_ex(&pmlmeext->survey_timer);
-               _cancel_timer_ex(&pmlmeext->link_timer);
-               /* _cancel_timer_ex(&pmlmeext->ADDBA_timer); */
-       }
-}
-
-static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da)
-{
-       bool response = true;
-
-       /*      do nothing if the device name is empty */
-       if (!padapter->wdinfo.device_name_len)
-               response = false;
-
-       if (response)
-               issue_probersp_p2p(padapter, da);
-
-       return _SUCCESS;
-}
-
-static void correct_TSF(struct adapter *padapter)
-{
-       u8 reg;
-       int res;
-       u64 tsf;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       tsf = pmlmeext->TSFValue - do_div(pmlmeext->TSFValue,
-                                         pmlmeinfo->bcn_interval * 1024) - 1024; /* us */
-
-       if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) ||
-           ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE))
-               rtw_stop_tx_beacon(padapter);
-
-       /* disable related TSF function */
-       res = rtw_read8(padapter, REG_BCN_CTRL, &reg);
-       if (res)
-               return;
-
-       rtw_write8(padapter, REG_BCN_CTRL, reg & (~BIT(3)));
-
-       rtw_write32(padapter, REG_TSFTR, tsf);
-       rtw_write32(padapter, REG_TSFTR + 4, tsf >> 32);
-
-       /* enable related TSF function */
-       res = rtw_read8(padapter, REG_BCN_CTRL, &reg);
-       if (res)
-               return;
-
-       rtw_write8(padapter, REG_BCN_CTRL, reg | BIT(3));
-
-       if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) ||
-           ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE))
-               rtw_resume_tx_beacon(padapter);
-}
-
-/****************************************************************************
-
-Following are the callback functions for each subtype of the management frames
-
-*****************************************************************************/
-
-static void OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       unsigned int    ielen;
-       unsigned char   *p;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *cur = &pmlmeinfo->network;
-       u8 *pframe = precv_frame->rx_data;
-       uint len = precv_frame->len;
-       u8 is_valid_p2p_probereq = false;
-
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) &&
-           !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE) &&
-           !rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT) &&
-           !rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH) &&
-           !rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN)) {
-               /*      mcs_rate = 0 -> CCK 1M rate */
-               /*      mcs_rate = 1 -> CCK 2M rate */
-               /*      mcs_rate = 2 -> CCK 5.5M rate */
-               /*      mcs_rate = 3 -> CCK 11M rate */
-               /*      In the P2P mode, the driver should not support the CCK rate */
-
-               /*      Commented by Kurt 2012/10/16 */
-               /*      IOT issue: Google Nexus7 use 1M rate to send p2p_probe_req after GO nego completed and Nexus7 is client */
-               is_valid_p2p_probereq = process_probe_req_p2p_ie(pwdinfo, pframe, len);
-               if (is_valid_p2p_probereq) {
-                       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) {
-                               /*  FIXME */
-                               report_survey_event(padapter, precv_frame);
-                               p2p_listen_state_process(padapter,  get_sa(pframe));
-
-                               return;
-                       }
-               }
-       }
-
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
-               return;
-
-       if (!check_fwstate(pmlmepriv, _FW_LINKED) &&
-           !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE))
-               return;
-
-       p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen,
-                       len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_);
-
-       /* check (wildcard) SSID */
-       if (p) {
-               if (is_valid_p2p_probereq)
-                       goto _issue_probersp;
-
-               if ((ielen != 0 && memcmp((void *)(p + 2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) ||
-                   (ielen == 0 && pmlmeinfo->hidden_ssid_mode))
-                       return;
-
-_issue_probersp:
-
-               if (check_fwstate(pmlmepriv, _FW_LINKED) &&
-                   (pmlmepriv->cur_network.join_res ||
-                   check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)))
-                       issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq);
-       }
-}
-
-static void OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8 *pframe = precv_frame->rx_data;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) {
-               if (pwdinfo->tx_prov_disc_info.benable) {
-                       if (!memcmp(pwdinfo->tx_prov_disc_info.peerIFAddr, GetAddr2Ptr(pframe), ETH_ALEN)) {
-                               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) {
-                                       pwdinfo->tx_prov_disc_info.benable = false;
-                                       issue_p2p_provision_request(padapter,
-                                                                   pwdinfo->tx_prov_disc_info.ssid.Ssid,
-                                                                   pwdinfo->tx_prov_disc_info.ssid.SsidLength,
-                                                                   pwdinfo->tx_prov_disc_info.peerDevAddr);
-                               } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                                       pwdinfo->tx_prov_disc_info.benable = false;
-                                       issue_p2p_provision_request(padapter, NULL, 0,
-                                                                   pwdinfo->tx_prov_disc_info.peerDevAddr);
-                               }
-                       }
-               }
-               return;
-       } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) {
-               if (pwdinfo->nego_req_info.benable) {
-                       if (!memcmp(pwdinfo->nego_req_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN)) {
-                               pwdinfo->nego_req_info.benable = false;
-                               issue_p2p_GO_request(padapter, pwdinfo->nego_req_info.peerDevAddr);
-                       }
-               }
-       } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) {
-               if (pwdinfo->invitereq_info.benable) {
-                       if (!memcmp(pwdinfo->invitereq_info.peer_macaddr, GetAddr2Ptr(pframe), ETH_ALEN)) {
-                               pwdinfo->invitereq_info.benable = false;
-                               issue_p2p_invitation_request(padapter, pwdinfo->invitereq_info.peer_macaddr);
-                       }
-               }
-       }
-       if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
-               report_survey_event(padapter, precv_frame);
-               return;
-       }
-}
-
-static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
-       int cam_idx;
-       struct sta_info *psta;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       u8 *pframe = precv_frame->rx_data;
-       uint len = precv_frame->len;
-       struct wlan_bssid_ex *pbss;
-       u8 *ie_ptr;
-       u32 ie_len;
-
-       ie_ptr = (u8 *)&mgmt->u.beacon.variable;
-       if (precv_frame->len < offsetof(struct ieee80211_mgmt, u.beacon.variable))
-               return;
-       ie_len = precv_frame->len - offsetof(struct ieee80211_mgmt, u.beacon.variable);
-
-       if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
-               report_survey_event(padapter, precv_frame);
-               return;
-       }
-
-       if (memcmp(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))
-               return;
-
-       if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
-               /* we should update current network before auth, or some IE is wrong */
-               pbss = kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC);
-               if (!pbss)
-                       return;
-
-               if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) {
-                       update_network(&pmlmepriv->cur_network.network, pbss, padapter, true);
-                       rtw_get_bcn_info(&pmlmepriv->cur_network);
-               }
-               kfree(pbss);
-
-               /* check the vendor of the assoc AP */
-               pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe + sizeof(struct ieee80211_hdr_3addr), len - sizeof(struct ieee80211_hdr_3addr));
-
-               pmlmeext->TSFValue = le64_to_cpu(mgmt->u.beacon.timestamp);
-
-               /* start auth */
-               start_clnt_auth(padapter);
-
-               return;
-       }
-
-       if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
-               psta = rtw_get_stainfo(pstapriv, mgmt->sa);
-               if (!psta)
-                       return;
-
-               if (rtw_check_bcn_info(padapter, pframe, len) != _SUCCESS) {
-                       receive_disconnect(padapter, pmlmeinfo->network.MacAddress, 0);
-                       return;
-               }
-               /* update WMM, ERP in the beacon */
-               /* todo: the timer is used instead of the number of the beacon received */
-               if ((sta_rx_pkts(psta) & 0xf) == 0)
-                       update_beacon_info(padapter, ie_ptr, ie_len, psta);
-               process_p2p_ps_ie(padapter, ie_ptr, ie_len);
-       } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) {
-               psta = rtw_get_stainfo(pstapriv, mgmt->sa);
-               if (psta) {
-                       /* update WMM, ERP in the beacon */
-                       /* todo: the timer is used instead of the number of the beacon received */
-                       if ((sta_rx_pkts(psta) & 0xf) == 0)
-                               update_beacon_info(padapter, ie_ptr, ie_len, psta);
-               } else {
-                       /* allocate a new CAM entry for IBSS station */
-                       cam_idx = allocate_fw_sta_entry(padapter);
-                       if (cam_idx == NUM_STA)
-                               return;
-
-                       /* get supported rate */
-                       if (update_sta_support_rate(padapter, ie_ptr, ie_len, cam_idx) == _FAIL) {
-                               pmlmeinfo->FW_sta_info[cam_idx].status = 0;
-                               return;
-                       }
-
-                       pmlmeext->TSFValue = le64_to_cpu(mgmt->u.beacon.timestamp);
-
-                       report_add_sta_event(padapter, mgmt->sa, cam_idx);
-               }
-       }
-}
-
-static void OnAuth(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       unsigned int    auth_mode, ie_len;
-       u16 seq;
-       unsigned char   *sa, *p;
-       u16 algorithm;
-       int     status;
-       static struct sta_info stat;
-       struct  sta_info        *pstat = NULL;
-       struct  sta_priv *pstapriv = &padapter->stapriv;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       u8 *pframe = precv_frame->rx_data;
-       uint len = precv_frame->len;
-
-       if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
-               return;
-
-       sa = GetAddr2Ptr(pframe);
-
-       auth_mode = psecuritypriv->dot11AuthAlgrthm;
-       seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + 2));
-       algorithm = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN));
-
-       if (auth_mode == 2 && psecuritypriv->dot11PrivacyAlgrthm != _WEP40_ &&
-           psecuritypriv->dot11PrivacyAlgrthm != _WEP104_)
-               auth_mode = 0;
-
-       if ((algorithm > 0 && auth_mode == 0) ||        /*  rx a shared-key auth but shared not enabled */
-           (algorithm == 0 && auth_mode == 1)) {       /*  rx a open-system auth but shared-key is enabled */
-
-               status = _STATS_NO_SUPP_ALG_;
-
-               goto auth_fail;
-       }
-
-       if (!rtw_access_ctrl(padapter, sa)) {
-               status = _STATS_UNABLE_HANDLE_STA_;
-               goto auth_fail;
-       }
-
-       pstat = rtw_get_stainfo(pstapriv, sa);
-       if (!pstat) {
-               /*  allocate a new one */
-               pstat = rtw_alloc_stainfo(pstapriv, sa);
-               if (!pstat) {
-                       status = _STATS_UNABLE_HANDLE_STA_;
-                       goto auth_fail;
-               }
-
-               pstat->state = WIFI_FW_AUTH_NULL;
-               pstat->auth_seq = 0;
-       } else {
-               spin_lock_bh(&pstapriv->asoc_list_lock);
-               if (!list_empty(&pstat->asoc_list)) {
-                       list_del_init(&pstat->asoc_list);
-                       pstapriv->asoc_list_cnt--;
-               }
-               spin_unlock_bh(&pstapriv->asoc_list_lock);
-
-               if (seq == 1) {
-                       /* TODO: STA re_auth and auth timeout */
-               }
-       }
-
-       spin_lock_bh(&pstapriv->auth_list_lock);
-       if (list_empty(&pstat->auth_list)) {
-               list_add_tail(&pstat->auth_list, &pstapriv->auth_list);
-               pstapriv->auth_list_cnt++;
-       }
-       spin_unlock_bh(&pstapriv->auth_list_lock);
-
-       if (pstat->auth_seq == 0)
-               pstat->expire_to = pstapriv->auth_to;
-
-       if ((pstat->auth_seq + 1) != seq) {
-               status = _STATS_OUT_OF_AUTH_SEQ_;
-               goto auth_fail;
-       }
-
-       if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2)) {
-               if (seq == 1) {
-                       pstat->state &= ~WIFI_FW_AUTH_NULL;
-                       pstat->state |= WIFI_FW_AUTH_SUCCESS;
-                       pstat->expire_to = pstapriv->assoc_to;
-                       pstat->authalg = algorithm;
-               } else {
-                       status = _STATS_OUT_OF_AUTH_SEQ_;
-                       goto auth_fail;
-               }
-       } else { /*  shared system or auto authentication */
-               if (seq == 1) {
-                       /* prepare for the challenging txt... */
-
-                       pstat->state &= ~WIFI_FW_AUTH_NULL;
-                       pstat->state |= WIFI_FW_AUTH_STATE;
-                       pstat->authalg = algorithm;
-                       pstat->auth_seq = 2;
-               } else if (seq == 3) {
-                       /* checking for challenging txt... */
-
-                       p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&ie_len,
-                                       len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4);
-
-                       if (!p || ie_len <= 0) {
-                               status = _STATS_CHALLENGE_FAIL_;
-                               goto auth_fail;
-                       }
-
-                       if (!memcmp((void *)(p + 2), pstat->chg_txt, 128)) {
-                               pstat->state &= (~WIFI_FW_AUTH_STATE);
-                               pstat->state |= WIFI_FW_AUTH_SUCCESS;
-                               /*  challenging txt is correct... */
-                               pstat->expire_to =  pstapriv->assoc_to;
-                       } else {
-                               status = _STATS_CHALLENGE_FAIL_;
-                               goto auth_fail;
-                       }
-               } else {
-                       status = _STATS_OUT_OF_AUTH_SEQ_;
-                       goto auth_fail;
-               }
-       }
-
-       /*  Now, we are going to issue_auth... */
-       pstat->auth_seq = seq + 1;
-
-       issue_auth(padapter, pstat, (unsigned short)(_STATS_SUCCESSFUL_));
-
-       if (pstat->state & WIFI_FW_AUTH_SUCCESS)
-               pstat->auth_seq = 0;
-
-       return;
-
-auth_fail:
-
-       if (pstat)
-               rtw_free_stainfo(padapter, pstat);
-
-       pstat = &stat;
-       memset((char *)pstat, '\0', sizeof(stat));
-       pstat->auth_seq = 2;
-       memcpy(pstat->hwaddr, sa, 6);
-
-       issue_auth(padapter, pstat, (unsigned short)status);
-}
-
-static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       unsigned int    seq, len, status, offset;
-       unsigned char   *p;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
-       u8 *pframe = precv_frame->rx_data;
-       uint pkt_len = precv_frame->len;
-
-       /* check A1 matches or not */
-       if (memcmp(myid(&padapter->eeprompriv), ieee80211_get_DA(hdr), ETH_ALEN))
-               return;
-
-       if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE))
-               return;
-
-       offset = ieee80211_has_protected(hdr->frame_control) ? 4 : 0;
-
-       seq     = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 2));
-       status  = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 4));
-
-       if (status != 0) {
-               if (status == 13) { /*  pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */
-                       if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
-                               pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open;
-                       else
-                               pmlmeinfo->auth_algo = dot11AuthAlgrthm_Shared;
-               }
-
-               set_link_timer(pmlmeext, 1);
-               return;
-       }
-
-       if (seq == 2) {
-               if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) {
-                        /*  legendary shared system */
-                       p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len,
-                               pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_);
-
-                       if (!p)
-                               return;
-
-                       memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len);
-                       pmlmeinfo->auth_seq = 3;
-                       issue_auth(padapter, NULL, 0);
-                       set_link_timer(pmlmeext, REAUTH_TO);
-
-                       return;
-               } else {
-                       /*  open system */
-                       start_clnt_assoc(padapter);
-               }
-       } else if (seq == 4) {
-               if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
-                       start_clnt_assoc(padapter);
-       }
-}
-
-static void UpdateBrateTbl(u8 *mbrate)
-{
-       u8 i;
-       u8 rate;
-
-       /*  1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */
-       for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) {
-               rate = mbrate[i] & 0x7f;
-               switch (rate) {
-               case IEEE80211_CCK_RATE_1MB:
-               case IEEE80211_CCK_RATE_2MB:
-               case IEEE80211_CCK_RATE_5MB:
-               case IEEE80211_CCK_RATE_11MB:
-               case IEEE80211_OFDM_RATE_6MB:
-               case IEEE80211_OFDM_RATE_12MB:
-               case IEEE80211_OFDM_RATE_24MB:
-                       mbrate[i] |= IEEE80211_BASIC_RATE_MASK;
-                       break;
-               }
-       }
-}
-
-static void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen)
-{
-       u8 i;
-       u8 rate;
-
-       for (i = 0; i < bssratelen; i++) {
-               rate = bssrateset[i] & 0x7f;
-               switch (rate) {
-               case IEEE80211_CCK_RATE_1MB:
-               case IEEE80211_CCK_RATE_2MB:
-               case IEEE80211_CCK_RATE_5MB:
-               case IEEE80211_CCK_RATE_11MB:
-                       bssrateset[i] |= IEEE80211_BASIC_RATE_MASK;
-                       break;
-               }
-       }
-}
-
-static void OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       u16 capab_info;
-       struct rtw_ieee802_11_elems elems;
-       struct sta_info *pstat;
-       unsigned char           *p, *pos, *wpa_ie;
-       unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01};
-       int             i, ie_len, wpa_ie_len, left;
-       unsigned char           supportRate[16];
-       int                                     supportRateNum;
-       unsigned short          status = _STATS_SUCCESSFUL_;
-       unsigned short          frame_type, ie_offset = 0;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *cur = &pmlmeinfo->network;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       u8 *pframe = precv_frame->rx_data;
-       uint pkt_len = precv_frame->len;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8 p2p_status_code = P2P_STATUS_SUCCESS;
-       u8 *p2pie;
-       u32 p2pielen = 0;
-
-       if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
-               return;
-
-       frame_type = GetFrameSubType(pframe);
-       if (frame_type == WIFI_ASSOCREQ)
-               ie_offset = _ASOCREQ_IE_OFFSET_;
-       else /*  WIFI_REASSOCREQ */
-               ie_offset = _REASOCREQ_IE_OFFSET_;
-
-       if (pkt_len < IEEE80211_3ADDR_LEN + ie_offset)
-               return;
-
-       pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
-       if (pstat == (struct sta_info *)NULL) {
-               status = _RSON_CLS2_;
-               goto asoc_class2_error;
-       }
-
-       capab_info = get_unaligned_le16(pframe + WLAN_HDR_A3_LEN);
-
-       left = pkt_len - (IEEE80211_3ADDR_LEN + ie_offset);
-       pos = pframe + (IEEE80211_3ADDR_LEN + ie_offset);
-
-       /*  check if this stat has been successfully authenticated/assocated */
-       if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) {
-               if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) {
-                       status = _RSON_CLS2_;
-                       goto asoc_class2_error;
-               } else {
-                       pstat->state &= (~WIFI_FW_ASSOC_SUCCESS);
-                       pstat->state |= WIFI_FW_ASSOC_STATE;
-               }
-       } else {
-               pstat->state &= (~WIFI_FW_AUTH_SUCCESS);
-               pstat->state |= WIFI_FW_ASSOC_STATE;
-       }
-       pstat->capability = capab_info;
-       /* now parse all ieee802_11 ie to point to elems */
-       if (rtw_ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed ||
-           !elems.ssid) {
-               status = _STATS_FAILURE_;
-               goto OnAssocReqFail;
-       }
-
-       /*  now we should check all the fields... */
-       /*  checking SSID */
-       p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len,
-               pkt_len - WLAN_HDR_A3_LEN - ie_offset);
-       if (!p)
-               status = _STATS_FAILURE_;
-
-       if (ie_len == 0) { /*  broadcast ssid, however it is not allowed in assocreq */
-               status = _STATS_FAILURE_;
-       } else {
-               /*  check if ssid match */
-               if (memcmp((void *)(p + 2), cur->Ssid.Ssid, cur->Ssid.SsidLength))
-                       status = _STATS_FAILURE_;
-
-               if (ie_len != cur->Ssid.SsidLength)
-                       status = _STATS_FAILURE_;
-       }
-
-       if (status != _STATS_SUCCESSFUL_)
-               goto OnAssocReqFail;
-
-       /*  check if the supported rate is ok */
-       p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset);
-       if (!p) {
-               /*  use our own rate set as statoin used */
-               /* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */
-               /* supportRateNum = AP_BSSRATE_LEN; */
-
-               status = _STATS_FAILURE_;
-               goto OnAssocReqFail;
-       } else {
-               memcpy(supportRate, p + 2, ie_len);
-               supportRateNum = ie_len;
-
-               p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len,
-                               pkt_len - WLAN_HDR_A3_LEN - ie_offset);
-               if (p) {
-                       if (supportRateNum <= sizeof(supportRate)) {
-                               memcpy(supportRate + supportRateNum, p + 2, ie_len);
-                               supportRateNum += ie_len;
-                       }
-               }
-       }
-
-       /* todo: mask supportRate between AP & STA -> move to update raid */
-       /* get_matched_rate(pmlmeext, supportRate, &supportRateNum, 0); */
-
-       /* update station supportRate */
-       pstat->bssratelen = supportRateNum;
-       memcpy(pstat->bssrateset, supportRate, supportRateNum);
-       UpdateBrateTblForSoftAP(pstat->bssrateset, pstat->bssratelen);
-
-       /* check RSN/WPA/WPS */
-       pstat->dot8021xalg = 0;
-       pstat->wpa_psk = 0;
-       pstat->wpa_group_cipher = 0;
-       pstat->wpa2_group_cipher = 0;
-       pstat->wpa_pairwise_cipher = 0;
-       pstat->wpa2_pairwise_cipher = 0;
-       memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie));
-       if ((psecuritypriv->wpa_psk & BIT(1)) && elems.rsn_ie) {
-               int group_cipher = 0, pairwise_cipher = 0;
-
-               wpa_ie = elems.rsn_ie;
-               wpa_ie_len = elems.rsn_ie_len;
-
-               if (rtw_parse_wpa2_ie(wpa_ie - 2, wpa_ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) {
-                       pstat->dot8021xalg = 1;/* psk,  todo:802.1x */
-                       pstat->wpa_psk |= BIT(1);
-
-                       pstat->wpa2_group_cipher = group_cipher & psecuritypriv->wpa2_group_cipher;
-                       pstat->wpa2_pairwise_cipher = pairwise_cipher & psecuritypriv->wpa2_pairwise_cipher;
-
-                       if (!pstat->wpa2_group_cipher)
-                               status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
-
-                       if (!pstat->wpa2_pairwise_cipher)
-                               status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
-               } else {
-                       status = WLAN_STATUS_INVALID_IE;
-               }
-       } else if ((psecuritypriv->wpa_psk & BIT(0)) && elems.wpa_ie) {
-               int group_cipher = 0, pairwise_cipher = 0;
-
-               wpa_ie = elems.wpa_ie;
-               wpa_ie_len = elems.wpa_ie_len;
-
-               if (rtw_parse_wpa_ie(wpa_ie - 2, wpa_ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) {
-                       pstat->dot8021xalg = 1;/* psk,  todo:802.1x */
-                       pstat->wpa_psk |= BIT(0);
-
-                       pstat->wpa_group_cipher = group_cipher & psecuritypriv->wpa_group_cipher;
-                       pstat->wpa_pairwise_cipher = pairwise_cipher & psecuritypriv->wpa_pairwise_cipher;
-
-                       if (!pstat->wpa_group_cipher)
-                               status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
-
-                       if (!pstat->wpa_pairwise_cipher)
-                               status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
-               } else {
-                       status = WLAN_STATUS_INVALID_IE;
-               }
-       } else {
-               wpa_ie = NULL;
-               wpa_ie_len = 0;
-       }
-
-       if (status != _STATS_SUCCESSFUL_)
-               goto OnAssocReqFail;
-
-       pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS);
-       if (!wpa_ie) {
-               if (elems.wps_ie)
-                       pstat->flags |= WLAN_STA_WPS;
-                       /* wpabuf_free(sta->wps_ie); */
-                       /* sta->wps_ie = wpabuf_alloc_copy(elems.wps_ie + 4, */
-                       /*                              elems.wps_ie_len - 4); */
-               else
-                       pstat->flags |= WLAN_STA_MAYBE_WPS;
-
-               /*  AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */
-               /*  that the selected registrar of AP is _FLASE */
-               if ((psecuritypriv->wpa_psk > 0) && (pstat->flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS))) {
-                       if (pmlmepriv->wps_beacon_ie) {
-                               u8 selected_registrar = 0;
-
-                               rtw_get_wps_attr_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR, &selected_registrar, NULL);
-
-                               if (!selected_registrar) {
-
-                                       status = _STATS_UNABLE_HANDLE_STA_;
-
-                                       goto OnAssocReqFail;
-                               }
-                       }
-               }
-       } else {
-               int copy_len;
-
-               if (psecuritypriv->wpa_psk == 0) {
-
-                       status = WLAN_STATUS_INVALID_IE;
-
-                       goto OnAssocReqFail;
-               }
-
-               if (elems.wps_ie) {
-                       pstat->flags |= WLAN_STA_WPS;
-                       copy_len = 0;
-               } else {
-                       copy_len = ((wpa_ie_len + 2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)) : (wpa_ie_len + 2);
-               }
-               if (copy_len > 0)
-                       memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len);
-       }
-       /*  check if there is WMM IE & support WWM-PS */
-       pstat->flags &= ~WLAN_STA_WME;
-       pstat->qos_option = 0;
-       pstat->qos_info = 0;
-       pstat->has_legacy_ac = true;
-       pstat->uapsd_vo = 0;
-       pstat->uapsd_vi = 0;
-       pstat->uapsd_be = 0;
-       pstat->uapsd_bk = 0;
-       if (pmlmepriv->qospriv.qos_option) {
-               p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0;
-               for (;;) {
-                       p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset);
-                       if (p) {
-                               if (!memcmp(p + 2, WMM_IE, 6)) {
-                                       pstat->flags |= WLAN_STA_WME;
-
-                                       pstat->qos_option = 1;
-                                       pstat->qos_info = *(p + 8);
-
-                                       pstat->max_sp_len = (pstat->qos_info >> 5) & 0x3;
-
-                                       if ((pstat->qos_info & 0xf) != 0xf)
-                                               pstat->has_legacy_ac = true;
-                                       else
-                                               pstat->has_legacy_ac = false;
-
-                                       if (pstat->qos_info & 0xf) {
-                                               if (pstat->qos_info & BIT(0))
-                                                       pstat->uapsd_vo = BIT(0) | BIT(1);
-                                               else
-                                                       pstat->uapsd_vo = 0;
-
-                                               if (pstat->qos_info & BIT(1))
-                                                       pstat->uapsd_vi = BIT(0) | BIT(1);
-                                               else
-                                                       pstat->uapsd_vi = 0;
-
-                                               if (pstat->qos_info & BIT(2))
-                                                       pstat->uapsd_bk = BIT(0) | BIT(1);
-                                               else
-                                                       pstat->uapsd_bk = 0;
-
-                                               if (pstat->qos_info & BIT(3))
-                                                       pstat->uapsd_be = BIT(0) | BIT(1);
-                                               else
-                                                       pstat->uapsd_be = 0;
-                                       }
-                                       break;
-                               }
-                       } else {
-                               break;
-                       }
-                       p = p + ie_len + 2;
-               }
-       }
-
-       /* save HT capabilities in the sta object */
-       memset(&pstat->htpriv.ht_cap, 0, sizeof(struct ieee80211_ht_cap));
-       if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct ieee80211_ht_cap)) {
-               pstat->flags |= WLAN_STA_HT;
-
-               pstat->flags |= WLAN_STA_WME;
-
-               memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, sizeof(struct ieee80211_ht_cap));
-       } else {
-               pstat->flags &= ~WLAN_STA_HT;
-       }
-       if ((!pmlmepriv->htpriv.ht_option) && (pstat->flags & WLAN_STA_HT)) {
-               status = _STATS_FAILURE_;
-               goto OnAssocReqFail;
-       }
-
-       pstat->flags |= WLAN_STA_NONERP;
-       for (i = 0; i < pstat->bssratelen; i++) {
-               if ((pstat->bssrateset[i] & 0x7f) > 22) {
-                       pstat->flags &= ~WLAN_STA_NONERP;
-                       break;
-               }
-       }
-
-       if (pstat->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
-               pstat->flags |= WLAN_STA_SHORT_PREAMBLE;
-       else
-               pstat->flags &= ~WLAN_STA_SHORT_PREAMBLE;
-
-       if (status != _STATS_SUCCESSFUL_)
-               goto OnAssocReqFail;
-
-       pstat->is_p2p_device = false;
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-               p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, pkt_len - WLAN_HDR_A3_LEN - ie_offset, NULL, &p2pielen);
-               if (p2pie) {
-                       pstat->is_p2p_device = true;
-                       p2p_status_code = (u8)process_assoc_req_p2p_ie(pwdinfo, pframe, pkt_len, pstat);
-                       if (p2p_status_code > 0) {
-                               pstat->p2p_status_code = p2p_status_code;
-                               status = _STATS_CAP_FAIL_;
-                               goto OnAssocReqFail;
-                       }
-               }
-       }
-       pstat->p2p_status_code = p2p_status_code;
-
-       /* TODO: identify_proprietary_vendor_ie(); */
-       /*  Realtek proprietary IE */
-       /*  identify if this is Broadcom sta */
-       /*  identify if this is ralink sta */
-       /*  Customer proprietary IE */
-
-       /* get a unique AID */
-       if (pstat->aid == 0) {
-               for (pstat->aid = 1; pstat->aid <= NUM_STA; pstat->aid++)
-                       if (!pstapriv->sta_aid[pstat->aid - 1])
-                               break;
-
-               /* if (pstat->aid > NUM_STA) { */
-               if (pstat->aid > pstapriv->max_num_sta) {
-                       pstat->aid = 0;
-
-                       status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
-
-                       goto OnAssocReqFail;
-               } else {
-                       pstapriv->sta_aid[pstat->aid - 1] = pstat;
-               }
-       }
-
-       pstat->state &= (~WIFI_FW_ASSOC_STATE);
-       pstat->state |= WIFI_FW_ASSOC_SUCCESS;
-
-       spin_lock_bh(&pstapriv->auth_list_lock);
-       if (!list_empty(&pstat->auth_list)) {
-               list_del_init(&pstat->auth_list);
-               pstapriv->auth_list_cnt--;
-       }
-       spin_unlock_bh(&pstapriv->auth_list_lock);
-
-       spin_lock_bh(&pstapriv->asoc_list_lock);
-       if (list_empty(&pstat->asoc_list)) {
-               pstat->expire_to = pstapriv->expire_to;
-               list_add_tail(&pstat->asoc_list, &pstapriv->asoc_list);
-               pstapriv->asoc_list_cnt++;
-       }
-       spin_unlock_bh(&pstapriv->asoc_list_lock);
-
-       /*  now the station is qualified to join our BSS... */
-       if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (status == _STATS_SUCCESSFUL_)) {
-               /* 1 bss_cap_update & sta_info_update */
-               bss_cap_update_on_sta_join(padapter, pstat);
-               sta_info_update(padapter, pstat);
-
-               /* issue assoc rsp before notify station join event. */
-               if (frame_type == WIFI_ASSOCREQ)
-                       issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP);
-               else
-                       issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP);
-
-               /* 2 - report to upper layer */
-               rtw_indicate_sta_assoc_event(padapter, pstat);
-
-               /* 3-(1) report sta add event */
-               report_add_sta_event(padapter, pstat->hwaddr, pstat->aid);
-       }
-
-       return;
-
-asoc_class2_error:
-
-       issue_deauth(padapter, (void *)GetAddr2Ptr(pframe), status);
-
-       return;
-
-OnAssocReqFail:
-
-       pstat->aid = 0;
-       if (frame_type == WIFI_ASSOCREQ)
-               issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP);
-       else
-               issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP);
-
-       return;
-}
-
-static void OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
-       uint i;
-       int res;
-       struct ndis_802_11_var_ie *pIE;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       /* struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); */
-       u8 *pframe = precv_frame->rx_data;
-       uint pkt_len = precv_frame->len;
-
-       /* check A1 matches or not */
-       if (memcmp(myid(&padapter->eeprompriv), mgmt->da, ETH_ALEN))
-               return;
-
-       if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE)))
-               return;
-
-       if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)
-               return;
-
-       _cancel_timer_ex(&pmlmeext->link_timer);
-
-       if (le16_to_cpu(mgmt->u.assoc_resp.status_code) > 0) {
-               pmlmeinfo->state = WIFI_FW_NULL_STATE;
-               res = -4;
-               goto report_assoc_result;
-       }
-
-       pmlmeinfo->capability = le16_to_cpu(mgmt->u.assoc_resp.capab_info);
-
-       /* set slot time */
-       pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10)) ? 9 : 20;
-
-       pmlmeinfo->aid = le16_to_cpu(mgmt->u.assoc_resp.aid) & 0x3fff;
-       res = pmlmeinfo->aid;
-
-       /* following are moved to join event callback function */
-       /* to handle HT, WMM, rate adaptive, update MAC reg */
-       /* for not to handle the synchronous IO in the tasklet */
-       for (i = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); i < pkt_len;) {
-               pIE = (struct ndis_802_11_var_ie *)(pframe + i);
-
-               switch (pIE->ElementID) {
-               case _VENDOR_SPECIFIC_IE_:
-                       if (!memcmp(pIE->data, WMM_PARA_OUI, 6))        /* WMM */
-                               WMM_param_handler(padapter, pIE);
-                       break;
-               case _HT_CAPABILITY_IE_:        /* HT caps */
-                       HT_caps_handler(padapter, pIE);
-                       break;
-               case _HT_EXTRA_INFO_IE_:        /* HT info */
-                       HT_info_handler(padapter, pIE);
-                       break;
-               case _ERPINFO_IE_:
-                       ERP_IE_handler(padapter, pIE);
-                       break;
-               default:
-                       break;
-               }
-
-               i += (pIE->Length + 2);
-       }
-
-       pmlmeinfo->state &= (~WIFI_FW_ASSOC_STATE);
-       pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS;
-
-       /* Update Basic Rate Table for spec, 2010-12-28 , by thomas */
-       UpdateBrateTbl(pmlmeinfo->network.SupportedRates);
-
-report_assoc_result:
-       report_join_res(padapter, res);
-}
-
-static void OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
-       unsigned short  reason;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if (memcmp(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))
-               return;
-
-       if (pwdinfo->rx_invitereq_info.scan_op_ch_only) {
-               _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey);
-               _set_timer(&pwdinfo->reset_ch_sitesurvey, 10);
-       }
-
-       reason = le16_to_cpu(mgmt->u.disassoc.reason_code);
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               struct sta_info *psta;
-               struct sta_priv *pstapriv = &padapter->stapriv;
-               u8 updated = 0;
-
-               psta = rtw_get_stainfo(pstapriv, mgmt->sa);
-               if (!psta)
-                       return;
-
-               spin_lock_bh(&pstapriv->asoc_list_lock);
-               if (!list_empty(&psta->asoc_list)) {
-                       list_del_init(&psta->asoc_list);
-                       pstapriv->asoc_list_cnt--;
-                       updated = ap_free_sta(padapter, psta, false, reason);
-               }
-               spin_unlock_bh(&pstapriv->asoc_list_lock);
-
-               associated_clients_update(padapter, updated);
-       } else {
-               bool ignore_received_deauth = false;
-
-               /* Before sending the auth frame to start the STA/GC mode connection with AP/GO,
-                *      we will send the deauth first.
-                *      However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth.
-                *      Added the following code to avoid this case.
-                */
-               if (pmlmeinfo->state & (WIFI_FW_AUTH_STATE | WIFI_FW_ASSOC_STATE)) {
-                       if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) {
-                               ignore_received_deauth = true;
-                       } else if (reason == WLAN_REASON_PREV_AUTH_NOT_VALID) {
-                               // TODO: 802.11r
-                               ignore_received_deauth = true;
-                       }
-               }
-
-               if (!ignore_received_deauth)
-                       receive_disconnect(padapter, mgmt->bssid, reason);
-
-               pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
-       }
-}
-
-static void OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
-       u16 reason;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       struct sta_info *psta;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       u8 updated = 0;
-
-       if (memcmp(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))
-               return;
-
-       if (pwdinfo->rx_invitereq_info.scan_op_ch_only) {
-               _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey);
-               _set_timer(&pwdinfo->reset_ch_sitesurvey, 10);
-       }
-
-       reason = le16_to_cpu(mgmt->u.disassoc.reason_code);
-
-       if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               receive_disconnect(padapter, mgmt->bssid, reason);
-               pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
-               return;
-       }
-
-       psta = rtw_get_stainfo(pstapriv, mgmt->sa);
-       if (!psta)
-               return;
-
-       spin_lock_bh(&pstapriv->asoc_list_lock);
-       if (!list_empty(&psta->asoc_list)) {
-               list_del_init(&psta->asoc_list);
-               pstapriv->asoc_list_cnt--;
-               updated = ap_free_sta(padapter, psta, false, reason);
-       }
-       spin_unlock_bh(&pstapriv->asoc_list_lock);
-
-       associated_clients_update(padapter, updated);
-}
-
-static void OnAction_back(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
-       struct sta_info *psta = NULL;
-       struct recv_reorder_ctrl *preorder_ctrl;
-       unsigned short  tid;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
-               if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS))
-                       return;
-
-       psta = rtw_get_stainfo(pstapriv, mgmt->sa);
-       if (!psta)
-               return;
-
-       if (!pmlmeinfo->HT_enable)
-               return;
-       /* All union members start with an action code, it's ok to use addba_req. */
-       switch (mgmt->u.action.u.addba_req.action_code) {
-       case WLAN_ACTION_ADDBA_REQ:
-               tid = u16_get_bits(le16_to_cpu(mgmt->u.action.u.addba_req.capab),
-                                  IEEE80211_ADDBA_PARAM_TID_MASK);
-               preorder_ctrl = &psta->recvreorder_ctrl[tid];
-               preorder_ctrl->indicate_seq = 0xffff;
-               preorder_ctrl->enable = pmlmeinfo->bAcceptAddbaReq;
-               issue_action_BA(padapter, mgmt->sa, WLAN_ACTION_ADDBA_RESP,
-                               pmlmeinfo->bAcceptAddbaReq ?
-                                       WLAN_STATUS_SUCCESS : WLAN_STATUS_REQUEST_DECLINED, mgmt);
-               break;
-       case WLAN_ACTION_ADDBA_RESP:
-               tid = u16_get_bits(le16_to_cpu(mgmt->u.action.u.addba_resp.capab),
-                                  IEEE80211_ADDBA_PARAM_TID_MASK);
-               if (mgmt->u.action.u.addba_resp.status == 0) {  /* successful */
-                       psta->htpriv.agg_enable_bitmap |= BIT(tid);
-                       psta->htpriv.candidate_tid_bitmap &= ~BIT(tid);
-               } else {
-                       psta->htpriv.agg_enable_bitmap &= ~BIT(tid);
-               }
-               break;
-       case WLAN_ACTION_DELBA:
-               tid = u16_get_bits(le16_to_cpu(mgmt->u.action.u.delba.params),
-                                  IEEE80211_DELBA_PARAM_TID_MASK);
-               if (u16_get_bits(le16_to_cpu(mgmt->u.action.u.delba.params),
-                                IEEE80211_DELBA_PARAM_INITIATOR_MASK) == WLAN_BACK_RECIPIENT) {
-                       psta->htpriv.agg_enable_bitmap &= ~BIT(tid);
-                       psta->htpriv.candidate_tid_bitmap &= ~BIT(tid);
-               } else {
-                       preorder_ctrl =  &psta->recvreorder_ctrl[tid];
-                       preorder_ctrl->enable = false;
-                       preorder_ctrl->indicate_seq = 0xffff;
-               }
-               /* todo: how to notify the host while receiving DELETE BA */
-               break;
-       default:
-               break;
-       }
-}
-
-static int get_reg_classes_full_count(struct p2p_channels *channel_list)
-{
-       int cnt = 0;
-       int i;
-
-       for (i = 0; i < channel_list->reg_classes; i++) {
-               cnt += channel_list->reg_class[i].channels;
-       }
-
-       return cnt;
-}
-
-void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr)
-{
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       __be32 p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_GO_NEGO_REQ;
-       u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 };
-       u8 wpsielen = 0, p2pielen = 0;
-       u16 len_channellist_attr = 0;
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       unsigned char *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pwdinfo->negotiation_dialog_token = 1;  /*      Initialize the dialog value */
-       pframe = rtw_set_fixed_ie(pframe, 1, &pwdinfo->negotiation_dialog_token, &pattrib->pktlen);
-
-       /*      WPS Section */
-       wpsielen = 0;
-       /*      WPS OUI */
-       *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      WPS version */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-       /*      Device Password ID */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002);
-       wpsielen += 2;
-
-       /*      Value: */
-
-       if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN)
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC);
-       else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN)
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC);
-       else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC)
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC);
-
-       wpsielen += 2;
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen);
-
-       /*      P2P IE Section. */
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20110306 */
-       /*      According to the P2P Specification, the group negotiation request frame should contain 9 P2P attributes */
-       /*      1. P2P Capability */
-       /*      2. Group Owner Intent */
-       /*      3. Configuration Timeout */
-       /*      4. Listen Channel */
-       /*      5. Extended Listen Timing */
-       /*      6. Intended P2P Interface Address */
-       /*      7. Channel List */
-       /*      8. P2P Device Info */
-       /*      9. Operating Channel */
-
-       /*      P2P Capability */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (pwdinfo->persistent_supported)
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP;
-       else
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN;
-
-       /*      Group Owner Intent */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_GO_INTENT;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Todo the tie breaker bit. */
-       p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0));
-
-       /*      Configuration Timeout */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = 200;        /*      2 seconds needed to be the P2P GO */
-       p2pie[p2pielen++] = 200;        /*      2 seconds needed to be the P2P Client */
-
-       /*      Listen Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Operating Class */
-       p2pie[p2pielen++] = 0x51;       /*      Copy from SD7 */
-
-       /*      Channel Number */
-       p2pie[p2pielen++] = pwdinfo->listen_channel;    /*      listening channel number */
-
-       /*      Extended Listen Timing ATTR */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Availability Period */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-       p2pielen += 2;
-
-       /*      Availability Interval */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-       p2pielen += 2;
-
-       /*      Intended P2P Interface Address */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Channel List */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CH_LIST;
-
-       /*  Length: */
-       /*  Country String(3) */
-       /*  + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */
-       /*  + number of channels in all classes */
-       len_channellist_attr = 3
-          + (1 + 1) * (u16)(pmlmeext->channel_list.reg_classes)
-          + get_reg_classes_full_count(&pmlmeext->channel_list);
-
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Channel Entry List */
-
-       {
-               int i, j;
-               for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class;
-
-                       /*      Number of Channels */
-                       p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels;
-
-                       /*      Channel List */
-                       for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) {
-                               p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i];
-                       }
-               }
-       }
-
-       /*      Device Info */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
-       /*      + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address */
-       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Config Method */
-       /*      This field should be big endian. Noted by P2P specification. */
-
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm);
-
-       p2pielen += 2;
-
-       /*      Primary Device Type */
-       /*      Category ID */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-       p2pielen += 2;
-
-       /*      OUI */
-       *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI);
-       p2pielen += 4;
-
-       /*      Sub Category ID */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-       p2pielen += 2;
-
-       /*      Number of Secondary Device Types */
-       p2pie[p2pielen++] = 0x00;       /*      No Secondary Device Type List */
-
-       /*      Device Name */
-       /*      Type: */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-       p2pielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len);
-       p2pielen += pwdinfo->device_name_len;
-
-       /*      Operating Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Operating Class */
-       p2pie[p2pielen++] = 0x51;
-
-       /*      Channel Number */
-       p2pie[p2pielen++] = pwdinfo->operating_channel; /*      operating channel number */
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame_body, uint len, u8 result)
-{
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       __be32                  p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_GO_NEGO_RESP;
-       u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 };
-       u8 p2pielen = 0;
-       uint                    wpsielen = 0;
-       u16 wps_devicepassword_id = 0x0000;
-       __be16                  be_tmp;
-       uint                    wps_devicepassword_id_len = 0;
-       u16 len_channellist_attr = 0;
-
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pwdinfo->negotiation_dialog_token = frame_body[7];      /*      The Dialog Token of provisioning discovery request frame. */
-       pframe = rtw_set_fixed_ie(pframe, 1, &pwdinfo->negotiation_dialog_token, &pattrib->pktlen);
-
-       /*      Commented by Albert 20110328 */
-       /*      Try to get the device password ID from the WPS IE of group negotiation request frame */
-       /*      WiFi Direct test plan 5.1.15 */
-       rtw_get_wps_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, wpsie, &wpsielen);
-       rtw_get_wps_attr_content(wpsie, wpsielen, WPS_ATTR_DEVICE_PWID, (u8 *)&be_tmp, &wps_devicepassword_id_len);
-       wps_devicepassword_id = be16_to_cpu(be_tmp);
-
-       memset(wpsie, 0x00, 255);
-       wpsielen = 0;
-
-       /*      WPS Section */
-       wpsielen = 0;
-       /*      WPS OUI */
-       *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      WPS version */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-       /*      Device Password ID */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002);
-       wpsielen += 2;
-
-       /*      Value: */
-       if (wps_devicepassword_id == WPS_DPID_USER_SPEC)
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC);
-       else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC)
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC);
-       else
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC);
-       wpsielen += 2;
-
-       /*      Commented by Kurt 20120113 */
-       /*      If some device wants to do p2p handshake without sending prov_disc_req */
-       /*      We have to get peer_req_cm from here. */
-       if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) {
-               if (wps_devicepassword_id == WPS_DPID_USER_SPEC)
-                       memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3);
-               else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC)
-                       memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3);
-               else
-                       memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3);
-       }
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen);
-
-       /*      P2P IE Section. */
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20100908 */
-       /*      According to the P2P Specification, the group negotiation response frame should contain 9 P2P attributes */
-       /*      1. Status */
-       /*      2. P2P Capability */
-       /*      3. Group Owner Intent */
-       /*      4. Configuration Timeout */
-       /*      5. Operating Channel */
-       /*      6. Intended P2P Interface Address */
-       /*      7. Channel List */
-       /*      8. Device Info */
-       /*      9. Group ID     (Only GO) */
-
-       /*      ToDo: */
-
-       /*      P2P Status */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_STATUS;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = result;
-
-       /*      P2P Capability */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) {
-               /*      Commented by Albert 2011/03/08 */
-               /*      According to the P2P specification */
-               /*      if the sending device will be client, the P2P Capability should be reserved of group negotiation response frame */
-               p2pie[p2pielen++] = 0;
-       } else {
-               /*      Be group owner or meet the error case */
-               p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-       }
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (pwdinfo->persistent_supported) {
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP;
-       } else {
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN;
-       }
-
-       /*      Group Owner Intent */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_GO_INTENT;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       if (pwdinfo->peer_intent & 0x01) {
-               /*      Peer's tie breaker bit is 1, our tie breaker bit should be 0 */
-               p2pie[p2pielen++] = (pwdinfo->intent << 1);
-       } else {
-               /*      Peer's tie breaker bit is 0, our tie breaker bit should be 1 */
-               p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0));
-       }
-
-       /*      Configuration Timeout */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = 200;        /*      2 seconds needed to be the P2P GO */
-       p2pie[p2pielen++] = 200;        /*      2 seconds needed to be the P2P Client */
-
-       /*      Operating Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Operating Class */
-       p2pie[p2pielen++] = 0x51;
-
-       /*      Channel Number */
-       p2pie[p2pielen++] = pwdinfo->operating_channel; /*      operating channel number */
-
-       /*      Intended P2P Interface Address */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Channel List */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CH_LIST;
-
-       /*  Country String(3) */
-       /*  + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */
-       /*  + number of channels in all classes */
-       len_channellist_attr = 3
-          + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes
-          + get_reg_classes_full_count(&pmlmeext->channel_list);
-
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr);
-
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Channel Entry List */
-
-       {
-               int i, j;
-               for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class;
-
-                       /*      Number of Channels */
-                       p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels;
-
-                       /*      Channel List */
-                       for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) {
-                               p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i];
-                       }
-               }
-       }
-
-       /*      Device Info */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
-       /*      + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address */
-       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Config Method */
-       /*      This field should be big endian. Noted by P2P specification. */
-
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm);
-
-       p2pielen += 2;
-
-       /*      Primary Device Type */
-       /*      Category ID */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-       p2pielen += 2;
-
-       /*      OUI */
-       *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI);
-       p2pielen += 4;
-
-       /*      Sub Category ID */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-       p2pielen += 2;
-
-       /*      Number of Secondary Device Types */
-       p2pie[p2pielen++] = 0x00;       /*      No Secondary Device Type List */
-
-       /*      Device Name */
-       /*      Type: */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-       p2pielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len);
-       p2pielen += pwdinfo->device_name_len;
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-               /*      Group ID Attribute */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_GROUP_ID;
-
-               /*      Length: */
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      p2P Device Address */
-               memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN);
-               p2pielen += ETH_ALEN;
-
-               /*      SSID */
-               memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen);
-               p2pielen += pwdinfo->nego_ssidlen;
-       }
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result)
-{
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       __be32                  p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_GO_NEGO_CONF;
-       u8 p2pie[255] = { 0x00 };
-       u8 p2pielen = 0;
-
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &pwdinfo->negotiation_dialog_token, &pattrib->pktlen);
-
-       /*      P2P IE Section. */
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20110306 */
-       /*      According to the P2P Specification, the group negotiation request frame should contain 5 P2P attributes */
-       /*      1. Status */
-       /*      2. P2P Capability */
-       /*      3. Operating Channel */
-       /*      4. Channel List */
-       /*      5. Group ID     (if this WiFi is GO) */
-
-       /*      P2P Status */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_STATUS;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = result;
-
-       /*      P2P Capability */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (pwdinfo->persistent_supported)
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP;
-       else
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN;
-
-       /*      Operating Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) {
-               /*      Operating Class */
-               p2pie[p2pielen++] = 0x51;
-               p2pie[p2pielen++] = pwdinfo->peer_operating_ch;
-       } else {
-               /*      Operating Class */
-               p2pie[p2pielen++] = 0x51;
-
-               /*      Channel Number */
-               p2pie[p2pielen++] = pwdinfo->operating_channel;         /*      Use the listen channel as the operating channel */
-       }
-
-       /*      Channel List */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CH_LIST;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(pwdinfo->channel_list_attr_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len);
-       p2pielen += pwdinfo->channel_list_attr_len;
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-               /*      Group ID Attribute */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_GROUP_ID;
-
-               /*      Length: */
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      p2P Device Address */
-               memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN);
-               p2pielen += ETH_ALEN;
-
-               /*      SSID */
-               memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen);
-               p2pielen += pwdinfo->nego_ssidlen;
-       }
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen);
-       pattrib->last_txcmdsz = pattrib->pktlen;
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr)
-{
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       __be32                  p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_INVIT_REQ;
-       u8 p2pie[255] = { 0x00 };
-       u8 p2pielen = 0;
-       u8 dialogToken = 3;
-       u16 len_channellist_attr = 0;
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, raddr,  ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /*      P2P IE Section. */
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20101011 */
-       /*      According to the P2P Specification, the P2P Invitation request frame should contain 7 P2P attributes */
-       /*      1. Configuration Timeout */
-       /*      2. Invitation Flags */
-       /*      3. Operating Channel    (Only GO) */
-       /*      4. P2P Group BSSID      (Should be included if I am the GO) */
-       /*      5. Channel List */
-       /*      6. P2P Group ID */
-       /*      7. P2P Device Info */
-
-       /*      Configuration Timeout */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = 200;        /*      2 seconds needed to be the P2P GO */
-       p2pie[p2pielen++] = 200;        /*      2 seconds needed to be the P2P Client */
-
-       /*      Invitation Flags */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_INVITATION_FLAGS;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = P2P_INVITATION_FLAGS_PERSISTENT;
-
-       /*      Operating Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Operating Class */
-       p2pie[p2pielen++] = 0x51;
-
-       /*      Channel Number */
-       p2pie[p2pielen++] = pwdinfo->invitereq_info.operating_ch;       /*      operating channel number */
-
-       if (!memcmp(myid(&padapter->eeprompriv), pwdinfo->invitereq_info.go_bssid, ETH_ALEN)) {
-               /*      P2P Group BSSID */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID;
-
-               /*      Length: */
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      P2P Device Address for GO */
-               memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN);
-               p2pielen += ETH_ALEN;
-       }
-
-       /*      Channel List */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CH_LIST;
-
-       /*      Length: */
-       /*  Country String(3) */
-       /*  + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */
-       /*  + number of channels in all classes */
-       len_channellist_attr = 3
-          + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes
-          + get_reg_classes_full_count(&pmlmeext->channel_list);
-
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr);
-
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Channel Entry List */
-       {
-               int i, j;
-               for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class;
-
-                       /*      Number of Channels */
-                       p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels;
-
-                       /*      Channel List */
-                       for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) {
-                               p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i];
-                       }
-               }
-       }
-
-       /*      P2P Group ID */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_GROUP_ID;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(6 + pwdinfo->invitereq_info.ssidlen);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address for GO */
-       memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      SSID */
-       memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_ssid, pwdinfo->invitereq_info.ssidlen);
-       p2pielen += pwdinfo->invitereq_info.ssidlen;
-
-       /*      Device Info */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
-       /*      + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address */
-       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Config Method */
-       /*      This field should be big endian. Noted by P2P specification. */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY);
-       p2pielen += 2;
-
-       /*      Primary Device Type */
-       /*      Category ID */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-       p2pielen += 2;
-
-       /*      OUI */
-       *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI);
-       p2pielen  += 4;
-
-       /*      Sub Category ID */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-       p2pielen += 2;
-
-       /*      Number of Secondary Device Types */
-       p2pie[p2pielen++] = 0x00;       /*      No Secondary Device Type List */
-
-       /*      Device Name */
-       /*      Type: */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-       p2pielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len);
-       p2pielen += pwdinfo->device_name_len;
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, u8 dialogToken, u8 status_code)
-{
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       __be32                  p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_INVIT_RESP;
-       u8 p2pie[255] = { 0x00 };
-       u8 p2pielen = 0;
-       u16 len_channellist_attr = 0;
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, raddr,  ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /*      P2P IE Section. */
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20101005 */
-       /*      According to the P2P Specification, the P2P Invitation response frame should contain 5 P2P attributes */
-       /*      1. Status */
-       /*      2. Configuration Timeout */
-       /*      3. Operating Channel    (Only GO) */
-       /*      4. P2P Group BSSID      (Only GO) */
-       /*      5. Channel List */
-
-       /*      P2P Status */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_STATUS;
-
-       /*      Length: */
-       *(__le16  *)(p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      When status code is P2P_STATUS_FAIL_INFO_UNAVAILABLE. */
-       /*      Sent the event receiving the P2P Invitation Req frame to DMP UI. */
-       /*      DMP had to compare the MAC address to find out the profile. */
-       /*      So, the WiFi driver will send the P2P_STATUS_FAIL_INFO_UNAVAILABLE to NB. */
-       /*      If the UI found the corresponding profile, the WiFi driver sends the P2P Invitation Req */
-       /*      to NB to rebuild the persistent group. */
-       p2pie[p2pielen++] = status_code;
-
-       /*      Configuration Timeout */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = 200;        /*      2 seconds needed to be the P2P GO */
-       p2pie[p2pielen++] = 200;        /*      2 seconds needed to be the P2P Client */
-
-       if (status_code == P2P_STATUS_SUCCESS) {
-               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                       /*      The P2P Invitation request frame asks this Wi-Fi device to be the P2P GO */
-                       /*      In this case, the P2P Invitation response frame should carry the two more P2P attributes. */
-                       /*      First one is operating channel attribute. */
-                       /*      Second one is P2P Group BSSID attribute. */
-
-                       /*      Operating Channel */
-                       /*      Type: */
-                       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-                       /*      Length: */
-                       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005);
-                       p2pielen += 2;
-
-                       /*      Value: */
-                       /*      Country String */
-                       p2pie[p2pielen++] = 'X';
-                       p2pie[p2pielen++] = 'X';
-
-                       /*      The third byte should be set to 0x04. */
-                       /*      Described in the "Operating Channel Attribute" section. */
-                       p2pie[p2pielen++] = 0x04;
-
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = 0x51;       /*      Copy from SD7 */
-
-                       /*      Channel Number */
-                       p2pie[p2pielen++] = pwdinfo->operating_channel; /*      operating channel number */
-
-                       /*      P2P Group BSSID */
-                       /*      Type: */
-                       p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID;
-
-                       /*      Length: */
-                       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN);
-                       p2pielen += 2;
-
-                       /*      Value: */
-                       /*      P2P Device Address for GO */
-                       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-                       p2pielen += ETH_ALEN;
-               }
-
-               /*      Channel List */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_CH_LIST;
-
-               /*      Length: */
-               /*  Country String(3) */
-               /*  + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */
-               /*  + number of channels in all classes */
-               len_channellist_attr = 3
-                       + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes
-                       + get_reg_classes_full_count(&pmlmeext->channel_list);
-
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      Country String */
-               p2pie[p2pielen++] = 'X';
-               p2pie[p2pielen++] = 'X';
-
-               /*      The third byte should be set to 0x04. */
-               /*      Described in the "Operating Channel Attribute" section. */
-               p2pie[p2pielen++] = 0x04;
-
-               /*      Channel Entry List */
-               {
-                       int i, j;
-                       for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) {
-                               /*      Operating Class */
-                               p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class;
-
-                               /*      Number of Channels */
-                               p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels;
-
-                               /*      Channel List */
-                               for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) {
-                                       p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i];
-                               }
-                       }
-               }
-       }
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, u8 ussidlen, u8 *pdev_raddr)
-{
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       u8 dialogToken = 1;
-       u8 oui_subtype = P2P_PROVISION_DISC_REQ;
-       u8 wpsie[100] = { 0x00 };
-       u8 wpsielen = 0;
-       __be32 p2poui = cpu_to_be32(P2POUI);
-       u32                     p2pielen = 0;
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, pdev_raddr, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, pdev_raddr, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       p2pielen = build_prov_disc_request_p2p_ie(pwdinfo, pframe, pssid, ussidlen, pdev_raddr);
-
-       pframe += p2pielen;
-       pattrib->pktlen += p2pielen;
-
-       wpsielen = 0;
-       /*      WPS OUI */
-       *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      WPS version */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-       /*      Config Method */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002);
-       wpsielen += 2;
-
-       /*      Value: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request);
-       wpsielen += 2;
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-static u8 is_matched_in_profilelist(u8 *peermacaddr, struct profile_info *profileinfo)
-{
-       u8 i, match_result = 0;
-
-       for (i = 0; i < P2P_MAX_PERSISTENT_GROUP_NUM; i++, profileinfo++) {
-               if (!memcmp(peermacaddr, profileinfo->peermac, ETH_ALEN)) {
-                       match_result = 1;
-                       break;
-               }
-       }
-       return match_result;
-}
-
-void issue_probersp_p2p(struct adapter *padapter, unsigned char *da)
-{
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       unsigned char                                   *mac;
-       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       u16 beacon_interval = 100;
-       u16 capInfo = 0;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8 wpsie[255] = { 0x00 };
-       u32                                     wpsielen = 0, p2pielen = 0;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       mac = myid(&padapter->eeprompriv);
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
-
-       /*      Use the device address for BSSID field. */
-       memcpy(pwlanhdr->addr3, mac, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(fctrl, WIFI_PROBERSP);
-
-       pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = pattrib->hdrlen;
-       pframe += pattrib->hdrlen;
-
-       /* timestamp will be inserted by hardware */
-       pframe += 8;
-       pattrib->pktlen += 8;
-
-       /*  beacon interval: 2 bytes */
-       memcpy(pframe, (unsigned char *)&beacon_interval, 2);
-       pframe += 2;
-       pattrib->pktlen += 2;
-
-       /*      capability info: 2 bytes */
-       /*      ESS and IBSS bits must be 0 (defined in the 3.1.2.1.1 of WiFi Direct Spec) */
-       capInfo |= cap_ShortPremble;
-       capInfo |= cap_ShortSlot;
-
-       memcpy(pframe, (unsigned char *)&capInfo, 2);
-       pframe += 2;
-       pattrib->pktlen += 2;
-
-       /*  SSID */
-       pframe = rtw_set_ie(pframe, _SSID_IE_, 7, pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen);
-
-       /*  supported rates... */
-       /*      Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */
-       pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pwdinfo->support_rate, &pattrib->pktlen);
-
-       /*  DS parameter set */
-       pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&pwdinfo->listen_channel, &pattrib->pktlen);
-
-       /*      Todo: WPS IE */
-       /*      Noted by Albert 20100907 */
-       /*      According to the WPS specification, all the WPS attribute is presented by Big Endian. */
-
-       wpsielen = 0;
-       /*      WPS OUI */
-       *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      WPS version */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-       /*      WiFi Simple Config State */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_SIMPLE_CONF_STATE);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_WSC_STATE_NOT_CONFIG;   /*      Not Configured. */
-
-       /*      Response Type */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_RESP_TYPE);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_RESPONSE_TYPE_8021X;
-
-       /*      UUID-E */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0010);
-       wpsielen += 2;
-
-       /*      Value: */
-       memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       wpsielen += 0x10;
-
-       /*      Manufacturer */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MANUFACTURER);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0007);
-       wpsielen += 2;
-
-       /*      Value: */
-       memcpy(wpsie + wpsielen, "Realtek", 7);
-       wpsielen += 7;
-
-       /*      Model Name */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NAME);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0006);
-       wpsielen += 2;
-
-       /*      Value: */
-       memcpy(wpsie + wpsielen, "8188EU", 6);
-       wpsielen += 6;
-
-       /*      Model Number */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NUMBER);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = 0x31;               /*      character 1 */
-
-       /*      Serial Number */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_SERIAL_NUMBER);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(ETH_ALEN);
-       wpsielen += 2;
-
-       /*      Value: */
-       memcpy(wpsie + wpsielen, "123456", ETH_ALEN);
-       wpsielen += ETH_ALEN;
-
-       /*      Primary Device Type */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0008);
-       wpsielen += 2;
-
-       /*      Value: */
-       /*      Category ID */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-       wpsielen += 2;
-
-       /*      OUI */
-       *(__be32 *)(wpsie + wpsielen) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      Sub Category ID */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-       wpsielen += 2;
-
-       /*      Device Name */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->device_name_len);
-       wpsielen += 2;
-
-       /*      Value: */
-       if (pwdinfo->device_name_len) {
-               memcpy(wpsie + wpsielen, pwdinfo->device_name, pwdinfo->device_name_len);
-               wpsielen += pwdinfo->device_name_len;
-       }
-
-       /*      Config Method */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002);
-       wpsielen += 2;
-
-       /*      Value: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->supported_wps_cm);
-       wpsielen += 2;
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen);
-
-       p2pielen = build_probe_resp_p2p_ie(pwdinfo, pframe);
-       pframe += p2pielen;
-       pattrib->pktlen += p2pielen;
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-inline void issue_probereq_p2p(struct adapter *padapter)
-{
-       struct xmit_frame               *pmgntframe;
-       struct pkt_attrib               *pattrib;
-       unsigned char                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       unsigned char                   *mac;
-       struct xmit_priv                *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 };
-       u16 wpsielen = 0, p2pielen = 0;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       mac = myid(&padapter->eeprompriv);
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       if ((pwdinfo->p2p_info.scan_op_ch_only) || (pwdinfo->rx_invitereq_info.scan_op_ch_only)) {
-               /*      This two flags will be set when this is only the P2P client mode. */
-               memcpy(pwlanhdr->addr1, pwdinfo->p2p_peer_interface_addr, ETH_ALEN);
-               memcpy(pwlanhdr->addr3, pwdinfo->p2p_peer_interface_addr, ETH_ALEN);
-       } else {
-               /*      broadcast probe request frame */
-               eth_broadcast_addr(pwlanhdr->addr1);
-               eth_broadcast_addr(pwlanhdr->addr3);
-       }
-
-       memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_PROBEREQ);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ))
-               pframe = rtw_set_ie(pframe, _SSID_IE_, pwdinfo->tx_prov_disc_info.ssid.SsidLength, pwdinfo->tx_prov_disc_info.ssid.Ssid, &pattrib->pktlen);
-       else
-               pframe = rtw_set_ie(pframe, _SSID_IE_, P2P_WILDCARD_SSID_LEN, pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen);
-
-       /*      Use the OFDM rate in the P2P probe request frame. (6(B), 9(B), 12(B), 24(B), 36, 48, 54) */
-       pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pwdinfo->support_rate, &pattrib->pktlen);
-
-       /*      WPS IE */
-       /*      Noted by Albert 20110221 */
-       /*      According to the WPS specification, all the WPS attribute is presented by Big Endian. */
-
-       wpsielen = 0;
-       /*      WPS OUI */
-       *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      WPS version */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-       if (!pmlmepriv->wps_probe_req_ie) {
-               /*      UUID-E */
-               /*      Type: */
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0010);
-               wpsielen += 2;
-
-               /*      Value: */
-               memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN);
-               wpsielen += 0x10;
-
-               /*      Config Method */
-               /*      Type: */
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002);
-               wpsielen += 2;
-
-               /*      Value: */
-               *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->supported_wps_cm);
-               wpsielen += 2;
-       }
-
-       /*      Device Name */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->device_name_len);
-       wpsielen += 2;
-
-       /*      Value: */
-       memcpy(wpsie + wpsielen, pwdinfo->device_name, pwdinfo->device_name_len);
-       wpsielen += pwdinfo->device_name_len;
-
-       /*      Primary Device Type */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0008);
-       wpsielen += 2;
-
-       /*      Value: */
-       /*      Category ID */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_RTK_WIDI);
-       wpsielen += 2;
-
-       /*      OUI */
-       *(__be32 *)(wpsie + wpsielen) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      Sub Category ID */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_RTK_DMP);
-       wpsielen += 2;
-
-       /*      Device Password ID */
-       /*      Type: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002);
-       wpsielen += 2;
-
-       /*      Value: */
-       *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC);   /*      Registrar-specified */
-       wpsielen += 2;
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen);
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20110221 */
-       /*      According to the P2P Specification, the probe request frame should contain 5 P2P attributes */
-       /*      1. P2P Capability */
-       /*      2. P2P Device ID if this probe request wants to find the specific P2P device */
-       /*      3. Listen Channel */
-       /*      4. Extended Listen Timing */
-       /*      5. Operating Channel if this WiFi is working as the group owner now */
-
-       /*      P2P Capability */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (pwdinfo->persistent_supported)
-               p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT;
-       else
-               p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT;
-
-       /*      Listen Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Operating Class */
-       p2pie[p2pielen++] = 0x51;       /*      Copy from SD7 */
-
-       /*      Channel Number */
-       p2pie[p2pielen++] = pwdinfo->listen_channel;    /*      listen channel */
-
-       /*      Extended Listen Timing */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING;
-
-       /*      Length: */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Availability Period */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-       p2pielen += 2;
-
-       /*      Availability Interval */
-       *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-       p2pielen += 2;
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-               /*      Operating Channel (if this WiFi is working as the group owner now) */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-               /*      Length: */
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      Country String */
-               p2pie[p2pielen++] = 'X';
-               p2pie[p2pielen++] = 'X';
-
-               /*      The third byte should be set to 0x04. */
-               /*      Described in the "Operating Channel Attribute" section. */
-               p2pie[p2pielen++] = 0x04;
-
-               /*      Operating Class */
-               p2pie[p2pielen++] = 0x51;       /*      Copy from SD7 */
-
-               /*      Channel Number */
-               p2pie[p2pielen++] = pwdinfo->operating_channel; /*      operating channel number */
-       }
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen);
-
-       if (pmlmepriv->wps_probe_req_ie) {
-               /* WPS IE */
-               memcpy(pframe, pmlmepriv->wps_probe_req_ie, pmlmepriv->wps_probe_req_ie_len);
-               pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len;
-               pframe += pmlmepriv->wps_probe_req_ie_len;
-       }
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-static s32 rtw_action_public_decache(struct recv_frame *recv_frame, u8 token)
-{
-       struct adapter *adapter = recv_frame->adapter;
-       struct mlme_ext_priv *mlmeext = &adapter->mlmeextpriv;
-       u8 *frame = recv_frame->rx_data;
-       u16 seq_ctrl = ((recv_frame->attrib.seq_num & 0xffff) << 4) |
-               (recv_frame->attrib.frag_num & 0xf);
-
-       if (GetRetry(frame)) {
-               if ((seq_ctrl == mlmeext->action_public_rxseq) &&
-                   (token == mlmeext->action_public_dialog_token))
-                       return _FAIL;
-       }
-
-       mlmeext->action_public_rxseq = seq_ctrl;
-       mlmeext->action_public_dialog_token = token;
-       return _SUCCESS;
-}
-
-static unsigned int on_action_public_p2p(struct recv_frame *precv_frame)
-{
-       u8 *pframe = precv_frame->rx_data;
-       u8 *frame_body;
-       u8 dialogToken = 0;
-       struct adapter *padapter = precv_frame->adapter;
-       uint len = precv_frame->len;
-       u8 *p2p_ie;
-       u32     p2p_ielen;
-       struct  wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8      result = P2P_STATUS_SUCCESS;
-       u8      empty_addr[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-       frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       dialogToken = frame_body[7];
-
-       if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL)
-               return _FAIL;
-
-       _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey);
-       /*      Do nothing if the driver doesn't enable the P2P function. */
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE))
-               return _SUCCESS;
-
-       len -= sizeof(struct ieee80211_hdr_3addr);
-
-       switch (frame_body[6]) { /* OUI Subtype */
-       case P2P_GO_NEGO_REQ:
-               memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info));
-
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ))
-                       rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) {
-                       /*      Commented by Albert 20110526 */
-                       /*      In this case, this means the previous nego fail doesn't be reset yet. */
-                       _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer);
-                       /*      Restore the previous p2p state */
-                       rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-               }
-
-               /*      Commented by Kurt 20110902 */
-               /* Add if statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */
-               if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING))
-                       rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-
-               /*      Commented by Kurt 20120113 */
-               /*      Get peer_dev_addr here if peer doesn't issue prov_disc frame. */
-               if (!memcmp(pwdinfo->rx_prov_disc_info.peerDevAddr, empty_addr, ETH_ALEN))
-                       memcpy(pwdinfo->rx_prov_disc_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN);
-
-               result = process_p2p_group_negotation_req(pwdinfo, frame_body, len);
-               issue_p2p_GO_response(padapter, GetAddr2Ptr(pframe), frame_body, len, result);
-
-               /*      Commented by Albert 20110718 */
-               /*      No matter negotiating or negotiation failure, the driver should set up the restore P2P state timer. */
-               _set_timer(&pwdinfo->restore_p2p_state_timer, 5000);
-               break;
-       case P2P_GO_NEGO_RESP:
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) {
-                       /*      Commented by Albert 20110425 */
-                       /*      The restore timer is enabled when issuing the nego request frame of rtw_p2p_connect function. */
-                       _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer);
-                       pwdinfo->nego_req_info.benable = false;
-                       result = process_p2p_group_negotation_resp(pwdinfo, frame_body, len);
-                       issue_p2p_GO_confirm(pwdinfo->padapter, GetAddr2Ptr(pframe), result);
-                       if (result == P2P_STATUS_SUCCESS) {
-                               if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT) {
-                                       pwdinfo->p2p_info.operation_ch[0] = pwdinfo->peer_operating_ch;
-                                       pwdinfo->p2p_info.scan_op_ch_only = 1;
-                                       _set_timer(&pwdinfo->reset_ch_sitesurvey2, P2P_RESET_SCAN_CH);
-                               }
-                       }
-                       /*      Reset the dialog token for group negotiation frames. */
-                       pwdinfo->negotiation_dialog_token = 1;
-                       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL))
-                               _set_timer(&pwdinfo->restore_p2p_state_timer, 5000);
-               }
-               break;
-       case P2P_GO_NEGO_CONF:
-               result = process_p2p_group_negotation_confirm(pwdinfo, frame_body, len);
-               if (result == P2P_STATUS_SUCCESS) {
-                       if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT) {
-                               pwdinfo->p2p_info.operation_ch[0] = pwdinfo->peer_operating_ch;
-                               pwdinfo->p2p_info.scan_op_ch_only = 1;
-                               _set_timer(&pwdinfo->reset_ch_sitesurvey2, P2P_RESET_SCAN_CH);
-                       }
-               }
-               break;
-       case P2P_INVIT_REQ:
-               /*      Added by Albert 2010/10/05 */
-               /*      Received the P2P Invite Request frame. */
-
-               p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen);
-               if (p2p_ie) {
-                       /*      Parse the necessary information from the P2P Invitation Request frame. */
-                       /*      For example: The MAC address of sending this P2P Invitation Request frame. */
-                       u32     attr_contentlen = 0;
-                       u8      status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                       struct group_id_info group_id;
-                       u8      invitation_flag = 0;
-
-                       rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INVITATION_FLAGS, &invitation_flag, &attr_contentlen);
-                       if (attr_contentlen) {
-                               rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_BSSID, pwdinfo->p2p_peer_interface_addr, &attr_contentlen);
-                               /*      Commented by Albert 20120510 */
-                               /*      Copy to the pwdinfo->p2p_peer_interface_addr. */
-                               /*      So that the WFD UI (or Sigma) can get the peer interface address by using the following command. */
-                               /*      #> iwpriv wlan0 p2p_get peer_ifa */
-                               /*      After having the peer interface address, the sigma can find the correct conf file for wpa_supplicant. */
-
-                               if (invitation_flag & P2P_INVITATION_FLAGS_PERSISTENT) {
-                                       /*      Re-invoke the persistent group. */
-
-                                       memset(&group_id, 0x00, sizeof(struct group_id_info));
-                                       rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8 *)&group_id, &attr_contentlen);
-                                       if (attr_contentlen) {
-                                               if (!memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) {
-                                                       /*      The p2p device sending this p2p invitation request wants this Wi-Fi device to be the persistent GO. */
-                                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_GO);
-                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                                                       status_code = P2P_STATUS_SUCCESS;
-                                               } else {
-                                                       /*      The p2p device sending this p2p invitation request wants to be the persistent GO. */
-                                                       if (is_matched_in_profilelist(pwdinfo->p2p_peer_interface_addr, &pwdinfo->profileinfo[0])) {
-                                                               u8 operatingch_info[5] = { 0x00 };
-                                                               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) {
-                                                                       if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, (u32)operatingch_info[4])) {
-                                                                               /*      The operating channel is acceptable for this device. */
-                                                                               pwdinfo->rx_invitereq_info.operation_ch[0] = operatingch_info[4];
-                                                                               pwdinfo->rx_invitereq_info.scan_op_ch_only = 1;
-                                                                               _set_timer(&pwdinfo->reset_ch_sitesurvey, P2P_RESET_SCAN_CH);
-                                                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH);
-                                                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                                                               status_code = P2P_STATUS_SUCCESS;
-                                                                       } else {
-                                                                               /*      The operating channel isn't supported by this device. */
-                                                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH);
-                                                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                                                               status_code = P2P_STATUS_FAIL_NO_COMMON_CH;
-                                                                               _set_timer(&pwdinfo->restore_p2p_state_timer, 3000);
-                                                                       }
-                                                               } else {
-                                                                       /*      Commented by Albert 20121130 */
-                                                                       /*      Intel will use the different P2P IE to store the operating channel information */
-                                                                       /*      Workaround for Intel WiDi 3.5 */
-                                                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH);
-                                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                                                       status_code = P2P_STATUS_SUCCESS;
-                                                               }
-                                                       } else {
-                                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH);
-                                                               status_code = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP;
-                                                       }
-                                               }
-                                       } else {
-                                               status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                                       }
-                               } else {
-                                       /*      Received the invitation to join a P2P group. */
-
-                                       memset(&group_id, 0x00, sizeof(struct group_id_info));
-                                       rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8 *)&group_id, &attr_contentlen);
-                                       if (attr_contentlen) {
-                                               if (!memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) {
-                                                       /*      In this case, the GO can't be myself. */
-                                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH);
-                                                       status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                                               } else {
-                                                       /*      The p2p device sending this p2p invitation request wants to join an existing P2P group */
-                                                       /*      Commented by Albert 2012/06/28 */
-                                                       /*      In this case, this Wi-Fi device should use the iwpriv command to get the peer device address. */
-                                                       /*      The peer device address should be the destination address for the provisioning discovery request. */
-                                                       /*      Then, this Wi-Fi device should use the iwpriv command to get the peer interface address. */
-                                                       /*      The peer interface address should be the address for WPS mac address */
-                                                       memcpy(pwdinfo->p2p_peer_device_addr, group_id.go_device_addr, ETH_ALEN);
-                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_JOIN);
-                                                       status_code = P2P_STATUS_SUCCESS;
-                                               }
-                                       } else {
-                                               status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                                       }
-                               }
-                       } else {
-                               status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                       }
-
-                       pwdinfo->inviteresp_info.token = frame_body[7];
-                       issue_p2p_invitation_response(padapter, GetAddr2Ptr(pframe), pwdinfo->inviteresp_info.token, status_code);
-               }
-               break;
-       case P2P_INVIT_RESP: {
-               u8      attr_content = 0x00;
-               u32     attr_contentlen = 0;
-
-               _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer);
-               p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen);
-               if (p2p_ie) {
-                       rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen);
-
-                       if (attr_contentlen == 1) {
-                               pwdinfo->invitereq_info.benable = false;
-
-                               if (attr_content == P2P_STATUS_SUCCESS) {
-                                       if (!memcmp(pwdinfo->invitereq_info.go_bssid, myid(&padapter->eeprompriv), ETH_ALEN)) {
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                                       } else {
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                       }
-                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_OK);
-                               } else {
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL);
-                               }
-                       } else {
-                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL);
-                       }
-               } else {
-                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL);
-               }
-
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL))
-                       _set_timer(&pwdinfo->restore_p2p_state_timer, 5000);
-               break;
-       }
-       case P2P_DEVDISC_REQ:
-               process_p2p_devdisc_req(pwdinfo, pframe, len);
-               break;
-       case P2P_DEVDISC_RESP:
-               process_p2p_devdisc_resp(pwdinfo, pframe, len);
-               break;
-       case P2P_PROVISION_DISC_REQ:
-               process_p2p_provdisc_req(pwdinfo, pframe, len);
-               memcpy(pwdinfo->rx_prov_disc_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN);
-
-               /* 20110902 Kurt */
-               /* Add the following statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */
-               if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ))
-                       rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ);
-               _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT);
-               break;
-       case P2P_PROVISION_DISC_RESP:
-               /*      Commented by Albert 20110707 */
-               /*      Should we check the pwdinfo->tx_prov_disc_info.bsent flag here?? */
-               /*      Commented by Albert 20110426 */
-               /*      The restore timer is enabled when issuing the provisioing request frame in rtw_p2p_prov_disc function. */
-               _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_RSP);
-               process_p2p_provdisc_resp(pwdinfo, pframe);
-               _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT);
-               break;
-       }
-
-       return _SUCCESS;
-}
-
-static void on_action_public(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
-       u8 *frame_body = (u8 *)&mgmt->u;
-
-       /* All members of the action enum start with action_code. */
-       if (mgmt->u.action.u.s1g.action_code == WLAN_PUB_ACTION_VENDOR_SPECIFIC) {
-               if (!memcmp(frame_body + 2, P2P_OUI, 4))
-                       on_action_public_p2p(precv_frame);
-       } else {
-               rtw_action_public_decache(precv_frame, frame_body[2]);
-       }
-}
-
-static void OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       u8 *frame_body;
-       u8 OUI_Subtype;
-       u8 *pframe = precv_frame->rx_data;
-       uint len = precv_frame->len;
-       struct  wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       if (be32_to_cpu(*((__be32 *)(frame_body + 1))) != P2POUI)
-               return;
-
-       len -= sizeof(struct ieee80211_hdr_3addr);
-       OUI_Subtype = frame_body[5];
-
-       if (OUI_Subtype == P2P_PRESENCE_REQUEST)
-               process_p2p_presence_req(pwdinfo, pframe, len);
-}
-
-static void OnAction(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
-
-       if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da))
-               return;
-
-       switch (mgmt->u.action.category) {
-       case WLAN_CATEGORY_BACK:
-               OnAction_back(padapter, precv_frame);
-               break;
-       case WLAN_CATEGORY_PUBLIC:
-               on_action_public(padapter, precv_frame);
-               break;
-       case RTW_WLAN_CATEGORY_P2P:
-               OnAction_p2p(padapter, precv_frame);
-               break;
-       }
-}
-
-struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv)
-{
-       struct xmit_frame                       *pmgntframe;
-       struct xmit_buf                         *pxmitbuf;
-
-       pmgntframe = rtw_alloc_xmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return NULL;
-
-       pxmitbuf = rtw_alloc_xmitbuf_ext(pxmitpriv);
-       if (!pxmitbuf) {
-               rtw_free_xmitframe(pxmitpriv, pmgntframe);
-               return NULL;
-       }
-       pmgntframe->frame_tag = MGNT_FRAMETAG;
-       pmgntframe->pxmitbuf = pxmitbuf;
-       pmgntframe->buf_addr = pxmitbuf->pbuf;
-       pxmitbuf->priv_data = pmgntframe;
-       return pmgntframe;
-}
-
-void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       mlme_handler mlme_sta_tbl[] = {
-               OnAssocReq,
-               OnAssocRsp,
-               OnAssocReq,
-               OnAssocRsp,
-               OnProbeReq,
-               OnProbeRsp,
-               NULL,
-               NULL,
-               OnBeacon,
-               NULL,
-               OnDisassoc,
-               OnAuthClient,
-               OnDeAuth,
-               OnAction,
-       };
-       int index;
-       mlme_handler fct;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
-       struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
-
-       if (!ieee80211_is_mgmt(hdr->frame_control))
-               return;
-
-       /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
-       if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
-           !is_broadcast_ether_addr(hdr->addr1))
-               return;
-
-       index = (le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
-       if (index >= ARRAY_SIZE(mlme_sta_tbl))
-               return;
-       fct = mlme_sta_tbl[index];
-
-       if (psta) {
-               if (ieee80211_has_retry(hdr->frame_control)) {
-                       if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum)
-                               /* drop the duplicate management frame */
-                               return;
-               }
-               psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num;
-       }
-
-       if (ieee80211_is_auth(hdr->frame_control)) {
-               if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
-                       fct = OnAuth;
-               else
-                       fct = OnAuthClient;
-       }
-
-       if (fct)
-               fct(padapter, precv_frame);
-}
-
-/****************************************************************************
-
-Following are some TX functions for WiFi MLME
-
-*****************************************************************************/
-
-void update_mgnt_tx_rate(struct adapter *padapter, u8 rate)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-
-       pmlmeext->tx_rate = rate;
-}
-
-void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-
-       memset((u8 *)(pattrib), 0, sizeof(struct pkt_attrib));
-
-       pattrib->hdrlen = 24;
-       pattrib->nr_frags = 1;
-       pattrib->priority = 7;
-       pattrib->mac_id = 0;
-       pattrib->qsel = 0x12;
-
-       pattrib->pktlen = 0;
-
-       if (pmlmeext->cur_wireless_mode & WIRELESS_11B)
-               pattrib->raid = 6;/* b mode */
-       else
-               pattrib->raid = 5;/* a/g mode */
-
-       pattrib->encrypt = _NO_PRIVACY_;
-       pattrib->bswenc = false;
-
-       pattrib->qos_en = false;
-       pattrib->ht_en = false;
-       pattrib->bwmode = HT_CHANNEL_WIDTH_20;
-       pattrib->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-       pattrib->sgi = false;
-
-       pattrib->seqnum = pmlmeext->mgnt_seq;
-
-       pattrib->retry_ctrl = true;
-}
-
-void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe)
-{
-       rtl8188eu_mgnt_xmit(padapter, pmgntframe);
-}
-
-s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms)
-{
-       s32 ret = _FAIL;
-       struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf;
-       struct submit_ctx sctx;
-
-       if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
-               return ret;
-
-       rtw_sctx_init(&sctx, timeout_ms);
-       pxmitbuf->sctx = &sctx;
-
-       ret = rtl8188eu_mgnt_xmit(padapter, pmgntframe);
-
-       if (ret == _SUCCESS)
-               ret = rtw_sctx_wait(&sctx);
-
-       return ret;
-}
-
-s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmgntframe)
-{
-       s32 ret = _FAIL;
-       u32 timeout_ms = 500;/*   500ms */
-       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
-
-       mutex_lock(&pxmitpriv->ack_tx_mutex);
-       pxmitpriv->ack_tx = true;
-
-       pmgntframe->ack_report = 1;
-       if (rtl8188eu_mgnt_xmit(padapter, pmgntframe) == _SUCCESS) {
-               ret = rtw_ack_tx_wait(pxmitpriv, timeout_ms);
-       }
-
-       pxmitpriv->ack_tx = false;
-       mutex_unlock(&pxmitpriv->ack_tx_mutex);
-
-       return ret;
-}
-
-static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode)
-{
-       u8 *ssid_ie;
-       int ssid_len_ori;
-       int len_diff = 0;
-
-       ssid_ie = rtw_get_ie(ies,  WLAN_EID_SSID, &ssid_len_ori, ies_len);
-
-       if (ssid_ie && ssid_len_ori > 0) {
-               switch (hidden_ssid_mode) {
-               case 1: {
-                       u8 *next_ie = ssid_ie + 2 + ssid_len_ori;
-                       u32 remain_len = 0;
-
-                       remain_len = ies_len - (next_ie - ies);
-
-                       ssid_ie[1] = 0;
-                       memcpy(ssid_ie + 2, next_ie, remain_len);
-                       len_diff -= ssid_len_ori;
-
-                       break;
-               }
-               case 2:
-                       memset(&ssid_ie[2], 0, ssid_len_ori);
-                       break;
-               default:
-                       break;
-               }
-       }
-
-       return len_diff;
-}
-
-void issue_beacon(struct adapter *padapter, int timeout_ms)
-{
-       struct xmit_frame       *pmgntframe;
-       struct pkt_attrib       *pattrib;
-       unsigned char   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       unsigned int    rate_len;
-       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex            *cur_network = &pmlmeinfo->network;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-       spin_lock_bh(&pmlmepriv->bcn_update_lock);
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-       pattrib->qsel = 0x10;
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       eth_broadcast_addr(pwlanhdr->addr1);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/);
-       /* pmlmeext->mgnt_seq++; */
-       SetFrameSubType(pframe, WIFI_BEACON);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
-               /*  for P2P : Primary Device Type & Device Name */
-               u32 wpsielen = 0, insert_len = 0;
-               u8 *wpsie = NULL;
-               wpsie = rtw_get_wps_ie(cur_network->IEs + _FIXED_IE_LENGTH_, cur_network->IELength - _FIXED_IE_LENGTH_, NULL, &wpsielen);
-
-               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && wpsie && wpsielen > 0) {
-                       uint wps_offset, remainder_ielen;
-                       u8 *premainder_ie, *pframe_wscie;
-
-                       wps_offset = (uint)(wpsie - cur_network->IEs);
-                       premainder_ie = wpsie + wpsielen;
-                       remainder_ielen = cur_network->IELength - wps_offset - wpsielen;
-                       pframe_wscie = pframe + wps_offset;
-                       memcpy(pframe, cur_network->IEs, wps_offset + wpsielen);
-                       pframe += (wps_offset + wpsielen);
-                       pattrib->pktlen += (wps_offset + wpsielen);
-
-                       /* now pframe is end of wsc ie, insert Primary Device Type & Device Name */
-                       /*      Primary Device Type */
-                       /*      Type: */
-                       *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE);
-                       insert_len += 2;
-
-                       /*      Length: */
-                       *(__be16 *)(pframe + insert_len) = cpu_to_be16(0x0008);
-                       insert_len += 2;
-
-                       /*      Value: */
-                       /*      Category ID */
-                       *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-                       insert_len += 2;
-
-                       /*      OUI */
-                       *(__be32 *)(pframe + insert_len) = cpu_to_be32(WPSOUI);
-                       insert_len += 4;
-
-                       /*      Sub Category ID */
-                       *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-                       insert_len += 2;
-
-                       /*      Device Name */
-                       /*      Type: */
-                       *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-                       insert_len += 2;
-
-                       /*      Length: */
-                       *(__be16 *)(pframe + insert_len) = cpu_to_be16(pwdinfo->device_name_len);
-                       insert_len += 2;
-
-                       /*      Value: */
-                       memcpy(pframe + insert_len, pwdinfo->device_name, pwdinfo->device_name_len);
-                       insert_len += pwdinfo->device_name_len;
-
-                       /* update wsc ie length */
-                       *(pframe_wscie + 1) = (wpsielen - 2) + insert_len;
-
-                       /* pframe move to end */
-                       pframe += insert_len;
-                       pattrib->pktlen += insert_len;
-
-                       /* copy remainder_ie to pframe */
-                       memcpy(pframe, premainder_ie, remainder_ielen);
-                       pframe += remainder_ielen;
-                       pattrib->pktlen += remainder_ielen;
-               } else {
-                       int len_diff;
-                       memcpy(pframe, cur_network->IEs, cur_network->IELength);
-                       len_diff = update_hidden_ssid(
-                               pframe + _BEACON_IE_OFFSET_
-                               , cur_network->IELength - _BEACON_IE_OFFSET_
-                               , pmlmeinfo->hidden_ssid_mode
-                       );
-                       pframe += (cur_network->IELength + len_diff);
-                       pattrib->pktlen += (cur_network->IELength + len_diff);
-               }
-
-               {
-                       u8 *wps_ie;
-                       uint wps_ielen;
-                       u8 sr = 0;
-                       wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr + TXDESC_OFFSET + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_,
-                               pattrib->pktlen - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_, NULL, &wps_ielen);
-                       if (wps_ie && wps_ielen > 0)
-                               rtw_get_wps_attr_content(wps_ie,  wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL);
-                       if (sr != 0)
-                               set_fwstate(pmlmepriv, WIFI_UNDER_WPS);
-                       else
-                               _clr_fwstate_(pmlmepriv, WIFI_UNDER_WPS);
-               }
-
-               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                       u32 len;
-                       len = build_beacon_p2p_ie(pwdinfo, pframe);
-
-                       pframe += len;
-                       pattrib->pktlen += len;
-               }
-
-               goto _issue_bcn;
-       }
-
-       /* below for ad-hoc mode */
-
-       /* timestamp will be inserted by hardware */
-       pframe += 8;
-       pattrib->pktlen += 8;
-
-       /*  beacon interval: 2 bytes */
-
-       memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2);
-
-       pframe += 2;
-       pattrib->pktlen += 2;
-
-       /*  capability info: 2 bytes */
-
-       memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2);
-
-       pframe += 2;
-       pattrib->pktlen += 2;
-
-       /*  SSID */
-       pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen);
-
-       /*  supported rates... */
-       rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
-       pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen);
-
-       /*  DS parameter set */
-       pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen);
-
-       {
-               u8 erpinfo = 0;
-               u32 ATIMWindow;
-               /*  IBSS Parameter Set... */
-               ATIMWindow = 0;
-               pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen);
-
-               /* ERP IE */
-               pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen);
-       }
-
-       /*  EXTERNDED SUPPORTED RATE */
-       if (rate_len > 8)
-               pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen);
-       /* todo:HT for adhoc */
-_issue_bcn:
-
-       pmlmepriv->update_bcn = false;
-
-       spin_unlock_bh(&pmlmepriv->bcn_update_lock);
-
-       if ((pattrib->pktlen + TXDESC_SIZE) > 512)
-               return;
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       if (timeout_ms > 0)
-               dump_mgntframe_and_wait(padapter, pmgntframe, timeout_ms);
-       else
-               dump_mgntframe(padapter, pmgntframe);
-}
-
-void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq)
-{
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       unsigned char                                   *mac, *bssid;
-       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
-       u8 *pwps_ie;
-       uint wps_ielen;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex            *cur_network = &pmlmeinfo->network;
-       unsigned int    rate_len;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       mac = myid(&padapter->eeprompriv);
-       bssid = cur_network->MacAddress;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
-       memcpy(pwlanhdr->addr3, bssid, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(fctrl, WIFI_PROBERSP);
-
-       pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = pattrib->hdrlen;
-       pframe += pattrib->hdrlen;
-
-       if (cur_network->IELength > MAX_IE_SZ)
-               return;
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
-               pwps_ie = rtw_get_wps_ie(cur_network->IEs + _FIXED_IE_LENGTH_, cur_network->IELength - _FIXED_IE_LENGTH_, NULL, &wps_ielen);
-
-               /* inerset & update wps_probe_resp_ie */
-               if (pmlmepriv->wps_probe_resp_ie && pwps_ie && wps_ielen > 0) {
-                       uint wps_offset, remainder_ielen;
-                       u8 *premainder_ie;
-
-                       wps_offset = (uint)(pwps_ie - cur_network->IEs);
-
-                       premainder_ie = pwps_ie + wps_ielen;
-
-                       remainder_ielen = cur_network->IELength - wps_offset - wps_ielen;
-
-                       memcpy(pframe, cur_network->IEs, wps_offset);
-                       pframe += wps_offset;
-                       pattrib->pktlen += wps_offset;
-
-                       wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1];/* to get ie data len */
-                       if ((wps_offset + wps_ielen + 2) <= MAX_IE_SZ) {
-                               memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen + 2);
-                               pframe += wps_ielen + 2;
-                               pattrib->pktlen += wps_ielen + 2;
-                       }
-
-                       if ((wps_offset + wps_ielen + 2 + remainder_ielen) <= MAX_IE_SZ) {
-                               memcpy(pframe, premainder_ie, remainder_ielen);
-                               pframe += remainder_ielen;
-                               pattrib->pktlen += remainder_ielen;
-                       }
-               } else {
-                       memcpy(pframe, cur_network->IEs, cur_network->IELength);
-                       pframe += cur_network->IELength;
-                       pattrib->pktlen += cur_network->IELength;
-               }
-       } else {
-               /* timestamp will be inserted by hardware */
-               pframe += 8;
-               pattrib->pktlen += 8;
-
-               /*  beacon interval: 2 bytes */
-
-               memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2);
-
-               pframe += 2;
-               pattrib->pktlen += 2;
-
-               /*  capability info: 2 bytes */
-
-               memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2);
-
-               pframe += 2;
-               pattrib->pktlen += 2;
-
-               /* below for ad-hoc mode */
-
-               /*  SSID */
-               pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen);
-
-               /*  supported rates... */
-               rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
-               pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen);
-
-               /*  DS parameter set */
-               pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen);
-
-               if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) {
-                       u8 erpinfo = 0;
-                       u32 ATIMWindow;
-                       /*  IBSS Parameter Set... */
-                       /* ATIMWindow = cur->Configuration.ATIMWindow; */
-                       ATIMWindow = 0;
-                       pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen);
-
-                       /* ERP IE */
-                       pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen);
-               }
-
-               /*  EXTERNDED SUPPORTED RATE */
-               if (rate_len > 8)
-                       pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen);
-               /* todo:HT for adhoc */
-       }
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && is_valid_p2p_probereq) {
-               u32 len;
-               len = build_probe_resp_p2p_ie(pwdinfo, pframe);
-
-               pframe += len;
-               pattrib->pktlen += len;
-       }
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, int wait_ack)
-{
-       int ret = _FAIL;
-       struct xmit_frame               *pmgntframe;
-       struct pkt_attrib               *pattrib;
-       unsigned char                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       unsigned char                   *mac;
-       unsigned char                   bssrate[NumRates];
-       struct xmit_priv                *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       int     bssrate_len = 0;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               goto exit;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       mac = myid(&padapter->eeprompriv);
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       if (da) {
-               /*      unicast probe request frame */
-               memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-               memcpy(pwlanhdr->addr3, da, ETH_ALEN);
-       } else {
-               /*      broadcast probe request frame */
-               eth_broadcast_addr(pwlanhdr->addr1);
-               eth_broadcast_addr(pwlanhdr->addr3);
-       }
-
-       memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_PROBEREQ);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       if (pssid)
-               pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &pattrib->pktlen);
-       else
-               pframe = rtw_set_ie(pframe, _SSID_IE_, 0, NULL, &pattrib->pktlen);
-
-       get_rate_set(padapter, bssrate, &bssrate_len);
-
-       if (bssrate_len > 8) {
-               pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &pattrib->pktlen);
-               pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, bssrate_len - 8, bssrate + 8, &pattrib->pktlen);
-       } else {
-               pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &pattrib->pktlen);
-       }
-
-       /* add wps_ie for wps2.0 */
-       if (pmlmepriv->wps_probe_req_ie_len > 0 && pmlmepriv->wps_probe_req_ie) {
-               memcpy(pframe, pmlmepriv->wps_probe_req_ie, pmlmepriv->wps_probe_req_ie_len);
-               pframe += pmlmepriv->wps_probe_req_ie_len;
-               pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len;
-       }
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       if (wait_ack) {
-               ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe);
-       } else {
-               dump_mgntframe(padapter, pmgntframe);
-               ret = _SUCCESS;
-       }
-
-exit:
-       return ret;
-}
-
-inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
-{
-       _issue_probereq(padapter, pssid, da, false);
-}
-
-void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
-{
-       int i;
-
-       for (i = 0; i < 3; i++) {
-               if (_issue_probereq(padapter, pssid, da, true) == _FAIL)
-                       msleep(1);
-               else
-                       break;
-       }
-}
-
-/*  if psta == NULL, indicate we are station (client) now... */
-void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status)
-{
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       unsigned char *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       unsigned int val32;
-       u16 val16;
-       __le16 le_val16;
-       int use_shared_key = 0;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_AUTH);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       if (psta) {/*  for AP mode */
-               memcpy(pwlanhdr->addr1, psta->hwaddr, ETH_ALEN);
-               memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-               memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN);
-
-               /*  setting auth algo number */
-               val16 = (u16)psta->authalg;
-
-               if (status != _STATS_SUCCESSFUL_)
-                       val16 = 0;
-
-               if (val16) {
-                       le_val16 = cpu_to_le16(val16);
-                       use_shared_key = 1;
-               } else {
-                       le_val16 = 0;
-               }
-
-               pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_val16, &pattrib->pktlen);
-
-               /*  setting auth seq number */
-               val16 = (u16)psta->auth_seq;
-               le_val16 = cpu_to_le16(val16);
-               pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_val16, &pattrib->pktlen);
-
-               /*  setting status code... */
-               val16 = status;
-               le_val16 = cpu_to_le16(val16);
-               pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_val16, &pattrib->pktlen);
-
-               /*  added challenging text... */
-               if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1))
-                       pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &pattrib->pktlen);
-       } else {
-               __le32 le_tmp32;
-               __le16 le_tmp16;
-               memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-               memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-               memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-
-               /*  setting auth algo number */
-               val16 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) ? 1 : 0;/*  0:OPEN System, 1:Shared key */
-               if (val16)
-                       use_shared_key = 1;
-
-               /* setting IV for auth seq #3 */
-               if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) {
-                       val32 = ((pmlmeinfo->iv++) | (pmlmeinfo->key_index << 30));
-                       le_tmp32 = cpu_to_le32(val32);
-                       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&le_tmp32, &pattrib->pktlen);
-
-                       pattrib->iv_len = 4;
-               }
-
-               le_tmp16 = cpu_to_le16(val16);
-               pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_tmp16, &pattrib->pktlen);
-
-               /*  setting auth seq number */
-               val16 = pmlmeinfo->auth_seq;
-               le_tmp16 = cpu_to_le16(val16);
-               pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_tmp16, &pattrib->pktlen);
-
-               /*  setting status code... */
-               le_tmp16 = cpu_to_le16(status);
-               pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_tmp16, &pattrib->pktlen);
-
-               /*  then checking to see if sending challenging text... */
-               if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) {
-                       pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, pmlmeinfo->chg_txt, &pattrib->pktlen);
-
-                       SetPrivacy(fctrl);
-
-                       pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr);
-
-                       pattrib->encrypt = _WEP40_;
-
-                       pattrib->icv_len = 4;
-
-                       pattrib->pktlen += pattrib->icv_len;
-               }
-       }
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       rtw_wep_encrypt(padapter, pmgntframe);
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type)
-{
-       struct xmit_frame       *pmgntframe;
-       struct ieee80211_hdr *pwlanhdr;
-       struct pkt_attrib *pattrib;
-       unsigned char   *pbuf, *pframe;
-       unsigned short val;
-       __le16 *fctrl;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
-       u8 *ie = pnetwork->IEs;
-       __le16 lestatus, leval;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy((void *)GetAddr1Ptr(pwlanhdr), pstat->hwaddr, ETH_ALEN);
-       memcpy((void *)GetAddr2Ptr(pwlanhdr), myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy((void *)GetAddr3Ptr(pwlanhdr), get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       if ((pkt_type == WIFI_ASSOCRSP) || (pkt_type == WIFI_REASSOCRSP))
-               SetFrameSubType(pwlanhdr, pkt_type);
-       else
-               return;
-
-       pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen += pattrib->hdrlen;
-       pframe += pattrib->hdrlen;
-
-       /* capability */
-       val = *(unsigned short *)rtw_get_capability_from_ie(ie);
-
-       pframe = rtw_set_fixed_ie(pframe, _CAPABILITY_, (unsigned char *)&val, &pattrib->pktlen);
-
-       lestatus = cpu_to_le16(status);
-       pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&lestatus, &pattrib->pktlen);
-
-       leval = cpu_to_le16(pstat->aid | BIT(14) | BIT(15));
-       pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_, (unsigned char *)&leval, &pattrib->pktlen);
-
-       if (pstat->bssratelen <= 8) {
-               pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &pattrib->pktlen);
-       } else {
-               pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &pattrib->pktlen);
-               pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, pstat->bssratelen - 8, pstat->bssrateset + 8, &pattrib->pktlen);
-       }
-
-       if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) {
-               uint ie_len = 0;
-
-               /* FILL HT CAP INFO IE */
-               pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_));
-               if (pbuf && ie_len > 0) {
-                       memcpy(pframe, pbuf, ie_len + 2);
-                       pframe += (ie_len + 2);
-                       pattrib->pktlen += (ie_len + 2);
-               }
-
-               /* FILL HT ADD INFO IE */
-               pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_));
-               if (pbuf && ie_len > 0) {
-                       memcpy(pframe, pbuf, ie_len + 2);
-                       pframe += (ie_len + 2);
-                       pattrib->pktlen += (ie_len + 2);
-               }
-       }
-
-       /* FILL WMM IE */
-       if ((pstat->flags & WLAN_STA_WME) && (pmlmepriv->qospriv.qos_option)) {
-               uint ie_len = 0;
-               unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01};
-
-               for (pbuf = ie + _BEACON_IE_OFFSET_;; pbuf += (ie_len + 2)) {
-                       pbuf = rtw_get_ie(pbuf, _VENDOR_SPECIFIC_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)));
-                       if (pbuf && !memcmp(pbuf + 2, WMM_PARA_IE, 6)) {
-                               memcpy(pframe, pbuf, ie_len + 2);
-                               pframe += (ie_len + 2);
-                               pattrib->pktlen += (ie_len + 2);
-                               break;
-                       }
-
-                       if (!pbuf || ie_len == 0)
-                               break;
-               }
-       }
-
-       if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK)
-               pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &pattrib->pktlen);
-
-       /* add WPS IE ie for wps 2.0 */
-       if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len > 0) {
-               memcpy(pframe, pmlmepriv->wps_assoc_resp_ie, pmlmepriv->wps_assoc_resp_ie_len);
-
-               pframe += pmlmepriv->wps_assoc_resp_ie_len;
-               pattrib->pktlen += pmlmepriv->wps_assoc_resp_ie_len;
-       }
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && (pstat->is_p2p_device)) {
-               u32 len;
-
-               len = build_assoc_resp_p2p_ie(pwdinfo, pframe, pstat->p2p_status_code);
-
-               pframe += len;
-               pattrib->pktlen += len;
-       }
-       pattrib->last_txcmdsz = pattrib->pktlen;
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-void issue_assocreq(struct adapter *padapter)
-{
-       int ret = _FAIL;
-       struct xmit_frame       *pmgntframe;
-       struct pkt_attrib       *pattrib;
-       unsigned char           *pframe, *p;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       __le16          le_tmp;
-       unsigned int    i, j, ie_len, index = 0;
-       unsigned char bssrate[NumRates], sta_bssrate[NumRates];
-       struct ndis_802_11_var_ie *pIE;
-       struct registry_priv    *pregpriv = &padapter->registrypriv;
-       struct xmit_priv                *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       int     bssrate_len = 0, sta_bssrate_len = 0;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8 p2pie[255] = { 0x00 };
-       u16 p2pielen = 0;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               goto exit;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-       memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ASSOCREQ);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       /* caps */
-
-       memcpy(pframe, rtw_get_capability_from_ie(pmlmeinfo->network.IEs), 2);
-
-       pframe += 2;
-       pattrib->pktlen += 2;
-
-       /* listen interval */
-       /* todo: listen interval for power saving */
-       le_tmp = cpu_to_le16(3);
-       memcpy(pframe, (unsigned char *)&le_tmp, 2);
-       pframe += 2;
-       pattrib->pktlen += 2;
-
-       /* SSID */
-       pframe = rtw_set_ie(pframe, _SSID_IE_,  pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &pattrib->pktlen);
-
-       /* supported rate & extended supported rate */
-
-       /*  Check if the AP's supported rates are also supported by STA. */
-       get_rate_set(padapter, sta_bssrate, &sta_bssrate_len);
-
-       if (pmlmeext->cur_channel == 14)/*  for JAPAN, channel 14 can only uses B Mode(CCK) */
-               sta_bssrate_len = 4;
-
-       for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) {
-               if (pmlmeinfo->network.SupportedRates[i] == 0)
-                       break;
-
-               /*  Check if the AP's supported rates are also supported by STA. */
-               for (j = 0; j < sta_bssrate_len; j++) {
-                        /*  Avoid the proprietary data rate (22Mbps) of Handlink WSG-4000 AP */
-                       if ((pmlmeinfo->network.SupportedRates[i] | IEEE80211_BASIC_RATE_MASK)
-                                       == (sta_bssrate[j] | IEEE80211_BASIC_RATE_MASK))
-                               break;
-               }
-
-               if (j != sta_bssrate_len)
-                       /*  the rate is supported by STA */
-                       bssrate[index++] = pmlmeinfo->network.SupportedRates[i];
-       }
-
-       bssrate_len = index;
-
-       if (bssrate_len == 0) {
-               rtw_free_xmitbuf(pxmitpriv, pmgntframe->pxmitbuf);
-               rtw_free_xmitframe(pxmitpriv, pmgntframe);
-               goto exit; /* don't connect to AP if no joint supported rate */
-       }
-
-       if (bssrate_len > 8) {
-               pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &pattrib->pktlen);
-               pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, bssrate_len - 8, bssrate + 8, &pattrib->pktlen);
-       } else {
-               pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &pattrib->pktlen);
-       }
-
-       /* RSN */
-       p = rtw_get_ie((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ie)), _RSN_IE_2_, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ie)));
-       if (p)
-               pframe = rtw_set_ie(pframe, _RSN_IE_2_, ie_len, p + 2, &pattrib->pktlen);
-
-       /* HT caps */
-       if (padapter->mlmepriv.htpriv.ht_option) {
-               p = rtw_get_ie((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ie)), _HT_CAPABILITY_IE_, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ie)));
-               if (p && !is_ap_in_tkip(padapter)) {
-                       memcpy(&pmlmeinfo->HT_caps, p + 2, sizeof(struct HT_caps_element));
-
-                       /* to disable 40M Hz support while gd_bw_40MHz_en = 0 */
-                       if (pregpriv->cbw40_enable == 0)
-                               pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info &= cpu_to_le16(~(BIT(6) | BIT(1)));
-                       else
-                               pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(BIT(1));
-
-                       /* todo: disable SM power save mode */
-                       pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x000c);
-
-                       if (pregpriv->rx_stbc)
-                               pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0100);/* RX STBC One spatial stream */
-                       memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_1R, 16);
-
-                       pframe = rtw_set_ie(pframe, _HT_CAPABILITY_IE_, ie_len, (u8 *)(&pmlmeinfo->HT_caps), &pattrib->pktlen);
-               }
-       }
-
-       /* vendor specific IE, such as WPA, WMM, WPS */
-       for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) {
-               pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.IEs + i);
-
-               switch (pIE->ElementID) {
-               case _VENDOR_SPECIFIC_IE_:
-                       if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) ||
-                           (!memcmp(pIE->data, WMM_OUI, 4)) ||
-                           (!memcmp(pIE->data, WPS_OUI, 4))) {
-                               if (!padapter->registrypriv.wifi_spec) {
-                                       /* Commented by Kurt 20110629 */
-                                       /* In some older APs, WPS handshake */
-                                       /* would be fail if we append vendor extension information to AP */
-                                       if (!memcmp(pIE->data, WPS_OUI, 4))
-                                               pIE->Length = 14;
-                               }
-                               pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, pIE->Length, pIE->data, &pattrib->pktlen);
-                       }
-                       break;
-               default:
-                       break;
-               }
-               i += (pIE->Length + 2);
-       }
-
-       if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK)
-               pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &pattrib->pktlen);
-
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) {
-               /*      Should add the P2P IE in the association request frame. */
-               /*      P2P OUI */
-
-               p2pielen = 0;
-               p2pie[p2pielen++] = 0x50;
-               p2pie[p2pielen++] = 0x6F;
-               p2pie[p2pielen++] = 0x9A;
-               p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-               /*      Commented by Albert 20101109 */
-               /*      According to the P2P Specification, the association request frame should contain 3 P2P attributes */
-               /*      1. P2P Capability */
-               /*      2. Extended Listen Timing */
-               /*      3. Device Info */
-               /*      Commented by Albert 20110516 */
-               /*      4. P2P Interface */
-
-               /*      P2P Capability */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-               /*      Length: */
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      Device Capability Bitmap, 1 byte */
-               p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-
-               /*      Group Capability Bitmap, 1 byte */
-               if (pwdinfo->persistent_supported)
-                       p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT;
-               else
-                       p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT;
-
-               /*      Extended Listen Timing */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING;
-
-               /*      Length: */
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      Availability Period */
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-               p2pielen += 2;
-
-               /*      Availability Interval */
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-               p2pielen += 2;
-
-               /*      Device Info */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-               /*      Length: */
-               /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
-               /*      + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      P2P Device Address */
-               memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-               p2pielen += ETH_ALEN;
-
-               /*      Config Method */
-               /*      This field should be big endian. Noted by P2P specification. */
-               if ((pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) ||
-                   (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN))
-                       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY);
-               else
-                       *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC);
-
-               p2pielen += 2;
-
-               /*      Primary Device Type */
-               /*      Category ID */
-               *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-               p2pielen += 2;
-
-               /*      OUI */
-               *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI);
-               p2pielen += 4;
-
-               /*      Sub Category ID */
-               *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-               p2pielen += 2;
-
-               /*      Number of Secondary Device Types */
-               p2pie[p2pielen++] = 0x00;       /*      No Secondary Device Type List */
-
-               /*      Device Name */
-               /*      Type: */
-               *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-               p2pielen += 2;
-
-               /*      Length: */
-               *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len);
-               p2pielen += 2;
-
-               /*      Value: */
-               memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len);
-               p2pielen += pwdinfo->device_name_len;
-
-               /*      P2P Interface */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_INTERFACE;
-
-               /*      Length: */
-               *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x000D);
-               p2pielen += 2;
-
-               /*      Value: */
-               memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN);       /*      P2P Device Address */
-               p2pielen += ETH_ALEN;
-
-               p2pie[p2pielen++] = 1;  /*      P2P Interface Address Count */
-
-               memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN);       /*      P2P Interface Address List */
-               p2pielen += ETH_ALEN;
-
-               pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen);
-       }
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-       dump_mgntframe(padapter, pmgntframe);
-
-       ret = _SUCCESS;
-
-exit:
-       if (ret == _SUCCESS)
-               rtw_buf_update(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen);
-       else
-               kfree(pmlmepriv->assoc_req);
-}
-
-/* when wait_ack is true, this function should be called at process context */
-static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int wait_ack)
-{
-       int ret = _FAIL;
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct xmit_priv        *pxmitpriv;
-       struct mlme_ext_priv    *pmlmeext;
-       struct mlme_ext_info    *pmlmeinfo;
-
-       if (!padapter)
-               goto exit;
-
-       pxmitpriv = &padapter->xmitpriv;
-       pmlmeext = &padapter->mlmeextpriv;
-       pmlmeinfo = &pmlmeext->mlmext_info;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               goto exit;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-       pattrib->retry_ctrl = false;
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)
-               SetFrDs(fctrl);
-       else if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)
-               SetToDs(fctrl);
-
-       if (power_mode)
-               SetPwrMgt(fctrl);
-
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_DATA_NULL);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       if (wait_ack) {
-               ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe);
-       } else {
-               dump_mgntframe(padapter, pmgntframe);
-               ret = _SUCCESS;
-       }
-
-exit:
-       return ret;
-}
-
-/* when wait_ms > 0, this function should be called at process context */
-/* da == NULL for station mode */
-int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms)
-{
-       int ret;
-       int i = 0;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       /* da == NULL, assume it's null data for sta to ap*/
-       if (!da)
-               da = get_my_bssid(&pmlmeinfo->network);
-
-       do {
-               ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0);
-
-               i++;
-
-               if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
-                       break;
-
-               if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
-                       msleep(wait_ms);
-       } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0)));
-
-       if (ret != _FAIL) {
-               ret = _SUCCESS;
-               goto exit;
-       }
-exit:
-       return ret;
-}
-
-/* when wait_ack is true, this function should be called at process context */
-static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int wait_ack)
-{
-       int ret = _FAIL;
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       unsigned short *qc;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               goto exit;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       pattrib->hdrlen += 2;
-       pattrib->qos_en = true;
-       pattrib->eosp = 1;
-       pattrib->ack_policy = 0;
-       pattrib->mdata = 0;
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)
-               SetFrDs(fctrl);
-       else if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)
-               SetToDs(fctrl);
-
-       qc = (unsigned short *)(pframe + pattrib->hdrlen - 2);
-
-       SetPriority(qc, tid);
-
-       SetEOSP(qc, pattrib->eosp);
-
-       SetAckpolicy(qc, pattrib->ack_policy);
-
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_QOS_DATA_NULL);
-
-       pframe += sizeof(struct ieee80211_qos_hdr);
-       pattrib->pktlen = sizeof(struct ieee80211_qos_hdr);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       if (wait_ack) {
-               ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe);
-       } else {
-               dump_mgntframe(padapter, pmgntframe);
-               ret = _SUCCESS;
-       }
-
-exit:
-       return ret;
-}
-
-/* when wait_ms > 0 , this function should be called at process context */
-/* da == NULL for station mode */
-int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms)
-{
-       int ret;
-       int i = 0;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       /* da == NULL, assume it's null data for sta to ap*/
-       if (!da)
-               da = get_my_bssid(&pmlmeinfo->network);
-
-       do {
-               ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0);
-
-               i++;
-
-               if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
-                       break;
-
-               if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
-                       msleep(wait_ms);
-       } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0)));
-
-       if (ret != _FAIL) {
-               ret = _SUCCESS;
-               goto exit;
-       }
-exit:
-       return ret;
-}
-
-static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason, u8 wait_ack)
-{
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       int ret = _FAIL;
-       __le16 le_tmp;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if (!(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) && (pwdinfo->rx_invitereq_info.scan_op_ch_only)) {
-               _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey);
-               _set_timer(&pwdinfo->reset_ch_sitesurvey, 10);
-       }
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               goto exit;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-       pattrib->retry_ctrl = false;
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_DEAUTH);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       le_tmp = cpu_to_le16(reason);
-       pframe = rtw_set_fixed_ie(pframe, _RSON_CODE_, (unsigned char *)&le_tmp, &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       if (wait_ack) {
-               ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe);
-       } else {
-               dump_mgntframe(padapter, pmgntframe);
-               ret = _SUCCESS;
-       }
-
-exit:
-       return ret;
-}
-
-int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason)
-{
-       return _issue_deauth(padapter, da, reason, false);
-}
-
-int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int try_cnt,
-       int wait_ms)
-{
-       int ret;
-       int i = 0;
-
-       do {
-               ret = _issue_deauth(padapter, da, reason, wait_ms > 0);
-
-               i++;
-
-               if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
-                       break;
-
-               if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
-                       msleep(wait_ms);
-       } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0)));
-
-       if (ret != _FAIL) {
-               ret = _SUCCESS;
-               goto exit;
-       }
-exit:
-       return ret;
-}
-
-void issue_action_BA(struct adapter *padapter, unsigned char *raddr, u8 action,
-                    u16 status, struct ieee80211_mgmt *mgmt_req)
-{
-       u16 start_seq;
-       u16 BA_starting_seqctrl = 0;
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct sta_info *psta;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct registry_priv *pregpriv = &padapter->registrypriv;
-       struct ieee80211_mgmt *mgmt;
-       u16 capab, params;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       mgmt = (struct ieee80211_mgmt *)(pmgntframe->buf_addr + TXDESC_OFFSET);
-
-       mgmt->frame_control = cpu_to_le16(IEEE80211_STYPE_ACTION | IEEE80211_FTYPE_MGMT);
-
-       memcpy(mgmt->da, raddr, ETH_ALEN);
-       memcpy(mgmt->sa, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-
-       mgmt->seq_ctrl = cpu_to_le16(pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-
-       mgmt->u.action.category = WLAN_CATEGORY_BACK;
-
-       switch (action) {
-       case WLAN_ACTION_ADDBA_REQ:
-               mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ;
-               do {
-                       pmlmeinfo->dialogToken++;
-               } while (pmlmeinfo->dialogToken == 0);
-               mgmt->u.action.u.addba_req.dialog_token = pmlmeinfo->dialogToken;
-
-               /* immediate ack & 64 buffer size */
-               capab = u16_encode_bits(64, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
-               capab |= u16_encode_bits(1, IEEE80211_ADDBA_PARAM_POLICY_MASK);
-               capab |= u16_encode_bits(status, IEEE80211_ADDBA_PARAM_TID_MASK);
-               mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
-
-               mgmt->u.action.u.addba_req.timeout = cpu_to_le16(5000); /* 5 ms */
-
-               psta = rtw_get_stainfo(pstapriv, raddr);
-               if (psta) {
-                       start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07] & 0xfff) + 1;
-
-                       psta->BA_starting_seqctrl[status & 0x07] = start_seq;
-
-                       BA_starting_seqctrl = start_seq << 4;
-               }
-               mgmt->u.action.u.addba_req.start_seq_num = cpu_to_le16(BA_starting_seqctrl);
-
-               pattrib->pktlen = offsetofend(struct ieee80211_mgmt,
-                                             u.action.u.addba_req.start_seq_num);
-               break;
-       case WLAN_ACTION_ADDBA_RESP:
-               mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
-               mgmt->u.action.u.addba_resp.dialog_token = mgmt_req->u.action.u.addba_req.dialog_token;
-               mgmt->u.action.u.addba_resp.status = cpu_to_le16(status);
-               capab = le16_to_cpu(mgmt_req->u.action.u.addba_req.capab) & 0x3f;
-               capab |= u16_encode_bits(64, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
-               capab |= u16_encode_bits(pregpriv->ampdu_amsdu, IEEE80211_ADDBA_PARAM_AMSDU_MASK);
-               mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
-               mgmt->u.action.u.addba_resp.timeout = mgmt_req->u.action.u.addba_req.timeout;
-               pattrib->pktlen = offsetofend(struct ieee80211_mgmt, u.action.u.addba_resp.timeout);
-               break;
-       case WLAN_ACTION_DELBA:
-               mgmt->u.action.u.delba.action_code = WLAN_ACTION_DELBA;
-               mgmt->u.action.u.delba.params = cpu_to_le16((status & 0x1F) << 3);
-               params = u16_encode_bits((status & 0x1), IEEE80211_DELBA_PARAM_INITIATOR_MASK);
-               params |= u16_encode_bits((status >> 1) & 0xF, IEEE80211_DELBA_PARAM_TID_MASK);
-               mgmt->u.action.u.delba.params = cpu_to_le16(params);
-               mgmt->u.action.u.delba.reason_code = cpu_to_le16(WLAN_STATUS_REQUEST_DECLINED);
-               pattrib->pktlen = offsetofend(struct ieee80211_mgmt, u.action.u.delba.reason_code);
-               break;
-       default:
-               break;
-       }
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-static void issue_action_BSSCoexistPacket(struct adapter *padapter)
-{
-       struct list_head *plist, *phead;
-       unsigned char category, action;
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                           *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct  wlan_network    *pnetwork = NULL;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       u8 InfoContent[16] = {0};
-       u8 ICS[8][15];
-       if ((pmlmepriv->num_FortyMHzIntolerant == 0) || (pmlmepriv->num_sta_no_ht == 0))
-               return;
-
-       if (pmlmeinfo->bwmode_updated)
-               return;
-
-       category = WLAN_CATEGORY_PUBLIC;
-       action = ACT_PUBLIC_BSSCOEXIST;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen);
-
-       /*  */
-       if (pmlmepriv->num_FortyMHzIntolerant > 0) {
-               u8 iedata = 0;
-
-               iedata |= BIT(2);/* 20 MHz BSS Width Request */
-
-               pframe = rtw_set_ie(pframe, EID_BSSCoexistence,  1, &iedata, &pattrib->pktlen);
-       }
-
-       /*  */
-       memset(ICS, 0, sizeof(ICS));
-       if (pmlmepriv->num_sta_no_ht > 0) {
-               int i;
-
-               spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-               phead = get_list_head(queue);
-               plist = phead->next;
-
-               while (phead != plist) {
-                       int len;
-                       u8 *p;
-                       struct wlan_bssid_ex *pbss_network;
-
-                       pnetwork = container_of(plist, struct wlan_network, list);
-
-                       plist = plist->next;
-
-                       pbss_network = (struct wlan_bssid_ex *)&pnetwork->network;
-
-                       p = rtw_get_ie(pbss_network->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pbss_network->IELength - _FIXED_IE_LENGTH_);
-                       if (!p || len == 0) { /* non-HT */
-                               if ((pbss_network->Configuration.DSConfig <= 0) || (pbss_network->Configuration.DSConfig > 14))
-                                       continue;
-
-                               ICS[0][pbss_network->Configuration.DSConfig] = 1;
-
-                               if (ICS[0][0] == 0)
-                                       ICS[0][0] = 1;
-                       }
-               }
-               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-               for (i = 0; i < 8; i++) {
-                       if (ICS[i][0] == 1) {
-                               int j, k = 0;
-
-                               InfoContent[k] = i;
-                               /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */
-                               k++;
-
-                               for (j = 1; j <= 14; j++) {
-                                       if (ICS[i][j] == 1) {
-                                               if (k < 16) {
-                                                       InfoContent[k] = j; /* channel number */
-                                                       /* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */
-                                                       k++;
-                                               }
-                                       }
-                               }
-
-                               pframe = rtw_set_ie(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &pattrib->pktlen);
-                       }
-               }
-       }
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr)
-{
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct sta_info *psta = NULL;
-       /* struct recv_reorder_ctrl *preorder_ctrl; */
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       u16 tid;
-
-       if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
-               if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS))
-                       return _SUCCESS;
-
-       psta = rtw_get_stainfo(pstapriv, addr);
-       if (!psta)
-               return _SUCCESS;
-
-       if (initiator == 0) { /*  recipient */
-               for (tid = 0; tid < MAXTID; tid++) {
-                       if (psta->recvreorder_ctrl[tid].enable) {
-                               issue_action_BA(padapter, addr, WLAN_ACTION_DELBA,
-                                               (((tid << 1) | initiator) & 0x1F), NULL);
-                               psta->recvreorder_ctrl[tid].enable = false;
-                               psta->recvreorder_ctrl[tid].indicate_seq = 0xffff;
-                       }
-               }
-       } else if (initiator == 1) { /*  originator */
-               for (tid = 0; tid < MAXTID; tid++) {
-                       if (psta->htpriv.agg_enable_bitmap & BIT(tid)) {
-                               issue_action_BA(padapter, addr, WLAN_ACTION_DELBA,
-                                               (((tid << 1) | initiator) & 0x1F), NULL);
-                               psta->htpriv.agg_enable_bitmap &= ~BIT(tid);
-                               psta->htpriv.candidate_tid_bitmap &= ~BIT(tid);
-                       }
-               }
-       }
-
-       return _SUCCESS;
-}
-
-unsigned int send_beacon(struct adapter *padapter)
-{
-       bool bxmitok = false;
-       int     issue = 0;
-       int poll = 0;
-
-       clear_beacon_valid_bit(padapter);
-
-       do {
-               issue_beacon(padapter, 100);
-               issue++;
-               do {
-                       yield();
-                       bxmitok = get_beacon_valid_bit(padapter);
-                       poll++;
-               } while ((poll % 10) != 0 && !bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped);
-       } while (!bxmitok && issue < 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped);
-
-       if (padapter->bSurpriseRemoved || padapter->bDriverStopped || !bxmitok)
-               return _FAIL;
-
-       return _SUCCESS;
-}
-
-bool get_beacon_valid_bit(struct adapter *adapter)
-{
-       int res;
-       u8 reg;
-
-       res = rtw_read8(adapter, REG_TDECTRL + 2, &reg);
-       if (res)
-               return false;
-
-       /* BIT(16) of REG_TDECTRL = BIT(0) of REG_TDECTRL+2 */
-       return BIT(0) & reg;
-}
-
-void clear_beacon_valid_bit(struct adapter *adapter)
-{
-       int res;
-       u8 reg;
-
-       res = rtw_read8(adapter, REG_TDECTRL + 2, &reg);
-       if (res)
-               return;
-
-       /* BIT(16) of REG_TDECTRL = BIT(0) of REG_TDECTRL+2, write 1 to clear, Clear by sw */
-       rtw_write8(adapter, REG_TDECTRL + 2, reg | BIT(0));
-}
-
-void rtw_resume_tx_beacon(struct adapter *adapt)
-{
-       struct hal_data_8188e *haldata = &adapt->haldata;
-
-       /*  2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */
-       /*  which should be read from register to a global variable. */
-
-       rtw_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl) | BIT(6));
-       haldata->RegFwHwTxQCtrl |= BIT(6);
-       rtw_write8(adapt, REG_TBTT_PROHIBIT + 1, 0xff);
-       haldata->RegReg542 |= BIT(0);
-       rtw_write8(adapt, REG_TBTT_PROHIBIT + 2, haldata->RegReg542);
-}
-
-void rtw_stop_tx_beacon(struct adapter *adapt)
-{
-       struct hal_data_8188e *haldata = &adapt->haldata;
-
-       /*  2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */
-       /*  which should be read from register to a global variable. */
-
-       rtw_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl) & (~BIT(6)));
-       haldata->RegFwHwTxQCtrl &= (~BIT(6));
-       rtw_write8(adapt, REG_TBTT_PROHIBIT + 1, 0x64);
-       haldata->RegReg542 &= ~(BIT(0));
-       rtw_write8(adapt, REG_TBTT_PROHIBIT + 2, haldata->RegReg542);
-
-        /* todo: CheckFwRsvdPageContent(Adapter);  2010.06.23. Added by tynli. */
-}
-
-static void rtw_set_opmode(struct adapter *adapter, u8 mode)
-{
-       u8 val8;
-       int res;
-
-       /*  disable Port0 TSF update */
-       res = rtw_read8(adapter, REG_BCN_CTRL, &val8);
-       if (res)
-               return;
-
-       rtw_write8(adapter, REG_BCN_CTRL, val8 | BIT(4));
-
-       /*  set net_type */
-       res = rtw_read8(adapter, MSR, &val8);
-       if (res)
-               return;
-
-       val8 &= 0x0c;
-       val8 |= mode;
-       rtw_write8(adapter, MSR, val8);
-
-       if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) {
-               rtw_stop_tx_beacon(adapter);
-
-               rtw_write8(adapter, REG_BCN_CTRL, 0x19);/* disable atim wnd */
-       } else if (mode == _HW_STATE_ADHOC_) {
-               rtw_resume_tx_beacon(adapter);
-               rtw_write8(adapter, REG_BCN_CTRL, 0x1a);
-       } else if (mode == _HW_STATE_AP_) {
-               rtw_resume_tx_beacon(adapter);
-
-               rtw_write8(adapter, REG_BCN_CTRL, 0x12);
-
-               /* Set RCR */
-               rtw_write32(adapter, REG_RCR, 0x7000208e);/* CBSSID_DATA must set to 0,reject ICV_ERR packet */
-               /* enable to rx data frame */
-               rtw_write16(adapter, REG_RXFLTMAP2, 0xFFFF);
-               /* enable to rx ps-poll */
-               rtw_write16(adapter, REG_RXFLTMAP1, 0x0400);
-
-               /* Beacon Control related register for first time */
-               rtw_write8(adapter, REG_BCNDMATIM, 0x02); /*  2ms */
-
-               rtw_write8(adapter, REG_ATIMWND, 0x0a); /*  10ms */
-               rtw_write16(adapter, REG_BCNTCFG, 0x00);
-               rtw_write16(adapter, REG_TBTT_PROHIBIT, 0xff04);
-               rtw_write16(adapter, REG_TSFTR_SYN_OFFSET, 0x7fff);/*  +32767 (~32ms) */
-
-               /* reset TSF */
-               rtw_write8(adapter, REG_DUAL_TSF_RST, BIT(0));
-
-               /* BIT(3) - If set 0, hw will clr bcnq when tx becon ok/fail or port 0 */
-               res = rtw_read8(adapter, REG_MBID_NUM, &val8);
-               if (res)
-                       return;
-
-               rtw_write8(adapter, REG_MBID_NUM, val8 | BIT(3) | BIT(4));
-
-               /* enable BCN0 Function for if1 */
-               /* don't enable update TSF0 for if1 (due to TSF update when beacon/probe rsp are received) */
-               rtw_write8(adapter, REG_BCN_CTRL, (DIS_TSF_UDT0_NORMAL_CHIP | EN_BCN_FUNCTION | BIT(1)));
-
-               /* dis BCN1 ATIM  WND if if2 is station */
-               res = rtw_read8(adapter, REG_BCN_CTRL_1, &val8);
-               if (res)
-                       return;
-
-               rtw_write8(adapter, REG_BCN_CTRL_1, val8 | BIT(0));
-       }
-}
-
-/****************************************************************************
-
-Following are some utility functions for WiFi MLME
-
-*****************************************************************************/
-
-static void rtw_set_initial_gain(struct adapter *adapter, u8 gain)
-{
-       struct hal_data_8188e *haldata = &adapter->haldata;
-       struct odm_dm_struct *odmpriv = &haldata->odmpriv;
-       struct rtw_dig *digtable = &odmpriv->DM_DigTable;
-
-       if (gain == 0xff) {
-               /* restore rx gain */
-               ODM_Write_DIG(odmpriv, digtable->BackupIGValue);
-       } else {
-               digtable->BackupIGValue = digtable->CurIGValue;
-               ODM_Write_DIG(odmpriv, gain);
-       }
-}
-
-void rtw_mlme_under_site_survey(struct adapter *adapter)
-{
-       /* config RCR to receive different BSSID & not to receive data frame */
-
-       int res;
-       u8 reg;
-       u32 v;
-
-       res = rtw_read32(adapter, REG_RCR, &v);
-       if (res)
-               return;
-
-       v &= ~(RCR_CBSSID_BCN);
-       rtw_write32(adapter, REG_RCR, v);
-       /* reject all data frame */
-       rtw_write16(adapter, REG_RXFLTMAP2, 0x00);
-
-       /* disable update TSF */
-       res = rtw_read8(adapter, REG_BCN_CTRL, &reg);
-       if (res)
-               return;
-
-       rtw_write8(adapter, REG_BCN_CTRL, reg | BIT(4));
-}
-
-void rtw_mlme_site_survey_done(struct adapter *adapter)
-{
-       struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
-       struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       u32 reg32;
-       int res;
-       u8 reg;
-
-       if ((r8188eu_is_client_associated_to_ap(adapter)) ||
-           ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)) {
-               /* enable to rx data frame */
-               rtw_write16(adapter, REG_RXFLTMAP2, 0xFFFF);
-
-               /* enable update TSF */
-               res = rtw_read8(adapter, REG_BCN_CTRL, &reg);
-               if (res)
-                       return;
-
-               rtw_write8(adapter, REG_BCN_CTRL, reg & (~BIT(4)));
-       } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
-               rtw_write16(adapter, REG_RXFLTMAP2, 0xFFFF);
-               /* enable update TSF */
-               res = rtw_read8(adapter, REG_BCN_CTRL, &reg);
-               if (res)
-                       return;
-
-               rtw_write8(adapter, REG_BCN_CTRL, reg & (~BIT(4)));
-       }
-
-       res = rtw_read32(adapter, REG_RCR, &reg32);
-       if (res)
-               return;
-
-       rtw_write32(adapter, REG_RCR, reg32 | RCR_CBSSID_BCN);
-}
-
-void site_survey(struct adapter *padapter)
-{
-       unsigned char survey_channel = 0;
-       enum rt_scan_type ScanType = SCAN_PASSIVE;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) {
-               if (pwdinfo->rx_invitereq_info.scan_op_ch_only) {
-                       survey_channel = pwdinfo->rx_invitereq_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx];
-               } else {
-                       survey_channel = pwdinfo->p2p_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx];
-               }
-               ScanType = SCAN_ACTIVE;
-       } else if (rtw_p2p_findphase_ex_is_social(pwdinfo)) {
-               /*      Commented by Albert 2011/06/03 */
-               /*      The driver is in the find phase, it should go through the social channel. */
-               int ch_set_idx;
-               survey_channel = pwdinfo->social_chan[pmlmeext->sitesurvey_res.channel_idx];
-               ch_set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, survey_channel);
-               if (ch_set_idx >= 0)
-                       ScanType = pmlmeext->channel_set[ch_set_idx].ScanType;
-               else
-                       ScanType = SCAN_ACTIVE;
-       } else {
-               struct rtw_ieee80211_channel *ch;
-               if (pmlmeext->sitesurvey_res.channel_idx < pmlmeext->sitesurvey_res.ch_num) {
-                       ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx];
-                       survey_channel = ch->hw_value;
-                       ScanType = (ch->flags & RTW_IEEE80211_CHAN_PASSIVE_SCAN) ? SCAN_PASSIVE : SCAN_ACTIVE;
-               }
-       }
-
-       if (survey_channel != 0) {
-               if (pmlmeext->sitesurvey_res.channel_idx == 0)
-                       set_channel_bwmode(padapter, survey_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-               else
-                       SelectChannel(padapter, survey_channel);
-
-               if (ScanType == SCAN_ACTIVE) { /* obey the channel plan setting... */
-                       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) ||
-                           rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) {
-                               issue_probereq_p2p(padapter);
-                               issue_probereq_p2p(padapter);
-                               issue_probereq_p2p(padapter);
-                       } else {
-                               int i;
-                               for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) {
-                                       if (pmlmeext->sitesurvey_res.ssid[i].SsidLength) {
-                                               /* todo: to issue two probe req??? */
-                                               issue_probereq(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL);
-                                               /* msleep(SURVEY_TO>>1); */
-                                               issue_probereq(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL);
-                                       }
-                               }
-
-                               if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) {
-                                       /* todo: to issue two probe req??? */
-                                       issue_probereq(padapter, NULL, NULL);
-                                       /* msleep(SURVEY_TO>>1); */
-                                       issue_probereq(padapter, NULL, NULL);
-                               }
-                       }
-               }
-
-               set_survey_timer(pmlmeext, pmlmeext->chan_scan_time);
-       } else {
-               /*      channel number is 0 or this channel is not valid. */
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) {
-                       if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) {
-                               /*      Set the find_phase_state_exchange_cnt to P2P_FINDPHASE_EX_CNT. */
-                               /*      This will let the following flow to run the scanning end. */
-                               rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX);
-                       }
-               }
-
-               if (rtw_p2p_findphase_ex_is_needed(pwdinfo)) {
-                       /*      Set the P2P State to the listen state of find phase and set the current channel to the listen channel */
-                       set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-                       rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_LISTEN);
-                       pmlmeext->sitesurvey_res.state = SCAN_DISABLE;
-
-                       /* restore RX GAIN */
-                       rtw_set_initial_gain(padapter, 0xff);
-                       /* turn on dynamic functions */
-                       Restore_DM_Func_Flag(padapter);
-                       /* Switch_DM_Func(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */
-
-                       _set_timer(&pwdinfo->find_phase_timer, (u32)((u32)(pwdinfo->listen_dwell) * 100));
-               } else {
-                       /*  20100721:Interrupt scan operation here. */
-                       /*  For SW antenna diversity before link, it needs to switch to another antenna and scan again. */
-                       /*  It compares the scan result and selects a better one to do connection. */
-                       if (AntDivBeforeLink8188E(padapter)) {
-                               pmlmeext->sitesurvey_res.bss_cnt = 0;
-                               pmlmeext->sitesurvey_res.channel_idx = -1;
-                               pmlmeext->chan_scan_time = SURVEY_TO / 2;
-                               set_survey_timer(pmlmeext, pmlmeext->chan_scan_time);
-                               return;
-                       }
-                       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH))
-                               rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-                       rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE);
-
-                       pmlmeext->sitesurvey_res.state = SCAN_COMPLETE;
-
-                       /* switch back to the original channel */
-
-                       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN))
-                               set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-                       else
-                               set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
-
-                       /* config MSR */
-                       Set_MSR(padapter, (pmlmeinfo->state & 0x3));
-
-                       /* restore RX GAIN */
-                       rtw_set_initial_gain(padapter, 0xff);
-                       /* turn on dynamic functions */
-                       Restore_DM_Func_Flag(padapter);
-                       /* Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */
-
-                       if (r8188eu_is_client_associated_to_ap(padapter))
-                               issue_nulldata(padapter, NULL, 0, 3, 500);
-
-                       rtw_mlme_site_survey_done(padapter);
-
-                       report_surveydone_event(padapter);
-
-                       pmlmeext->chan_scan_time = SURVEY_TO;
-                       pmlmeext->sitesurvey_res.state = SCAN_DISABLE;
-
-                       issue_action_BSSCoexistPacket(padapter);
-                       issue_action_BSSCoexistPacket(padapter);
-                       issue_action_BSSCoexistPacket(padapter);
-               }
-       }
-}
-
-/* collect bss info from Beacon and Probe request/response frames. */
-u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid)
-{
-       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
-       int     i;
-       u32     len;
-       u8 *p;
-       u16 val16;
-       u8 *pframe = precv_frame->rx_data;
-       u32     packet_len = precv_frame->len;
-       u8 ie_offset;
-       struct registry_priv    *pregistrypriv = &padapter->registrypriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       __le32 le32_tmp;
-
-       len = packet_len - sizeof(struct ieee80211_hdr_3addr);
-
-       if (len > MAX_IE_SZ)
-               return _FAIL;
-
-       memset(bssid, 0, sizeof(struct wlan_bssid_ex));
-
-       if (ieee80211_is_beacon(mgmt->frame_control)) {
-               bssid->Reserved[0] = 1;
-               ie_offset = _BEACON_IE_OFFSET_;
-       } else if (ieee80211_is_probe_req(mgmt->frame_control)) {
-               ie_offset = _PROBEREQ_IE_OFFSET_;
-               bssid->Reserved[0] = 2;
-       } else if (ieee80211_is_probe_resp(mgmt->frame_control)) {
-               ie_offset = _PROBERSP_IE_OFFSET_;
-               bssid->Reserved[0] = 3;
-       } else {
-               bssid->Reserved[0] = 0;
-               ie_offset = _FIXED_IE_LENGTH_;
-       }
-
-       bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len;
-
-       /* below is to copy the information element */
-       bssid->IELength = len;
-       memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength);
-
-       /* get the signal strength */
-       bssid->Rssi = precv_frame->attrib.phy_info.recvpower; /*  in dBM.raw data */
-       bssid->PhyInfo.SignalQuality = precv_frame->attrib.phy_info.SignalQuality;/* in percentage */
-       bssid->PhyInfo.SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */
-       bssid->PhyInfo.Optimum_antenna = rtw_current_antenna(padapter);
-
-       /*  checking SSID */
-       p = rtw_get_ie(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset);
-       if (!p)
-               return _FAIL;
-
-       if (*(p + 1)) {
-               if (len > NDIS_802_11_LENGTH_SSID)
-                       return _FAIL;
-               memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1));
-               bssid->Ssid.SsidLength = *(p + 1);
-       } else {
-               bssid->Ssid.SsidLength = 0;
-       }
-
-       memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX);
-
-       /* checking rate info... */
-       i = 0;
-       p = rtw_get_ie(bssid->IEs + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset);
-       if (p) {
-               if (len > NDIS_802_11_LENGTH_RATES_EX)
-                       return _FAIL;
-               memcpy(bssid->SupportedRates, (p + 2), len);
-               i = len;
-       }
-
-       p = rtw_get_ie(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset);
-       if (p) {
-               if (len > (NDIS_802_11_LENGTH_RATES_EX - i))
-                       return _FAIL;
-               memcpy(bssid->SupportedRates + i, (p + 2), len);
-       }
-
-       if (bssid->IELength < 12)
-               return _FAIL;
-
-       /*  Checking for DSConfig */
-       p = rtw_get_ie(bssid->IEs + ie_offset, _DSSET_IE_, &len, bssid->IELength - ie_offset);
-
-       bssid->Configuration.DSConfig = 0;
-       bssid->Configuration.Length = 0;
-
-       if (p) {
-               bssid->Configuration.DSConfig = *(p + 2);
-       } else {/*  In 5G, some ap do not have DSSET IE */
-               /*  checking HT info for channel */
-               p = rtw_get_ie(bssid->IEs + ie_offset, _HT_ADD_INFO_IE_, &len, bssid->IELength - ie_offset);
-               if (p) {
-                       struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2);
-                       bssid->Configuration.DSConfig = HT_info->primary_channel;
-               } else { /*  use current channel */
-                       bssid->Configuration.DSConfig = rtw_get_oper_ch(padapter);
-               }
-       }
-
-       memcpy(&le32_tmp, rtw_get_beacon_interval_from_ie(bssid->IEs), 2);
-       bssid->Configuration.BeaconPeriod = le32_to_cpu(le32_tmp);
-
-       val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid);
-
-       if (val16 & BIT(0)) {
-               bssid->InfrastructureMode = Ndis802_11Infrastructure;
-               memcpy(bssid->MacAddress, GetAddr2Ptr(pframe), ETH_ALEN);
-       } else {
-               bssid->InfrastructureMode = Ndis802_11IBSS;
-               memcpy(bssid->MacAddress, GetAddr3Ptr(pframe), ETH_ALEN);
-       }
-
-       if (val16 & BIT(4))
-               bssid->Privacy = 1;
-       else
-               bssid->Privacy = 0;
-
-       bssid->Configuration.ATIMWindow = 0;
-
-       /* 20/40 BSS Coexistence check */
-       if ((pregistrypriv->wifi_spec == 1) && (!pmlmeinfo->bwmode_updated)) {
-               struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-               p = rtw_get_ie(bssid->IEs + ie_offset, _HT_CAPABILITY_IE_, &len, bssid->IELength - ie_offset);
-               if (p && len > 0) {
-                       struct HT_caps_element  *pHT_caps;
-                       pHT_caps = (struct HT_caps_element *)(p + 2);
-
-                       if (le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info) & BIT(14))
-                               pmlmepriv->num_FortyMHzIntolerant++;
-               } else {
-                       pmlmepriv->num_sta_no_ht++;
-               }
-       }
-
-       /*  mark bss info receiving from nearby channel as SignalQuality 101 */
-       if (bssid->Configuration.DSConfig != rtw_get_oper_ch(padapter))
-               bssid->PhyInfo.SignalQuality = 101;
-       return _SUCCESS;
-}
-
-static void rtw_set_bssid(struct adapter *adapter, u8 *bssid)
-{
-       int i;
-
-       for (i = 0; i < ETH_ALEN; i++)
-               rtw_write8(adapter, REG_BSSID + i, bssid[i]);
-}
-
-static void mlme_join(struct adapter *adapter, int type)
-{
-       struct mlme_priv *mlmepriv = &adapter->mlmepriv;
-       u8 retry_limit = 0x30, reg;
-       u32 reg32;
-       int res;
-
-       switch (type) {
-       case 0:
-               /* prepare to join */
-               /* enable to rx data frame, accept all data frame */
-               rtw_write16(adapter, REG_RXFLTMAP2, 0xFFFF);
-
-               res = rtw_read32(adapter, REG_RCR, &reg32);
-               if (res)
-                       return;
-
-               rtw_write32(adapter, REG_RCR,
-                           reg32 | RCR_CBSSID_DATA | RCR_CBSSID_BCN);
-
-               if (check_fwstate(mlmepriv, WIFI_STATION_STATE)) {
-                       retry_limit = 48;
-               } else {
-                       /* ad-hoc mode */
-                       retry_limit = 0x7;
-               }
-               break;
-       case 1:
-               /* joinbss_event call back when join res < 0 */
-               rtw_write16(adapter, REG_RXFLTMAP2, 0x00);
-               break;
-       case 2:
-               /* sta add event call back */
-               /* enable update TSF */
-               res = rtw_read8(adapter, REG_BCN_CTRL, &reg);
-               if (res)
-                       return;
-
-               rtw_write8(adapter, REG_BCN_CTRL, reg & (~BIT(4)));
-
-               if (check_fwstate(mlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE))
-                       retry_limit = 0x7;
-               break;
-       default:
-               break;
-       }
-
-       rtw_write16(adapter, REG_RL,
-                   retry_limit << RETRY_LIMIT_SHORT_SHIFT | retry_limit << RETRY_LIMIT_LONG_SHIFT);
-}
-
-void start_create_ibss(struct adapter *padapter)
-{
-       unsigned short  caps;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network);
-       pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig;
-       pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork);
-
-       /* update wireless mode */
-       update_wireless_mode(padapter);
-
-       /* update capability */
-       caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork);
-       update_capinfo(padapter, caps);
-       if (caps & cap_IBSS) {/* adhoc master */
-               rtw_write8(padapter, REG_SECCFG, 0xcf);
-
-               /* switch channel */
-               /* SelectChannel(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE); */
-               set_channel_bwmode(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-
-               beacon_timing_control(padapter);
-
-               /* set msr to WIFI_FW_ADHOC_STATE */
-               pmlmeinfo->state = WIFI_FW_ADHOC_STATE;
-               Set_MSR(padapter, (pmlmeinfo->state & 0x3));
-
-               /* issue beacon */
-               if (send_beacon(padapter) == _FAIL) {
-                       report_join_res(padapter, -1);
-                       pmlmeinfo->state = WIFI_FW_NULL_STATE;
-               } else {
-                       rtw_set_bssid(padapter, padapter->registrypriv.dev_network.MacAddress);
-                       mlme_join(padapter, 0);
-
-                       report_join_res(padapter, 1);
-                       pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS;
-                       rtw_indicate_connect(padapter);
-               }
-       } else {
-               return;
-       }
-       /* update bc/mc sta_info */
-       update_bmc_sta(padapter);
-}
-
-void start_clnt_join(struct adapter *padapter)
-{
-       unsigned short  caps;
-       u8 val8;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network);
-       int beacon_timeout;
-
-       pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig;
-       pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork);
-
-       /* update wireless mode */
-       update_wireless_mode(padapter);
-
-       /* update capability */
-       caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork);
-       update_capinfo(padapter, caps);
-       if (caps & cap_ESS) {
-               Set_MSR(padapter, WIFI_FW_STATION_STATE);
-
-               val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf;
-
-               rtw_write8(padapter, REG_SECCFG, val8);
-
-               /* switch channel */
-               set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
-
-               /* here wait for receiving the beacon to start auth */
-               /* and enable a timer */
-               beacon_timeout = decide_wait_for_beacon_timeout(pmlmeinfo->bcn_interval);
-               set_link_timer(pmlmeext, beacon_timeout);
-               _set_timer(&padapter->mlmepriv.assoc_timer,
-                          (REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO * REASSOC_LIMIT) + beacon_timeout);
-
-               pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE;
-       } else if (caps & cap_IBSS) { /* adhoc client */
-               Set_MSR(padapter, WIFI_FW_ADHOC_STATE);
-
-               rtw_write8(padapter, REG_SECCFG, 0xcf);
-
-               /* switch channel */
-               set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
-
-               beacon_timing_control(padapter);
-
-               pmlmeinfo->state = WIFI_FW_ADHOC_STATE;
-
-               report_join_res(padapter, 1);
-       } else {
-               return;
-       }
-}
-
-void start_clnt_auth(struct adapter *padapter)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       _cancel_timer_ex(&pmlmeext->link_timer);
-
-       pmlmeinfo->state &= (~WIFI_FW_AUTH_NULL);
-       pmlmeinfo->state |= WIFI_FW_AUTH_STATE;
-
-       pmlmeinfo->auth_seq = 1;
-       pmlmeinfo->reauth_count = 0;
-       pmlmeinfo->reassoc_count = 0;
-       pmlmeinfo->link_count = 0;
-       pmlmeext->retry = 0;
-
-       /*  Because of AP's not receiving deauth before */
-       /*  AP may: 1)not response auth or 2)deauth us after link is complete */
-       /*  issue deauth before issuing auth to deal with the situation */
-       /*      Commented by Albert 2012/07/21 */
-       /*      For the Win8 P2P connection, it will be hard to have a successful connection if this Wi-Fi doesn't connect to it. */
-       issue_deauth(padapter, (&pmlmeinfo->network)->MacAddress, WLAN_REASON_DEAUTH_LEAVING);
-
-       issue_auth(padapter, NULL, 0);
-
-       set_link_timer(pmlmeext, REAUTH_TO);
-}
-
-void start_clnt_assoc(struct adapter *padapter)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       _cancel_timer_ex(&pmlmeext->link_timer);
-
-       pmlmeinfo->state &= (~(WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE));
-       pmlmeinfo->state |= (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE);
-
-       issue_assocreq(padapter);
-
-       set_link_timer(pmlmeext, REASSOC_TO);
-}
-
-void receive_disconnect(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       /* check A3 */
-       if (!(!memcmp(MacAddr, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)))
-               return;
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) {
-               if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {
-                       pmlmeinfo->state = WIFI_FW_NULL_STATE;
-                       report_del_sta_event(padapter, MacAddr, reason);
-               } else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE) {
-                       pmlmeinfo->state = WIFI_FW_NULL_STATE;
-                       report_join_res(padapter, -2);
-               }
-       }
-}
-
-static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid)
-{
-       struct registry_priv *pregistrypriv;
-       struct mlme_ext_priv *pmlmeext;
-       struct rt_channel_info *chplan_new;
-       u8 channel;
-       u8 i;
-
-       pregistrypriv = &padapter->registrypriv;
-       pmlmeext = &padapter->mlmeextpriv;
-
-       /*  Adjust channel plan by AP Country IE */
-       if (pregistrypriv->enable80211d &&
-           (!pmlmeext->update_channel_plan_by_ap_done)) {
-               u8 *ie, *p;
-               u32 len;
-               struct rt_channel_plan chplan_ap;
-               struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM];
-               u8 country[4];
-               u8 fcn; /*  first channel number */
-               u8 noc; /*  number of channel */
-               u8 j, k;
-
-               ie = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _COUNTRY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-               if (!ie)
-                       return;
-               if (len < 6)
-                       return;
-               ie += 2;
-               p = ie;
-               ie += len;
-
-               memset(country, 0, 4);
-               memcpy(country, p, 3);
-               p += 3;
-
-               i = 0;
-               while ((ie - p) >= 3) {
-                       fcn = *(p++);
-                       noc = *(p++);
-                       p++;
-
-                       for (j = 0; j < noc; j++) {
-                               channel = fcn + j;
-                               chplan_ap.Channel[i++] = channel;
-                       }
-               }
-               chplan_ap.Len = i;
-
-               memcpy(chplan_sta, pmlmeext->channel_set, sizeof(chplan_sta));
-
-               memset(pmlmeext->channel_set, 0, sizeof(pmlmeext->channel_set));
-               chplan_new = pmlmeext->channel_set;
-
-               i = 0;
-               j = 0;
-               k = 0;
-               if (pregistrypriv->wireless_mode & WIRELESS_11G) {
-                       do {
-                               if ((i == MAX_CHANNEL_NUM) ||
-                                   (chplan_sta[i].ChannelNum == 0))
-                                       break;
-
-                               if (j == chplan_ap.Len)
-                                       break;
-
-                               if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) {
-                                       chplan_new[k].ChannelNum = chplan_ap.Channel[j];
-                                       chplan_new[k].ScanType = SCAN_ACTIVE;
-                                       i++;
-                                       j++;
-                                       k++;
-                               } else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) {
-                                       chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum;
-                                       chplan_new[k].ScanType = SCAN_PASSIVE;
-                                       i++;
-                                       k++;
-                               } else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) {
-                                       chplan_new[k].ChannelNum = chplan_ap.Channel[j];
-                                       chplan_new[k].ScanType = SCAN_ACTIVE;
-                                       j++;
-                                       k++;
-                               }
-                       } while (1);
-
-                       /*  change AP not support channel to Passive scan */
-                       while ((i < MAX_CHANNEL_NUM) &&
-                              (chplan_sta[i].ChannelNum != 0) &&
-                              (chplan_sta[i].ChannelNum <= 14)) {
-                               chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum;
-                               chplan_new[k].ScanType = SCAN_PASSIVE;
-                               i++;
-                               k++;
-                       }
-
-                       /*  add channel AP supported */
-                       while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) {
-                               chplan_new[k].ChannelNum = chplan_ap.Channel[j];
-                               chplan_new[k].ScanType = SCAN_ACTIVE;
-                               j++;
-                               k++;
-                       }
-               } else {
-                       /*  keep original STA 2.4G channel plan */
-                       while ((i < MAX_CHANNEL_NUM) &&
-                              (chplan_sta[i].ChannelNum != 0) &&
-                              (chplan_sta[i].ChannelNum <= 14)) {
-                               chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum;
-                               chplan_new[k].ScanType = chplan_sta[i].ScanType;
-                               i++;
-                               k++;
-                       }
-
-                       /*  skip AP 2.4G channel plan */
-                       while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14))
-                               j++;
-               }
-
-               /*  keep original STA 5G channel plan */
-               while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) {
-                       chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum;
-                       chplan_new[k].ScanType = chplan_sta[i].ScanType;
-                       i++;
-                       k++;
-               }
-
-               pmlmeext->update_channel_plan_by_ap_done = 1;
-       }
-
-       /*  If channel is used by AP, set channel scan type to active */
-       channel = bssid->Configuration.DSConfig;
-       chplan_new = pmlmeext->channel_set;
-       i = 0;
-       while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) {
-               if (chplan_new[i].ChannelNum == channel) {
-                       if (chplan_new[i].ScanType == SCAN_PASSIVE)
-                               chplan_new[i].ScanType = SCAN_ACTIVE;
-                       break;
-               }
-               i++;
-       }
-}
-
-/****************************************************************************
-
-Following are the functions to report events
-
-*****************************************************************************/
-
-void report_survey_event(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct cmd_obj *pcmd_obj;
-       u8 *pevtcmd;
-       u32 cmdsz;
-       struct survey_event     *psurvey_evt;
-       struct C2HEvent_Header *pc2h_evt_hdr;
-       struct mlme_ext_priv *pmlmeext;
-       struct cmd_priv *pcmdpriv;
-       /* u8 *pframe = precv_frame->rx_data; */
-       /* uint len = precv_frame->len; */
-
-       if (!padapter)
-               return;
-
-       pmlmeext = &padapter->mlmeextpriv;
-       pcmdpriv = &padapter->cmdpriv;
-
-       pcmd_obj = kzalloc(sizeof(*pcmd_obj), GFP_ATOMIC);
-       if (!pcmd_obj)
-               return;
-
-       cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
-       pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
-       if (!pevtcmd) {
-               kfree(pcmd_obj);
-               return;
-       }
-
-       INIT_LIST_HEAD(&pcmd_obj->list);
-
-       pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT);
-       pcmd_obj->cmdsz = cmdsz;
-       pcmd_obj->parmbuf = pevtcmd;
-
-       pcmd_obj->rsp = NULL;
-       pcmd_obj->rspsz  = 0;
-
-       pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd);
-       pc2h_evt_hdr->len = sizeof(struct survey_event);
-       pc2h_evt_hdr->ID = GEN_EVT_CODE(_Survey);
-       pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq);
-
-       psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
-
-       if (collect_bss_info(padapter, precv_frame, (struct wlan_bssid_ex *)&psurvey_evt->bss) == _FAIL) {
-               kfree(pcmd_obj);
-               kfree(pevtcmd);
-               return;
-       }
-
-       process_80211d(padapter, &psurvey_evt->bss);
-
-       rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-
-       pmlmeext->sitesurvey_res.bss_cnt++;
-}
-
-void report_surveydone_event(struct adapter *padapter)
-{
-       struct cmd_obj *pcmd_obj;
-       u8 *pevtcmd;
-       u32 cmdsz;
-       struct surveydone_event *psurveydone_evt;
-       struct C2HEvent_Header  *pc2h_evt_hdr;
-       struct mlme_ext_priv            *pmlmeext = &padapter->mlmeextpriv;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-
-       pcmd_obj = kzalloc(sizeof(*pcmd_obj), GFP_KERNEL);
-       if (!pcmd_obj)
-               return;
-
-       cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header));
-       pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
-       if (!pevtcmd) {
-               kfree(pcmd_obj);
-               return;
-       }
-
-       INIT_LIST_HEAD(&pcmd_obj->list);
-
-       pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT);
-       pcmd_obj->cmdsz = cmdsz;
-       pcmd_obj->parmbuf = pevtcmd;
-
-       pcmd_obj->rsp = NULL;
-       pcmd_obj->rspsz  = 0;
-
-       pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd);
-       pc2h_evt_hdr->len = sizeof(struct surveydone_event);
-       pc2h_evt_hdr->ID = GEN_EVT_CODE(_SurveyDone);
-       pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq);
-
-       psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
-       psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt;
-
-       rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-}
-
-void report_join_res(struct adapter *padapter, int res)
-{
-       struct cmd_obj *pcmd_obj;
-       u8 *pevtcmd;
-       u32 cmdsz;
-       struct joinbss_event            *pjoinbss_evt;
-       struct C2HEvent_Header  *pc2h_evt_hdr;
-       struct mlme_ext_priv            *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-
-       pcmd_obj = kzalloc(sizeof(*pcmd_obj), GFP_ATOMIC);
-       if (!pcmd_obj)
-               return;
-
-       cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
-       pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
-       if (!pevtcmd) {
-               kfree(pcmd_obj);
-               return;
-       }
-
-       INIT_LIST_HEAD(&pcmd_obj->list);
-
-       pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT);
-       pcmd_obj->cmdsz = cmdsz;
-       pcmd_obj->parmbuf = pevtcmd;
-
-       pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd);
-       pc2h_evt_hdr->len = sizeof(struct joinbss_event);
-       pc2h_evt_hdr->ID = GEN_EVT_CODE(_JoinBss);
-       pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq);
-
-       pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
-       memcpy((unsigned char *)(&pjoinbss_evt->network.network), &pmlmeinfo->network, sizeof(struct wlan_bssid_ex));
-       pjoinbss_evt->network.join_res  = res;
-       pjoinbss_evt->network.aid = res;
-
-       rtw_joinbss_event_prehandle(padapter, (u8 *)&pjoinbss_evt->network);
-
-       rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-}
-
-void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason)
-{
-       struct cmd_obj *pcmd_obj;
-       u8 *pevtcmd;
-       u32 cmdsz;
-       struct sta_info *psta;
-       int     mac_id;
-       struct stadel_event                     *pdel_sta_evt;
-       struct C2HEvent_Header  *pc2h_evt_hdr;
-       struct mlme_ext_priv            *pmlmeext = &padapter->mlmeextpriv;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-
-       pcmd_obj = kzalloc(sizeof(*pcmd_obj), GFP_ATOMIC);
-       if (!pcmd_obj)
-               return;
-
-       cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header));
-       pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
-       if (!pevtcmd) {
-               kfree(pcmd_obj);
-               return;
-       }
-
-       INIT_LIST_HEAD(&pcmd_obj->list);
-
-       pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT);
-       pcmd_obj->cmdsz = cmdsz;
-       pcmd_obj->parmbuf = pevtcmd;
-
-       pcmd_obj->rsp = NULL;
-       pcmd_obj->rspsz  = 0;
-
-       pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd);
-       pc2h_evt_hdr->len = sizeof(struct stadel_event);
-       pc2h_evt_hdr->ID = GEN_EVT_CODE(_DelSTA);
-       pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq);
-
-       pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
-       memcpy((unsigned char *)(&pdel_sta_evt->macaddr), MacAddr, ETH_ALEN);
-       memcpy((unsigned char *)(pdel_sta_evt->rsvd), (unsigned char *)(&reason), 2);
-
-       psta = rtw_get_stainfo(&padapter->stapriv, MacAddr);
-       if (psta)
-               mac_id = (int)psta->mac_id;
-       else
-               mac_id = (-1);
-
-       pdel_sta_evt->mac_id = mac_id;
-
-       rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-}
-
-void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx)
-{
-       struct cmd_obj *pcmd_obj;
-       u8 *pevtcmd;
-       u32 cmdsz;
-       struct stassoc_event            *padd_sta_evt;
-       struct C2HEvent_Header  *pc2h_evt_hdr;
-       struct mlme_ext_priv            *pmlmeext = &padapter->mlmeextpriv;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-
-       pcmd_obj = kzalloc(sizeof(*pcmd_obj), GFP_KERNEL);
-       if (!pcmd_obj)
-               return;
-
-       cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header));
-       pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
-       if (!pevtcmd) {
-               kfree(pcmd_obj);
-               return;
-       }
-
-       INIT_LIST_HEAD(&pcmd_obj->list);
-
-       pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT);
-       pcmd_obj->cmdsz = cmdsz;
-       pcmd_obj->parmbuf = pevtcmd;
-
-       pcmd_obj->rsp = NULL;
-       pcmd_obj->rspsz  = 0;
-
-       pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd);
-       pc2h_evt_hdr->len = sizeof(struct stassoc_event);
-       pc2h_evt_hdr->ID = GEN_EVT_CODE(_AddSTA);
-       pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq);
-
-       padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
-       memcpy((unsigned char *)(&padd_sta_evt->macaddr), MacAddr, ETH_ALEN);
-       padd_sta_evt->cam_id = cam_idx;
-
-       rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-}
-
-/****************************************************************************
-
-Following are the event callback functions
-
-*****************************************************************************/
-
-/* for sta/adhoc mode */
-void update_sta_info(struct adapter *padapter, struct sta_info *psta)
-{
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       /* ERP */
-       VCS_update(padapter, psta);
-
-       /* HT */
-       if (pmlmepriv->htpriv.ht_option) {
-               psta->htpriv.ht_option = true;
-
-               psta->htpriv.ampdu_enable = pmlmepriv->htpriv.ampdu_enable;
-
-               if (support_short_GI(padapter, &pmlmeinfo->HT_caps))
-                       psta->htpriv.sgi = true;
-
-               psta->qos_option = true;
-       } else {
-               psta->htpriv.ht_option = false;
-
-               psta->htpriv.ampdu_enable = false;
-
-               psta->htpriv.sgi = false;
-               psta->qos_option = false;
-       }
-       psta->htpriv.bwmode = pmlmeext->cur_bwmode;
-       psta->htpriv.ch_offset = pmlmeext->cur_ch_offset;
-
-       psta->htpriv.agg_enable_bitmap = 0x0;/* reset */
-       psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */
-
-       /* QoS */
-       if (pmlmepriv->qospriv.qos_option)
-               psta->qos_option = true;
-
-       psta->state = _FW_LINKED;
-}
-
-static void rtw_reset_dm_func_flag(struct adapter *adapter)
-{
-       struct hal_data_8188e *haldata = &adapter->haldata;
-       struct dm_priv *dmpriv = &haldata->dmpriv;
-       struct odm_dm_struct *odmpriv = &haldata->odmpriv;
-
-       odmpriv->SupportAbility = dmpriv->InitODMFlag;
-}
-
-static void rtw_clear_dm_func_flag(struct adapter *adapter)
-{
-       struct hal_data_8188e *haldata = &adapter->haldata;
-       struct odm_dm_struct *odmpriv = &haldata->odmpriv;
-
-       odmpriv->SupportAbility = 0;
-}
-
-void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res)
-{
-       struct sta_info         *psta, *psta_bmc;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
-       struct sta_priv         *pstapriv = &padapter->stapriv;
-       u16 media_status;
-
-       if (join_res < 0) {
-               mlme_join(padapter, 1);
-               rtw_set_bssid(padapter, null_addr);
-
-               /* restore to initial setting. */
-               update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode);
-
-               return;
-       }
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) {
-               /* for bc/mc */
-               psta_bmc = rtw_get_bcmc_stainfo(padapter);
-               if (psta_bmc) {
-                       pmlmeinfo->FW_sta_info[psta_bmc->mac_id].psta = psta_bmc;
-                       update_bmc_sta_support_rate(padapter, psta_bmc->mac_id);
-                       Update_RA_Entry(padapter, psta_bmc->mac_id);
-               }
-       }
-
-       /* turn on dynamic functions */
-       rtw_reset_dm_func_flag(padapter);
-
-       /*  update IOT-releated issue */
-       update_IOT_info(padapter);
-
-       rtw_set_basic_rate(padapter, cur_network->SupportedRates);
-
-       /* BCN interval */
-       rtw_write16(padapter, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval);
-
-       /* update capability */
-       update_capinfo(padapter, pmlmeinfo->capability);
-
-       /* WMM, Update EDCA param */
-       WMMOnAssocRsp(padapter);
-
-       /* HT */
-       HTOnAssocRsp(padapter);
-
-       set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
-
-       psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress);
-       if (psta) { /* only for infra. mode */
-               pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta;
-
-               psta->wireless_mode = pmlmeext->cur_wireless_mode;
-
-               /* set per sta rate after updating HT cap. */
-               set_sta_rate(padapter, psta);
-               rtw_set_max_rpt_macid(padapter, psta->mac_id);
-
-               media_status = (psta->mac_id << 8) | 1; /*   MACID|OPMODE: 1 means connect */
-               rtl8188e_set_FwMediaStatus_cmd(padapter, media_status);
-       }
-
-       mlme_join(padapter, 2);
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) {
-               /*  correcting TSF */
-               correct_TSF(padapter);
-       }
-       rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_CONNECT, 0);
-}
-
-void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *psta)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) {
-               if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {/* adhoc master or sta_count>1 */
-                       /* nothing to do */
-               } else { /* adhoc client */
-                       /*  correcting TSF */
-                       correct_TSF(padapter);
-
-                       /* start beacon */
-                       if (send_beacon(padapter) == _FAIL) {
-                               pmlmeinfo->FW_sta_info[psta->mac_id].status = 0;
-                               pmlmeinfo->state ^= WIFI_FW_ADHOC_STATE;
-                               return;
-                       }
-                       pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS;
-               }
-               mlme_join(padapter, 2);
-       }
-
-       pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta;
-
-       /* rate radaptive */
-       Update_RA_Entry(padapter, psta->mac_id);
-
-       /* update adhoc sta_info */
-       update_sta_info(padapter, psta);
-}
-
-static void mlme_disconnect(struct adapter *adapter)
-{
-       int res;
-       u8 reg;
-
-       /* Set RCR to not to receive data frame when NO LINK state */
-       /* reject all data frames */
-       rtw_write16(adapter, REG_RXFLTMAP2, 0x00);
-
-       /* reset TSF */
-       rtw_write8(adapter, REG_DUAL_TSF_RST, (BIT(0) | BIT(1)));
-
-       /* disable update TSF */
-
-       res = rtw_read8(adapter, REG_BCN_CTRL, &reg);
-       if (res)
-               return;
-
-       rtw_write8(adapter, REG_BCN_CTRL, reg | BIT(4));
-}
-
-void mlmeext_sta_del_event_callback(struct adapter *padapter)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (r8188eu_is_client_associated_to_ap(padapter) || r8188eu_is_ibss_empty(padapter)) {
-               mlme_disconnect(padapter);
-               rtw_set_bssid(padapter, null_addr);
-
-               /* restore to initial setting. */
-               update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode);
-
-               /* switch to the 20M Hz mode after disconnect */
-               pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20;
-               pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-
-               /* SelectChannel(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset); */
-               set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
-
-               flush_all_cam_entry(padapter);
-
-               pmlmeinfo->state = WIFI_FW_NULL_STATE;
-
-               /* set MSR to no link state -> infra. mode */
-               Set_MSR(padapter, _HW_STATE_STATION_);
-
-               _cancel_timer_ex(&pmlmeext->link_timer);
-       }
-}
-
-/****************************************************************************
-
-Following are the functions for the timer handlers
-
-*****************************************************************************/
-static u8 chk_ap_is_alive(struct sta_info *psta)
-{
-       u8 ret = false;
-
-       if ((sta_rx_data_pkts(psta) == sta_last_rx_data_pkts(psta)) &&
-           sta_rx_beacon_pkts(psta) == sta_last_rx_beacon_pkts(psta) &&
-           sta_rx_probersp_pkts(psta) == sta_last_rx_probersp_pkts(psta))
-               ret = false;
-       else
-               ret = true;
-
-       sta_update_last_rx_pkts(psta);
-
-       return ret;
-}
-
-static int rtl8188e_sreset_linked_status_check(struct adapter *padapter)
-{
-       u32 rx_dma_status;
-       int res;
-       u8 reg;
-
-       res = rtw_read32(padapter, REG_RXDMA_STATUS, &rx_dma_status);
-       if (res)
-               return res;
-
-       if (rx_dma_status != 0x00)
-               rtw_write32(padapter, REG_RXDMA_STATUS, rx_dma_status);
-
-       return rtw_read8(padapter, REG_FMETHR, &reg);
-}
-
-void linked_status_chk(struct adapter *padapter)
-{
-       u32     i;
-       struct sta_info         *psta;
-       struct xmit_priv                *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct sta_priv         *pstapriv = &padapter->stapriv;
-
-       rtl8188e_sreset_linked_status_check(padapter);
-
-       if (r8188eu_is_client_associated_to_ap(padapter)) {
-               /* linked infrastructure client mode */
-
-               int tx_chk = _SUCCESS, rx_chk = _SUCCESS;
-               int rx_chk_limit;
-
-               rx_chk_limit = 4;
-               psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress);
-               if (psta) {
-                       bool is_p2p_enable = false;
-                       is_p2p_enable = !rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE);
-
-                       if (!chk_ap_is_alive(psta))
-                               rx_chk = _FAIL;
-
-                       if (pxmitpriv->last_tx_pkts == pxmitpriv->tx_pkts)
-                               tx_chk = _FAIL;
-
-                       if (pmlmeext->active_keep_alive_check && (rx_chk == _FAIL || tx_chk == _FAIL)) {
-                               u8 backup_oper_channel = 0;
-
-                               /* switch to correct channel of current network  before issue keep-alive frames */
-                               if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) {
-                                       backup_oper_channel = rtw_get_oper_ch(padapter);
-                                       SelectChannel(padapter, pmlmeext->cur_channel);
-                               }
-
-                               if (rx_chk != _SUCCESS)
-                                       issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, psta->hwaddr);
-
-                               if ((tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) || rx_chk != _SUCCESS) {
-                                       tx_chk = issue_nulldata(padapter, psta->hwaddr, 0, 3, 1);
-                                       /* if tx acked and p2p disabled, set rx_chk _SUCCESS to reset retry count */
-                                       if (tx_chk == _SUCCESS && !is_p2p_enable)
-                                               rx_chk = _SUCCESS;
-                               }
-
-                               /* back to the original operation channel */
-                               if (backup_oper_channel > 0)
-                                       SelectChannel(padapter, backup_oper_channel);
-                       } else {
-                               if (rx_chk != _SUCCESS) {
-                                       if (pmlmeext->retry == 0) {
-                                               issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress);
-                                               issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress);
-                                               issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress);
-                                       }
-                               }
-
-                               if (tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) {
-                                       tx_chk = issue_nulldata(padapter, NULL, 0, 1, 0);
-                               }
-                       }
-
-                       if (rx_chk == _FAIL) {
-                               pmlmeext->retry++;
-                               if (pmlmeext->retry > rx_chk_limit) {
-                                       receive_disconnect(padapter, pmlmeinfo->network.MacAddress,
-                                                          WLAN_REASON_EXPIRATION_CHK);
-                                       return;
-                               }
-                       } else {
-                               pmlmeext->retry = 0;
-                       }
-
-                       if (tx_chk == _FAIL) {
-                               pmlmeinfo->link_count &= 0xf;
-                       } else {
-                               pxmitpriv->last_tx_pkts = pxmitpriv->tx_pkts;
-                               pmlmeinfo->link_count = 0;
-                       }
-               } /* end of if ((psta = rtw_get_stainfo(pstapriv, passoc_res->network.MacAddress)) != NULL) */
-       } else if (r8188eu_is_client_associated_to_ibss(padapter)) {
-               /* linked IBSS mode */
-               /* for each assoc list entry to check the rx pkt counter */
-               for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) {
-                       if (pmlmeinfo->FW_sta_info[i].status == 1) {
-                               psta = pmlmeinfo->FW_sta_info[i].psta;
-
-                               if (psta == NULL)
-                                       continue;
-                               if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) {
-                                       if (pmlmeinfo->FW_sta_info[i].retry < 3) {
-                                               pmlmeinfo->FW_sta_info[i].retry++;
-                                       } else {
-                                               pmlmeinfo->FW_sta_info[i].retry = 0;
-                                               pmlmeinfo->FW_sta_info[i].status = 0;
-                                               report_del_sta_event(padapter, psta->hwaddr
-                                                       , 65535/*  indicate disconnect caused by no rx */
-                                       );
-                                       }
-                               } else {
-                                       pmlmeinfo->FW_sta_info[i].retry = 0;
-                                       pmlmeinfo->FW_sta_info[i].rx_pkt = (u32)sta_rx_pkts(psta);
-                               }
-                       }
-               }
-       }
-}
-
-void survey_timer_hdl(struct adapter *padapter)
-{
-       struct cmd_obj  *ph2c;
-       struct sitesurvey_parm  *psurveyPara;
-       struct cmd_priv                                 *pcmdpriv = &padapter->cmdpriv;
-       struct mlme_ext_priv            *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       /* issue rtw_sitesurvey_cmd */
-       if (pmlmeext->sitesurvey_res.state > SCAN_START) {
-               if (pmlmeext->sitesurvey_res.state ==  SCAN_PROCESS)
-                       pmlmeext->sitesurvey_res.channel_idx++;
-
-               if (pmlmeext->scan_abort) {
-                       if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE)) {
-                               rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX);
-                               pmlmeext->sitesurvey_res.channel_idx = 3;
-                       } else {
-                               pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num;
-                       }
-
-                       pmlmeext->scan_abort = false;/* reset */
-               }
-
-               ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-               if (!ph2c)
-                       goto exit_survey_timer_hdl;
-
-               psurveyPara = kzalloc(sizeof(*psurveyPara), GFP_ATOMIC);
-               if (!psurveyPara) {
-                       kfree(ph2c);
-                       goto exit_survey_timer_hdl;
-               }
-
-               init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey));
-               rtw_enqueue_cmd(pcmdpriv, ph2c);
-       }
-
-exit_survey_timer_hdl:
-       return;
-}
-
-void link_timer_hdl(struct adapter *padapter)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
-               pmlmeinfo->state = WIFI_FW_NULL_STATE;
-               report_join_res(padapter, -3);
-       } else if (pmlmeinfo->state & WIFI_FW_AUTH_STATE) {
-               /* re-auth timer */
-               if (++pmlmeinfo->reauth_count > REAUTH_LIMIT) {
-                       pmlmeinfo->state = 0;
-                       report_join_res(padapter, -1);
-                       return;
-               }
-
-               pmlmeinfo->auth_seq = 1;
-               issue_auth(padapter, NULL, 0);
-               set_link_timer(pmlmeext, REAUTH_TO);
-       } else if (pmlmeinfo->state & WIFI_FW_ASSOC_STATE) {
-               /* re-assoc timer */
-               if (++pmlmeinfo->reassoc_count > REASSOC_LIMIT) {
-                       pmlmeinfo->state = WIFI_FW_NULL_STATE;
-                       report_join_res(padapter, -2);
-                       return;
-               }
-
-               issue_assocreq(padapter);
-               set_link_timer(pmlmeext, REASSOC_TO);
-       }
-}
-
-void addba_timer_hdl(struct sta_info *psta)
-{
-       struct ht_priv  *phtpriv;
-
-       if (!psta)
-               return;
-
-       phtpriv = &psta->htpriv;
-
-       if ((phtpriv->ht_option) && (phtpriv->ampdu_enable)) {
-               if (phtpriv->candidate_tid_bitmap)
-                       phtpriv->candidate_tid_bitmap = 0x0;
-       }
-}
-
-u8 NULL_hdl(struct adapter *padapter, u8 *pbuf)
-{
-       return H2C_SUCCESS;
-}
-
-u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf)
-{
-       u8 type;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf;
-
-       if (psetop->mode == Ndis802_11APMode) {
-               pmlmeinfo->state = WIFI_FW_AP_STATE;
-               type = _HW_STATE_AP_;
-       } else if (psetop->mode == Ndis802_11Infrastructure) {
-               pmlmeinfo->state &= ~(BIT(0) | BIT(1));/*  clear state */
-               pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to     STATION_STATE */
-               type = _HW_STATE_STATION_;
-       } else if (psetop->mode == Ndis802_11IBSS) {
-               type = _HW_STATE_ADHOC_;
-       } else {
-               type = _HW_STATE_NOLINK_;
-       }
-
-       rtw_set_opmode(padapter, type);
-
-       return H2C_SUCCESS;
-}
-
-u8 createbss_hdl(struct adapter *padapter, u8 *pbuf)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network);
-       struct joinbss_parm *pparm = (struct joinbss_parm *)pbuf;
-       /* u32  initialgain; */
-
-       if (pparm->network.InfrastructureMode == Ndis802_11APMode) {
-               if (pmlmeinfo->state == WIFI_FW_AP_STATE) {
-                       /* todo: */
-                       return H2C_SUCCESS;
-               }
-       }
-
-       /* below is for ad-hoc master */
-       if (pparm->network.InfrastructureMode == Ndis802_11IBSS) {
-               rtw_joinbss_reset(padapter);
-
-               pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20;
-               pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-               pmlmeinfo->ERP_enable = 0;
-               pmlmeinfo->WMM_enable = 0;
-               pmlmeinfo->HT_enable = 0;
-               pmlmeinfo->HT_caps_enable = 0;
-               pmlmeinfo->HT_info_enable = 0;
-               pmlmeinfo->agg_enable_bitmap = 0;
-               pmlmeinfo->candidate_tid_bitmap = 0;
-
-               /* disable dynamic functions, such as high power, DIG */
-               Save_DM_Func_Flag(padapter);
-               rtw_clear_dm_func_flag(padapter);
-
-               /* cancel link timer */
-               _cancel_timer_ex(&pmlmeext->link_timer);
-
-               /* clear CAM */
-               flush_all_cam_entry(padapter);
-
-               memcpy(pnetwork, pbuf, offsetof(struct wlan_bssid_ex, IELength));
-               pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength;
-
-               if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */
-                       return H2C_PARAMETERS_ERROR;
-
-               memcpy(pnetwork->IEs, ((struct wlan_bssid_ex *)pbuf)->IEs, pnetwork->IELength);
-
-               start_create_ibss(padapter);
-       }
-
-       return H2C_SUCCESS;
-}
-
-u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf)
-{
-       struct ndis_802_11_var_ie *pIE;
-       struct registry_priv    *pregpriv = &padapter->registrypriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network);
-       struct joinbss_parm     *pparm = (struct joinbss_parm *)pbuf;
-       u32 i;
-
-       /* check already connecting to AP or not */
-       if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {
-               if (pmlmeinfo->state & WIFI_FW_STATION_STATE)
-                       issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, 5, 100);
-
-               pmlmeinfo->state = WIFI_FW_NULL_STATE;
-
-               /* clear CAM */
-               flush_all_cam_entry(padapter);
-
-               _cancel_timer_ex(&pmlmeext->link_timer);
-
-               /* set MSR to nolink -> infra. mode */
-               Set_MSR(padapter, _HW_STATE_STATION_);
-
-               mlme_disconnect(padapter);
-       }
-
-       rtw_antenna_select_cmd(padapter, pparm->network.PhyInfo.Optimum_antenna, false);
-
-       rtw_joinbss_reset(padapter);
-
-       pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20;
-       pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-       pmlmeinfo->ERP_enable = 0;
-       pmlmeinfo->WMM_enable = 0;
-       pmlmeinfo->HT_enable = 0;
-       pmlmeinfo->HT_caps_enable = 0;
-       pmlmeinfo->HT_info_enable = 0;
-       pmlmeinfo->agg_enable_bitmap = 0;
-       pmlmeinfo->candidate_tid_bitmap = 0;
-       pmlmeinfo->bwmode_updated = false;
-
-       memcpy(pnetwork, pbuf, offsetof(struct wlan_bssid_ex, IELength));
-       pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength;
-
-       if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */
-               return H2C_PARAMETERS_ERROR;
-
-       memcpy(pnetwork->IEs, ((struct wlan_bssid_ex *)pbuf)->IEs, pnetwork->IELength);
-
-       /* Check AP vendor to move rtw_joinbss_cmd() */
-
-       for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->IELength;) {
-               pIE = (struct ndis_802_11_var_ie *)(pnetwork->IEs + i);
-
-               switch (pIE->ElementID) {
-               case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */
-                       if (!memcmp(pIE->data, WMM_OUI, 4))
-                               pmlmeinfo->WMM_enable = 1;
-                       break;
-               case _HT_CAPABILITY_IE_:        /* Get HT Cap IE. */
-                       pmlmeinfo->HT_caps_enable = 1;
-                       break;
-               case _HT_EXTRA_INFO_IE_:        /* Get HT Info IE. */
-                       pmlmeinfo->HT_info_enable = 1;
-
-                       /* spec case only for cisco's ap because cisco's ap issue assoc rsp using mcs rate @40MHz or @20MHz */
-                       {
-                               struct HT_info_element *pht_info = (struct HT_info_element *)(pIE->data);
-
-                               if ((pregpriv->cbw40_enable) &&  (pht_info->infos[0] & BIT(2))) {
-                                       /* switch to the 40M Hz mode according to the AP */
-                                       pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40;
-                                       switch (pht_info->infos[0] & 0x3) {
-                                       case 1:
-                                               pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
-                                               break;
-                                       case 3:
-                                               pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
-                                               break;
-                                       default:
-                                               pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-                                               break;
-                                       }
-                               }
-                       }
-                       break;
-               default:
-                       break;
-               }
-
-               i += (pIE->Length + 2);
-       }
-       /* disable dynamic functions, such as high power, DIG */
-
-       /* config the initial gain under linking, need to write the BB registers */
-
-       rtw_set_bssid(padapter, pmlmeinfo->network.MacAddress);
-       mlme_join(padapter, 0);
-
-       /* cancel link timer */
-       _cancel_timer_ex(&pmlmeext->link_timer);
-
-       start_clnt_join(padapter);
-
-       return H2C_SUCCESS;
-}
-
-u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       struct disconnect_parm *param = (struct disconnect_parm *)pbuf;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network);
-       u8 val8;
-       int res;
-
-       if (r8188eu_is_client_associated_to_ap(padapter))
-               issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms / 100, 100);
-
-       mlme_disconnect(padapter);
-       rtw_set_bssid(padapter, null_addr);
-
-       /* restore to initial setting. */
-       update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode);
-
-       if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) {
-               /* Stop BCN */
-               res = rtw_read8(padapter, REG_BCN_CTRL, &val8);
-               if (res)
-                       return H2C_DROPPED;
-
-               rtw_write8(padapter, REG_BCN_CTRL, val8 & (~(EN_BCN_FUNCTION | EN_TXBCN_RPT)));
-       }
-
-       /* set MSR to no link state -> infra. mode */
-       Set_MSR(padapter, _HW_STATE_STATION_);
-
-       pmlmeinfo->state = WIFI_FW_NULL_STATE;
-
-       /* switch to the 20M Hz mode after disconnect */
-       pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20;
-       pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-
-       set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
-
-       flush_all_cam_entry(padapter);
-
-       _cancel_timer_ex(&pmlmeext->link_timer);
-
-       rtw_free_uc_swdec_pending_queue(padapter);
-
-       return  H2C_SUCCESS;
-}
-
-static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_channel *out,
-       u32 out_num, struct rtw_ieee80211_channel *in, u32 in_num)
-{
-       int i, j;
-       int set_idx;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-
-       /* clear out first */
-       memset(out, 0, sizeof(struct rtw_ieee80211_channel) * out_num);
-
-       /* acquire channels from in */
-       j = 0;
-       for (i = 0; i < in_num; i++) {
-               set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, in[i].hw_value);
-               if (in[i].hw_value && !(in[i].flags & RTW_IEEE80211_CHAN_DISABLED) &&
-                   set_idx >= 0) {
-                       memcpy(&out[j], &in[i], sizeof(struct rtw_ieee80211_channel));
-
-                       if (pmlmeext->channel_set[set_idx].ScanType == SCAN_PASSIVE)
-                               out[j].flags &= RTW_IEEE80211_CHAN_PASSIVE_SCAN;
-
-                       j++;
-               }
-               if (j >= out_num)
-                       break;
-       }
-
-       /* if out is empty, use channel_set as default */
-       if (j == 0) {
-               for (i = 0; i < pmlmeext->max_chan_nums; i++) {
-                       out[i].hw_value = pmlmeext->channel_set[i].ChannelNum;
-
-                       if (pmlmeext->channel_set[i].ScanType == SCAN_PASSIVE)
-                               out[i].flags &= RTW_IEEE80211_CHAN_PASSIVE_SCAN;
-
-                       j++;
-               }
-       }
-
-       return j;
-}
-
-u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct sitesurvey_parm  *pparm = (struct sitesurvey_parm *)pbuf;
-       u8 bdelayscan = false;
-       u32     i;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) {
-               /* for first time sitesurvey_cmd */
-
-               pmlmeext->sitesurvey_res.state = SCAN_START;
-               pmlmeext->sitesurvey_res.bss_cnt = 0;
-               pmlmeext->sitesurvey_res.channel_idx = 0;
-
-               for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) {
-                       if (pparm->ssid[i].SsidLength) {
-                               memcpy(pmlmeext->sitesurvey_res.ssid[i].Ssid, pparm->ssid[i].Ssid, IW_ESSID_MAX_SIZE);
-                               pmlmeext->sitesurvey_res.ssid[i].SsidLength = pparm->ssid[i].SsidLength;
-                       } else {
-                               pmlmeext->sitesurvey_res.ssid[i].SsidLength = 0;
-                       }
-               }
-
-               pmlmeext->sitesurvey_res.ch_num = rtw_scan_ch_decision(padapter
-                       , pmlmeext->sitesurvey_res.ch, RTW_CHANNEL_SCAN_AMOUNT
-                       , pparm->ch, pparm->ch_num
-       );
-
-               pmlmeext->sitesurvey_res.scan_mode = pparm->scan_mode;
-
-               /* issue null data if associating to the AP */
-               if (r8188eu_is_client_associated_to_ap(padapter)) {
-                       pmlmeext->sitesurvey_res.state = SCAN_TXNULL;
-
-                       issue_nulldata(padapter, NULL, 1, 3, 500);
-
-                       bdelayscan = true;
-               }
-               if (bdelayscan) {
-                       /* delay 50ms to protect nulldata(1). */
-                       set_survey_timer(pmlmeext, 50);
-                       return H2C_SUCCESS;
-               }
-       }
-
-       if ((pmlmeext->sitesurvey_res.state == SCAN_START) || (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) {
-               /* disable dynamic functions, such as high power, DIG */
-               Save_DM_Func_Flag(padapter);
-               rtw_clear_dm_func_flag(padapter);
-
-               /* config the initial gain under scanning, need to write the BB registers */
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-                       rtw_set_initial_gain(padapter, 0x1e);
-               else
-                       rtw_set_initial_gain(padapter, 0x28);
-
-
-               /* set MSR to no link state */
-               Set_MSR(padapter, _HW_STATE_NOLINK_);
-
-               rtw_mlme_under_site_survey(padapter);
-
-               pmlmeext->sitesurvey_res.state = SCAN_PROCESS;
-       }
-
-       site_survey(padapter);
-
-       return H2C_SUCCESS;
-}
-
-u8 setauth_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       struct setauth_parm             *pparm = (struct setauth_parm *)pbuf;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (pparm->mode < 4)
-               pmlmeinfo->auth_algo = pparm->mode;
-       return  H2C_SUCCESS;
-}
-
-u8 setkey_hdl(struct adapter *padapter, u8 *pbuf)
-{
-       unsigned short                          ctrl;
-       struct setkey_parm              *pparm = (struct setkey_parm *)pbuf;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       unsigned char                                   null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-       /* main tx key for wep. */
-       if (pparm->set_tx)
-               pmlmeinfo->key_index = pparm->keyid;
-
-       /* write cam */
-       ctrl = BIT(15) | ((pparm->algorithm) << 2) | pparm->keyid;
-
-       write_cam(padapter, pparm->keyid, ctrl, null_sta, pparm->key);
-
-       return H2C_SUCCESS;
-}
-
-u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf)
-{
-       u16 ctrl = 0;
-       u8 cam_id;/* cam_entry */
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct set_stakey_parm  *pparm = (struct set_stakey_parm *)pbuf;
-
-       /* cam_entry: */
-       /* 0~3 for default key */
-
-       /* for concurrent mode (ap+sta): */
-       /* default key is disable, using sw encrypt/decrypt */
-       /* cam_entry = 4 for sta mode (macid = 0) */
-       /* cam_entry(macid+3) = 5 ~ N for ap mode (aid = 1~N, macid = 2 ~N) */
-
-       /* for concurrent mode (sta+sta): */
-       /* default key is disable, using sw encrypt/decrypt */
-       /* cam_entry = 4 mapping to macid = 0 */
-       /* cam_entry = 5 mapping to macid = 2 */
-
-       cam_id = 4;
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
-               struct sta_info *psta;
-               struct sta_priv *pstapriv = &padapter->stapriv;
-
-               if (pparm->algorithm == _NO_PRIVACY_)   /*  clear cam entry */ {
-                       clear_cam_entry(padapter, pparm->id);
-                       return H2C_SUCCESS_RSP;
-               }
-
-               psta = rtw_get_stainfo(pstapriv, pparm->addr);
-               if (psta) {
-                       ctrl = (BIT(15) | ((pparm->algorithm) << 2));
-
-                       if ((psta->mac_id < 1) || (psta->mac_id > (NUM_STA - 4)))
-                               return H2C_REJECTED;
-
-                       cam_id = (psta->mac_id + 3);/* 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */
-
-                       write_cam(padapter, cam_id, ctrl, pparm->addr, pparm->key);
-
-                       return H2C_SUCCESS_RSP;
-               } else {
-                       return H2C_REJECTED;
-               }
-       }
-
-       /* below for sta mode */
-
-       if (pparm->algorithm == _NO_PRIVACY_) { /*  clear cam entry */
-               clear_cam_entry(padapter, pparm->id);
-               return H2C_SUCCESS;
-       }
-       ctrl = BIT(15) | ((pparm->algorithm) << 2);
-       write_cam(padapter, cam_id, ctrl, pparm->addr, pparm->key);
-       pmlmeinfo->enc_algo = pparm->algorithm;
-       return H2C_SUCCESS;
-}
-
-u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       struct addBaReq_parm    *pparm = (struct addBaReq_parm *)pbuf;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, pparm->addr);
-
-       if (!psta)
-               return  H2C_SUCCESS;
-
-       if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && (pmlmeinfo->HT_enable)) ||
-           ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) {
-               issue_action_BA(padapter, pparm->addr, WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid, NULL);
-               _set_timer(&psta->addba_retry_timer, ADDBA_TO);
-       } else {
-               psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid);
-       }
-       return  H2C_SUCCESS;
-}
-
-u8 set_tx_beacon_cmd(struct adapter *padapter)
-{
-       struct cmd_obj  *ph2c;
-       struct Tx_Beacon_param  *ptxBeacon_parm;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       u8 res = _SUCCESS;
-       int len_diff = 0;
-
-       ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
-       if (!ph2c) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       ptxBeacon_parm = kzalloc(sizeof(*ptxBeacon_parm), GFP_ATOMIC);
-       if (!ptxBeacon_parm) {
-               kfree(ph2c);
-               res = _FAIL;
-               goto exit;
-       }
-
-       memcpy(&ptxBeacon_parm->network, &pmlmeinfo->network, sizeof(struct wlan_bssid_ex));
-
-       len_diff = update_hidden_ssid(ptxBeacon_parm->network.IEs + _BEACON_IE_OFFSET_,
-                                     ptxBeacon_parm->network.IELength - _BEACON_IE_OFFSET_,
-                                     pmlmeinfo->hidden_ssid_mode);
-       ptxBeacon_parm->network.IELength += len_diff;
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, ptxBeacon_parm, GEN_CMD_CODE(_TX_Beacon));
-
-       res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-
-exit:
-
-       return res;
-}
-
-u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       u8 evt_code;
-       u16 evt_sz;
-       uint    *peventbuf;
-       void (*event_callback)(struct adapter *dev, u8 *pbuf);
-       struct evt_priv *pevt_priv = &padapter->evtpriv;
-
-       peventbuf = (uint *)pbuf;
-       evt_sz = (u16)(*peventbuf & 0xffff);
-       evt_code = (u8)((*peventbuf >> 16) & 0xff);
-
-       /*  checking if event code is valid */
-       if (evt_code >= MAX_C2HEVT)
-               goto _abort_event_;
-
-       /*  checking if event size match the event parm size */
-       if ((wlanevents[evt_code].parmsize != 0) &&
-           (wlanevents[evt_code].parmsize != evt_sz))
-               goto _abort_event_;
-
-       atomic_inc(&pevt_priv->event_seq);
-
-       peventbuf += 2;
-
-       if (peventbuf) {
-               event_callback = wlanevents[evt_code].event_callback;
-               event_callback(padapter, (u8 *)peventbuf);
-       }
-
-_abort_event_:
-       return H2C_SUCCESS;
-}
-
-u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       if (!pbuf)
-               return H2C_PARAMETERS_ERROR;
-
-       return H2C_SUCCESS;
-}
-
-u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       if (send_beacon(padapter) == _FAIL) {
-               return H2C_PARAMETERS_ERROR;
-       } else {
-               /* tx bc/mc frames after update TIM */
-               struct sta_info *psta_bmc;
-               struct list_head *xmitframe_plist, *xmitframe_phead;
-               struct xmit_frame *pxmitframe = NULL;
-               struct sta_priv  *pstapriv = &padapter->stapriv;
-
-               /* for BC/MC Frames */
-               psta_bmc = rtw_get_bcmc_stainfo(padapter);
-               if (!psta_bmc)
-                       return H2C_SUCCESS;
-
-               if ((pstapriv->tim_bitmap & BIT(0)) && (psta_bmc->sleepq_len > 0)) {
-                       msleep(10);/*  10ms, ATIM(HIQ) Windows */
-                       spin_lock_bh(&psta_bmc->sleep_q.lock);
-
-                       xmitframe_phead = get_list_head(&psta_bmc->sleep_q);
-                       xmitframe_plist = xmitframe_phead->next;
-
-                       while (xmitframe_phead != xmitframe_plist) {
-                               pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
-
-                               xmitframe_plist = xmitframe_plist->next;
-
-                               list_del_init(&pxmitframe->list);
-
-                               psta_bmc->sleepq_len--;
-                               if (psta_bmc->sleepq_len > 0)
-                                       pxmitframe->attrib.mdata = 1;
-                               else
-                                       pxmitframe->attrib.mdata = 0;
-
-                               pxmitframe->attrib.triggered = 1;
-
-                               pxmitframe->attrib.qsel = 0x11;/* HIQ */
-
-                               spin_unlock_bh(&psta_bmc->sleep_q.lock);
-                               if (rtl8188eu_hal_xmit(padapter, pxmitframe))
-                                       rtw_xmit_complete(padapter, pxmitframe);
-                               spin_lock_bh(&psta_bmc->sleep_q.lock);
-                       }
-                       spin_unlock_bh(&psta_bmc->sleep_q.lock);
-               }
-       }
-       return H2C_SUCCESS;
-}
-
-u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf)
-{
-       struct set_ch_parm *set_ch_parm;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-
-       if (!pbuf)
-               return H2C_PARAMETERS_ERROR;
-
-       set_ch_parm = (struct set_ch_parm *)pbuf;
-
-       pmlmeext->cur_channel = set_ch_parm->ch;
-       pmlmeext->cur_ch_offset = set_ch_parm->ch_offset;
-       pmlmeext->cur_bwmode = set_ch_parm->bw;
-
-       set_channel_bwmode(padapter, set_ch_parm->ch, set_ch_parm->ch_offset, set_ch_parm->bw);
-
-       return  H2C_SUCCESS;
-}
-
-u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       struct SetChannelPlan_param *setChannelPlan_param;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-
-       if (!pbuf)
-               return H2C_PARAMETERS_ERROR;
-
-       setChannelPlan_param = (struct SetChannelPlan_param *)pbuf;
-
-       pmlmeext->max_chan_nums = init_channel_set(padapter, setChannelPlan_param->channel_plan, pmlmeext->channel_set);
-       init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list);
-
-       return  H2C_SUCCESS;
-}
-
-u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       if (!pbuf)
-               return H2C_PARAMETERS_ERROR;
-       return  H2C_SUCCESS;
-}
-
-u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       return  H2C_REJECTED;
-}
-
-/*  TDLS_WRCR          : write RCR DATA BIT */
-/*  TDLS_SD_PTI                : issue peer traffic indication */
-/*  TDLS_CS_OFF                : go back to the channel linked with AP, terminating channel switch procedure */
-/*  TDLS_INIT_CH_SEN   : init channel sensing, receive all data and mgnt frame */
-/*  TDLS_DONE_CH_SEN: channel sensing and report candidate channel */
-/*  TDLS_OFF_CH                : first time set channel to off channel */
-/*  TDLS_BASE_CH               : go back tp the channel linked with AP when set base channel as target channel */
-/*  TDLS_P_OFF_CH      : periodically go to off channel */
-/*  TDLS_P_BASE_CH     : periodically go back to base channel */
-/*  TDLS_RS_RCR                : restore RCR */
-/*  TDLS_CKALV_PH1     : check alive timer phase1 */
-/*  TDLS_CKALV_PH2     : check alive timer phase2 */
-/*  TDLS_FREE_STA      : free tdls sta */
-u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
-       return H2C_REJECTED;
-}
diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c
deleted file mode 100644 (file)
index 93d3c9c..0000000
+++ /dev/null
@@ -1,1918 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _RTW_P2P_C_
-
-#include "../include/drv_types.h"
-#include "../include/rtw_p2p.h"
-#include "../include/wifi.h"
-
-static int rtw_p2p_is_channel_list_ok(u8 desired_ch, u8 *ch_list, u8 ch_cnt)
-{
-       int found = 0, i = 0;
-
-       for (i = 0; i < ch_cnt; i++) {
-               if (ch_list[i] == desired_ch) {
-                       found = 1;
-                       break;
-               }
-       }
-       return found;
-}
-
-static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       struct list_head *phead, *plist;
-       u32 len = 0;
-       u16 attr_len = 0;
-       u8 tmplen, *pdata_attr, *pstart, *pcur;
-       struct sta_info *psta = NULL;
-       struct adapter *padapter = pwdinfo->padapter;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       pdata_attr = kzalloc(MAX_P2P_IE_LEN, GFP_KERNEL);
-
-       pstart = pdata_attr;
-       pcur = pdata_attr;
-
-       spin_lock_bh(&pstapriv->asoc_list_lock);
-       phead = &pstapriv->asoc_list;
-       plist = phead->next;
-
-       /* look up sta asoc_queue */
-       while (phead != plist) {
-               psta = container_of(plist, struct sta_info, asoc_list);
-
-               plist = plist->next;
-
-               if (psta->is_p2p_device) {
-                       tmplen = 0;
-
-                       pcur++;
-
-                       /* P2P device address */
-                       memcpy(pcur, psta->dev_addr, ETH_ALEN);
-                       pcur += ETH_ALEN;
-
-                       /* P2P interface address */
-                       memcpy(pcur, psta->hwaddr, ETH_ALEN);
-                       pcur += ETH_ALEN;
-
-                       *pcur = psta->dev_cap;
-                       pcur++;
-
-                       /* u16*)(pcur) = cpu_to_be16(psta->config_methods); */
-                       RTW_PUT_BE16(pcur, psta->config_methods);
-                       pcur += 2;
-
-                       memcpy(pcur, psta->primary_dev_type, 8);
-                       pcur += 8;
-
-                       *pcur = psta->num_of_secdev_type;
-                       pcur++;
-
-                       memcpy(pcur, psta->secdev_types_list, psta->num_of_secdev_type * 8);
-                       pcur += psta->num_of_secdev_type * 8;
-
-                       if (psta->dev_name_len > 0) {
-                               /* u16*)(pcur) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */
-                               RTW_PUT_BE16(pcur, WPS_ATTR_DEVICE_NAME);
-                               pcur += 2;
-
-                               /* u16*)(pcur) = cpu_to_be16(psta->dev_name_len); */
-                               RTW_PUT_BE16(pcur, psta->dev_name_len);
-                               pcur += 2;
-
-                               memcpy(pcur, psta->dev_name, psta->dev_name_len);
-                               pcur += psta->dev_name_len;
-                       }
-
-                       tmplen = (u8)(pcur - pstart);
-
-                       *pstart = (tmplen - 1);
-
-                       attr_len += tmplen;
-
-                       /* pstart += tmplen; */
-                       pstart = pcur;
-               }
-       }
-       spin_unlock_bh(&pstapriv->asoc_list_lock);
-
-       if (attr_len > 0)
-               len = rtw_set_p2p_attr_content(pbuf, P2P_ATTR_GROUP_INFO, attr_len, pdata_attr);
-
-       kfree(pdata_attr);
-       return len;
-}
-
-static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da)
-{
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct adapter *padapter = pwdinfo->padapter;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       unsigned char category = RTW_WLAN_CATEGORY_P2P;/* P2P action frame */
-       __be32  p2poui = cpu_to_be32(P2POUI);
-       u8      oui_subtype = P2P_GO_DISC_REQUEST;
-       u8      dialogToken = 0;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN);
-       memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       /* Build P2P action frame header */
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /* there is no IE in this P2P action frame */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken)
-{
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct adapter *padapter = pwdinfo->padapter;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8                      action = P2P_PUB_ACTION_ACTION;
-       __be32                  p2poui = cpu_to_be32(P2POUI);
-       u8                      oui_subtype = P2P_DEVDISC_RESP;
-       u8 p2pie[8] = { 0x00 };
-       u32 p2pielen = 0;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, pwdinfo->device_addr, ETH_ALEN);
-       memcpy(pwlanhdr->addr3, pwdinfo->device_addr, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       /* Build P2P public action frame header */
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /* Build P2P IE */
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*  P2P_ATTR_STATUS */
-       p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status);
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8 *raddr, u8 *frame_body, u16 config_method)
-{
-       struct adapter *padapter = pwdinfo->padapter;
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8                      action = P2P_PUB_ACTION_ACTION;
-       u8                      dialogToken = frame_body[7];    /*      The Dialog Token of provisioning discovery request frame. */
-       __be32                  p2poui = cpu_to_be32(P2POUI);
-       u8                      oui_subtype = P2P_PROVISION_DISC_RESP;
-       u8                      wpsie[100] = { 0x00 };
-       u8                      wpsielen = 0;
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       wpsielen = 0;
-       /*      WPS OUI */
-       RTW_PUT_BE32(wpsie, WPSOUI);
-       wpsielen += 4;
-
-       /*      Config Method */
-       /*      Type: */
-       RTW_PUT_BE16(wpsie + wpsielen, WPS_ATTR_CONF_METHOD);
-       wpsielen += 2;
-
-       /*      Length: */
-       RTW_PUT_BE16(wpsie + wpsielen, 0x0002);
-       wpsielen += 2;
-
-       /*      Value: */
-       RTW_PUT_BE16(wpsie + wpsielen, config_method);
-       wpsielen += 2;
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken)
-{
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       struct adapter *padapter = pwdinfo->padapter;
-       struct xmit_priv                        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       unsigned char category = RTW_WLAN_CATEGORY_P2P;/* P2P action frame */
-       __be32  p2poui = cpu_to_be32(P2POUI);
-       u8      oui_subtype = P2P_PRESENCE_RESPONSE;
-       u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 };
-       u8 noa_attr_content[32] = { 0x00 };
-       u32 p2pielen = 0;
-
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN);
-       memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       /* Build P2P action frame header */
-       pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /* Add P2P IE header */
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /* Add Status attribute in P2P IE */
-       p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status);
-
-       /* Add NoA attribute in P2P IE */
-       noa_attr_content[0] = 0x1;/* index */
-       noa_attr_content[1] = 0x0;/* CTWindow and OppPS Parameters */
-
-       /* todo: Notice of Absence Descriptor(s) */
-
-       p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_NOA, 2, noa_attr_content);
-
-       pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe(padapter, pmgntframe);
-}
-
-u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 };
-       u16 capability = 0;
-       u32 len = 0, p2pielen = 0;
-       __le16 le_tmp;
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      According to the P2P Specification, the beacon frame should contain 3 P2P attributes */
-       /*      1. P2P Capability */
-       /*      2. P2P Device ID */
-       /*      3. Notice of Absence (NOA) */
-
-       /*      P2P Capability ATTR */
-       /*      Type: */
-       /*      Length: */
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       /*      Be able to participate in additional P2P Groups and */
-       /*      support the P2P Invitation Procedure */
-       /*      Group Capability Bitmap, 1 byte */
-       capability = P2P_DEVCAP_INVITATION_PROC | P2P_DEVCAP_CLIENT_DISCOVERABILITY;
-       capability |=  ((P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS) << 8);
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING))
-               capability |= (P2P_GRPCAP_GROUP_FORMATION << 8);
-
-       le_tmp = cpu_to_le16(capability);
-       p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_CAPABILITY, 2, (u8 *)&le_tmp);
-
-       /*  P2P Device ID ATTR */
-       p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_DEVICE_ID, ETH_ALEN, pwdinfo->device_addr);
-
-       /*  Notice of Absence ATTR */
-       /*      Type: */
-       /*      Length: */
-       /*      Value: */
-
-       pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len);
-       return len;
-}
-
-u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 };
-       u32 len = 0, p2pielen = 0;
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20100907 */
-       /*      According to the P2P Specification, the probe response frame should contain 5 P2P attributes */
-       /*      1. P2P Capability */
-       /*      2. Extended Listen Timing */
-       /*      3. Notice of Absence (NOA)      (Only GO needs this) */
-       /*      4. Device Info */
-       /*      5. Group Info   (Only GO need this) */
-
-       /*      P2P Capability ATTR */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */
-       RTW_PUT_LE16(p2pie + p2pielen, 0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-               p2pie[p2pielen] = (P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS);
-
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING))
-                       p2pie[p2pielen] |= P2P_GRPCAP_GROUP_FORMATION;
-
-               p2pielen++;
-       } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) {
-               /*      Group Capability Bitmap, 1 byte */
-               if (pwdinfo->persistent_supported)
-                       p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT;
-               else
-                       p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT;
-       }
-
-       /*      Extended Listen Timing ATTR */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING;
-
-       /*      Length: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); */
-       RTW_PUT_LE16(p2pie + p2pielen, 0x0004);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Availability Period */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */
-       RTW_PUT_LE16(p2pie + p2pielen, 0xFFFF);
-       p2pielen += 2;
-
-       /*      Availability Interval */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */
-       RTW_PUT_LE16(p2pie + p2pielen, 0xFFFF);
-       p2pielen += 2;
-
-       /*  Notice of Absence ATTR */
-       /*      Type: */
-       /*      Length: */
-       /*      Value: */
-
-       /*      Device Info ATTR */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
-       /*      + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */
-       RTW_PUT_LE16(p2pie + p2pielen, 21 + pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address */
-       memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Config Method */
-       /*      This field should be big endian. Noted by P2P specification. */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); */
-       RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->supported_wps_cm);
-       p2pielen += 2;
-
-       /*      Primary Device Type */
-       /*      Category ID */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */
-       RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_CID_MULIT_MEDIA);
-       p2pielen += 2;
-
-       /*      OUI */
-       /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */
-       RTW_PUT_BE32(p2pie + p2pielen, WPSOUI);
-       p2pielen += 4;
-
-       /*      Sub Category ID */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */
-       RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_SCID_MEDIA_SERVER);
-       p2pielen += 2;
-
-       /*      Number of Secondary Device Types */
-       p2pie[p2pielen++] = 0x00;       /*      No Secondary Device Type List */
-
-       /*      Device Name */
-       /*      Type: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */
-       RTW_PUT_BE16(p2pie + p2pielen, WPS_ATTR_DEVICE_NAME);
-       p2pielen += 2;
-
-       /*      Length: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */
-       RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len);
-       p2pielen += pwdinfo->device_name_len;
-
-       /*  Group Info ATTR */
-       /*      Type: */
-       /*      Length: */
-       /*      Value: */
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-               p2pielen += go_add_group_info_attr(pwdinfo, p2pie + p2pielen);
-
-       pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len);
-
-       return len;
-}
-
-u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 *pssid, u8 ussidlen, u8 *pdev_raddr)
-{
-       u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 };
-       u32 len = 0, p2pielen = 0;
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20110301 */
-       /*      According to the P2P Specification, the provision discovery request frame should contain 3 P2P attributes */
-       /*      1. P2P Capability */
-       /*      2. Device Info */
-       /*      3. Group ID (When joining an operating P2P Group) */
-
-       /*      P2P Capability ATTR */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */
-       RTW_PUT_LE16(p2pie + p2pielen, 0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (pwdinfo->persistent_supported)
-               p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT;
-       else
-               p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT;
-
-       /*      Device Info ATTR */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
-       /*      + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */
-       RTW_PUT_LE16(p2pie + p2pielen, 21 + pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address */
-       memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Config Method */
-       /*      This field should be big endian. Noted by P2P specification. */
-       if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) {
-               /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); */
-               RTW_PUT_BE16(p2pie + p2pielen, WPS_CONFIG_METHOD_PBC);
-       } else {
-               /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); */
-               RTW_PUT_BE16(p2pie + p2pielen, WPS_CONFIG_METHOD_DISPLAY);
-       }
-
-       p2pielen += 2;
-
-       /*      Primary Device Type */
-       /*      Category ID */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */
-       RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_CID_MULIT_MEDIA);
-       p2pielen += 2;
-
-       /*      OUI */
-       /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */
-       RTW_PUT_BE32(p2pie + p2pielen, WPSOUI);
-       p2pielen += 4;
-
-       /*      Sub Category ID */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */
-       RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_SCID_MEDIA_SERVER);
-       p2pielen += 2;
-
-       /*      Number of Secondary Device Types */
-       p2pie[p2pielen++] = 0x00;       /*      No Secondary Device Type List */
-
-       /*      Device Name */
-       /*      Type: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */
-       RTW_PUT_BE16(p2pie + p2pielen, WPS_ATTR_DEVICE_NAME);
-       p2pielen += 2;
-
-       /*      Length: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */
-       RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len);
-       p2pielen += pwdinfo->device_name_len;
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) {
-               /*      Added by Albert 2011/05/19 */
-               /*      In this case, the pdev_raddr is the device address of the group owner. */
-
-               /*      P2P Group ID ATTR */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_GROUP_ID;
-
-               /*      Length: */
-               /* u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + ussidlen); */
-               RTW_PUT_LE16(p2pie + p2pielen, ETH_ALEN + ussidlen);
-               p2pielen += 2;
-
-               /*      Value: */
-               memcpy(p2pie + p2pielen, pdev_raddr, ETH_ALEN);
-               p2pielen += ETH_ALEN;
-
-               memcpy(p2pie + p2pielen, pssid, ussidlen);
-               p2pielen += ussidlen;
-       }
-
-       pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len);
-
-       return len;
-}
-
-u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status_code)
-{
-       u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 };
-       u32 len = 0, p2pielen = 0;
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*  According to the P2P Specification, the Association response frame should contain 2 P2P attributes */
-       /*      1. Status */
-       /*      2. Extended Listen Timing (optional) */
-
-       /*      Status ATTR */
-       p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status_code);
-
-       /*  Extended Listen Timing ATTR */
-       /*      Type: */
-       /*      Length: */
-       /*      Value: */
-
-       pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len);
-
-       return len;
-}
-
-u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       u8 *p;
-       u32 ret = false;
-       u8 *p2pie;
-       u32     p2pielen = 0;
-       int ssid_len = 0, rate_cnt = 0;
-
-       p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SUPPORTEDRATES_IE_, (int *)&rate_cnt,
-                       len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_);
-
-       if (rate_cnt <= 4) {
-               int i, g_rate = 0;
-
-               for (i = 0; i < rate_cnt; i++) {
-                       if (((*(p + 2 + i) & 0xff) != 0x02) &&
-                           ((*(p + 2 + i) & 0xff) != 0x04) &&
-                           ((*(p + 2 + i) & 0xff) != 0x0B) &&
-                           ((*(p + 2 + i) & 0xff) != 0x16))
-                               g_rate = 1;
-               }
-
-               if (g_rate == 0) {
-                       /*      There is no OFDM rate included in SupportedRates IE of this probe request frame */
-                       /*      The driver should response this probe request. */
-                       return ret;
-               }
-       } else {
-               /*      rate_cnt > 4 means the SupportRates IE contains the OFDM rate because the count of CCK rates are 4. */
-               /*      We should proceed the following check for this probe request. */
-       }
-
-       /*      Added comments by Albert 20100906 */
-       /*      There are several items we should check here. */
-       /*      1. This probe request frame must contain the P2P IE. (Done) */
-       /*      2. This probe request frame must contain the wildcard SSID. (Done) */
-       /*      3. Wildcard BSSID. (Todo) */
-       /*      4. Destination Address. (Done in mgt_dispatcher function) */
-       /*      5. Requested Device Type in WSC IE. (Todo) */
-       /*      6. Device ID attribute in P2P IE. (Todo) */
-
-       p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ssid_len,
-                       len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_);
-
-       ssid_len &= 0xff;       /*      Just last 1 byte is valid for ssid len of the probe request */
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-               p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_, NULL, &p2pielen);
-               if (p2pie) {
-                       if (p && !memcmp((void *)(p + 2), (void *)pwdinfo->p2p_wildcard_ssid, 7)) {
-                               /* todo: */
-                               /* Check Requested Device Type attributes in WSC IE. */
-                               /* Check Device ID attribute in P2P IE */
-
-                               ret = true;
-                       } else if (p && ssid_len == 0) {
-                               ret = true;
-                       }
-               } else {
-                       /* non -p2p device */
-               }
-       }
-
-       return ret;
-}
-
-u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len, struct sta_info *psta)
-{
-       u8 status_code = P2P_STATUS_SUCCESS;
-       u8 *pbuf, *pattr_content = NULL;
-       u32 attr_contentlen = 0;
-       u16 cap_attr = 0;
-       unsigned short  frame_type, ie_offset = 0;
-       u8 *ies;
-       u32 ies_len;
-       u8 *p2p_ie;
-       u32     p2p_ielen = 0;
-       __be16 be_tmp;
-       __le16 le_tmp;
-
-       if (!rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-               return P2P_STATUS_FAIL_REQUEST_UNABLE;
-
-       frame_type = GetFrameSubType(pframe);
-       if (frame_type == WIFI_ASSOCREQ)
-               ie_offset = _ASOCREQ_IE_OFFSET_;
-       else /*  WIFI_REASSOCREQ */
-               ie_offset = _REASOCREQ_IE_OFFSET_;
-
-       ies = pframe + WLAN_HDR_A3_LEN + ie_offset;
-       ies_len = len - WLAN_HDR_A3_LEN - ie_offset;
-
-       p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen);
-
-       if (!p2p_ie)
-               status_code =  P2P_STATUS_FAIL_INVALID_PARAM;
-
-       while (p2p_ie) {
-               /* Check P2P Capability ATTR */
-               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8 *)&le_tmp, (uint *)&attr_contentlen)) {
-                       cap_attr = le16_to_cpu(le_tmp);
-                       psta->dev_cap = cap_attr & 0xff;
-               }
-
-               /* Check Extended Listen Timing ATTR */
-
-               /* Check P2P Device Info ATTR */
-               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint *)&attr_contentlen)) {
-                       pattr_content = kzalloc(attr_contentlen, GFP_KERNEL);
-                       pbuf = pattr_content;
-                       if (pattr_content) {
-                               u8 num_of_secdev_type;
-                               u16 dev_name_len;
-
-                               rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, pattr_content, (uint *)&attr_contentlen);
-
-                               memcpy(psta->dev_addr,  pattr_content, ETH_ALEN);/* P2P Device Address */
-
-                               pattr_content += ETH_ALEN;
-
-                               memcpy(&be_tmp, pattr_content, 2);/* Config Methods */
-                               psta->config_methods = be16_to_cpu(be_tmp);
-
-                               pattr_content += 2;
-
-                               memcpy(psta->primary_dev_type, pattr_content, 8);
-
-                               pattr_content += 8;
-
-                               num_of_secdev_type = *pattr_content;
-                               pattr_content += 1;
-
-                               if (num_of_secdev_type == 0) {
-                                       psta->num_of_secdev_type = 0;
-                               } else {
-                                       u32 len;
-
-                                       psta->num_of_secdev_type = num_of_secdev_type;
-
-                                       len = (sizeof(psta->secdev_types_list) < (num_of_secdev_type * 8)) ?
-                                             (sizeof(psta->secdev_types_list)) : (num_of_secdev_type * 8);
-
-                                       memcpy(psta->secdev_types_list, pattr_content, len);
-
-                                       pattr_content += (num_of_secdev_type * 8);
-                               }
-
-                               psta->dev_name_len = 0;
-                               if (be16_to_cpu(*(__be16 *)pattr_content) == WPS_ATTR_DEVICE_NAME) {
-                                       dev_name_len = be16_to_cpu(*(__be16 *)(pattr_content + 2));
-
-                                       psta->dev_name_len = (sizeof(psta->dev_name) < dev_name_len) ? sizeof(psta->dev_name) : dev_name_len;
-
-                                       memcpy(psta->dev_name, pattr_content + 4, psta->dev_name_len);
-                               }
-                               kfree(pbuf);
-                       }
-               }
-
-               /* Get the next P2P IE */
-               p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen);
-       }
-
-       return status_code;
-}
-
-u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       u8 *frame_body;
-       u8 status, dialogToken;
-       struct sta_info *psta = NULL;
-       struct adapter *padapter = pwdinfo->padapter;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       u8 *p2p_ie;
-       u32     p2p_ielen = 0;
-
-       frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       dialogToken = frame_body[7];
-       status = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP;
-
-       p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen);
-       if (p2p_ie) {
-               u8 groupid[38] = { 0x00 };
-               u8 dev_addr[ETH_ALEN] = { 0x00 };
-               u32     attr_contentlen = 0;
-
-               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) {
-                       if (!memcmp(pwdinfo->device_addr, groupid, ETH_ALEN) &&
-                           !memcmp(pwdinfo->p2p_group_ssid, groupid + ETH_ALEN, pwdinfo->p2p_group_ssid_len)) {
-                               attr_contentlen = 0;
-                               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_ID, dev_addr, &attr_contentlen)) {
-                                       struct list_head *phead, *plist;
-
-                                       spin_lock_bh(&pstapriv->asoc_list_lock);
-                                       phead = &pstapriv->asoc_list;
-                                       plist = phead->next;
-
-                                       /* look up sta asoc_queue */
-                                       while (phead != plist) {
-                                               psta = container_of(plist, struct sta_info, asoc_list);
-
-                                               plist = plist->next;
-
-                                               if (psta->is_p2p_device && (psta->dev_cap & P2P_DEVCAP_CLIENT_DISCOVERABILITY) &&
-                                                   !memcmp(psta->dev_addr, dev_addr, ETH_ALEN)) {
-                                                       /* issue GO Discoverability Request */
-                                                       issue_group_disc_req(pwdinfo, psta->hwaddr);
-                                                       status = P2P_STATUS_SUCCESS;
-                                                       break;
-                                               } else {
-                                                       status = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                                               }
-                                       }
-                                       spin_unlock_bh(&pstapriv->asoc_list_lock);
-                               } else {
-                                       status = P2P_STATUS_FAIL_INVALID_PARAM;
-                               }
-                       } else {
-                               status = P2P_STATUS_FAIL_INVALID_PARAM;
-                       }
-               }
-       }
-
-       /* issue Device Discoverability Response */
-       issue_p2p_devdisc_resp(pwdinfo, GetAddr2Ptr(pframe), status, dialogToken);
-
-       return status == P2P_STATUS_SUCCESS;
-}
-
-u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       return true;
-}
-
-u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo,  u8 *pframe, uint len)
-{
-       u8 *frame_body;
-       u8 *wpsie;
-       uint    wps_ielen = 0, attr_contentlen = 0;
-       u16     uconfig_method = 0;
-       __be16 be_tmp;
-
-       frame_body = (pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       wpsie = rtw_get_wps_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen);
-       if (wpsie) {
-               if (rtw_get_wps_attr_content(wpsie, wps_ielen, WPS_ATTR_CONF_METHOD, (u8 *)&be_tmp, &attr_contentlen)) {
-                       uconfig_method = be16_to_cpu(be_tmp);
-                       switch (uconfig_method) {
-                       case WPS_CM_DISPLYA:
-                               memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3);
-                               break;
-                       case WPS_CM_LABEL:
-                               memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "lab", 3);
-                               break;
-                       case WPS_CM_PUSH_BUTTON:
-                               memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3);
-                               break;
-                       case WPS_CM_KEYPAD:
-                               memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3);
-                               break;
-                       }
-                       issue_p2p_provision_resp(pwdinfo, GetAddr2Ptr(pframe), frame_body, uconfig_method);
-               }
-       }
-       return true;
-}
-
-u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo,  u8 *pframe)
-{
-       return true;
-}
-
-static u8 rtw_p2p_get_peer_ch_list(struct wifidirect_info *pwdinfo, u8 *ch_content, u8 ch_cnt, u8 *peer_ch_list)
-{
-       u8 i = 0, j = 0;
-       u8 temp = 0;
-       u8 ch_no = 0;
-       ch_content += 3;
-       ch_cnt -= 3;
-
-       while (ch_cnt > 0) {
-               ch_content += 1;
-               ch_cnt -= 1;
-               temp = *ch_content;
-               for (i = 0 ; i < temp ; i++, j++)
-                       peer_ch_list[j] = *(ch_content + 1 + i);
-               ch_content += (temp + 1);
-               ch_cnt -= (temp + 1);
-               ch_no += temp;
-       }
-
-       return ch_no;
-}
-
-static u8 rtw_p2p_ch_inclusion(struct mlme_ext_priv *pmlmeext, u8 *peer_ch_list, u8 peer_ch_num, u8 *ch_list_inclusioned)
-{
-       int     i = 0, j = 0, temp = 0;
-       u8 ch_no = 0;
-
-       for (i = 0; i < peer_ch_num; i++) {
-               for (j = temp; j < pmlmeext->max_chan_nums; j++) {
-                       if (*(peer_ch_list + i) == pmlmeext->channel_set[j].ChannelNum) {
-                               ch_list_inclusioned[ch_no++] = *(peer_ch_list + i);
-                               temp = j;
-                               break;
-                       }
-               }
-       }
-
-       return ch_no;
-}
-
-u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       struct adapter *padapter = pwdinfo->padapter;
-       u8      result = P2P_STATUS_SUCCESS;
-       u32     p2p_ielen = 0, wps_ielen = 0;
-       u8 *ies;
-       u32 ies_len;
-       u8 *p2p_ie;
-       u8 *wpsie;
-       u16             wps_devicepassword_id = 0x0000;
-       uint    wps_devicepassword_id_len = 0;
-       __be16 be_tmp;
-
-       wpsie = rtw_get_wps_ie(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen);
-       if (wpsie) {
-               /*      Commented by Kurt 20120113 */
-               /*      If some device wants to do p2p handshake without sending prov_disc_req */
-               /*      We have to get peer_req_cm from here. */
-               if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) {
-                       rtw_get_wps_attr_content(wpsie, wps_ielen, WPS_ATTR_DEVICE_PWID, (u8 *)&be_tmp, &wps_devicepassword_id_len);
-                       wps_devicepassword_id = be16_to_cpu(be_tmp);
-
-                       if (wps_devicepassword_id == WPS_DPID_USER_SPEC)
-                               memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3);
-                       else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC)
-                               memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3);
-                       else
-                               memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3);
-               }
-       } else {
-               result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM;
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-               return result;
-       }
-
-       if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) {
-               result = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INFOR_NOREADY);
-               return result;
-       }
-
-       ies = pframe + _PUBLIC_ACTION_IE_OFFSET_;
-       ies_len = len - _PUBLIC_ACTION_IE_OFFSET_;
-
-       p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen);
-
-       if (!p2p_ie) {
-               result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM;
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-       }
-
-       while (p2p_ie) {
-               u8      attr_content = 0x00;
-               u32     attr_contentlen = 0;
-               u8      ch_content[50] = { 0x00 };
-               uint    ch_cnt = 0;
-               u8      peer_ch_list[50] = { 0x00 };
-               u8      peer_ch_num = 0;
-               u8      ch_list_inclusioned[50] = { 0x00 };
-               u8      ch_num_inclusioned = 0;
-
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING);
-
-               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen)) {
-                       pwdinfo->peer_intent = attr_content;    /*      include both intent and tie breaker values. */
-
-                       if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) {
-                               /*      Try to match the tie breaker value */
-                               if (pwdinfo->intent == P2P_MAX_INTENT) {
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                       result = P2P_STATUS_FAIL_BOTH_GOINTENT_15;
-                               } else {
-                                       if (attr_content & 0x01)
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                       else
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                               }
-                       } else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) {
-                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                       } else {
-                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                       }
-
-                       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                               /*      Store the group id information. */
-                               memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN);
-                               memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen);
-                       }
-               }
-
-               attr_contentlen = 0;
-               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) {
-                       if (attr_contentlen != ETH_ALEN)
-                               memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN);
-               }
-
-               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, ch_content, &ch_cnt)) {
-                       peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, ch_content, ch_cnt, peer_ch_list);
-                       ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned);
-
-                       if (ch_num_inclusioned == 0) {
-                               result = P2P_STATUS_FAIL_NO_COMMON_CH;
-                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-                               break;
-                       }
-
-                       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                               if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel,
-                                   ch_list_inclusioned, ch_num_inclusioned)) {
-                                       u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0;
-                                       attr_contentlen = 0;
-
-                                       if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen))
-                                               peer_operating_ch = operatingch_info[4];
-
-                                       if (rtw_p2p_is_channel_list_ok(peer_operating_ch,
-                                                                      ch_list_inclusioned,
-                                                                      ch_num_inclusioned))
-                                               /**
-                                                *      Change our operating channel as peer's for compatibility.
-                                                */
-                                               pwdinfo->operating_channel = peer_operating_ch;
-                                       else
-                                               /*  Take first channel of ch_list_inclusioned as operating channel */
-                                               pwdinfo->operating_channel = ch_list_inclusioned[0];
-                               }
-                       }
-               }
-
-               /* Get the next P2P IE */
-               p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen);
-       }
-       return result;
-}
-
-u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       struct adapter *padapter = pwdinfo->padapter;
-       u8      result = P2P_STATUS_SUCCESS;
-       u32     p2p_ielen, wps_ielen;
-       u8 *ies;
-       u32 ies_len;
-       u8 *p2p_ie;
-
-       ies = pframe + _PUBLIC_ACTION_IE_OFFSET_;
-       ies_len = len - _PUBLIC_ACTION_IE_OFFSET_;
-
-       /*      Be able to know which one is the P2P GO and which one is P2P client. */
-
-       if (!rtw_get_wps_ie(ies, ies_len, NULL, &wps_ielen)) {
-               result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM;
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-       }
-
-       p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen);
-       if (!p2p_ie) {
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-               result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM;
-       } else {
-               u8      attr_content = 0x00;
-               u32     attr_contentlen = 0;
-               u8      operatingch_info[5] = { 0x00 };
-               u8      groupid[38];
-               u8      peer_ch_list[50] = { 0x00 };
-               u8      peer_ch_num = 0;
-               u8      ch_list_inclusioned[50] = { 0x00 };
-               u8      ch_num_inclusioned = 0;
-
-               while (p2p_ie) {        /*      Found the P2P IE. */
-                       rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen);
-                       if (attr_contentlen == 1) {
-                               if (attr_content == P2P_STATUS_SUCCESS) {
-                                       /*      Do nothing. */
-                               } else {
-                                       if (attr_content == P2P_STATUS_FAIL_INFO_UNAVAILABLE) {
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INFOR_NOREADY);
-                                       } else {
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-                                       }
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                       result = attr_content;
-                                       break;
-                               }
-                       }
-
-                       /*      Try to get the peer's interface address */
-                       attr_contentlen = 0;
-                       if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) {
-                               if (attr_contentlen != ETH_ALEN)
-                                       memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN);
-                       }
-
-                       /*      Try to get the peer's intent and tie breaker value. */
-                       attr_content = 0x00;
-                       attr_contentlen = 0;
-                       if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen)) {
-                               pwdinfo->peer_intent = attr_content;    /*      include both intent and tie breaker values. */
-
-                               if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) {
-                                       /*      Try to match the tie breaker value */
-                                       if (pwdinfo->intent == P2P_MAX_INTENT) {
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                               result = P2P_STATUS_FAIL_BOTH_GOINTENT_15;
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-                                       } else {
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                               rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                               if (attr_content & 0x01)
-                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                               else
-                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                                       }
-                               } else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) {
-                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                       rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                               } else {
-                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                       rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                               }
-
-                               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                                       /*      Store the group id information. */
-                                       memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN);
-                                       memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen);
-                               }
-                       }
-
-                       /*      Try to get the operation channel information */
-
-                       attr_contentlen = 0;
-                       if (rtw_get_p2p_attr_content(p2p_ie,
-                                                    p2p_ielen,
-                                                    P2P_ATTR_OPERATING_CH,
-                                                    operatingch_info,
-                                                    &attr_contentlen))
-                               pwdinfo->peer_operating_ch = operatingch_info[4];
-
-                       /*      Try to get the channel list information */
-                       if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, pwdinfo->channel_list_attr, &pwdinfo->channel_list_attr_len)) {
-
-                               peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len, peer_ch_list);
-                               ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned);
-
-                               if (ch_num_inclusioned == 0) {
-                                       result = P2P_STATUS_FAIL_NO_COMMON_CH;
-                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-                                       break;
-                               }
-
-                               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                                       if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel,
-                                           ch_list_inclusioned, ch_num_inclusioned)) {
-                                               u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0;
-                                               attr_contentlen = 0;
-
-                                               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen))
-                                                       peer_operating_ch = operatingch_info[4];
-
-                                               if (rtw_p2p_is_channel_list_ok(peer_operating_ch,
-                                                   ch_list_inclusioned, ch_num_inclusioned))
-                                                       /**
-                                                        *      Change our operating channel as peer's for compatibility.
-                                                        */
-                                                       pwdinfo->operating_channel = peer_operating_ch;
-                                               else
-                                                       /*  Take first channel of ch_list_inclusioned as operating channel */
-                                                       pwdinfo->operating_channel = ch_list_inclusioned[0];
-                                       }
-                               }
-                       }
-
-                       /*      Try to get the group id information if peer is GO */
-                       attr_contentlen = 0;
-                       memset(groupid, 0x00, 38);
-                       if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) {
-                               memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN);
-                               memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN);
-                       }
-
-                       /* Get the next P2P IE */
-                       p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen);
-               }
-       }
-       return result;
-}
-
-u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       u8 *ies;
-       u32 ies_len;
-       u8 *p2p_ie;
-       u32     p2p_ielen = 0;
-       u8      result = P2P_STATUS_SUCCESS;
-       ies = pframe + _PUBLIC_ACTION_IE_OFFSET_;
-       ies_len = len - _PUBLIC_ACTION_IE_OFFSET_;
-
-       p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen);
-       while (p2p_ie) {        /*      Found the P2P IE. */
-               u8      attr_content = 0x00, operatingch_info[5] = { 0x00 };
-               u8      groupid[38] = { 0x00 };
-               u32     attr_contentlen = 0;
-
-               pwdinfo->negotiation_dialog_token = 1;
-               rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen);
-               if (attr_contentlen == 1) {
-                       result = attr_content;
-
-                       if (attr_content == P2P_STATUS_SUCCESS) {
-                               del_timer_sync(&pwdinfo->restore_p2p_state_timer);
-
-                               /*      Commented by Albert 20100911 */
-                               /*      Todo: Need to handle the case which both Intents are the same. */
-                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                               rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                               if ((pwdinfo->intent) > (pwdinfo->peer_intent >> 1)) {
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                               } else if ((pwdinfo->intent) < (pwdinfo->peer_intent >> 1)) {
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                               } else {
-                                       /*      Have to compare the Tie Breaker */
-                                       if (pwdinfo->peer_intent & 0x01)
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                       else
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                               }
-                       } else {
-                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-                               break;
-                       }
-               }
-
-               /*      Try to get the group id information */
-               attr_contentlen = 0;
-               memset(groupid, 0x00, 38);
-               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) {
-                       memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN);
-                       memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN);
-               }
-
-               attr_contentlen = 0;
-               if (rtw_get_p2p_attr_content(p2p_ie,
-                                            p2p_ielen,
-                                            P2P_ATTR_OPERATING_CH,
-                                            operatingch_info,
-                                            &attr_contentlen))
-                       pwdinfo->peer_operating_ch = operatingch_info[4];
-
-               /* Get the next P2P IE */
-               p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen);
-       }
-       return result;
-}
-
-u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       u8 *frame_body;
-       u8 dialogToken = 0;
-       u8 status = P2P_STATUS_SUCCESS;
-
-       frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       dialogToken = frame_body[6];
-
-       /* todo: check NoA attribute */
-
-       issue_p2p_presence_resp(pwdinfo, GetAddr2Ptr(pframe), status, dialogToken);
-
-       return true;
-}
-
-static void find_phase_handler(struct adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct ndis_802_11_ssid ssid;
-
-       memset((unsigned char *)&ssid, 0, sizeof(struct ndis_802_11_ssid));
-       memcpy(ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN);
-       ssid.SsidLength = P2P_WILDCARD_SSID_LEN;
-
-       rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH);
-
-       spin_lock_bh(&pmlmepriv->lock);
-       spin_unlock_bh(&pmlmepriv->lock);
-
-}
-
-void p2p_concurrent_handler(struct adapter *padapter);
-
-static void restore_p2p_state_handler(struct adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL))
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-       rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) {
-               /*      In the P2P client mode, the driver should not switch back to its listen channel */
-               /*      because this P2P client should stay at the operating channel of P2P GO. */
-               set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-       }
-
-}
-
-static void pre_tx_invitereq_handler(struct adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       set_channel_bwmode(padapter, pwdinfo->invitereq_info.peer_ch, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-       rtw_mlme_under_site_survey(padapter);
-       issue_probereq_p2p(padapter);
-       _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT);
-
-}
-
-static void pre_tx_provdisc_handler(struct adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       set_channel_bwmode(padapter, pwdinfo->tx_prov_disc_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-       rtw_mlme_under_site_survey(padapter);
-       issue_probereq_p2p(padapter);
-       _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT);
-
-}
-
-static void pre_tx_negoreq_handler(struct adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       set_channel_bwmode(padapter, pwdinfo->nego_req_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-       rtw_mlme_under_site_survey(padapter);
-       issue_probereq_p2p(padapter);
-       _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT);
-
-}
-
-void p2p_protocol_wk_hdl(struct adapter *padapter, int intCmdType)
-{
-
-       switch (intCmdType) {
-       case P2P_FIND_PHASE_WK:
-               find_phase_handler(padapter);
-               break;
-       case P2P_RESTORE_STATE_WK:
-               restore_p2p_state_handler(padapter);
-               break;
-       case P2P_PRE_TX_PROVDISC_PROCESS_WK:
-               pre_tx_provdisc_handler(padapter);
-               break;
-       case P2P_PRE_TX_INVITEREQ_PROCESS_WK:
-               pre_tx_invitereq_handler(padapter);
-               break;
-       case P2P_PRE_TX_NEGOREQ_PROCESS_WK:
-               pre_tx_negoreq_handler(padapter);
-               break;
-       }
-
-}
-
-void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength)
-{
-       u8 *p2p_ie;
-       u32     p2p_ielen = 0;
-       u8      noa_attr[MAX_P2P_IE_LEN] = { 0x00 };/*  NoA length should be n*(13) + 2 */
-       u32     attr_contentlen = 0;
-
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8      find_p2p = false, find_p2p_ps = false;
-       u8      noa_offset, noa_num, noa_index;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       p2p_ie = rtw_get_p2p_ie(IEs, IELength, NULL, &p2p_ielen);
-
-       while (p2p_ie) {
-               find_p2p = true;
-               /*  Get Notice of Absence IE. */
-               if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_NOA, noa_attr, &attr_contentlen)) {
-                       find_p2p_ps = true;
-                       noa_index = noa_attr[0];
-
-                       if ((pwdinfo->p2p_ps_mode == P2P_PS_NONE) ||
-                           (noa_index != pwdinfo->noa_index)) { /*  if index change, driver should reconfigure related setting. */
-                               pwdinfo->noa_index = noa_index;
-                               pwdinfo->opp_ps = noa_attr[1] >> 7;
-                               pwdinfo->ctwindow = noa_attr[1] & 0x7F;
-
-                               noa_offset = 2;
-                               noa_num = 0;
-                               /*  NoA length should be n*(13) + 2 */
-                               if (attr_contentlen > 2) {
-                                       while (noa_offset < attr_contentlen) {
-                                               /* memcpy(&wifidirect_info->noa_count[noa_num], &noa_attr[noa_offset], 1); */
-                                               pwdinfo->noa_count[noa_num] = noa_attr[noa_offset];
-                                               noa_offset += 1;
-
-                                               memcpy(&pwdinfo->noa_duration[noa_num], &noa_attr[noa_offset], 4);
-                                               noa_offset += 4;
-
-                                               memcpy(&pwdinfo->noa_interval[noa_num], &noa_attr[noa_offset], 4);
-                                               noa_offset += 4;
-
-                                               memcpy(&pwdinfo->noa_start_time[noa_num], &noa_attr[noa_offset], 4);
-                                               noa_offset += 4;
-
-                                               noa_num++;
-                                       }
-                               }
-                               pwdinfo->noa_num = noa_num;
-
-                               if (pwdinfo->opp_ps == 1) {
-                                       pwdinfo->p2p_ps_mode = P2P_PS_CTWINDOW;
-                                       /*  driver should wait LPS for entering CTWindow */
-                                       if (padapter->pwrctrlpriv.bFwCurrentInPSMode)
-                                               p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 1);
-                               } else if (pwdinfo->noa_num > 0) {
-                                       pwdinfo->p2p_ps_mode = P2P_PS_NOA;
-                                       p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 1);
-                               } else if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) {
-                                       p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1);
-                               }
-                       }
-
-                       break; /*  find target, just break. */
-               }
-
-               /* Get the next P2P IE */
-               p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, IELength - (p2p_ie - IEs + p2p_ielen), NULL, &p2p_ielen);
-       }
-
-       if (find_p2p) {
-               if ((pwdinfo->p2p_ps_mode > P2P_PS_NONE) && !find_p2p_ps)
-                       p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1);
-       }
-
-}
-
-void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state)
-{
-       struct pwrctrl_priv             *pwrpriv = &padapter->pwrctrlpriv;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       /*  Pre action for p2p state */
-       switch (p2p_ps_state) {
-       case P2P_PS_DISABLE:
-               pwdinfo->p2p_ps_state = p2p_ps_state;
-
-               rtl8188e_set_p2p_ps_offload_cmd(padapter, p2p_ps_state);
-
-               pwdinfo->noa_index = 0;
-               pwdinfo->ctwindow = 0;
-               pwdinfo->opp_ps = 0;
-               pwdinfo->noa_num = 0;
-               pwdinfo->p2p_ps_mode = P2P_PS_NONE;
-               if (padapter->pwrctrlpriv.bFwCurrentInPSMode) {
-                       if (pwrpriv->smart_ps == 0) {
-                               pwrpriv->smart_ps = 2;
-                               rtw_set_firmware_ps_mode(padapter, pwrpriv->pwr_mode);
-                       }
-               }
-               break;
-       case P2P_PS_ENABLE:
-               if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) {
-                       pwdinfo->p2p_ps_state = p2p_ps_state;
-
-                       if (pwdinfo->ctwindow > 0) {
-                               if (pwrpriv->smart_ps != 0) {
-                                       pwrpriv->smart_ps = 0;
-                                       rtw_set_firmware_ps_mode(padapter, pwrpriv->pwr_mode);
-                               }
-                       }
-                       rtl8188e_set_p2p_ps_offload_cmd(padapter, p2p_ps_state);
-               }
-               break;
-       case P2P_PS_SCAN:
-       case P2P_PS_SCAN_DONE:
-       case P2P_PS_ALLSTASLEEP:
-               if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) {
-                       pwdinfo->p2p_ps_state = p2p_ps_state;
-                       rtl8188e_set_p2p_ps_offload_cmd(padapter, p2p_ps_state);
-               }
-               break;
-       default:
-               break;
-       }
-
-}
-
-u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue)
-{
-       struct cmd_obj  *ph2c;
-       struct drvextra_cmd_parm        *pdrvextra_cmd_parm;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       u8      res = _SUCCESS;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return res;
-
-       if (enqueue) {
-               ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
-               if (!ph2c) {
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
-               if (!pdrvextra_cmd_parm) {
-                       kfree(ph2c);
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               pdrvextra_cmd_parm->ec_id = P2P_PS_WK_CID;
-               pdrvextra_cmd_parm->type_size = p2p_ps_state;
-               pdrvextra_cmd_parm->pbuf = NULL;
-
-               init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
-
-               res = rtw_enqueue_cmd(pcmdpriv, ph2c);
-       } else {
-               p2p_ps_wk_hdl(padapter, p2p_ps_state);
-       }
-
-exit:
-
-       return res;
-}
-
-static void reset_ch_sitesurvey_timer_process(struct timer_list *t)
-{
-       struct adapter *adapter = from_timer(adapter, t, pwrctrlpriv.pwr_state_check_timer);
-       struct  wifidirect_info         *pwdinfo = &adapter->wdinfo;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       /*      Reset the operation channel information */
-       pwdinfo->rx_invitereq_info.operation_ch[0] = 0;
-       pwdinfo->rx_invitereq_info.scan_op_ch_only = 0;
-}
-
-static void reset_ch_sitesurvey_timer_process2(struct timer_list *t)
-{
-       struct adapter *adapter = from_timer(adapter, t, pwrctrlpriv.pwr_state_check_timer);
-       struct  wifidirect_info         *pwdinfo = &adapter->wdinfo;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       /*      Reset the operation channel information */
-       pwdinfo->p2p_info.operation_ch[0] = 0;
-       pwdinfo->p2p_info.scan_op_ch_only = 0;
-}
-
-static void restore_p2p_state_timer_process(struct timer_list *t)
-{
-       struct adapter *adapter = from_timer(adapter, t, wdinfo.restore_p2p_state_timer);
-       struct  wifidirect_info         *pwdinfo = &adapter->wdinfo;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       p2p_protocol_wk_cmd(adapter, P2P_RESTORE_STATE_WK);
-}
-
-static void pre_tx_scan_timer_process(struct timer_list *t)
-{
-       struct adapter *adapter = from_timer(adapter, t, wdinfo.pre_tx_scan_timer);
-       struct  wifidirect_info *pwdinfo = &adapter->wdinfo;
-       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) {
-               if (pwdinfo->tx_prov_disc_info.benable) {       /*      the provision discovery request frame is trigger to send or not */
-                       p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_PROVDISC_PROCESS_WK);
-                       /* issue_probereq_p2p(adapter); */
-                       /* _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); */
-               }
-       } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) {
-               if (pwdinfo->nego_req_info.benable)
-                       p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_NEGOREQ_PROCESS_WK);
-       } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) {
-               if (pwdinfo->invitereq_info.benable)
-                       p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_INVITEREQ_PROCESS_WK);
-       }
-
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-
-static void find_phase_timer_process(struct timer_list *t)
-{
-       struct adapter *adapter = from_timer(adapter, t, wdinfo.find_phase_timer);
-       struct  wifidirect_info         *pwdinfo = &adapter->wdinfo;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       adapter->wdinfo.find_phase_state_exchange_cnt++;
-
-       p2p_protocol_wk_cmd(adapter, P2P_FIND_PHASE_WK);
-}
-
-void reset_global_wifidirect_info(struct adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo;
-
-       pwdinfo = &padapter->wdinfo;
-       pwdinfo->persistent_supported = 0;
-       pwdinfo->session_available = true;
-}
-
-void rtw_init_wifidirect_timers(struct adapter *padapter)
-{
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       timer_setup(&pwdinfo->find_phase_timer, find_phase_timer_process, 0);
-       timer_setup(&pwdinfo->restore_p2p_state_timer, restore_p2p_state_timer_process, 0);
-       timer_setup(&pwdinfo->pre_tx_scan_timer, pre_tx_scan_timer_process, 0);
-       timer_setup(&pwdinfo->reset_ch_sitesurvey, reset_ch_sitesurvey_timer_process, 0);
-       timer_setup(&pwdinfo->reset_ch_sitesurvey2, reset_ch_sitesurvey_timer_process2, 0);
-}
-
-void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr, u8 *iface_addr)
-{
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       /*init device&interface address */
-       if (dev_addr)
-               memcpy(pwdinfo->device_addr, dev_addr, ETH_ALEN);
-       if (iface_addr)
-               memcpy(pwdinfo->interface_addr, iface_addr, ETH_ALEN);
-}
-
-void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role)
-{
-       struct wifidirect_info  *pwdinfo;
-
-       pwdinfo = &padapter->wdinfo;
-       pwdinfo->padapter = padapter;
-
-       /*      1, 6, 11 are the social channel defined in the WiFi Direct specification. */
-       pwdinfo->social_chan[0] = 1;
-       pwdinfo->social_chan[1] = 6;
-       pwdinfo->social_chan[2] = 11;
-       pwdinfo->social_chan[3] = 0;    /*      channel 0 for scanning ending in site survey function. */
-
-       /*      Use the channel 11 as the listen channel */
-       pwdinfo->listen_channel = 11;
-
-       if (role == P2P_ROLE_DEVICE) {
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN);
-               pwdinfo->intent = 1;
-               rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_LISTEN);
-       } else if (role == P2P_ROLE_CLIENT) {
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-               pwdinfo->intent = 1;
-               rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-       } else if (role == P2P_ROLE_GO) {
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-               pwdinfo->intent = 15;
-               rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-       }
-
-/*     Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */
-       pwdinfo->support_rate[0] = 0x8c;        /*      6(B) */
-       pwdinfo->support_rate[1] = 0x92;        /*      9(B) */
-       pwdinfo->support_rate[2] = 0x18;        /*      12 */
-       pwdinfo->support_rate[3] = 0x24;        /*      18 */
-       pwdinfo->support_rate[4] = 0x30;        /*      24 */
-       pwdinfo->support_rate[5] = 0x48;        /*      36 */
-       pwdinfo->support_rate[6] = 0x60;        /*      48 */
-       pwdinfo->support_rate[7] = 0x6c;        /*      54 */
-
-       memcpy(pwdinfo->p2p_wildcard_ssid, "DIRECT-", 7);
-
-       memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN);
-       pwdinfo->device_name_len = 0;
-
-       memset(&pwdinfo->invitereq_info, 0x00, sizeof(struct tx_invite_req_info));
-       pwdinfo->invitereq_info.token = 3;      /*      Token used for P2P invitation request frame. */
-
-       memset(&pwdinfo->inviteresp_info, 0x00, sizeof(struct tx_invite_resp_info));
-       pwdinfo->inviteresp_info.token = 0;
-
-       pwdinfo->profileindex = 0;
-       memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM);
-
-       rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE);
-
-       pwdinfo->listen_dwell = (u8)((jiffies % 3) + 1);
-
-       memset(&pwdinfo->tx_prov_disc_info, 0x00, sizeof(struct tx_provdisc_req_info));
-       pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_NONE;
-
-       memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info));
-
-       pwdinfo->device_password_id_for_nego = WPS_DPID_PBC;
-       pwdinfo->negotiation_dialog_token = 1;
-
-       memset(pwdinfo->nego_ssid, 0x00, WLAN_SSID_MAXLEN);
-       pwdinfo->nego_ssidlen = 0;
-
-       pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO;
-       pwdinfo->supported_wps_cm = WPS_CONFIG_METHOD_DISPLAY | WPS_CONFIG_METHOD_PBC | WPS_CONFIG_METHOD_KEYPAD;
-       pwdinfo->channel_list_attr_len = 0;
-       memset(pwdinfo->channel_list_attr, 0x00, 100);
-
-       memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, 0x00, 4);
-       memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, '0', 3);
-       memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info));
-       memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN);
-       memset(pwdinfo->p2p_peer_device_addr, 0x00, ETH_ALEN);
-
-       pwdinfo->rx_invitereq_info.operation_ch[0] = 0;
-       pwdinfo->rx_invitereq_info.operation_ch[1] = 0; /*      Used to indicate the scan end in site survey function */
-       pwdinfo->rx_invitereq_info.scan_op_ch_only = 0;
-       pwdinfo->p2p_info.operation_ch[0] = 0;
-       pwdinfo->p2p_info.operation_ch[1] = 0;                  /*      Used to indicate the scan end in site survey function */
-       pwdinfo->p2p_info.scan_op_ch_only = 0;
-}
-
-int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role)
-{
-       int ret;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) {
-               /* leave IPS/Autosuspend */
-               ret = rtw_pwr_wakeup(padapter);
-               if (ret)
-                       return ret;
-
-               /*      Added by Albert 2011/03/22 */
-               /*      In the P2P mode, the driver should not support the b mode. */
-               /*      So, the Tx packet shouldn't use the CCK rate */
-               update_tx_basic_rate(padapter, (WIRELESS_11G | WIRELESS_11_24N));
-
-               /* Enable P2P function */
-               init_wifidirect_info(padapter, role);
-
-       } else if (role == P2P_ROLE_DISABLE) {
-               ret = rtw_pwr_wakeup(padapter);
-               if (ret)
-                       return ret;
-
-               /* Disable P2P function */
-               if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-                       _cancel_timer_ex(&pwdinfo->find_phase_timer);
-                       _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer);
-                       _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer);
-                       _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey);
-                       _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey2);
-                       rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE);
-                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DISABLE);
-                       memset(&pwdinfo->rx_prov_disc_info, 0x00, sizeof(struct rx_provdisc_req_info));
-               }
-
-               /* Restore to initial setting. */
-               update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode);
-       }
-
-       return 0;
-}
diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
deleted file mode 100644 (file)
index 051cdcb..0000000
+++ /dev/null
@@ -1,445 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _RTW_PWRCTRL_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/osdep_intf.h"
-#include "../include/linux/usb.h"
-
-static void ips_enter(struct adapter *padapter)
-{
-       struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-       struct xmit_priv *pxmit_priv = &padapter->xmitpriv;
-
-       if (pxmit_priv->free_xmitbuf_cnt != NR_XMITBUFF ||
-           pxmit_priv->free_xmit_extbuf_cnt != NR_XMIT_EXTBUFF)
-               return;
-
-       mutex_lock(&pwrpriv->lock);
-
-       pwrpriv->bips_processing = true;
-
-       /*  syn ips_mode with request */
-       pwrpriv->ips_mode = pwrpriv->ips_mode_req;
-
-       pwrpriv->ips_enter_cnts++;
-       pwrpriv->bpower_saving = true;
-
-       if (pwrpriv->ips_mode == IPS_LEVEL_2)
-               pwrpriv->bkeepfwalive = true;
-
-       rtw_ips_pwr_down(padapter);
-       pwrpriv->rf_pwrstate = rf_off;
-
-       pwrpriv->bips_processing = false;
-
-       mutex_unlock(&pwrpriv->lock);
-}
-
-static int ips_leave(struct adapter *padapter)
-{
-       struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       int result = _SUCCESS;
-       int keyid;
-
-       mutex_lock(&pwrpriv->lock);
-
-       if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) {
-               pwrpriv->bips_processing = true;
-               pwrpriv->ips_leave_cnts++;
-
-               result = rtw_ips_pwr_up(padapter);
-               if (result == _SUCCESS) {
-                       pwrpriv->rf_pwrstate = rf_on;
-               }
-
-               if ((psecuritypriv->dot11PrivacyAlgrthm == _WEP40_) || (psecuritypriv->dot11PrivacyAlgrthm == _WEP104_)) {
-                       set_channel_bwmode(padapter, padapter->mlmeextpriv.cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-                       for (keyid = 0; keyid < 4; keyid++) {
-                               if (pmlmepriv->key_mask & BIT(keyid)) {
-                                       if (keyid == psecuritypriv->dot11PrivacyKeyIndex)
-                                               result = rtw_set_key(padapter, psecuritypriv, keyid, 1);
-                                       else
-                                               result = rtw_set_key(padapter, psecuritypriv, keyid, 0);
-                               }
-                       }
-               }
-
-               pwrpriv->bips_processing = false;
-
-               pwrpriv->bkeepfwalive = false;
-               pwrpriv->bpower_saving = false;
-       }
-
-       mutex_unlock(&pwrpriv->lock);
-
-       return result;
-}
-
-static bool rtw_pwr_unassociated_idle(struct adapter *adapter)
-{
-       struct adapter *buddy = adapter->pbuddy_adapter;
-       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       struct wifidirect_info  *pwdinfo = &adapter->wdinfo;
-       bool ret = false;
-
-       if (time_after_eq(adapter->pwrctrlpriv.ips_deny_time, jiffies))
-               goto exit;
-
-       if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR) ||
-           check_fwstate(pmlmepriv, WIFI_UNDER_LINKING | WIFI_UNDER_WPS) ||
-           check_fwstate(pmlmepriv, WIFI_UNDER_WPS) ||
-           check_fwstate(pmlmepriv, WIFI_AP_STATE) ||
-           check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE) ||
-           !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               goto exit;
-
-       /* consider buddy, if exist */
-       if (buddy) {
-               struct mlme_priv *b_pmlmepriv = &buddy->mlmepriv;
-               struct wifidirect_info *b_pwdinfo = &buddy->wdinfo;
-
-               if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR) ||
-                   check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING | WIFI_UNDER_WPS) ||
-                   check_fwstate(b_pmlmepriv, WIFI_AP_STATE) ||
-                   check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE) ||
-                   !rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE))
-                       goto exit;
-       }
-       ret = true;
-
-exit:
-       return ret;
-}
-
-void rtw_ps_processor(struct adapter *padapter)
-{
-       struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-
-       pwrpriv->ps_processing = true;
-
-       if (pwrpriv->bips_processing)
-               goto exit;
-
-       if (pwrpriv->ips_mode_req == IPS_NONE)
-               goto exit;
-
-       if (!rtw_pwr_unassociated_idle(padapter))
-               goto exit;
-
-       if (pwrpriv->rf_pwrstate == rf_on)
-               ips_enter(padapter);
-
-exit:
-       rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
-       pwrpriv->ps_processing = false;
-}
-
-static void pwr_state_check_handler(struct timer_list *t)
-{
-       struct adapter *padapter =
-               from_timer(padapter, t,
-                          pwrctrlpriv.pwr_state_check_timer);
-       rtw_ps_cmd(padapter);
-}
-
-static bool PS_RDY_CHECK(struct adapter *padapter)
-{
-       u32 curr_time, delta_time;
-       struct pwrctrl_priv     *pwrpriv = &padapter->pwrctrlpriv;
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-
-       curr_time = jiffies;
-       delta_time = curr_time - pwrpriv->DelayLPSLastTimeStamp;
-
-       if (delta_time < LPS_DELAY_TIME)
-               return false;
-
-       if (!check_fwstate(pmlmepriv, _FW_LINKED) ||
-           check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) ||
-           check_fwstate(pmlmepriv, WIFI_AP_STATE) ||
-           check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
-           check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))
-               return false;
-       if (pwrpriv->bInSuspend)
-               return false;
-       if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X &&
-           !padapter->securitypriv.binstallGrpkey)
-               return false;
-       return true;
-}
-
-void rtw_set_firmware_ps_mode(struct adapter *adapter, u8 mode)
-{
-       struct hal_data_8188e *haldata = &adapter->haldata;
-       struct odm_dm_struct *odmpriv = &haldata->odmpriv;
-
-       /* Force leave RF low power mode for 1T1R to prevent
-        * conflicting setting in firmware power saving sequence.
-        */
-       if (mode != PS_MODE_ACTIVE)
-               ODM_RF_Saving(odmpriv, true);
-       rtl8188e_set_FwPwrMode_cmd(adapter, mode);
-}
-
-void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode)
-{
-       struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       if (ps_mode > PM_Card_Disable)
-               return;
-
-       if (pwrpriv->pwr_mode == ps_mode) {
-               if (ps_mode == PS_MODE_ACTIVE)
-                       return;
-
-               if ((pwrpriv->smart_ps == smart_ps) &&
-                   (pwrpriv->bcn_ant_mode == bcn_ant_mode))
-                       return;
-       }
-
-       if (ps_mode == PS_MODE_ACTIVE) {
-               if (pwdinfo->opp_ps == 0) {
-                       pwrpriv->pwr_mode = ps_mode;
-                       rtw_set_firmware_ps_mode(padapter, ps_mode);
-                       pwrpriv->bFwCurrentInPSMode = false;
-               }
-       } else {
-               if (PS_RDY_CHECK(padapter)) {
-                       pwrpriv->bFwCurrentInPSMode = true;
-                       pwrpriv->pwr_mode = ps_mode;
-                       pwrpriv->smart_ps = smart_ps;
-                       pwrpriv->bcn_ant_mode = bcn_ant_mode;
-                       rtw_set_firmware_ps_mode(padapter, ps_mode);
-
-                       /*  Set CTWindow after LPS */
-                       if (pwdinfo->opp_ps == 1)
-                               p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 0);
-               }
-       }
-}
-
-static bool lps_rf_on(struct adapter *adapter)
-{
-       int res;
-       u32 reg;
-
-       /* When we halt NIC, we should check if FW LPS is leave. */
-       if (adapter->pwrctrlpriv.rf_pwrstate == rf_off) {
-               /*  If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave, */
-               /*  because Fw is unload. */
-               return true;
-       }
-
-       res = rtw_read32(adapter, REG_RCR, &reg);
-       if (res)
-               return false;
-
-       if (reg & 0x00070000)
-               return false;
-
-       return true;
-}
-
-/*
- * Return:
- *     0:      Leave OK
- *     -1:     Timeout
- *     -2:     Other error
- */
-static s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms)
-{
-       unsigned long timeout = jiffies + msecs_to_jiffies(delay_ms);
-       s32 err = 0;
-
-       while (1) {
-               if (lps_rf_on(padapter))
-                       break;
-
-               if (padapter->bSurpriseRemoved) {
-                       err = -2;
-                       break;
-               }
-
-               if (time_after(jiffies, timeout)) {
-                       err = -1;
-                       break;
-               }
-               mdelay(1);
-       }
-
-       return err;
-}
-
-/*  */
-/*     Description: */
-/*             Enter the leisure power save mode. */
-/*  */
-void LPS_Enter(struct adapter *padapter)
-{
-       struct pwrctrl_priv     *pwrpriv = &padapter->pwrctrlpriv;
-
-       if (!PS_RDY_CHECK(padapter))
-               return;
-
-       if (pwrpriv->bLeisurePs) {
-               /*  Idle for a while if we connect to AP a while ago. */
-               if (pwrpriv->LpsIdleCount >= 2) { /*   4 Sec */
-                       if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) {
-                               pwrpriv->bpower_saving = true;
-                               /* For Tenda W311R IOT issue */
-                               rtw_set_ps_mode(padapter, pwrpriv->power_mgnt,
-                                               pwrpriv->smart_ps, 0x40);
-                       }
-               } else {
-                       pwrpriv->LpsIdleCount++;
-               }
-       }
-
-}
-
-#define LPS_LEAVE_TIMEOUT_MS 100
-
-/*     Description: */
-/*             Leave the leisure power save mode. */
-void LPS_Leave(struct adapter *padapter)
-{
-       struct pwrctrl_priv     *pwrpriv = &padapter->pwrctrlpriv;
-
-       if (pwrpriv->bLeisurePs) {
-               if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) {
-                       rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0x40);
-
-                       if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
-                               LPS_RF_ON_check(padapter, LPS_LEAVE_TIMEOUT_MS);
-               }
-       }
-
-       pwrpriv->bpower_saving = false;
-
-}
-
-/*  */
-/*  Description: Leave all power save mode: LPS, FwLPS, IPS if needed. */
-/*  Move code to function by tynli. 2010.03.26. */
-/*  */
-void LeaveAllPowerSaveMode(struct adapter *Adapter)
-{
-       struct mlme_priv        *pmlmepriv = &Adapter->mlmepriv;
-       u8      enqueue = 0;
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED)) { /* connect */
-               p2p_ps_wk_cmd(Adapter, P2P_PS_DISABLE, enqueue);
-
-               rtw_lps_ctrl_wk_cmd(Adapter, LPS_CTRL_LEAVE, enqueue);
-       }
-
-}
-
-void rtw_init_pwrctrl_priv(struct adapter *padapter)
-{
-       struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
-
-       mutex_init(&pwrctrlpriv->lock);
-       pwrctrlpriv->rf_pwrstate = rf_on;
-       pwrctrlpriv->ips_enter_cnts = 0;
-       pwrctrlpriv->ips_leave_cnts = 0;
-       pwrctrlpriv->bips_processing = false;
-
-       pwrctrlpriv->ips_mode = padapter->registrypriv.ips_mode;
-       pwrctrlpriv->ips_mode_req = padapter->registrypriv.ips_mode;
-
-       pwrctrlpriv->pwr_state_check_interval = RTW_PWR_STATE_CHK_INTERVAL;
-       pwrctrlpriv->bInSuspend = false;
-       pwrctrlpriv->bkeepfwalive = false;
-
-       pwrctrlpriv->LpsIdleCount = 0;
-       pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/*  PS_MODE_MIN; */
-       pwrctrlpriv->bLeisurePs = pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE;
-
-       pwrctrlpriv->bFwCurrentInPSMode = false;
-
-       pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE;
-       pwrctrlpriv->smart_ps = padapter->registrypriv.smart_ps;
-       pwrctrlpriv->bcn_ant_mode = 0;
-
-       timer_setup(&pwrctrlpriv->pwr_state_check_timer, pwr_state_check_handler, 0);
-}
-
-/* Wake the NIC up from: 1)IPS 2)USB autosuspend */
-int rtw_pwr_wakeup(struct adapter *padapter)
-{
-       struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       unsigned long timeout = jiffies + msecs_to_jiffies(3000);
-       unsigned long deny_time;
-       int ret;
-
-       while (pwrpriv->ps_processing && time_before(jiffies, timeout))
-               msleep(10);
-
-       /* I think this should be check in IPS, LPS, autosuspend functions... */
-       /* Below goto is a success path taken for already linked devices */
-       ret = 0;
-       if (check_fwstate(pmlmepriv, _FW_LINKED))
-               goto exit;
-
-       if (pwrpriv->rf_pwrstate == rf_off && ips_leave(padapter) == _FAIL) {
-               ret = -ENOMEM;
-               goto exit;
-       }
-
-       if (padapter->bDriverStopped || !padapter->bup || !padapter->hw_init_completed) {
-               ret = -EBUSY;
-               goto exit;
-       }
-
-exit:
-       deny_time = jiffies + msecs_to_jiffies(RTW_PWR_STATE_CHK_INTERVAL);
-       if (time_before(pwrpriv->ips_deny_time, deny_time))
-               pwrpriv->ips_deny_time = deny_time;
-       return ret;
-}
-
-int rtw_pm_set_lps(struct adapter *padapter, u8 mode)
-{
-       int     ret = 0;
-       struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
-
-       if (mode < PS_MODE_NUM) {
-               if (pwrctrlpriv->power_mgnt != mode) {
-                       if (mode == PS_MODE_ACTIVE)
-                               LeaveAllPowerSaveMode(padapter);
-                       else
-                               pwrctrlpriv->LpsIdleCount = 2;
-                       pwrctrlpriv->power_mgnt = mode;
-                       pwrctrlpriv->bLeisurePs = pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE;
-               }
-       } else {
-               ret = -EINVAL;
-       }
-
-       return ret;
-}
-
-int rtw_pm_set_ips(struct adapter *padapter, u8 mode)
-{
-       struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
-
-       if (mode == IPS_NORMAL || mode == IPS_LEVEL_2) {
-               rtw_ips_mode_req(pwrctrlpriv, mode);
-               return 0;
-       } else if (mode == IPS_NONE) {
-               rtw_ips_mode_req(pwrctrlpriv, mode);
-               if ((padapter->bSurpriseRemoved == 0) && rtw_pwr_wakeup(padapter))
-                       return -EFAULT;
-       } else {
-               return -EINVAL;
-       }
-       return 0;
-}
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
deleted file mode 100644 (file)
index fc7568c..0000000
+++ /dev/null
@@ -1,2010 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _RTW_RECV_C_
-
-#include <linux/ieee80211.h>
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/usb_ops.h"
-#include "../include/wifi.h"
-#include "../include/rtl8188e_recv.h"
-
-static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37};
-static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3};
-
-/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
-static u8 rtw_bridge_tunnel_header[] = {
-       0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8
-};
-
-static u8 rtw_rfc1042_header[] = {
-       0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00
-};
-
-static void rtw_signal_stat_timer_hdl(struct timer_list *t);
-
-void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
-{
-
-       memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv));
-
-       spin_lock_init(&psta_recvpriv->lock);
-
-       rtw_init_queue(&psta_recvpriv->defrag_q);
-
-}
-
-static int rtl8188eu_init_recv_priv(struct adapter *padapter)
-{
-       struct recv_priv *precvpriv = &padapter->recvpriv;
-       int i, err = 0;
-       struct recv_buf *precvbuf;
-
-       tasklet_init(&precvpriv->recv_tasklet,
-                    rtl8188eu_recv_tasklet,
-                    (unsigned long)padapter);
-
-       /* init recv_buf */
-       rtw_init_queue(&precvpriv->free_recv_buf_queue);
-
-       precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4,
-                                                GFP_KERNEL);
-       if (!precvpriv->pallocated_recv_buf)
-               return -ENOMEM;
-
-       precvpriv->precv_buf = (u8 *)ALIGN((size_t)(precvpriv->pallocated_recv_buf), 4);
-
-       precvbuf = (struct recv_buf *)precvpriv->precv_buf;
-
-       for (i = 0; i < NR_RECVBUFF; i++) {
-               precvbuf->pskb = NULL;
-               precvbuf->reuse = false;
-               precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
-               if (!precvbuf->purb) {
-                       err = -ENOMEM;
-                       break;
-               }
-               precvbuf->adapter = padapter;
-               precvbuf++;
-       }
-       precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF;
-       skb_queue_head_init(&precvpriv->rx_skb_queue);
-       {
-               int i;
-               size_t tmpaddr = 0;
-               size_t alignment = 0;
-               struct sk_buff *pskb = NULL;
-
-               skb_queue_head_init(&precvpriv->free_recv_skb_queue);
-
-               for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) {
-                       pskb = __netdev_alloc_skb(padapter->pnetdev,
-                                                 MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, GFP_KERNEL);
-                       if (pskb) {
-                               pskb->dev = padapter->pnetdev;
-                               tmpaddr = (size_t)pskb->data;
-                               alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1);
-                               skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment));
-
-                               skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb);
-                       }
-                       pskb = NULL;
-               }
-       }
-
-       return err;
-}
-
-int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
-{
-       int i;
-       struct recv_frame *precvframe;
-       int err;
-
-       spin_lock_init(&precvpriv->lock);
-
-       rtw_init_queue(&precvpriv->free_recv_queue);
-       rtw_init_queue(&precvpriv->recv_pending_queue);
-       rtw_init_queue(&precvpriv->uc_swdec_pending_queue);
-
-       precvpriv->adapter = padapter;
-
-       precvpriv->free_recvframe_cnt = NR_RECVFRAME;
-
-       precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ);
-       if (!precvpriv->pallocated_frame_buf)
-               return -ENOMEM;
-
-       precvpriv->precv_frame_buf = (u8 *)ALIGN((size_t)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ);
-
-       precvframe = (struct recv_frame *)precvpriv->precv_frame_buf;
-
-       for (i = 0; i < NR_RECVFRAME; i++) {
-               INIT_LIST_HEAD(&precvframe->list);
-
-               list_add_tail(&precvframe->list, &precvpriv->free_recv_queue.queue);
-
-               precvframe->pkt = NULL;
-
-               precvframe->len = 0;
-
-               precvframe->adapter = padapter;
-               precvframe++;
-       }
-       precvpriv->rx_pending_cnt = 1;
-
-       err = rtl8188eu_init_recv_priv(padapter);
-
-       timer_setup(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl, 0);
-       precvpriv->signal_stat_sampling_interval = 1000; /* ms */
-
-       rtw_set_signal_stat_timer(precvpriv);
-
-       return err;
-}
-
-static void rtl8188eu_free_recv_priv(struct adapter *padapter)
-{
-       int i;
-       struct recv_buf *precvbuf;
-       struct recv_priv *precvpriv = &padapter->recvpriv;
-
-       precvbuf = (struct recv_buf *)precvpriv->precv_buf;
-
-       for (i = 0; i < NR_RECVBUFF; i++) {
-               usb_free_urb(precvbuf->purb);
-               precvbuf++;
-       }
-
-       kfree(precvpriv->pallocated_recv_buf);
-
-       skb_queue_purge(&precvpriv->rx_skb_queue);
-
-       skb_queue_purge(&precvpriv->free_recv_skb_queue);
-}
-
-void _rtw_free_recv_priv(struct recv_priv *precvpriv)
-{
-       struct adapter  *padapter = precvpriv->adapter;
-
-       rtw_free_uc_swdec_pending_queue(padapter);
-
-       vfree(precvpriv->pallocated_frame_buf);
-
-       rtl8188eu_free_recv_priv(padapter);
-       _cancel_timer_ex(&precvpriv->signal_stat_timer);
-}
-
-struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue)
-{
-       struct recv_frame *hdr;
-       struct list_head *plist, *phead;
-       struct adapter *padapter;
-       struct recv_priv *precvpriv;
-
-       if (list_empty(&pfree_recv_queue->queue)) {
-               hdr = NULL;
-       } else {
-               phead = get_list_head(pfree_recv_queue);
-
-               plist = phead->next;
-
-               hdr = container_of(plist, struct recv_frame, list);
-
-               list_del_init(&hdr->list);
-               padapter = hdr->adapter;
-               if (padapter) {
-                       precvpriv = &padapter->recvpriv;
-                       if (pfree_recv_queue == &precvpriv->free_recv_queue)
-                               precvpriv->free_recvframe_cnt--;
-               }
-       }
-
-       return (struct recv_frame *)hdr;
-}
-
-struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue)
-{
-       struct recv_frame  *precvframe;
-
-       spin_lock_bh(&pfree_recv_queue->lock);
-
-       precvframe = _rtw_alloc_recvframe(pfree_recv_queue);
-
-       spin_unlock_bh(&pfree_recv_queue->lock);
-
-       return precvframe;
-}
-
-int rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv_queue)
-{
-       struct adapter *padapter;
-       struct recv_priv *precvpriv;
-
-       if (!precvframe)
-               return _FAIL;
-       padapter = precvframe->adapter;
-       precvpriv = &padapter->recvpriv;
-       if (precvframe->pkt) {
-               dev_kfree_skb_any(precvframe->pkt);/* free skb by driver */
-               precvframe->pkt = NULL;
-       }
-
-       spin_lock_bh(&pfree_recv_queue->lock);
-
-       list_del_init(&precvframe->list);
-
-       precvframe->len = 0;
-
-       list_add_tail(&precvframe->list, get_list_head(pfree_recv_queue));
-
-       if (padapter && (pfree_recv_queue == &precvpriv->free_recv_queue))
-               precvpriv->free_recvframe_cnt++;
-
-       spin_unlock_bh(&pfree_recv_queue->lock);
-
-       return _SUCCESS;
-}
-
-int _rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue)
-{
-       struct adapter *padapter = precvframe->adapter;
-       struct recv_priv *precvpriv = &padapter->recvpriv;
-
-       list_del_init(&precvframe->list);
-       list_add_tail(&precvframe->list, get_list_head(queue));
-
-       if (padapter) {
-               if (queue == &precvpriv->free_recv_queue)
-                       precvpriv->free_recvframe_cnt++;
-       }
-
-       return _SUCCESS;
-}
-
-int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue)
-{
-       int ret;
-
-       spin_lock_bh(&queue->lock);
-       ret = _rtw_enqueue_recvframe(precvframe, queue);
-       spin_unlock_bh(&queue->lock);
-
-       return ret;
-}
-
-/*
- * caller : defrag ; recvframe_chk_defrag in recv_thread  (passive)
- * pframequeue: defrag_queue : will be accessed in recv_thread  (passive)
- *
- * using spinlock to protect
- *
- */
-
-void rtw_free_recvframe_queue(struct __queue *pframequeue,  struct __queue *pfree_recv_queue)
-{
-       struct recv_frame *hdr;
-       struct list_head *plist, *phead;
-
-       spin_lock(&pframequeue->lock);
-
-       phead = get_list_head(pframequeue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               hdr = container_of(plist, struct recv_frame, list);
-
-               plist = plist->next;
-
-               rtw_free_recvframe((struct recv_frame *)hdr, pfree_recv_queue);
-       }
-
-       spin_unlock(&pframequeue->lock);
-
-}
-
-u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter)
-{
-       u32 cnt = 0;
-       struct recv_frame *pending_frame;
-
-       while ((pending_frame = rtw_alloc_recvframe(&adapter->recvpriv.uc_swdec_pending_queue))) {
-               rtw_free_recvframe(pending_frame, &adapter->recvpriv.free_recv_queue);
-               cnt++;
-       }
-
-       return cnt;
-}
-
-static void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup)
-{
-       union iwreq_data wrqu;
-       struct iw_michaelmicfailure ev;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       u32 cur_time = 0;
-
-       if (psecuritypriv->last_mic_err_time == 0) {
-               psecuritypriv->last_mic_err_time = jiffies;
-       } else {
-               cur_time = jiffies;
-
-               if (cur_time - psecuritypriv->last_mic_err_time < 60 * HZ) {
-                       psecuritypriv->btkip_countermeasure = true;
-                       psecuritypriv->last_mic_err_time = 0;
-                       psecuritypriv->btkip_countermeasure_time = cur_time;
-               } else {
-                       psecuritypriv->last_mic_err_time = jiffies;
-               }
-       }
-
-       memset(&ev, 0x00, sizeof(ev));
-       if (bgroup)
-               ev.flags |= IW_MICFAILURE_GROUP;
-       else
-               ev.flags |= IW_MICFAILURE_PAIRWISE;
-
-       ev.src_addr.sa_family = ARPHRD_ETHER;
-       memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN);
-       memset(&wrqu, 0x00, sizeof(wrqu));
-       wrqu.data.length = sizeof(ev);
-       wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE,
-                           &wrqu, (char *)&ev);
-}
-
-static int recvframe_chkmic(struct adapter *adapter,  struct recv_frame *precvframe)
-{
-       int     i, res = _SUCCESS;
-       u32     datalen;
-       u8      miccode[8];
-       u8      bmic_err = false, brpt_micerror = true;
-       u8      *pframe, *payload, *pframemic;
-       u8      *mickey;
-       struct  sta_info                *stainfo;
-       struct  rx_pkt_attrib   *prxattrib = &precvframe->attrib;
-       struct  security_priv   *psecuritypriv = &adapter->securitypriv;
-
-       struct mlme_ext_priv    *pmlmeext = &adapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]);
-
-       if (prxattrib->encrypt == _TKIP_) {
-               /* calculate mic code */
-               if (stainfo) {
-                       if (is_multicast_ether_addr(prxattrib->ra)) {
-                               mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0];
-
-                               if (!psecuritypriv) {
-                                       res = _FAIL;
-                                       goto exit;
-                               }
-                       } else {
-                               mickey = &stainfo->dot11tkiprxmickey.skey[0];
-                       }
-
-                       datalen = precvframe->len - prxattrib->hdrlen - prxattrib->iv_len - prxattrib->icv_len - 8;/* icv_len included the mic code */
-                       pframe = precvframe->rx_data;
-                       payload = pframe + prxattrib->hdrlen + prxattrib->iv_len;
-
-                       rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0],
-                                          (unsigned char)prxattrib->priority); /* care the length of the data */
-
-                       pframemic = payload + datalen;
-
-                       bmic_err = false;
-
-                       for (i = 0; i < 8; i++) {
-                               if (miccode[i] != *(pframemic + i))
-                                       bmic_err = true;
-                       }
-
-                       if (bmic_err) {
-                               /*  double check key_index for some timing issue , */
-                               /*  cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */
-                               if (is_multicast_ether_addr(prxattrib->ra) && prxattrib->key_index != pmlmeinfo->key_index)
-                                       brpt_micerror = false;
-
-                               if ((prxattrib->bdecrypted) && (brpt_micerror))
-                                       rtw_handle_tkip_mic_err(adapter, (u8)is_multicast_ether_addr(prxattrib->ra));
-
-                               res = _FAIL;
-                       } else {
-                               /* mic checked ok */
-                               if (!psecuritypriv->bcheck_grpkey && is_multicast_ether_addr(prxattrib->ra))
-                                       psecuritypriv->bcheck_grpkey = true;
-                       }
-               }
-
-               recvframe_pull_tail(precvframe, 8);
-       }
-
-exit:
-
-       return res;
-}
-
-/* decrypt and set the ivlen, icvlen of the recv_frame */
-static struct recv_frame *decryptor(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct rx_pkt_attrib *prxattrib = &precv_frame->attrib;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct recv_frame *return_packet = precv_frame;
-       u32      res = _SUCCESS;
-
-       if (prxattrib->encrypt > 0) {
-               u8 *iv = precv_frame->rx_data + prxattrib->hdrlen;
-
-               prxattrib->key_index = (((iv[3]) >> 6) & 0x3);
-
-               if (prxattrib->key_index > WEP_KEYS) {
-                       switch (prxattrib->encrypt) {
-                       case _WEP40_:
-                       case _WEP104_:
-                               prxattrib->key_index = psecuritypriv->dot11PrivacyKeyIndex;
-                               break;
-                       case _TKIP_:
-                       case _AES_:
-                       default:
-                               prxattrib->key_index = psecuritypriv->dot118021XGrpKeyid;
-                               break;
-                       }
-               }
-       }
-
-       if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0) || (psecuritypriv->sw_decrypt))) {
-               psecuritypriv->hw_decrypted = false;
-
-               switch (prxattrib->encrypt) {
-               case _WEP40_:
-               case _WEP104_:
-                       rtw_wep_decrypt(padapter, precv_frame);
-                       break;
-               case _TKIP_:
-                       res = rtw_tkip_decrypt(padapter, precv_frame);
-                       break;
-               case _AES_:
-                       res = rtw_aes_decrypt(padapter, precv_frame);
-                       break;
-               default:
-                       break;
-               }
-       } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 &&
-                  (psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_))
-                       psecuritypriv->hw_decrypted = true;
-
-       if (res == _FAIL) {
-               rtw_free_recvframe(return_packet, &padapter->recvpriv.free_recv_queue);
-               return_packet = NULL;
-       } else {
-               prxattrib->bdecrypted = true;
-       }
-
-       return return_packet;
-}
-
-/* set the security information in the recv_frame */
-static struct recv_frame *portctrl(struct adapter *adapter, struct recv_frame *precv_frame)
-{
-       u8   *psta_addr, *ptr;
-       uint  auth_alg;
-       struct recv_frame *pfhdr;
-       struct sta_info *psta;
-       struct sta_priv *pstapriv;
-       struct recv_frame *prtnframe;
-       u16 ether_type = 0;
-       u16  eapol_type = 0x888e;/* for Funia BD's WPA issue */
-       struct rx_pkt_attrib *pattrib;
-       __be16 be_tmp;
-
-       pstapriv = &adapter->stapriv;
-
-       auth_alg = adapter->securitypriv.dot11AuthAlgrthm;
-
-       ptr = precv_frame->rx_data;
-       pfhdr = precv_frame;
-       pattrib = &pfhdr->attrib;
-       psta_addr = pattrib->ta;
-
-       prtnframe = NULL;
-
-       psta = rtw_get_stainfo(pstapriv, psta_addr);
-
-       if (auth_alg == 2) {
-               if (psta && psta->ieee8021x_blocked) {
-                       /* blocked */
-                       /* only accept EAPOL frame */
-                       prtnframe = precv_frame;
-
-                       /* get ether_type */
-                       ptr = ptr + pfhdr->attrib.hdrlen + pfhdr->attrib.iv_len + LLC_HEADER_SIZE;
-                       memcpy(&be_tmp, ptr, 2);
-                       ether_type = ntohs(be_tmp);
-
-                       if (ether_type == eapol_type) {
-                               prtnframe = precv_frame;
-                       } else {
-                               /* free this frame */
-                               rtw_free_recvframe(precv_frame, &adapter->recvpriv.free_recv_queue);
-                               prtnframe = NULL;
-                       }
-               } else {
-                       /* allowed */
-                       /* check decryption status, and decrypt the frame if needed */
-                       prtnframe = precv_frame;
-               }
-       } else {
-               prtnframe = precv_frame;
-       }
-
-       return prtnframe;
-}
-
-static int recv_decache(struct recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache)
-{
-       int tid = precv_frame->attrib.priority;
-
-       u16 seq_ctrl = ((precv_frame->attrib.seq_num & 0xffff) << 4) |
-               (precv_frame->attrib.frag_num & 0xf);
-
-       if (tid > 15)
-               return _FAIL;
-
-       if (1) {/* if (bretry) */
-               if (seq_ctrl == prxcache->tid_rxseq[tid])
-                       return _FAIL;
-       }
-
-       prxcache->tid_rxseq[tid] = seq_ctrl;
-
-       return _SUCCESS;
-}
-
-static void process_pwrbit_data(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       unsigned char pwrbit;
-       u8 *ptr = precv_frame->rx_data;
-       struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct sta_info *psta = NULL;
-
-       psta = rtw_get_stainfo(pstapriv, pattrib->src);
-
-       pwrbit = GetPwrMgt(ptr);
-
-       if (psta) {
-               if (pwrbit) {
-                       if (!(psta->state & WIFI_SLEEP_STATE))
-                               stop_sta_xmit(padapter, psta);
-               } else {
-                       if (psta->state & WIFI_SLEEP_STATE)
-                               wakeup_sta_to_xmit(padapter, psta);
-               }
-       }
-}
-
-static void process_wmmps_data(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct sta_info *psta = NULL;
-
-       psta = rtw_get_stainfo(pstapriv, pattrib->src);
-
-       if (!psta)
-               return;
-
-       if (!psta->qos_option)
-               return;
-
-       if (!(psta->qos_info & 0xf))
-               return;
-
-       if (psta->state & WIFI_SLEEP_STATE) {
-               u8 wmmps_ac = 0;
-
-               switch (pattrib->priority) {
-               case 1:
-               case 2:
-                       wmmps_ac = psta->uapsd_bk & BIT(1);
-                       break;
-               case 4:
-               case 5:
-                       wmmps_ac = psta->uapsd_vi & BIT(1);
-                       break;
-               case 6:
-               case 7:
-                       wmmps_ac = psta->uapsd_vo & BIT(1);
-                       break;
-               case 0:
-               case 3:
-               default:
-                       wmmps_ac = psta->uapsd_be & BIT(1);
-                       break;
-               }
-
-               if (wmmps_ac) {
-                       if (psta->sleepq_ac_len > 0) {
-                               /* process received triggered frame */
-                               xmit_delivery_enabled_frames(padapter, psta);
-                       } else {
-                               /* issue one qos null frame with More data bit = 0 and the EOSP bit set (= 1) */
-                               issue_qos_nulldata(padapter, psta->hwaddr, (u16)pattrib->priority, 0, 0);
-                       }
-               }
-       }
-}
-
-static void count_rx_stats(struct adapter *padapter, struct recv_frame *prframe, struct sta_info *sta)
-{
-       int     sz;
-       struct sta_info         *psta = NULL;
-       struct stainfo_stats    *pstats = NULL;
-       struct rx_pkt_attrib    *pattrib = &prframe->attrib;
-       struct recv_priv        *precvpriv = &padapter->recvpriv;
-
-       sz = get_recvframe_len(prframe);
-       precvpriv->rx_bytes += sz;
-
-       padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++;
-
-       if (!is_broadcast_ether_addr(pattrib->dst) && !is_multicast_ether_addr(pattrib->dst))
-               padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++;
-
-       if (sta)
-               psta = sta;
-       else
-               psta = prframe->psta;
-
-       if (psta) {
-               pstats = &psta->sta_stats;
-
-               pstats->rx_data_pkts++;
-               pstats->rx_bytes += sz;
-       }
-}
-
-static int sta2sta_data_frame(struct adapter *adapter,
-                             struct recv_frame *precv_frame, struct sta_info **psta)
-{
-       int ret = _SUCCESS;
-       struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
-       struct  sta_priv *pstapriv = &adapter->stapriv;
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       u8 *mybssid  = get_bssid(pmlmepriv);
-       u8 *myhwaddr = myid(&adapter->eeprompriv);
-       u8 *sta_addr = NULL;
-       bool bmcast = is_multicast_ether_addr(pattrib->dst);
-
-       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
-           check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
-               /*  filter packets that SA is myself or multicast or broadcast */
-               if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-
-               if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-
-               if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
-                   !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
-                   memcmp(pattrib->bssid, mybssid, ETH_ALEN)) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-
-               sta_addr = pattrib->src;
-       } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-               /*  For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */
-               if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-               sta_addr = pattrib->bssid;
-       } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               if (bmcast) {
-                       /*  For AP mode, if DA == MCAST, then BSSID should be also MCAST */
-                       if (!is_multicast_ether_addr(pattrib->bssid)) {
-                                       ret = _FAIL;
-                                       goto exit;
-                       }
-               } else { /*  not mc-frame */
-                       /*  For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */
-                       if (memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN)) {
-                               ret = _FAIL;
-                               goto exit;
-                       }
-
-                       sta_addr = pattrib->src;
-               }
-       } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) {
-               sta_addr = mybssid;
-       } else {
-               ret  = _FAIL;
-       }
-
-       if (bmcast)
-               *psta = rtw_get_bcmc_stainfo(adapter);
-       else
-               *psta = rtw_get_stainfo(pstapriv, sta_addr); /*  get ap_info */
-
-       if (!*psta)
-               goto exit;
-
-exit:
-
-       return ret;
-}
-
-static int ap2sta_data_frame(
-       struct adapter *adapter,
-       struct recv_frame *precv_frame,
-       struct sta_info **psta)
-{
-       u8 *ptr = precv_frame->rx_data;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
-       struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
-       int ret = _SUCCESS;
-       struct  sta_priv *pstapriv = &adapter->stapriv;
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       u8 *mybssid  = get_bssid(pmlmepriv);
-       u8 *myhwaddr = myid(&adapter->eeprompriv);
-       bool bmcast = is_multicast_ether_addr(pattrib->dst);
-
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) &&
-           (check_fwstate(pmlmepriv, _FW_LINKED) ||
-            check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) {
-               /*  filter packets that SA is myself or multicast or broadcast */
-               if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-
-               /*  da should be for me */
-               if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-
-               /*  check BSSID */
-               if (is_zero_ether_addr(pattrib->bssid) || is_zero_ether_addr(mybssid) ||
-                   (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) {
-                       if (!bmcast)
-                               issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
-
-                       ret = _FAIL;
-                       goto exit;
-               }
-
-               if (bmcast)
-                       *psta = rtw_get_bcmc_stainfo(adapter);
-               else
-                       *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /*  get ap_info */
-
-               if (!*psta) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-
-               if (ieee80211_is_nullfunc(hdr->frame_control)) {
-                       /* We count the nullfunc frame, but we'll not pass it on to higher layers. */
-                       count_rx_stats(adapter, precv_frame, *psta);
-                       ret = RTW_RX_HANDLED;
-                       goto exit;
-               }
-       } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) &&
-                  check_fwstate(pmlmepriv, _FW_LINKED)) {
-               memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN);
-
-               memcpy(pattrib->bssid,  mybssid, ETH_ALEN);
-
-               *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /*  get sta_info */
-               if (!*psta) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-       } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               /* Special case */
-               ret = RTW_RX_HANDLED;
-               goto exit;
-       } else {
-               if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) {
-                       *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /*  get sta_info */
-                       if (!*psta)
-                               issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
-               }
-
-               ret = _FAIL;
-       }
-
-exit:
-
-       return ret;
-}
-
-static int sta2ap_data_frame(struct adapter *adapter,
-                            struct recv_frame *precv_frame,
-                            struct sta_info **psta)
-{
-       struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
-       struct  sta_priv *pstapriv = &adapter->stapriv;
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       u8 *ptr = precv_frame->rx_data;
-       __le16 fc = *(__le16 *)ptr;
-       unsigned char *mybssid  = get_bssid(pmlmepriv);
-       int ret = _SUCCESS;
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               /* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */
-               if (memcmp(pattrib->bssid, mybssid, ETH_ALEN)) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-
-               *psta = rtw_get_stainfo(pstapriv, pattrib->src);
-               if (!*psta) {
-                       issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
-
-                       ret = RTW_RX_HANDLED;
-                       goto exit;
-               }
-
-               process_pwrbit_data(adapter, precv_frame);
-
-               if (ieee80211_is_data_qos(fc))
-                       process_wmmps_data(adapter, precv_frame);
-
-               if (GetFrameSubType(ptr) & BIT(6)) {
-                       /* No data, will not indicate to upper layer, temporily count it here */
-                       count_rx_stats(adapter, precv_frame, *psta);
-                       ret = RTW_RX_HANDLED;
-                       goto exit;
-               }
-       } else {
-               u8 *myhwaddr = myid(&adapter->eeprompriv);
-
-               if (memcmp(pattrib->ra, myhwaddr, ETH_ALEN)) {
-                       ret = RTW_RX_HANDLED;
-                       goto exit;
-               }
-               issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
-               ret = RTW_RX_HANDLED;
-               goto exit;
-       }
-
-exit:
-
-       return ret;
-}
-
-static void validate_recv_ctrl_frame(struct adapter *padapter,
-                                    struct recv_frame *precv_frame)
-{
-       struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
-       struct ieee80211_pspoll *pspoll = (struct ieee80211_pspoll *)hdr;
-       u8 wmmps_ac;
-       struct sta_info *psta;
-
-       /* receive the frames that ra(a1) is my address */
-       if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN))
-               return;
-
-       /* only handle ps-poll */
-       if (!ieee80211_is_pspoll(hdr->frame_control))
-               return;
-
-       psta = rtw_get_stainfo(pstapriv, hdr->addr2);
-       if (!psta || psta->aid != (le16_to_cpu(pspoll->aid) & 0x3FFF))
-               return;
-
-       /* for rx pkt statistics */
-       psta->sta_stats.rx_ctrl_pkts++;
-
-       switch (pattrib->priority) {
-       case 1:
-       case 2:
-               wmmps_ac = psta->uapsd_bk & BIT(0);
-               break;
-       case 4:
-       case 5:
-               wmmps_ac = psta->uapsd_vi & BIT(0);
-               break;
-       case 6:
-       case 7:
-               wmmps_ac = psta->uapsd_vo & BIT(0);
-               break;
-       case 0:
-       case 3:
-       default:
-               wmmps_ac = psta->uapsd_be & BIT(0);
-               break;
-       }
-
-       if (wmmps_ac)
-               return;
-
-       if (psta->state & WIFI_STA_ALIVE_CHK_STATE) {
-               psta->expire_to = pstapriv->expire_to;
-               psta->state ^= WIFI_STA_ALIVE_CHK_STATE;
-       }
-
-       if ((psta->state & WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap & BIT(psta->aid))) {
-               struct list_head *xmitframe_plist, *xmitframe_phead;
-               struct xmit_frame *pxmitframe = NULL;
-               struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-
-               spin_lock_bh(&pxmitpriv->lock);
-
-               xmitframe_phead = get_list_head(&psta->sleep_q);
-               xmitframe_plist = xmitframe_phead->next;
-
-               if (xmitframe_phead != xmitframe_plist) {
-                       pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
-
-                       xmitframe_plist = xmitframe_plist->next;
-
-                       list_del_init(&pxmitframe->list);
-
-                       psta->sleepq_len--;
-
-                       if (psta->sleepq_len > 0)
-                               pxmitframe->attrib.mdata = 1;
-                       else
-                               pxmitframe->attrib.mdata = 0;
-
-                       pxmitframe->attrib.triggered = 1;
-
-                       if (psta->sleepq_len == 0) {
-                               pstapriv->tim_bitmap &= ~BIT(psta->aid);
-
-                               /* update BCN for TIM IE */
-                               /* update_BCNTIM(padapter); */
-                               update_beacon(padapter, _TIM_IE_, NULL, false);
-                       }
-               } else {
-                       if (pstapriv->tim_bitmap & BIT(psta->aid)) {
-                               if (psta->sleepq_len == 0)
-                                       /* issue nulldata with More data bit = 0 to indicate we have no buffered packets */
-                                       issue_nulldata(padapter, psta->hwaddr, 0, 0, 0);
-                               else
-                                       psta->sleepq_len = 0;
-
-                               pstapriv->tim_bitmap &= ~BIT(psta->aid);
-
-                               /* update BCN for TIM IE */
-                               /* update_BCNTIM(padapter); */
-                               update_beacon(padapter, _TIM_IE_, NULL, false);
-                       }
-               }
-               spin_unlock_bh(&pxmitpriv->lock);
-       }
-}
-
-struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_frame *precv_frame);
-
-static void validate_recv_mgnt_frame(struct adapter *padapter,
-                                    struct recv_frame *precv_frame)
-{
-       struct sta_info *psta;
-       struct ieee80211_hdr *hdr;
-
-       precv_frame = recvframe_chk_defrag(padapter, precv_frame);
-       if (!precv_frame)
-               return;
-
-       hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
-       psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
-       if (psta) {
-               psta->sta_stats.rx_mgnt_pkts++;
-               if (ieee80211_is_beacon(hdr->frame_control))
-                       psta->sta_stats.rx_beacon_pkts++;
-               else if (ieee80211_is_probe_req(hdr->frame_control))
-                       psta->sta_stats.rx_probereq_pkts++;
-               else if (ieee80211_is_probe_resp(hdr->frame_control)) {
-                       if (!memcmp(padapter->eeprompriv.mac_addr, hdr->addr1, ETH_ALEN))
-                               psta->sta_stats.rx_probersp_pkts++;
-                       else if (is_broadcast_mac_addr(hdr->addr1) || is_multicast_mac_addr(hdr->addr1))
-                               psta->sta_stats.rx_probersp_bm_pkts++;
-                       else
-                               psta->sta_stats.rx_probersp_uo_pkts++;
-               }
-       }
-
-       mgt_dispatcher(padapter, precv_frame);
-}
-
-static int validate_recv_data_frame(struct adapter *adapter,
-                                   struct recv_frame *precv_frame)
-{
-       struct sta_info *psta = NULL;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
-       struct rx_pkt_attrib    *pattrib = &precv_frame->attrib;
-       struct security_priv    *psecuritypriv = &adapter->securitypriv;
-       int ret;
-
-       memcpy(pattrib->dst, ieee80211_get_DA(hdr), ETH_ALEN);
-       memcpy(pattrib->src, ieee80211_get_SA(hdr), ETH_ALEN);
-
-       /* address4 is used only if both to_ds and from_ds are set */
-       if (ieee80211_has_a4(hdr->frame_control))
-               return _FAIL;
-
-       memcpy(pattrib->ra, hdr->addr1, ETH_ALEN);
-       memcpy(pattrib->ta, hdr->addr2, ETH_ALEN);
-
-       if (ieee80211_has_fromds(hdr->frame_control)) {
-               memcpy(pattrib->bssid, hdr->addr2, ETH_ALEN);
-               ret = ap2sta_data_frame(adapter, precv_frame, &psta);
-       } else if (ieee80211_has_tods(hdr->frame_control)) {
-               memcpy(pattrib->bssid, hdr->addr1, ETH_ALEN);
-               ret = sta2ap_data_frame(adapter, precv_frame, &psta);
-       } else {
-               memcpy(pattrib->bssid, hdr->addr3, ETH_ALEN);
-               ret = sta2sta_data_frame(adapter, precv_frame, &psta);
-       }
-
-       if (ret == _FAIL || ret == RTW_RX_HANDLED)
-               return ret;
-
-       if (!psta)
-               return _FAIL;
-
-       precv_frame->psta = psta;
-
-       pattrib->amsdu = 0;
-       pattrib->ack_policy = 0;
-       /* parsing QC field */
-       if (pattrib->qos) {
-               struct ieee80211_qos_hdr *qos_hdr = (struct ieee80211_qos_hdr *)hdr;
-
-               pattrib->priority = ieee80211_get_tid(hdr);
-               pattrib->ack_policy = GetAckpolicy(&qos_hdr->qos_ctrl);
-               pattrib->amsdu = GetAMsdu(&qos_hdr->qos_ctrl);
-               pattrib->hdrlen = sizeof(*qos_hdr);
-
-               if (pattrib->priority != 0 && pattrib->priority != 3)
-                       adapter->recvpriv.bIsAnyNonBEPkts = true;
-       } else {
-               pattrib->priority = 0;
-               pattrib->hdrlen = 24;
-       }
-
-       if (pattrib->order)/* HT-CTRL 11n */
-               pattrib->hdrlen += 4;
-
-       precv_frame->preorder_ctrl = &psta->recvreorder_ctrl[pattrib->priority];
-
-       /*  decache, drop duplicate recv packets */
-       if (recv_decache(precv_frame, ieee80211_has_retry(hdr->frame_control),
-                        &psta->sta_recvpriv.rxcache) == _FAIL)
-               return _FAIL;
-
-       if (pattrib->privacy) {
-               GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, is_multicast_ether_addr(pattrib->ra));
-
-               SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt);
-       } else {
-               pattrib->encrypt = 0;
-               pattrib->iv_len = 0;
-               pattrib->icv_len = 0;
-       }
-
-       return _SUCCESS;
-}
-
-static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv_frame)
-{
-       /* shall check frame subtype, to / from ds, da, bssid */
-
-       /* then call check if rx seq/frag. duplicated. */
-
-       int retval = _FAIL;
-       struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
-       struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
-
-       if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
-               int ch_set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, rtw_get_oper_ch(adapter));
-
-               if (ch_set_idx >= 0)
-                       pmlmeext->channel_set[ch_set_idx].rx_count++;
-       }
-
-       if ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_VERS)) != 0)
-               return _FAIL;
-
-       pattrib->frag_num = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
-       pattrib->seq_num = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
-
-       pattrib->pw_save = ieee80211_has_pm(hdr->frame_control);
-       pattrib->mfrag = ieee80211_has_morefrags(hdr->frame_control);
-       pattrib->mdata = ieee80211_has_moredata(hdr->frame_control);
-       pattrib->privacy = ieee80211_has_protected(hdr->frame_control);
-       pattrib->order = ieee80211_has_order(hdr->frame_control);
-
-       /* We return _SUCCESS only for data frames. */
-       if (ieee80211_is_mgmt(hdr->frame_control))
-               validate_recv_mgnt_frame(adapter, precv_frame);
-       else if (ieee80211_is_ctl(hdr->frame_control))
-               validate_recv_ctrl_frame(adapter, precv_frame);
-       else if (ieee80211_is_data(hdr->frame_control)) {
-               rtw_led_control(adapter, LED_CTL_RX);
-               pattrib->qos = ieee80211_is_data_qos(hdr->frame_control);
-               retval = validate_recv_data_frame(adapter, precv_frame);
-               if (retval == _FAIL) {
-                       struct recv_priv *precvpriv = &adapter->recvpriv;
-
-                       precvpriv->rx_drop++;
-               }
-       }
-
-       return retval;
-}
-
-/* remove the wlanhdr and add the eth_hdr */
-
-static int wlanhdr_to_ethhdr(struct recv_frame *precvframe)
-{
-       int     rmv_len;
-       u16     eth_type, len;
-       __be16 be_tmp;
-       u8      bsnaphdr;
-       u8      *psnap_type;
-       struct ieee80211_snap_hdr       *psnap;
-
-       int ret = _SUCCESS;
-       struct adapter                  *adapter = precvframe->adapter;
-       struct mlme_priv        *pmlmepriv = &adapter->mlmepriv;
-
-       u8      *ptr = precvframe->rx_data; /*  point to frame_ctrl field */
-       struct rx_pkt_attrib *pattrib = &precvframe->attrib;
-
-       if (pattrib->encrypt)
-               recvframe_pull_tail(precvframe, pattrib->icv_len);
-
-       psnap = (struct ieee80211_snap_hdr *)(ptr + pattrib->hdrlen + pattrib->iv_len);
-       psnap_type = ptr + pattrib->hdrlen + pattrib->iv_len + SNAP_SIZE;
-       /* convert hdr + possible LLC headers into Ethernet header */
-       if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) &&
-            memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) &&
-           memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2)) ||
-           !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) {
-               /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
-               bsnaphdr = true;
-       } else {
-               /* Leave Ethernet header part of hdr and full payload */
-               bsnaphdr = false;
-       }
-
-       rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0);
-       len = precvframe->len - rmv_len;
-
-       memcpy(&be_tmp, ptr + rmv_len, 2);
-       eth_type = ntohs(be_tmp); /* pattrib->ether_type */
-       pattrib->eth_type = eth_type;
-
-       if ((check_fwstate(pmlmepriv, WIFI_MP_STATE))) {
-               ptr += rmv_len;
-               *ptr = 0x87;
-               *(ptr + 1) = 0x12;
-
-               eth_type = 0x8712;
-               /*  append rx status for mp test packets */
-               ptr = recvframe_pull(precvframe, (rmv_len - sizeof(struct ethhdr) + 2) - 24);
-               if (!ptr)
-                       return _FAIL;
-               memcpy(ptr, get_rxmem(precvframe), 24);
-               ptr += 24;
-       } else {
-               ptr = recvframe_pull(precvframe, (rmv_len - sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0)));
-               if (!ptr)
-                       return _FAIL;
-       }
-
-       memcpy(ptr, pattrib->dst, ETH_ALEN);
-       memcpy(ptr + ETH_ALEN, pattrib->src, ETH_ALEN);
-
-       if (!bsnaphdr) {
-               be_tmp = htons(len);
-               memcpy(ptr + 12, &be_tmp, 2);
-       }
-
-       return ret;
-}
-
-/* perform defrag */
-static struct recv_frame *recvframe_defrag(struct adapter *adapter, struct __queue *defrag_q)
-{
-       struct list_head *plist, *phead;
-       u8 wlanhdr_offset;
-       u8      curfragnum;
-       struct recv_frame *pfhdr, *pnfhdr;
-       struct recv_frame *prframe, *pnextrframe;
-       struct __queue *pfree_recv_queue;
-
-       curfragnum = 0;
-       pfree_recv_queue = &adapter->recvpriv.free_recv_queue;
-
-       phead = get_list_head(defrag_q);
-       plist = phead->next;
-       pfhdr = container_of(plist, struct recv_frame, list);
-       prframe = (struct recv_frame *)pfhdr;
-       list_del_init(&prframe->list);
-
-       if (curfragnum != pfhdr->attrib.frag_num) {
-               /* the first fragment number must be 0 */
-               /* free the whole queue */
-               rtw_free_recvframe(prframe, pfree_recv_queue);
-               rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
-
-               return NULL;
-       }
-
-       curfragnum++;
-
-       plist = get_list_head(defrag_q);
-       plist = phead->next;
-       pfhdr = container_of(plist, struct recv_frame, list);
-       prframe = (struct recv_frame *)pfhdr;
-       list_del_init(&prframe->list);
-
-       plist = plist->next;
-
-       while (phead != plist) {
-               pnfhdr = container_of(plist, struct recv_frame, list);
-               pnextrframe = (struct recv_frame *)pnfhdr;
-
-               /* check the fragment sequence  (2nd ~n fragment frame) */
-
-               if (curfragnum != pnfhdr->attrib.frag_num) {
-                       /* the fragment number must be increasing  (after decache) */
-                       /* release the defrag_q & prframe */
-                       rtw_free_recvframe(prframe, pfree_recv_queue);
-                       rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
-                       return NULL;
-               }
-
-               curfragnum++;
-
-               /* copy the 2nd~n fragment frame's payload to the first fragment */
-               /* get the 2nd~last fragment frame's payload */
-
-               wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len;
-
-               recvframe_pull(pnextrframe, wlanhdr_offset);
-
-               /* append  to first fragment frame's tail (if privacy frame, pull the ICV) */
-               recvframe_pull_tail(prframe, pfhdr->attrib.icv_len);
-
-               /* memcpy */
-               memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len);
-
-               recvframe_put(prframe, pnfhdr->len);
-
-               pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len;
-               plist = plist->next;
-       }
-
-       /* free the defrag_q queue and return the prframe */
-       rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
-
-       return prframe;
-}
-
-/* check if need to defrag, if needed queue the frame to defrag_q */
-struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       u8      ismfrag;
-       u8      fragnum;
-       u8      *psta_addr;
-       struct recv_frame *pfhdr;
-       struct sta_info *psta;
-       struct sta_priv *pstapriv;
-       struct list_head *phead;
-       struct recv_frame *prtnframe = NULL;
-       struct __queue *pfree_recv_queue, *pdefrag_q;
-
-       pstapriv = &padapter->stapriv;
-
-       pfhdr = precv_frame;
-
-       pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
-
-       /* need to define struct of wlan header frame ctrl */
-       ismfrag = pfhdr->attrib.mfrag;
-       fragnum = pfhdr->attrib.frag_num;
-
-       psta_addr = pfhdr->attrib.ta;
-       psta = rtw_get_stainfo(pstapriv, psta_addr);
-       if (!psta) {
-               __le16 fc = *(__le16 *)pfhdr->rx_data;
-
-               if (ieee80211_is_data(fc)) {
-                       psta = rtw_get_bcmc_stainfo(padapter);
-                       pdefrag_q = &psta->sta_recvpriv.defrag_q;
-               } else {
-                       pdefrag_q = NULL;
-               }
-       } else {
-               pdefrag_q = &psta->sta_recvpriv.defrag_q;
-       }
-
-       if ((ismfrag == 0) && (fragnum == 0))
-               prtnframe = precv_frame;/* isn't a fragment frame */
-
-       if (ismfrag == 1) {
-               /* 0~(n-1) fragment frame */
-               /* enqueue to defraf_g */
-               if (pdefrag_q) {
-                       if (fragnum == 0) {
-                               /* the first fragment */
-                               if (!list_empty(&pdefrag_q->queue)) {
-                                       /* free current defrag_q */
-                                       rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue);
-                               }
-                       }
-
-                       /* Then enqueue the 0~(n-1) fragment into the defrag_q */
-
-                       phead = get_list_head(pdefrag_q);
-                       list_add_tail(&pfhdr->list, phead);
-
-                       prtnframe = NULL;
-               } else {
-                       /* can't find this ta's defrag_queue, so free this recv_frame */
-                       if (precv_frame && pfree_recv_queue)
-                               rtw_free_recvframe(precv_frame, pfree_recv_queue);
-                       prtnframe = NULL;
-               }
-       }
-
-       if ((ismfrag == 0) && (fragnum != 0)) {
-               /* the last fragment frame */
-               /* enqueue the last fragment */
-               if (pdefrag_q) {
-                       phead = get_list_head(pdefrag_q);
-                       list_add_tail(&pfhdr->list, phead);
-
-                       /* call recvframe_defrag to defrag */
-                       precv_frame = recvframe_defrag(padapter, pdefrag_q);
-                       prtnframe = precv_frame;
-               } else {
-                       /* can't find this ta's defrag_queue, so free this recv_frame */
-                       if (precv_frame && pfree_recv_queue)
-                               rtw_free_recvframe(precv_frame, pfree_recv_queue);
-                       prtnframe = NULL;
-               }
-       }
-
-       if (prtnframe && prtnframe->attrib.privacy) {
-               /* after defrag we must check tkip mic code */
-               if (recvframe_chkmic(padapter,  prtnframe) == _FAIL) {
-                       if (precv_frame && pfree_recv_queue)
-                               rtw_free_recvframe(prtnframe, pfree_recv_queue);
-                       prtnframe = NULL;
-               }
-       }
-
-       return prtnframe;
-}
-
-static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe)
-{
-       int     a_len, padding_len;
-       u16     eth_type, nSubframe_Length;
-       u8      nr_subframes, i;
-       unsigned char *pdata;
-       struct rx_pkt_attrib *pattrib;
-       struct sk_buff *sub_skb, *subframes[MAX_SUBFRAME_COUNT];
-
-       struct recv_priv *precvpriv = &padapter->recvpriv;
-       struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue;
-
-       nr_subframes = 0;
-
-       pattrib = &prframe->attrib;
-
-       recvframe_pull(prframe, prframe->attrib.hdrlen);
-
-       if (prframe->attrib.iv_len > 0)
-               recvframe_pull(prframe, prframe->attrib.iv_len);
-
-       a_len = prframe->len;
-
-       pdata = prframe->rx_data;
-
-       while (a_len > ETH_HLEN) {
-               /* Offset 12 denote 2 mac address */
-               nSubframe_Length = RTW_GET_BE16(pdata + 12);
-
-               if (a_len < ETH_HLEN + nSubframe_Length)
-                       goto exit;
-
-               /* move the data point to data content */
-               pdata += ETH_HLEN;
-               a_len -= ETH_HLEN;
-
-               /* Allocate new skb for releasing to upper layer */
-               sub_skb = dev_alloc_skb(nSubframe_Length + 12);
-               if (sub_skb) {
-                       skb_reserve(sub_skb, 12);
-                       skb_put_data(sub_skb, pdata, nSubframe_Length);
-               } else {
-                       sub_skb = skb_clone(prframe->pkt, GFP_ATOMIC);
-                       if (sub_skb) {
-                               sub_skb->data = pdata;
-                               sub_skb->len = nSubframe_Length;
-                               skb_set_tail_pointer(sub_skb, nSubframe_Length);
-                       } else {
-                               break;
-                       }
-               }
-
-               subframes[nr_subframes++] = sub_skb;
-
-               if (nr_subframes >= MAX_SUBFRAME_COUNT)
-                       break;
-
-               pdata += nSubframe_Length;
-               a_len -= nSubframe_Length;
-               if (a_len != 0) {
-                       padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & (4 - 1));
-                       if (padding_len == 4)
-                               padding_len = 0;
-
-                       if (a_len < padding_len)
-                               goto exit;
-
-                       pdata += padding_len;
-                       a_len -= padding_len;
-               }
-       }
-
-       for (i = 0; i < nr_subframes; i++) {
-               sub_skb = subframes[i];
-               /* convert hdr + possible LLC headers into Ethernet header */
-               eth_type = RTW_GET_BE16(&sub_skb->data[6]);
-               if (sub_skb->len >= 8 &&
-                   ((!memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) &&
-                         eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) ||
-                        !memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) {
-                       /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
-                       skb_pull(sub_skb, SNAP_SIZE);
-                       memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN);
-                       memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN);
-               } else {
-                       __be16 len;
-                       /* Leave Ethernet header part of hdr and full payload */
-                       len = htons(sub_skb->len);
-                       memcpy(skb_push(sub_skb, 2), &len, 2);
-                       memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN);
-                       memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN);
-               }
-
-               /* Indicate the packets to upper layer */
-                       /*  Insert NAT2.5 RX here! */
-               sub_skb->protocol = eth_type_trans(sub_skb, padapter->pnetdev);
-               sub_skb->dev = padapter->pnetdev;
-
-               sub_skb->ip_summed = CHECKSUM_NONE;
-
-               netif_rx(sub_skb);
-       }
-
-exit:
-
-       prframe->len = 0;
-       rtw_free_recvframe(prframe, pfree_recv_queue);/* free this recv_frame */
-
-       return _SUCCESS;
-}
-
-static bool check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
-{
-       u8      wsize = preorder_ctrl->wsize_b;
-       u16     wend = (preorder_ctrl->indicate_seq + wsize - 1) & 0xFFF;/*  4096; */
-
-       /*  Rx Reorder initialize condition. */
-       if (preorder_ctrl->indicate_seq == 0xFFFF)
-               preorder_ctrl->indicate_seq = seq_num;
-
-       /*  Drop out the packet which SeqNum is smaller than WinStart */
-       if (SN_LESS(seq_num, preorder_ctrl->indicate_seq))
-               return false;
-
-       /*  */
-       /*  Sliding window manipulation. Conditions includes: */
-       /*  1. Incoming SeqNum is equal to WinStart =>Window shift 1 */
-       /*  2. Incoming SeqNum is larger than the WinEnd => Window shift N */
-       /*  */
-       if (SN_EQUAL(seq_num, preorder_ctrl->indicate_seq)) {
-               preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF;
-       } else if (SN_LESS(wend, seq_num)) {
-               if (seq_num >= (wsize - 1))
-                       preorder_ctrl->indicate_seq = seq_num + 1 - wsize;
-               else
-                       preorder_ctrl->indicate_seq = 0xFFF - (wsize - (seq_num + 1)) + 1;
-       }
-
-       return true;
-}
-
-static bool enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, struct recv_frame *prframe)
-{
-       struct rx_pkt_attrib *pattrib = &prframe->attrib;
-       struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
-       struct list_head *phead, *plist;
-       struct recv_frame *hdr;
-       struct rx_pkt_attrib *pnextattrib;
-
-       phead = get_list_head(ppending_recvframe_queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               hdr = container_of(plist, struct recv_frame, list);
-               pnextattrib = &hdr->attrib;
-
-               if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
-                       plist = plist->next;
-               else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
-                       return false;
-               else
-                       break;
-       }
-
-       list_del_init(&prframe->list);
-
-       list_add_tail(&prframe->list, plist);
-       return true;
-}
-
-static int rtw_recv_indicatepkt(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       struct recv_priv *precvpriv;
-       struct __queue *pfree_recv_queue;
-       struct sk_buff *skb;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       precvpriv = &padapter->recvpriv;
-       pfree_recv_queue = &precvpriv->free_recv_queue;
-
-       skb = precv_frame->pkt;
-       if (!skb)
-               goto _recv_indicatepkt_drop;
-
-       skb->data = precv_frame->rx_data;
-
-       skb_set_tail_pointer(skb, precv_frame->len);
-
-       skb->len = precv_frame->len;
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               struct sk_buff *pskb2 = NULL;
-               struct sta_info *psta = NULL;
-               struct sta_priv *pstapriv = &padapter->stapriv;
-               struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
-               bool bmcast = is_multicast_ether_addr(pattrib->dst);
-
-               if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), ETH_ALEN)) {
-                       if (bmcast) {
-                               psta = rtw_get_bcmc_stainfo(padapter);
-                               pskb2 = skb_clone(skb, GFP_ATOMIC);
-                       } else {
-                               psta = rtw_get_stainfo(pstapriv, pattrib->dst);
-                       }
-
-                       if (psta) {
-                               struct net_device *pnetdev;
-
-                               pnetdev = (struct net_device *)padapter->pnetdev;
-                               skb->dev = pnetdev;
-                               skb_set_queue_mapping(skb, rtw_recv_select_queue(skb));
-
-                               rtw_xmit_entry(skb, pnetdev);
-
-                               if (bmcast)
-                                       skb = pskb2;
-                               else
-                                       goto _recv_indicatepkt_end;
-                       }
-               }
-       }
-
-       rcu_read_lock();
-       rcu_dereference(padapter->pnetdev->rx_handler_data);
-       rcu_read_unlock();
-
-       skb->ip_summed = CHECKSUM_NONE;
-       skb->dev = padapter->pnetdev;
-       skb->protocol = eth_type_trans(skb, padapter->pnetdev);
-
-       netif_rx(skb);
-
-_recv_indicatepkt_end:
-
-       /*  pointers to NULL before rtw_free_recvframe() */
-       precv_frame->pkt = NULL;
-
-       rtw_free_recvframe(precv_frame, pfree_recv_queue);
-
-       return _SUCCESS;
-
-_recv_indicatepkt_drop:
-
-       /* enqueue back to free_recv_queue */
-       rtw_free_recvframe(precv_frame, pfree_recv_queue);
-
-       return _FAIL;
-}
-
-static bool recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced)
-{
-       struct list_head *phead, *plist;
-       struct recv_frame *prframe;
-       struct rx_pkt_attrib *pattrib;
-       int bPktInBuf = false;
-       struct recv_priv *precvpriv = &padapter->recvpriv;
-       struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
-
-       phead =         get_list_head(ppending_recvframe_queue);
-       plist = phead->next;
-
-       /*  Handling some condition for forced indicate case. */
-       if (bforced) {
-               if (list_empty(phead))
-                       return true;
-
-               prframe = container_of(plist, struct recv_frame, list);
-               pattrib = &prframe->attrib;
-               preorder_ctrl->indicate_seq = pattrib->seq_num;
-       }
-
-       /*  Prepare indication list and indication. */
-       /*  Check if there is any packet need indicate. */
-       while (!list_empty(phead)) {
-               prframe = container_of(plist, struct recv_frame, list);
-               pattrib = &prframe->attrib;
-
-               if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) {
-                       plist = plist->next;
-                       list_del_init(&prframe->list);
-
-                       if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num))
-                               preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF;
-
-                       /* Set this as a lock to make sure that only one thread is indicating packet. */
-
-                       /* indicate this recv_frame */
-                       if (!pattrib->amsdu) {
-                               if ((!padapter->bDriverStopped) &&
-                                   (!padapter->bSurpriseRemoved))
-                                       rtw_recv_indicatepkt(padapter, prframe);/* indicate this recv_frame */
-                       } else if (pattrib->amsdu == 1) {
-                               if (amsdu_to_msdu(padapter, prframe) != _SUCCESS)
-                                       rtw_free_recvframe(prframe, &precvpriv->free_recv_queue);
-                       } else {
-                               /* error condition; */
-                       }
-
-                       /* Update local variables. */
-                       bPktInBuf = false;
-               } else {
-                       bPktInBuf = true;
-                       break;
-               }
-       }
-       return bPktInBuf;
-}
-
-static int recv_indicatepkt_reorder(struct adapter *padapter, struct recv_frame *prframe)
-{
-       int retval = _SUCCESS;
-       struct rx_pkt_attrib *pattrib = &prframe->attrib;
-       struct recv_reorder_ctrl *preorder_ctrl = prframe->preorder_ctrl;
-       struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
-
-       if (!pattrib->amsdu) {
-               /* s1. */
-               wlanhdr_to_ethhdr(prframe);
-
-               if (!pattrib->qos) {
-                       if (!padapter->bDriverStopped &&
-                           !padapter->bSurpriseRemoved) {
-                               rtw_recv_indicatepkt(padapter, prframe);
-                               return _SUCCESS;
-                       }
-
-                       return _FAIL;
-               }
-
-               if (!preorder_ctrl->enable) {
-                       /* indicate this recv_frame */
-                       preorder_ctrl->indicate_seq = pattrib->seq_num;
-                       rtw_recv_indicatepkt(padapter, prframe);
-
-                       preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) % 4096;
-                       return _SUCCESS;
-               }
-       } else if (pattrib->amsdu == 1) { /* temp filter -> means didn't support A-MSDUs in a A-MPDU */
-               if (!preorder_ctrl->enable) {
-                       preorder_ctrl->indicate_seq = pattrib->seq_num;
-                       retval = amsdu_to_msdu(padapter, prframe);
-
-                       preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) % 4096;
-                       return retval;
-               }
-       }
-
-       spin_lock_bh(&ppending_recvframe_queue->lock);
-
-       /* s2. check if winstart_b(indicate_seq) needs to been updated */
-       if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num))
-               goto _err_exit;
-
-       /* s3. Insert all packet into Reorder Queue to maintain its ordering. */
-       if (!enqueue_reorder_recvframe(preorder_ctrl, prframe))
-               goto _err_exit;
-
-       /* s4. */
-       /*  Indication process. */
-       /*  After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets */
-       /*  with the SeqNum smaller than latest WinStart and buffer other packets. */
-       /*  */
-       /*  For Rx Reorder condition: */
-       /*  1. All packets with SeqNum smaller than WinStart => Indicate */
-       /*  2. All packets with SeqNum larger than or equal to WinStart => Buffer it. */
-       /*  */
-
-       /* recv_indicatepkts_in_order(padapter, preorder_ctrl, true); */
-       if (recv_indicatepkts_in_order(padapter, preorder_ctrl, false)) {
-               _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME);
-               spin_unlock_bh(&ppending_recvframe_queue->lock);
-       } else {
-               spin_unlock_bh(&ppending_recvframe_queue->lock);
-               _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
-       }
-
-       return _SUCCESS;
-
-_err_exit:
-
-       spin_unlock_bh(&ppending_recvframe_queue->lock);
-
-       return _FAIL;
-}
-
-void rtw_reordering_ctrl_timeout_handler(void *pcontext)
-{
-       struct recv_reorder_ctrl *preorder_ctrl = (struct recv_reorder_ctrl *)pcontext;
-       struct adapter *padapter = preorder_ctrl->padapter;
-       struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
-
-       if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
-               return;
-
-       spin_lock_bh(&ppending_recvframe_queue->lock);
-
-       if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true))
-               _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME);
-
-       spin_unlock_bh(&ppending_recvframe_queue->lock);
-}
-
-static int process_recv_indicatepkts(struct adapter *padapter, struct recv_frame *prframe)
-{
-       int retval = _SUCCESS;
-       /* struct recv_priv *precvpriv = &padapter->recvpriv; */
-       /* struct rx_pkt_attrib *pattrib = &prframe->attrib; */
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct ht_priv  *phtpriv = &pmlmepriv->htpriv;
-
-       if (phtpriv->ht_option) {  /* B/G/N Mode */
-               /* prframe->preorder_ctrl = &precvpriv->recvreorder_ctrl[pattrib->priority]; */
-
-               if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) {
-                       /*  including perform A-MPDU Rx Ordering Buffer Control */
-                       if ((!padapter->bDriverStopped) &&
-                           (!padapter->bSurpriseRemoved)) {
-                               retval = _FAIL;
-                               return retval;
-                       }
-               }
-       } else { /* B/G mode */
-               retval = wlanhdr_to_ethhdr(prframe);
-               if (retval != _SUCCESS)
-                       return retval;
-
-               if ((!padapter->bDriverStopped) &&
-                   (!padapter->bSurpriseRemoved)) {
-                       /* indicate this recv_frame */
-                       rtw_recv_indicatepkt(padapter, prframe);
-               } else {
-                       retval = _FAIL;
-                       return retval;
-               }
-       }
-
-       return retval;
-}
-
-static int recv_func_prehandle(struct adapter *padapter, struct recv_frame *rframe)
-{
-       int ret = _SUCCESS;
-       struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
-
-       /* check the frame crtl field and decache */
-       ret = validate_recv_frame(padapter, rframe);
-       if (ret != _SUCCESS)
-               rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */
-
-       return ret;
-}
-
-static int recv_func_posthandle(struct adapter *padapter, struct recv_frame *prframe)
-{
-       int ret = _SUCCESS;
-       struct recv_frame *orig_prframe = prframe;
-       struct recv_priv *precvpriv = &padapter->recvpriv;
-       struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
-
-       /*  DATA FRAME */
-       rtw_led_control(padapter, LED_CTL_RX);
-
-       prframe = decryptor(padapter, prframe);
-       if (!prframe) {
-               ret = _FAIL;
-               goto _recv_data_drop;
-       }
-
-       prframe = recvframe_chk_defrag(padapter, prframe);
-       if (!prframe)
-               goto _recv_data_drop;
-
-       prframe = portctrl(padapter, prframe);
-       if (!prframe) {
-               ret = _FAIL;
-               goto _recv_data_drop;
-       }
-
-       count_rx_stats(padapter, prframe, NULL);
-
-       ret = process_recv_indicatepkts(padapter, prframe);
-       if (ret != _SUCCESS) {
-               rtw_free_recvframe(orig_prframe, pfree_recv_queue);/* free this recv_frame */
-               goto _recv_data_drop;
-       }
-       return ret;
-
-_recv_data_drop:
-       precvpriv->rx_drop++;
-       return ret;
-}
-
-static int recv_func(struct adapter *padapter, struct recv_frame *rframe)
-{
-       int ret;
-       struct rx_pkt_attrib *prxattrib = &rframe->attrib;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct mlme_priv *mlmepriv = &padapter->mlmepriv;
-       struct recv_priv *recvpriv = &padapter->recvpriv;
-
-       /* check if need to handle uc_swdec_pending_queue*/
-       if (check_fwstate(mlmepriv, WIFI_STATION_STATE) &&
-           psecuritypriv->busetkipkey) {
-               struct recv_frame *pending_frame;
-
-               while ((pending_frame = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue)))
-                       recv_func_posthandle(padapter, pending_frame);
-       }
-
-       ret = recv_func_prehandle(padapter, rframe);
-
-       if (ret == _SUCCESS) {
-               /* check if need to enqueue into uc_swdec_pending_queue*/
-               if (check_fwstate(mlmepriv, WIFI_STATION_STATE) &&
-                   !is_multicast_ether_addr(prxattrib->ra) && prxattrib->encrypt > 0 &&
-                   (prxattrib->bdecrypted == 0 || psecuritypriv->sw_decrypt) &&
-                    psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPAPSK &&
-                    !psecuritypriv->busetkipkey) {
-                       rtw_enqueue_recvframe(rframe, &padapter->recvpriv.uc_swdec_pending_queue);
-                       if (recvpriv->free_recvframe_cnt < NR_RECVFRAME / 4) {
-                               /*
-                                * to prevent from recvframe starvation,
-                                * get recvframe from uc_swdec_pending_queue to
-                                * free_recvframe_cnt
-                                */
-                               rframe = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue);
-                               if (rframe)
-                                       goto do_posthandle;
-                       }
-                       goto exit;
-               }
-do_posthandle:
-               ret = recv_func_posthandle(padapter, rframe);
-       }
-
-exit:
-       return ret;
-}
-
-s32 rtw_recv_entry(struct recv_frame *precvframe)
-{
-       struct adapter *padapter;
-       struct recv_priv *precvpriv;
-       s32 ret = _SUCCESS;
-
-       padapter = precvframe->adapter;
-
-       precvpriv = &padapter->recvpriv;
-
-       ret = recv_func(padapter, precvframe);
-       if (ret == _FAIL)
-               goto _recv_entry_drop;
-
-       precvpriv->rx_pkts++;
-
-       return ret;
-
-_recv_entry_drop:
-
-       return ret;
-}
-
-static void rtw_signal_stat_timer_hdl(struct timer_list *t)
-{
-       struct adapter *adapter = from_timer(adapter, t, recvpriv.signal_stat_timer);
-       struct recv_priv *recvpriv = &adapter->recvpriv;
-
-       u32 tmp_s, tmp_q;
-       u8 avg_signal_strength = 0;
-       u8 avg_signal_qual = 0;
-       u8 _alpha = 3; /*  this value is based on converging_constant = 5000 and sampling_interval = 1000 */
-
-       if (adapter->recvpriv.is_signal_dbg) {
-               /* update the user specific value, signal_strength_dbg, to signal_strength, rssi */
-               adapter->recvpriv.signal_strength = adapter->recvpriv.signal_strength_dbg;
-               adapter->recvpriv.rssi = (s8)translate_percentage_to_dbm((u8)adapter->recvpriv.signal_strength_dbg);
-       } else {
-               if (recvpriv->signal_strength_data.update_req == 0) {/*  update_req is clear, means we got rx */
-                       avg_signal_strength = recvpriv->signal_strength_data.avg_val;
-                       /*  after avg_vals are acquired, we can re-stat the signal values */
-                       recvpriv->signal_strength_data.update_req = 1;
-               }
-
-               if (recvpriv->signal_qual_data.update_req == 0) {/*  update_req is clear, means we got rx */
-                       avg_signal_qual = recvpriv->signal_qual_data.avg_val;
-                       /*  after avg_vals are acquired, we can re-stat the signal values */
-                       recvpriv->signal_qual_data.update_req = 1;
-               }
-
-               /* update value of signal_strength, rssi, signal_qual */
-               if (!check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY)) {
-                       tmp_s = (avg_signal_strength + (_alpha - 1) * recvpriv->signal_strength);
-                       if (tmp_s % _alpha)
-                               tmp_s = tmp_s / _alpha + 1;
-                       else
-                               tmp_s = tmp_s / _alpha;
-                       if (tmp_s > 100)
-                               tmp_s = 100;
-
-                       tmp_q = (avg_signal_qual + (_alpha - 1) * recvpriv->signal_qual);
-                       if (tmp_q % _alpha)
-                               tmp_q = tmp_q / _alpha + 1;
-                       else
-                               tmp_q = tmp_q / _alpha;
-                       if (tmp_q > 100)
-                               tmp_q = 100;
-
-                       recvpriv->signal_strength = tmp_s;
-                       recvpriv->rssi = (s8)translate_percentage_to_dbm(tmp_s);
-                       recvpriv->signal_qual = tmp_q;
-               }
-       }
-       rtw_set_signal_stat_timer(recvpriv);
-}
diff --git a/drivers/staging/r8188eu/core/rtw_rf.c b/drivers/staging/r8188eu/core/rtw_rf.c
deleted file mode 100644 (file)
index 2d2f0fc..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/drv_types.h"
-
-static const u32 ch_freq_map[] = {
-       2412,
-       2417,
-       2422,
-       2427,
-       2432,
-       2437,
-       2442,
-       2447,
-       2452,
-       2457,
-       2462,
-       2467,
-       2472,
-       2484
-};
-
-u32 rtw_ch2freq(u32 channel)
-{
-       if (channel == 0 || channel > ARRAY_SIZE(ch_freq_map))
-               return 2412;
-
-       return ch_freq_map[channel - 1];
-}
diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c
deleted file mode 100644 (file)
index 780019c..0000000
+++ /dev/null
@@ -1,1374 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define  _RTW_SECURITY_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/wifi.h"
-#include "../include/osdep_intf.h"
-
-/* WEP related ===== */
-
-/*
-       Need to consider the fragment  situation
-*/
-void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
-{      /*  exclude ICV */
-       union {
-               __le32 f0;
-               u8 f1[4];
-       } crc;
-
-       int     curfragnum, length;
-       u32     keylength;
-
-       u8      *pframe, *payload, *iv;    /* wepkey */
-       u8      wepkey[16];
-       u8   hw_hdr_offset = 0;
-       struct  pkt_attrib       *pattrib = &pxmitframe->attrib;
-       struct  security_priv   *psecuritypriv = &padapter->securitypriv;
-       struct  xmit_priv               *pxmitpriv = &padapter->xmitpriv;
-       struct arc4_ctx *ctx = &psecuritypriv->xmit_arc4_ctx;
-
-       if (!pxmitframe->buf_addr)
-               return;
-
-       hw_hdr_offset = TXDESC_SIZE + pxmitframe->pkt_offset * PACKET_OFFSET_SZ;
-       pframe = pxmitframe->buf_addr + hw_hdr_offset;
-
-       /* start to encrypt each fragment */
-       if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) {
-               keylength = psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex];
-
-               for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
-                       iv = pframe + pattrib->hdrlen;
-                       memcpy(&wepkey[0], iv, 3);
-                       memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength);
-                       payload = pframe + pattrib->iv_len + pattrib->hdrlen;
-
-                       if ((curfragnum + 1) == pattrib->nr_frags) {    /* the last fragment */
-                               length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
-
-                               crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length));
-
-                               arc4_setkey(ctx, wepkey, 3 + keylength);
-                               arc4_crypt(ctx, payload, payload, length);
-                               arc4_crypt(ctx, payload + length, crc.f1, 4);
-                       } else {
-                               length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
-                               crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length));
-                               arc4_setkey(ctx, wepkey, 3 + keylength);
-                               arc4_crypt(ctx, payload, payload, length);
-                               arc4_crypt(ctx, payload + length, crc.f1, 4);
-
-                               pframe += pxmitpriv->frag_len;
-                               pframe = PTR_ALIGN(pframe, 4);
-                       }
-               }
-       }
-
-}
-
-void rtw_wep_decrypt(struct adapter *padapter, struct recv_frame *precvframe)
-{
-       /*  exclude ICV */
-       int     length;
-       u32     keylength;
-       u8      *pframe, *payload, *iv, wepkey[16];
-       u8       keyindex;
-       struct  rx_pkt_attrib    *prxattrib = &precvframe->attrib;
-       struct  security_priv   *psecuritypriv = &padapter->securitypriv;
-       struct arc4_ctx *ctx = &psecuritypriv->recv_arc4_ctx;
-
-       pframe = precvframe->rx_data;
-
-       /* start to decrypt recvframe */
-       if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) {
-               iv = pframe + prxattrib->hdrlen;
-               keyindex = prxattrib->key_index;
-               keylength = psecuritypriv->dot11DefKeylen[keyindex];
-               memcpy(&wepkey[0], iv, 3);
-               memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength);
-               length = precvframe->len - prxattrib->hdrlen - prxattrib->iv_len;
-
-               payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
-
-               /* decrypt payload include icv */
-               arc4_setkey(ctx, wepkey, 3 + keylength);
-               arc4_crypt(ctx, payload, payload, length);
-       }
-}
-
-/* 3           ===== TKIP related ===== */
-
-static u32 secmicgetuint32(u8 *p)
-/*  Convert from Byte[] to Us3232 in a portable way */
-{
-       s32 i;
-       u32 res = 0;
-
-       for (i = 0; i < 4; i++)
-               res |= ((u32)(*p++)) << (8 * i);
-
-       return res;
-}
-
-static void secmicputuint32(u8 *p, u32 val)
-/*  Convert from Us3232 to Byte[] in a portable way */
-{
-       long i;
-
-       for (i = 0; i < 4; i++) {
-               *p++ = (u8)(val & 0xff);
-               val >>= 8;
-       }
-
-}
-
-static void secmicclear(struct mic_data *pmicdata)
-{
-/*  Reset the state to the empty message. */
-
-       pmicdata->L = pmicdata->K0;
-       pmicdata->R = pmicdata->K1;
-       pmicdata->nBytesInM = 0;
-       pmicdata->M = 0;
-
-}
-
-void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key)
-{
-       /*  Set the key */
-
-       pmicdata->K0 = secmicgetuint32(key);
-       pmicdata->K1 = secmicgetuint32(key + 4);
-       /*  and reset the message */
-       secmicclear(pmicdata);
-
-}
-
-void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b)
-{
-
-       /*  Append the byte to our word-sized buffer */
-       pmicdata->M |= ((unsigned long)b) << (8 * pmicdata->nBytesInM);
-       pmicdata->nBytesInM++;
-       /*  Process the word if it is full. */
-       if (pmicdata->nBytesInM >= 4) {
-               pmicdata->L ^= pmicdata->M;
-               pmicdata->R ^= ROL32(pmicdata->L, 17);
-               pmicdata->L += pmicdata->R;
-               pmicdata->R ^= ((pmicdata->L & 0xff00ff00) >> 8) | ((pmicdata->L & 0x00ff00ff) << 8);
-               pmicdata->L += pmicdata->R;
-               pmicdata->R ^= ROL32(pmicdata->L, 3);
-               pmicdata->L += pmicdata->R;
-               pmicdata->R ^= ROR32(pmicdata->L, 2);
-               pmicdata->L += pmicdata->R;
-               /*  Clear the buffer */
-               pmicdata->M = 0;
-               pmicdata->nBytesInM = 0;
-       }
-
-}
-
-void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nbytes)
-{
-
-       /*  This is simple */
-       while (nbytes > 0) {
-               rtw_secmicappendbyte(pmicdata, *src++);
-               nbytes--;
-       }
-
-}
-
-void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst)
-{
-
-       /*  Append the minimum padding */
-       rtw_secmicappendbyte(pmicdata, 0x5a);
-       rtw_secmicappendbyte(pmicdata, 0);
-       rtw_secmicappendbyte(pmicdata, 0);
-       rtw_secmicappendbyte(pmicdata, 0);
-       rtw_secmicappendbyte(pmicdata, 0);
-       /*  and then zeroes until the length is a multiple of 4 */
-       while (pmicdata->nBytesInM != 0)
-               rtw_secmicappendbyte(pmicdata, 0);
-       /*  The appendByte function has already computed the result. */
-       secmicputuint32(dst, pmicdata->L);
-       secmicputuint32(dst + 4, pmicdata->R);
-       /*  Reset to the empty message. */
-       secmicclear(pmicdata);
-
-}
-
-void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_code, u8 pri)
-{
-       struct mic_data micdata;
-       u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
-
-       rtw_secmicsetkey(&micdata, key);
-       priority[0] = pri;
-
-       /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
-       if (header[1] & 1) {   /* ToDS == 1 */
-               rtw_secmicappend(&micdata, &header[16], 6);  /* DA */
-               if (header[1] & 2)  /* From Ds == 1 */
-                       rtw_secmicappend(&micdata, &header[24], 6);
-               else
-                       rtw_secmicappend(&micdata, &header[10], 6);
-       } else {        /* ToDS == 0 */
-               rtw_secmicappend(&micdata, &header[4], 6);   /* DA */
-               if (header[1] & 2)  /* From Ds == 1 */
-                       rtw_secmicappend(&micdata, &header[16], 6);
-               else
-                       rtw_secmicappend(&micdata, &header[10], 6);
-       }
-       rtw_secmicappend(&micdata, &priority[0], 4);
-
-       rtw_secmicappend(&micdata, data, data_len);
-
-       rtw_secgetmic(&micdata, mic_code);
-
-}
-
-/* macros for extraction/creation of unsigned char/unsigned short values  */
-#define RotR1(v16)   ((((v16) >> 1) & 0x7FFF) ^ (((v16) & 1) << 15))
-#define   Lo8(v16)   ((u8)((v16)       & 0x00FF))
-#define   Hi8(v16)   ((u8)(((v16) >> 8) & 0x00FF))
-#define  Lo16(v32)   ((u16)((v32)       & 0xFFFF))
-#define  Hi16(v32)   ((u16)(((v32) >> 16) & 0xFFFF))
-#define  Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8))
-
-/* select the Nth 16-bit word of the temporal key unsigned char array TK[]   */
-#define  TK16(N)     Mk16(tk[2 * (N) + 1], tk[2 * (N)])
-
-/* S-box lookup: 16 bits --> 16 bits */
-#define _S_(v16)     (Sbox1[0][Lo8(v16)] ^ Sbox1[1][Hi8(v16)])
-
-/* fixed algorithm "parameters" */
-#define PHASE1_LOOP_CNT   8    /* this needs to be "big enough"     */
-#define TA_SIZE           6    /*  48-bit transmitter address       */
-#define TK_SIZE          16    /* 128-bit temporal key       */
-#define P1K_SIZE        10    /*  80-bit Phase1 key            */
-#define RC4_KEY_SIZE     16    /* 128-bit RC4KEY (104 bits unknown) */
-
-/* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */
-static const unsigned short Sbox1[2][256] = {  /* Sbox for hash (can be in ROM)     */
-{
-   0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
-   0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A,
-   0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B,
-   0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B,
-   0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F,
-   0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F,
-   0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5,
-   0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F,
-   0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB,
-   0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397,
-   0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED,
-   0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A,
-   0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194,
-   0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3,
-   0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104,
-   0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D,
-   0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39,
-   0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695,
-   0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83,
-   0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76,
-   0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4,
-   0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B,
-   0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0,
-   0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018,
-   0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751,
-   0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85,
-   0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12,
-   0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9,
-   0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7,
-   0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A,
-   0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8,
-   0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A,
-  },
-
-  {  /* second half of table is unsigned char-reversed version of first! */
-   0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491,
-   0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC,
-   0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB,
-   0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B,
-   0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83,
-   0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A,
-   0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F,
-   0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA,
-   0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B,
-   0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713,
-   0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6,
-   0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85,
-   0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411,
-   0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B,
-   0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1,
-   0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF,
-   0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E,
-   0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6,
-   0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B,
-   0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD,
-   0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8,
-   0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2,
-   0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049,
-   0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810,
-   0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197,
-   0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F,
-   0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C,
-   0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927,
-   0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733,
-   0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5,
-   0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0,
-   0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C,
-  }
-};
-
- /*
-**********************************************************************
-* Routine: Phase 1 -- generate P1K, given TA, TK, IV32
-*
-* Inputs:
-*     tk[]      = temporal key                  [128 bits]
-*     ta[]      = transmitter's MAC address        [ 48 bits]
-*     iv32      = upper 32 bits of IV            [ 32 bits]
-* Output:
-*     p1k[]     = Phase 1 key                    [ 80 bits]
-*
-* Note:
-*     This function only needs to be called every 2**16 packets,
-*     although in theory it could be called every packet.
-*
-**********************************************************************
-*/
-static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
-{
-       int  i;
-
-       /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5]     */
-       p1k[0]      = Lo16(iv32);
-       p1k[1]      = Hi16(iv32);
-       p1k[2]      = Mk16(ta[1], ta[0]); /* use TA[] as little-endian */
-       p1k[3]      = Mk16(ta[3], ta[2]);
-       p1k[4]      = Mk16(ta[5], ta[4]);
-
-       /* Now compute an unbalanced Feistel cipher with 80-bit block */
-       /* size on the 80-bit block P1K[], using the 128-bit key TK[] */
-       for (i = 0; i < PHASE1_LOOP_CNT; i++) { /* Each add operation here is mod 2**16 */
-               p1k[0] += _S_(p1k[4] ^ TK16((i & 1) + 0));
-               p1k[1] += _S_(p1k[0] ^ TK16((i & 1) + 2));
-               p1k[2] += _S_(p1k[1] ^ TK16((i & 1) + 4));
-               p1k[3] += _S_(p1k[2] ^ TK16((i & 1) + 6));
-               p1k[4] += _S_(p1k[3] ^ TK16((i & 1) + 0));
-               p1k[4] +=  (unsigned short)i;   /* avoid "slide attacks" */
-       }
-
-}
-
-/*
-**********************************************************************
-* Routine: Phase 2 -- generate RC4KEY, given TK, P1K, IV16
-*
-* Inputs:
-*     tk[]      = Temporal key                  [128 bits]
-*     p1k[]     = Phase 1 output key              [ 80 bits]
-*     iv16      = low 16 bits of IV counter        [ 16 bits]
-* Output:
-*     rc4key[]  = the key used to encrypt the packet   [128 bits]
-*
-* Note:
-*     The value {TA, IV32, IV16} for Phase1/Phase2 must be unique
-*     across all packets using the same key TK value. Then, for a
-*     given value of TK[], this TKIP48 construction guarantees that
-*     the final RC4KEY value is unique across all packets.
-*
-* Suggested implementation optimization: if PPK[] is "overlaid"
-*     appropriately on RC4KEY[], there is no need for the final
-*     for loop below that copies the PPK[] result into RC4KEY[].
-*
-**********************************************************************
-*/
-static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)
-{
-       int  i;
-       u16 PPK[6];                     /* temporary key for mixing    */
-
-       /* Note: all adds in the PPK[] equations below are mod 2**16     */
-       for (i = 0; i < 5; i++)
-               PPK[i] = p1k[i];        /* first, copy P1K to PPK      */
-       PPK[5]  =  p1k[4] + iv16;       /* next,  add in IV16     */
-
-       /* Bijective non-linear mixing of the 96 bits of PPK[0..5]         */
-       PPK[0] +=    _S_(PPK[5] ^ TK16(0));   /* Mix key in each "round"     */
-       PPK[1] +=    _S_(PPK[0] ^ TK16(1));
-       PPK[2] +=    _S_(PPK[1] ^ TK16(2));
-       PPK[3] +=    _S_(PPK[2] ^ TK16(3));
-       PPK[4] +=    _S_(PPK[3] ^ TK16(4));
-       PPK[5] +=    _S_(PPK[4] ^ TK16(5));   /* Total # S-box lookups == 6  */
-
-       /* Final sweep: bijective, "linear". Rotates kill LSB correlations   */
-       PPK[0] +=  RotR1(PPK[5] ^ TK16(6));
-       PPK[1] +=  RotR1(PPK[0] ^ TK16(7));   /* Use all of TK[] in Phase2   */
-       PPK[2] +=  RotR1(PPK[1]);
-       PPK[3] +=  RotR1(PPK[2]);
-       PPK[4] +=  RotR1(PPK[3]);
-       PPK[5] +=  RotR1(PPK[4]);
-       /* Note: At this point, for a given key TK[0..15], the 96-bit output */
-       /*       value PPK[0..5] is guaranteed to be unique, as a function   */
-       /*       of the 96-bit "input" value   {TA, IV32, IV16}. That is, P1K  */
-       /*       is now a keyed permutation of {TA, IV32, IV16}.               */
-
-       /* Set RC4KEY[0..3], which includes "cleartext" portion of RC4 key   */
-       rc4key[0] = Hi8(iv16);          /* RC4KEY[0..2] is the WEP IV  */
-       rc4key[1] = (Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys  */
-       rc4key[2] = Lo8(iv16);
-       rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1);
-
-       /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15]  (little-endian)       */
-       for (i = 0; i < 6; i++) {
-               rc4key[4 + 2 * i] = Lo8(PPK[i]);
-               rc4key[5 + 2 * i] = Hi8(PPK[i]);
-       }
-
-}
-
-/* The hlen isn't include the IV */
-u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
-{                                                                                                                                      /*  exclude ICV */
-       u16     pnl;
-       u32     pnh;
-       u8      rc4key[16];
-       u8   ttkey[16];
-       union {
-               __le32 f0;
-               u8 f1[4];
-       } crc;
-       u8   hw_hdr_offset = 0;
-       int                     curfragnum, length;
-
-       u8      *pframe, *payload, *iv, *prwskey;
-       union pn48 dot11txpn;
-       struct  sta_info                *stainfo;
-       struct  pkt_attrib       *pattrib = &pxmitframe->attrib;
-       struct  security_priv   *psecuritypriv = &padapter->securitypriv;
-       struct  xmit_priv               *pxmitpriv = &padapter->xmitpriv;
-       struct arc4_ctx *ctx = &psecuritypriv->xmit_arc4_ctx;
-       u32     res = _SUCCESS;
-
-       if (!pxmitframe->buf_addr)
-               return _FAIL;
-
-       hw_hdr_offset = TXDESC_SIZE + pxmitframe->pkt_offset * PACKET_OFFSET_SZ;
-       pframe = pxmitframe->buf_addr + hw_hdr_offset;
-
-       /* 4 start to encrypt each fragment */
-       if (pattrib->encrypt == _TKIP_) {
-               if (pattrib->psta)
-                       stainfo = pattrib->psta;
-               else
-                       stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]);
-
-               if (stainfo) {
-                       if (is_multicast_ether_addr(pattrib->ra))
-                               prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
-                       else
-                               prwskey = &stainfo->dot118021x_UncstKey.skey[0];
-
-                       for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
-                               iv = pframe + pattrib->hdrlen;
-                               payload = pframe + pattrib->iv_len + pattrib->hdrlen;
-
-                               GET_TKIP_PN(iv, dot11txpn);
-
-                               pnl = (u16)(dot11txpn.val);
-                               pnh = (u32)(dot11txpn.val >> 16);
-                               phase1((u16 *)&ttkey[0], prwskey, &pattrib->ta[0], pnh);
-                               phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl);
-
-                               if ((curfragnum + 1) == pattrib->nr_frags) {    /* 4 the last fragment */
-                                       length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
-                                       crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length));
-
-                                       arc4_setkey(ctx, rc4key, 16);
-                                       arc4_crypt(ctx, payload, payload, length);
-                                       arc4_crypt(ctx, payload + length, crc.f1, 4);
-                               } else {
-                                       length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
-                                       crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length));
-
-                                       arc4_setkey(ctx, rc4key, 16);
-                                       arc4_crypt(ctx, payload, payload, length);
-                                       arc4_crypt(ctx, payload + length, crc.f1, 4);
-
-                                       pframe += pxmitpriv->frag_len;
-                                       pframe = PTR_ALIGN(pframe, 4);
-                               }
-                       }
-               } else {
-                       res = _FAIL;
-               }
-       }
-
-       return res;
-}
-
-/* The hlen isn't include the IV */
-u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe)
-{                                                                                                                                      /*  exclude ICV */
-       u16 pnl;
-       u32 pnh;
-       u8   rc4key[16];
-       u8   ttkey[16];
-       union {
-               __le32 f0;
-               u8 f1[4];
-       } crc;
-       int                     length;
-
-       u8      *pframe, *payload, *iv, *prwskey;
-       union pn48 dot11txpn;
-       struct  sta_info                *stainfo;
-       struct  rx_pkt_attrib    *prxattrib = &precvframe->attrib;
-       struct  security_priv   *psecuritypriv = &padapter->securitypriv;
-       struct arc4_ctx *ctx = &psecuritypriv->recv_arc4_ctx;
-       u32             res = _SUCCESS;
-
-       pframe = precvframe->rx_data;
-
-       /* 4 start to decrypt recvframe */
-       if (prxattrib->encrypt == _TKIP_) {
-               stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
-               if (stainfo) {
-                       if (is_multicast_ether_addr(prxattrib->ra)) {
-                               if (!psecuritypriv->binstallGrpkey) {
-                                       res = _FAIL;
-                                       goto exit;
-                               }
-                               prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
-                       } else {
-                               prwskey = &stainfo->dot118021x_UncstKey.skey[0];
-                       }
-
-                       iv = pframe + prxattrib->hdrlen;
-                       payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
-                       length = precvframe->len - prxattrib->hdrlen - prxattrib->iv_len;
-
-                       GET_TKIP_PN(iv, dot11txpn);
-
-                       pnl = (u16)(dot11txpn.val);
-                       pnh = (u32)(dot11txpn.val >> 16);
-
-                       phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh);
-                       phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl);
-
-                       /* 4 decrypt payload include icv */
-
-                       arc4_setkey(ctx, rc4key, 16);
-                       arc4_crypt(ctx, payload, payload, length);
-
-                       crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length));
-
-                       if (crc.f1[3] != payload[length - 1] ||
-                           crc.f1[2] != payload[length - 2] ||
-                           crc.f1[1] != payload[length - 3] ||
-                           crc.f1[0] != payload[length - 4])
-                               res = _FAIL;
-               } else {
-                       res = _FAIL;
-               }
-       }
-
-exit:
-       return res;
-}
-
-/* 3                   ===== AES related ===== */
-
-#define MAX_MSG_SIZE   2048
-/*****************************/
-/******** SBOX Table *********/
-/*****************************/
-
-static  u8 sbox_table[256] = {
-       0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
-       0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
-       0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
-       0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
-       0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
-       0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
-       0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
-       0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
-       0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
-       0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
-       0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
-       0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
-       0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
-       0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
-       0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
-       0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
-       0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
-       0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
-       0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
-       0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
-       0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
-       0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
-       0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
-       0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
-       0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
-       0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
-       0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
-       0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
-       0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
-       0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
-       0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
-       0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
-};
-
-/*****************************/
-/**** Function Prototypes ****/
-/*****************************/
-
-static void bitwise_xor(u8 *ina, u8 *inb, u8 *out);
-static void construct_mic_iv(u8 *mic_header1, int qc_exists, int a4_exists, u8 *mpdu, uint payload_length, u8 *pn_vector);
-static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu);
-static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists);
-static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c);
-static void xor_128(u8 *a, u8 *b, u8 *out);
-static void xor_32(u8 *a, u8 *b, u8 *out);
-static u8 sbox(u8 a);
-static void next_key(u8 *key, int round);
-static void byte_sub(u8 *in, u8 *out);
-static void shift_row(u8 *in, u8 *out);
-static void mix_column(u8 *in, u8 *out);
-static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext);
-
-/****************************************/
-/* aes128k128d()                       */
-/* Performs a 128 bit AES encrypt with  */
-/* 128 bit data.                       */
-/****************************************/
-static void xor_128(u8 *a, u8 *b, u8 *out)
-{
-       int i;
-
-       for (i = 0; i < 16; i++)
-               out[i] = a[i] ^ b[i];
-
-}
-
-static void xor_32(u8 *a, u8 *b, u8 *out)
-{
-       int i;
-
-       for (i = 0; i < 4; i++)
-               out[i] = a[i] ^ b[i];
-
-}
-
-static u8 sbox(u8 a)
-{
-       return sbox_table[(int)a];
-}
-
-static void next_key(u8 *key, int round)
-{
-       u8 rcon;
-       u8 sbox_key[4];
-       u8 rcon_table[12] = {
-               0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
-               0x1b, 0x36, 0x36, 0x36
-       };
-
-       sbox_key[0] = sbox(key[13]);
-       sbox_key[1] = sbox(key[14]);
-       sbox_key[2] = sbox(key[15]);
-       sbox_key[3] = sbox(key[12]);
-
-       rcon = rcon_table[round];
-
-       xor_32(&key[0], sbox_key, &key[0]);
-       key[0] = key[0] ^ rcon;
-
-       xor_32(&key[4], &key[0], &key[4]);
-       xor_32(&key[8], &key[4], &key[8]);
-       xor_32(&key[12], &key[8], &key[12]);
-
-}
-
-static void byte_sub(u8 *in, u8 *out)
-{
-       int i;
-
-       for (i = 0; i < 16; i++)
-               out[i] = sbox(in[i]);
-
-}
-
-static void shift_row(u8 *in, u8 *out)
-{
-
-       out[0] =  in[0];
-       out[1] =  in[5];
-       out[2] =  in[10];
-       out[3] =  in[15];
-       out[4] =  in[4];
-       out[5] =  in[9];
-       out[6] =  in[14];
-       out[7] =  in[3];
-       out[8] =  in[8];
-       out[9] =  in[13];
-       out[10] = in[2];
-       out[11] = in[7];
-       out[12] = in[12];
-       out[13] = in[1];
-       out[14] = in[6];
-       out[15] = in[11];
-
-}
-
-static void mix_column(u8 *in, u8 *out)
-{
-       int i;
-       u8 add1b[4];
-       u8 add1bf7[4];
-       u8 rotl[4];
-       u8 swap_halfs[4];
-       u8 andf7[4];
-       u8 rotr[4];
-       u8 temp[4];
-       u8 tempb[4];
-
-       for (i = 0 ; i < 4; i++) {
-               if ((in[i] & 0x80) == 0x80)
-                       add1b[i] = 0x1b;
-               else
-                       add1b[i] = 0x00;
-       }
-
-       swap_halfs[0] = in[2];    /* Swap halves */
-       swap_halfs[1] = in[3];
-       swap_halfs[2] = in[0];
-       swap_halfs[3] = in[1];
-
-       rotl[0] = in[3];        /* Rotate left 8 bits */
-       rotl[1] = in[0];
-       rotl[2] = in[1];
-       rotl[3] = in[2];
-
-       andf7[0] = in[0] & 0x7f;
-       andf7[1] = in[1] & 0x7f;
-       andf7[2] = in[2] & 0x7f;
-       andf7[3] = in[3] & 0x7f;
-
-       for (i = 3; i > 0; i--) {    /* logical shift left 1 bit */
-               andf7[i] = andf7[i] << 1;
-               if ((andf7[i - 1] & 0x80) == 0x80)
-                       andf7[i] = (andf7[i] | 0x01);
-       }
-       andf7[0] = andf7[0] << 1;
-       andf7[0] = andf7[0] & 0xfe;
-
-       xor_32(add1b, andf7, add1bf7);
-
-       xor_32(in, add1bf7, rotr);
-
-       temp[0] = rotr[0];       /* Rotate right 8 bits */
-       rotr[0] = rotr[1];
-       rotr[1] = rotr[2];
-       rotr[2] = rotr[3];
-       rotr[3] = temp[0];
-
-       xor_32(add1bf7, rotr, temp);
-       xor_32(swap_halfs, rotl, tempb);
-       xor_32(temp, tempb, out);
-
-}
-
-static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
-{
-       int round;
-       int i;
-       u8 intermediatea[16];
-       u8 intermediateb[16];
-       u8 round_key[16];
-
-       for (i = 0; i < 16; i++)
-               round_key[i] = key[i];
-       for (round = 0; round < 11; round++) {
-               if (round == 0) {
-                       xor_128(round_key, data, ciphertext);
-                       next_key(round_key, round);
-               } else if (round == 10) {
-                       byte_sub(ciphertext, intermediatea);
-                       shift_row(intermediatea, intermediateb);
-                       xor_128(intermediateb, round_key, ciphertext);
-               } else {    /* 1 - 9 */
-                       byte_sub(ciphertext, intermediatea);
-                       shift_row(intermediatea, intermediateb);
-                       mix_column(&intermediateb[0], &intermediatea[0]);
-                       mix_column(&intermediateb[4], &intermediatea[4]);
-                       mix_column(&intermediateb[8], &intermediatea[8]);
-                       mix_column(&intermediateb[12], &intermediatea[12]);
-                       xor_128(intermediatea, round_key, ciphertext);
-                       next_key(round_key, round);
-               }
-       }
-
-}
-
-/************************************************/
-/* construct_mic_iv()                     */
-/* Builds the MIC IV from header fields and PN  */
-/************************************************/
-static void construct_mic_iv(u8 *mic_iv, int qc_exists, int a4_exists, u8 *mpdu,
-                            uint payload_length, u8 *pn_vector)
-{
-       int i;
-
-       mic_iv[0] = 0x59;
-       if (qc_exists && a4_exists)
-               mic_iv[1] = mpdu[30] & 0x0f;    /* QoS_TC          */
-       if (qc_exists && !a4_exists)
-               mic_iv[1] = mpdu[24] & 0x0f;    /* mute bits 7-4    */
-       if (!qc_exists)
-               mic_iv[1] = 0x00;
-       for (i = 2; i < 8; i++)
-               mic_iv[i] = mpdu[i + 8];        /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */
-       for (i = 8; i < 14; i++)
-               mic_iv[i] = pn_vector[13 - i];  /* mic_iv[8:13] = PN[5:0] */
-       mic_iv[14] = (unsigned char)(payload_length / 256);
-       mic_iv[15] = (unsigned char)(payload_length % 256);
-
-}
-
-/************************************************/
-/* construct_mic_header1()                   */
-/* Builds the first MIC header block from       */
-/* header fields.                             */
-/************************************************/
-static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu)
-{
-
-       mic_header1[0] = (u8)((header_length - 2) / 256);
-       mic_header1[1] = (u8)((header_length - 2) % 256);
-       mic_header1[2] = mpdu[0] & 0xcf;    /* Mute CF poll & CF ack bits */
-       mic_header1[3] = mpdu[1] & 0xc7;    /* Mute retry, more data and pwr mgt bits */
-       mic_header1[4] = mpdu[4];       /* A1 */
-       mic_header1[5] = mpdu[5];
-       mic_header1[6] = mpdu[6];
-       mic_header1[7] = mpdu[7];
-       mic_header1[8] = mpdu[8];
-       mic_header1[9] = mpdu[9];
-       mic_header1[10] = mpdu[10];     /* A2 */
-       mic_header1[11] = mpdu[11];
-       mic_header1[12] = mpdu[12];
-       mic_header1[13] = mpdu[13];
-       mic_header1[14] = mpdu[14];
-       mic_header1[15] = mpdu[15];
-
-}
-
-/************************************************/
-/* construct_mic_header2()                   */
-/* Builds the last MIC header block from       */
-/* header fields.                             */
-/************************************************/
-static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists)
-{
-       int i;
-
-       for (i = 0; i < 16; i++)
-               mic_header2[i] = 0x00;
-
-       mic_header2[0] = mpdu[16];    /* A3 */
-       mic_header2[1] = mpdu[17];
-       mic_header2[2] = mpdu[18];
-       mic_header2[3] = mpdu[19];
-       mic_header2[4] = mpdu[20];
-       mic_header2[5] = mpdu[21];
-
-       mic_header2[6] = 0x00;
-       mic_header2[7] = 0x00; /* mpdu[23]; */
-
-       if (!qc_exists && a4_exists) {
-               for (i = 0; i < 6; i++)
-                       mic_header2[8 + i] = mpdu[24 + i];   /* A4 */
-       }
-
-       if (qc_exists && !a4_exists) {
-               mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */
-               mic_header2[9] = mpdu[25] & 0x00;
-       }
-
-       if (qc_exists && a4_exists) {
-               for (i = 0; i < 6; i++)
-                       mic_header2[8 + i] = mpdu[24 + i];   /* A4 */
-
-               mic_header2[14] = mpdu[30] & 0x0f;
-               mic_header2[15] = mpdu[31] & 0x00;
-       }
-
-}
-
-/************************************************/
-/* construct_mic_header2()                   */
-/* Builds the last MIC header block from       */
-/* header fields.                             */
-/************************************************/
-static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c)
-{
-       int i;
-
-       for (i = 0; i < 16; i++)
-               ctr_preload[i] = 0x00;
-       i = 0;
-
-       ctr_preload[0] = 0x01;                            /* flag */
-       if (qc_exists && a4_exists)
-               ctr_preload[1] = mpdu[30] & 0x0f;   /* QoC_Control */
-       if (qc_exists && !a4_exists)
-               ctr_preload[1] = mpdu[24] & 0x0f;
-
-       for (i = 2; i < 8; i++)
-               ctr_preload[i] = mpdu[i + 8];                  /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */
-       for (i = 8; i < 14; i++)
-               ctr_preload[i] =    pn_vector[13 - i];    /* ctr_preload[8:13] = PN[5:0] */
-       ctr_preload[14] =  (unsigned char)(c / 256); /* Ctr */
-       ctr_preload[15] =  (unsigned char)(c % 256);
-
-}
-
-/************************************/
-/* bitwise_xor()                   */
-/* A 128 bit, bitwise exclusive or  */
-/************************************/
-static void bitwise_xor(u8 *ina, u8 *inb, u8 *out)
-{
-       int i;
-
-       for (i = 0; i < 16; i++)
-               out[i] = ina[i] ^ inb[i];
-
-}
-
-static void aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
-{
-       uint    qc_exists, a4_exists, i, j, payload_remainder,
-               num_blocks, payload_index;
-
-       u8 pn_vector[6];
-       u8 mic_iv[16];
-       u8 mic_header1[16];
-       u8 mic_header2[16];
-       u8 ctr_preload[16];
-
-       /* Intermediate Buffers */
-       u8 chain_buffer[16];
-       u8 aes_out[16];
-       u8 padded_buffer[16];
-       u8 mic[8];
-       uint    frtype  = GetFrameType(pframe);
-       uint    frsubtype  = GetFrameSubType(pframe);
-
-       frsubtype = frsubtype >> 4;
-
-       memset((void *)mic_iv, 0, 16);
-       memset((void *)mic_header1, 0, 16);
-       memset((void *)mic_header2, 0, 16);
-       memset((void *)ctr_preload, 0, 16);
-       memset((void *)chain_buffer, 0, 16);
-       memset((void *)aes_out, 0, 16);
-       memset((void *)padded_buffer, 0, 16);
-
-       if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen ==  WLAN_HDR_A3_QOS_LEN))
-               a4_exists = 0;
-       else
-               a4_exists = 1;
-
-       if ((frtype == WIFI_DATA_CFACK) || (frtype == WIFI_DATA_CFPOLL) || (frtype == WIFI_DATA_CFACKPOLL)) {
-               qc_exists = 1;
-               if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
-                       hdrlen += 2;
-       } else if ((frsubtype == 0x08) || (frsubtype == 0x09) || (frsubtype == 0x0a) || (frsubtype == 0x0b)) {
-               if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
-                       hdrlen += 2;
-               qc_exists = 1;
-       } else {
-               qc_exists = 0;
-       }
-
-       pn_vector[0] = pframe[hdrlen];
-       pn_vector[1] = pframe[hdrlen + 1];
-       pn_vector[2] = pframe[hdrlen + 4];
-       pn_vector[3] = pframe[hdrlen + 5];
-       pn_vector[4] = pframe[hdrlen + 6];
-       pn_vector[5] = pframe[hdrlen + 7];
-
-       construct_mic_iv(mic_iv, qc_exists, a4_exists, pframe, plen, pn_vector);
-
-       construct_mic_header1(mic_header1, hdrlen, pframe);
-       construct_mic_header2(mic_header2, pframe, a4_exists, qc_exists);
-
-       payload_remainder = plen % 16;
-       num_blocks = plen / 16;
-
-       /* Find start of payload */
-       payload_index = (hdrlen + 8);
-
-       /* Calculate MIC */
-       aes128k128d(key, mic_iv, aes_out);
-       bitwise_xor(aes_out, mic_header1, chain_buffer);
-       aes128k128d(key, chain_buffer, aes_out);
-       bitwise_xor(aes_out, mic_header2, chain_buffer);
-       aes128k128d(key, chain_buffer, aes_out);
-
-       for (i = 0; i < num_blocks; i++) {
-               bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */
-
-               payload_index += 16;
-               aes128k128d(key, chain_buffer, aes_out);
-       }
-
-       /* Add on the final payload block if it needs padding */
-       if (payload_remainder > 0) {
-               for (j = 0; j < 16; j++)
-                       padded_buffer[j] = 0x00;
-               for (j = 0; j < payload_remainder; j++)
-                       padded_buffer[j] = pframe[payload_index++];/* padded_buffer[j] = message[payload_index++]; */
-               bitwise_xor(aes_out, padded_buffer, chain_buffer);
-               aes128k128d(key, chain_buffer, aes_out);
-       }
-
-       for (j = 0; j < 8; j++)
-               mic[j] = aes_out[j];
-
-       /* Insert MIC into payload */
-       for (j = 0; j < 8; j++)
-               pframe[payload_index + j] = mic[j]; /* message[payload_index+j] = mic[j]; */
-
-       payload_index = hdrlen + 8;
-       for (i = 0; i < num_blocks; i++) {
-               construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i + 1);
-               aes128k128d(key, ctr_preload, aes_out);
-               bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);
-               for (j = 0; j < 16; j++)
-                       pframe[payload_index++] = chain_buffer[j];
-       }
-
-       if (payload_remainder > 0) {    /* If there is a short final block, then pad it,*/
-                                       /* encrypt it and copy the unpadded part back   */
-               construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks + 1);
-
-               for (j = 0; j < 16; j++)
-                       padded_buffer[j] = 0x00;
-               for (j = 0; j < payload_remainder; j++)
-                       padded_buffer[j] = pframe[payload_index + j];
-               aes128k128d(key, ctr_preload, aes_out);
-               bitwise_xor(aes_out, padded_buffer, chain_buffer);
-               for (j = 0; j < payload_remainder; j++)
-                       pframe[payload_index++] = chain_buffer[j];
-       }
-       /* Encrypt the MIC */
-       construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, 0);
-
-       for (j = 0; j < 16; j++)
-               padded_buffer[j] = 0x00;
-       for (j = 0; j < 8; j++)
-               padded_buffer[j] = pframe[j + hdrlen + 8 + plen];
-
-       aes128k128d(key, ctr_preload, aes_out);
-       bitwise_xor(aes_out, padded_buffer, chain_buffer);
-       for (j = 0; j < 8; j++)
-               pframe[payload_index++] = chain_buffer[j];
-}
-
-u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
-{      /*  exclude ICV */
-
-       /*static*/
-/*     unsigned char   message[MAX_MSG_SIZE]; */
-
-       /* Intermediate Buffers */
-       int     curfragnum, length;
-       u8      *pframe, *prwskey;      /*  *payload,*iv */
-       u8   hw_hdr_offset = 0;
-       struct  sta_info                *stainfo;
-       struct  pkt_attrib       *pattrib = &pxmitframe->attrib;
-       struct  security_priv   *psecuritypriv = &padapter->securitypriv;
-       struct  xmit_priv               *pxmitpriv = &padapter->xmitpriv;
-
-/*     uint    offset = 0; */
-       u32 res = _SUCCESS;
-
-       if (!pxmitframe->buf_addr)
-               return _FAIL;
-
-       hw_hdr_offset = TXDESC_SIZE + pxmitframe->pkt_offset * PACKET_OFFSET_SZ;
-       pframe = pxmitframe->buf_addr + hw_hdr_offset;
-
-       /* 4 start to encrypt each fragment */
-       if (pattrib->encrypt == _AES_) {
-               if (pattrib->psta)
-                       stainfo = pattrib->psta;
-               else
-                       stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]);
-
-               if (stainfo) {
-                       if (is_multicast_ether_addr(pattrib->ra))
-                               prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
-                       else
-                               prwskey = &stainfo->dot118021x_UncstKey.skey[0];
-                       for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
-                               if ((curfragnum + 1) == pattrib->nr_frags) {    /* 4 the last fragment */
-                                       length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
-
-                                       aes_cipher(prwskey, pattrib->hdrlen, pframe, length);
-                               } else {
-                                       length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
-
-                                       aes_cipher(prwskey, pattrib->hdrlen, pframe, length);
-                                       pframe += pxmitpriv->frag_len;
-                                       pframe = PTR_ALIGN(pframe, 4);
-                               }
-                       }
-               } else {
-                       res = _FAIL;
-               }
-       }
-
-       return res;
-}
-
-static int aes_decipher(u8 *key, uint hdrlen,
-                       u8 *pframe, uint plen)
-{
-       static u8       message[MAX_MSG_SIZE];
-       uint    qc_exists, a4_exists, i, j, payload_remainder,
-                       num_blocks, payload_index;
-       int res = _SUCCESS;
-       u8 pn_vector[6];
-       u8 mic_iv[16];
-       u8 mic_header1[16];
-       u8 mic_header2[16];
-       u8 ctr_preload[16];
-
-       /* Intermediate Buffers */
-       u8 chain_buffer[16];
-       u8 aes_out[16];
-       u8 padded_buffer[16];
-       u8 mic[8];
-
-/*     uint    offset = 0; */
-       uint    frtype  = GetFrameType(pframe);
-       uint    frsubtype  = GetFrameSubType(pframe);
-
-       frsubtype = frsubtype >> 4;
-
-       memset((void *)mic_iv, 0, 16);
-       memset((void *)mic_header1, 0, 16);
-       memset((void *)mic_header2, 0, 16);
-       memset((void *)ctr_preload, 0, 16);
-       memset((void *)chain_buffer, 0, 16);
-       memset((void *)aes_out, 0, 16);
-       memset((void *)padded_buffer, 0, 16);
-
-       /* start to decrypt the payload */
-
-       num_blocks = (plen - 8) / 16; /* plen including llc, payload_length and mic) */
-
-       payload_remainder = (plen - 8) % 16;
-
-       pn_vector[0]  = pframe[hdrlen];
-       pn_vector[1]  = pframe[hdrlen + 1];
-       pn_vector[2]  = pframe[hdrlen + 4];
-       pn_vector[3]  = pframe[hdrlen + 5];
-       pn_vector[4]  = pframe[hdrlen + 6];
-       pn_vector[5]  = pframe[hdrlen + 7];
-
-       if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen ==  WLAN_HDR_A3_QOS_LEN))
-               a4_exists = 0;
-       else
-               a4_exists = 1;
-
-       if ((frtype == WIFI_DATA_CFACK) || (frtype == WIFI_DATA_CFPOLL) ||
-           (frtype == WIFI_DATA_CFACKPOLL)) {
-                       qc_exists = 1;
-                       if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
-                               hdrlen += 2;
-       } else if ((frsubtype == 0x08) || (frsubtype == 0x09) ||
-                  (frsubtype == 0x0a) || (frsubtype == 0x0b)) {
-               if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
-                       hdrlen += 2;
-               qc_exists = 1;
-       } else {
-               qc_exists = 0;
-       }
-
-       /*  now, decrypt pframe with hdrlen offset and plen long */
-
-       payload_index = hdrlen + 8; /*  8 is for extiv */
-
-       for (i = 0; i < num_blocks; i++) {
-               construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i + 1);
-
-               aes128k128d(key, ctr_preload, aes_out);
-               bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);
-
-               for (j = 0; j < 16; j++)
-                        pframe[payload_index++] = chain_buffer[j];
-       }
-
-       if (payload_remainder > 0) {    /* If there is a short final block, then pad it,*/
-                                       /* encrypt it and copy the unpadded part back   */
-               construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks + 1);
-
-               for (j = 0; j < 16; j++)
-                       padded_buffer[j] = 0x00;
-               for (j = 0; j < payload_remainder; j++)
-                       padded_buffer[j] = pframe[payload_index + j];
-               aes128k128d(key, ctr_preload, aes_out);
-               bitwise_xor(aes_out, padded_buffer, chain_buffer);
-               for (j = 0; j < payload_remainder; j++)
-                       pframe[payload_index++] = chain_buffer[j];
-       }
-
-       /* start to calculate the mic */
-       if ((hdrlen + plen + 8) <= MAX_MSG_SIZE)
-               memcpy(message, pframe, (hdrlen + plen + 8)); /* 8 is for ext iv len */
-
-       pn_vector[0] = pframe[hdrlen];
-       pn_vector[1] = pframe[hdrlen + 1];
-       pn_vector[2] = pframe[hdrlen + 4];
-       pn_vector[3] = pframe[hdrlen + 5];
-       pn_vector[4] = pframe[hdrlen + 6];
-       pn_vector[5] = pframe[hdrlen + 7];
-       construct_mic_iv(mic_iv, qc_exists, a4_exists, message, plen - 8, pn_vector);
-
-       construct_mic_header1(mic_header1, hdrlen, message);
-       construct_mic_header2(mic_header2, message, a4_exists, qc_exists);
-
-       payload_remainder = (plen - 8) % 16;
-       num_blocks = (plen - 8) / 16;
-
-       /* Find start of payload */
-       payload_index = (hdrlen + 8);
-
-       /* Calculate MIC */
-       aes128k128d(key, mic_iv, aes_out);
-       bitwise_xor(aes_out, mic_header1, chain_buffer);
-       aes128k128d(key, chain_buffer, aes_out);
-       bitwise_xor(aes_out, mic_header2, chain_buffer);
-       aes128k128d(key, chain_buffer, aes_out);
-
-       for (i = 0; i < num_blocks; i++) {
-               bitwise_xor(aes_out, &message[payload_index], chain_buffer);
-
-               payload_index += 16;
-               aes128k128d(key, chain_buffer, aes_out);
-       }
-
-       /* Add on the final payload block if it needs padding */
-       if (payload_remainder > 0) {
-               for (j = 0; j < 16; j++)
-                       padded_buffer[j] = 0x00;
-               for (j = 0; j < payload_remainder; j++)
-                       padded_buffer[j] = message[payload_index++];
-               bitwise_xor(aes_out, padded_buffer, chain_buffer);
-               aes128k128d(key, chain_buffer, aes_out);
-       }
-
-       for (j = 0 ; j < 8; j++)
-               mic[j] = aes_out[j];
-
-       /* Insert MIC into payload */
-       for (j = 0; j < 8; j++)
-               message[payload_index + j] = mic[j];
-
-       payload_index = hdrlen + 8;
-       for (i = 0; i < num_blocks; i++) {
-               construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, i + 1);
-               aes128k128d(key, ctr_preload, aes_out);
-               bitwise_xor(aes_out, &message[payload_index], chain_buffer);
-               for (j = 0; j < 16; j++)
-                       message[payload_index++] = chain_buffer[j];
-       }
-
-       if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/
-               /* encrypt it and copy the unpadded part back   */
-               construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, num_blocks + 1);
-
-               for (j = 0; j < 16; j++)
-                       padded_buffer[j] = 0x00;
-               for (j = 0; j < payload_remainder; j++)
-                       padded_buffer[j] = message[payload_index + j];
-               aes128k128d(key, ctr_preload, aes_out);
-               bitwise_xor(aes_out, padded_buffer, chain_buffer);
-               for (j = 0; j < payload_remainder; j++)
-                       message[payload_index++] = chain_buffer[j];
-       }
-
-       /* Encrypt the MIC */
-       construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, 0);
-
-       for (j = 0; j < 16; j++)
-               padded_buffer[j] = 0x00;
-       for (j = 0; j < 8; j++)
-               padded_buffer[j] = message[j + hdrlen + 8 + plen - 8];
-
-       aes128k128d(key, ctr_preload, aes_out);
-       bitwise_xor(aes_out, padded_buffer, chain_buffer);
-       for (j = 0; j < 8; j++)
-               message[payload_index++] = chain_buffer[j];
-
-       /* compare the mic */
-       for (i = 0; i < 8; i++) {
-               if (pframe[hdrlen + 8 + plen - 8 + i] != message[hdrlen + 8 + plen - 8 + i])
-                       res = _FAIL;
-       }
-
-       return res;
-}
-
-u32 rtw_aes_decrypt(struct adapter *padapter, struct recv_frame *precvframe)
-{      /*  exclude ICV */
-       /* Intermediate Buffers */
-       int             length;
-       u8      *pframe, *prwskey;      /*  *payload,*iv */
-       struct  sta_info                *stainfo;
-       struct  rx_pkt_attrib    *prxattrib = &precvframe->attrib;
-       struct  security_priv   *psecuritypriv = &padapter->securitypriv;
-       u32     res = _SUCCESS;
-
-       pframe = precvframe->rx_data;
-
-       /* 4 start to encrypt each fragment */
-       if (prxattrib->encrypt == _AES_) {
-               stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
-               if (stainfo) {
-                       if (is_multicast_ether_addr(prxattrib->ra)) {
-                               /* in concurrent we should use sw descrypt in group key, so we remove this message */
-                               if (!psecuritypriv->binstallGrpkey) {
-                                       res = _FAIL;
-                                       goto exit;
-                               }
-                               prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
-                               if (psecuritypriv->dot118021XGrpKeyid != prxattrib->key_index) {
-                                       res = _FAIL;
-                                       goto exit;
-                               }
-                       } else {
-                               prwskey = &stainfo->dot118021x_UncstKey.skey[0];
-                       }
-                       length = precvframe->len - prxattrib->hdrlen - prxattrib->iv_len;
-                       res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length);
-               } else {
-                       res = _FAIL;
-               }
-       }
-
-exit:
-       return res;
-}
diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c
deleted file mode 100644 (file)
index e1ae185..0000000
+++ /dev/null
@@ -1,490 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _RTW_STA_MGT_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/sta_info.h"
-
-static void _rtw_init_stainfo(struct sta_info *psta)
-{
-
-       memset((u8 *)psta, 0, sizeof(struct sta_info));
-
-       spin_lock_init(&psta->lock);
-       INIT_LIST_HEAD(&psta->list);
-       INIT_LIST_HEAD(&psta->hash_list);
-       rtw_init_queue(&psta->sleep_q);
-       psta->sleepq_len = 0;
-
-       _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv);
-       _rtw_init_sta_recv_priv(&psta->sta_recvpriv);
-
-       INIT_LIST_HEAD(&psta->asoc_list);
-
-       INIT_LIST_HEAD(&psta->auth_list);
-
-       psta->expire_to = 0;
-
-       psta->flags = 0;
-
-       psta->capability = 0;
-
-       psta->bpairwise_key_installed = false;
-
-       psta->nonerp_set = 0;
-       psta->no_short_slot_time_set = 0;
-       psta->no_short_preamble_set = 0;
-       psta->no_ht_gf_set = 0;
-       psta->no_ht_set = 0;
-       psta->ht_20mhz_set = 0;
-
-       psta->under_exist_checking = 0;
-
-       psta->keep_alive_trycnt = 0;
-}
-
-int _rtw_init_sta_priv(struct sta_priv *pstapriv)
-{
-       struct sta_info *psta;
-       s32 i;
-
-       pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4);
-
-       if (!pstapriv->pallocated_stainfo_buf)
-               return -ENOMEM;
-
-       pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
-               ((size_t)(pstapriv->pallocated_stainfo_buf) & 3);
-
-       rtw_init_queue(&pstapriv->free_sta_queue);
-
-       spin_lock_init(&pstapriv->sta_hash_lock);
-
-       pstapriv->asoc_sta_count = 0;
-       rtw_init_queue(&pstapriv->sleep_q);
-       rtw_init_queue(&pstapriv->wakeup_q);
-
-       psta = (struct sta_info *)(pstapriv->pstainfo_buf);
-
-       for (i = 0; i < NUM_STA; i++) {
-               _rtw_init_stainfo(psta);
-
-               INIT_LIST_HEAD(&pstapriv->sta_hash[i]);
-
-               list_add_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue));
-
-               psta++;
-       }
-
-       pstapriv->sta_dz_bitmap = 0;
-       pstapriv->tim_bitmap = 0;
-
-       INIT_LIST_HEAD(&pstapriv->asoc_list);
-       INIT_LIST_HEAD(&pstapriv->auth_list);
-       spin_lock_init(&pstapriv->asoc_list_lock);
-       spin_lock_init(&pstapriv->auth_list_lock);
-       pstapriv->asoc_list_cnt = 0;
-       pstapriv->auth_list_cnt = 0;
-
-       pstapriv->auth_to = 3; /*  3*2 = 6 sec */
-       pstapriv->assoc_to = 3;
-       pstapriv->expire_to = 3; /*  3*2 = 6 sec */
-       pstapriv->max_num_sta = NUM_STA;
-
-       return 0;
-}
-
-inline int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta)
-{
-       return (((u8 *)sta) - stapriv->pstainfo_buf) / sizeof(struct sta_info);
-}
-
-inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset)
-{
-       return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info));
-}
-
-void _rtw_free_sta_priv(struct sta_priv *pstapriv)
-{
-       struct list_head *phead, *plist;
-       struct sta_info *psta = NULL;
-       struct recv_reorder_ctrl *preorder_ctrl;
-       int     index;
-
-       if (pstapriv) {
-               /*      delete all reordering_ctrl_timer                */
-               spin_lock_bh(&pstapriv->sta_hash_lock);
-               for (index = 0; index < NUM_STA; index++) {
-                       phead = &pstapriv->sta_hash[index];
-                       plist = phead->next;
-
-                       while (phead != plist) {
-                               int i;
-                               psta = container_of(plist, struct sta_info, hash_list);
-                               plist = plist->next;
-
-                               for (i = 0; i < 16; i++) {
-                                       preorder_ctrl = &psta->recvreorder_ctrl[i];
-                                       _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
-                               }
-                       }
-               }
-               spin_unlock_bh(&pstapriv->sta_hash_lock);
-               /*===============================*/
-
-               vfree(pstapriv->pallocated_stainfo_buf);
-       }
-}
-
-static void _rtw_reordering_ctrl_timeout_handler(struct timer_list *t)
-{
-       struct recv_reorder_ctrl *preorder_ctrl;
-
-       preorder_ctrl = from_timer(preorder_ctrl, t, reordering_ctrl_timer);
-       rtw_reordering_ctrl_timeout_handler(preorder_ctrl);
-}
-
-static void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
-{
-       timer_setup(&preorder_ctrl->reordering_ctrl_timer, _rtw_reordering_ctrl_timeout_handler, 0);
-}
-
-static void _addba_timer_hdl(struct timer_list *t)
-{
-       struct sta_info *psta = from_timer(psta, t, addba_retry_timer);
-
-       addba_timer_hdl(psta);
-}
-
-static void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta)
-{
-       timer_setup(&psta->addba_retry_timer, _addba_timer_hdl, 0);
-}
-
-struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
-{
-       s32     index;
-       struct list_head *phash_list;
-       struct sta_info *psta;
-       struct __queue *pfree_sta_queue;
-       struct recv_reorder_ctrl *preorder_ctrl;
-       int i = 0;
-       u16  wRxSeqInitialValue = 0xffff;
-
-       pfree_sta_queue = &pstapriv->free_sta_queue;
-
-       spin_lock_bh(&pfree_sta_queue->lock);
-
-       if (list_empty(&pfree_sta_queue->queue)) {
-               spin_unlock_bh(&pfree_sta_queue->lock);
-               psta = NULL;
-       } else {
-               psta = container_of((&pfree_sta_queue->queue)->next, struct sta_info, list);
-               list_del_init(&psta->list);
-               spin_unlock_bh(&pfree_sta_queue->lock);
-               _rtw_init_stainfo(psta);
-               memcpy(psta->hwaddr, hwaddr, ETH_ALEN);
-               index = wifi_mac_hash(hwaddr);
-               if (index >= NUM_STA) {
-                       psta = NULL;
-                       goto exit;
-               }
-               phash_list = &pstapriv->sta_hash[index];
-
-               spin_lock_bh(&pstapriv->sta_hash_lock);
-
-               list_add_tail(&psta->hash_list, phash_list);
-
-               pstapriv->asoc_sta_count++;
-
-               spin_unlock_bh(&pstapriv->sta_hash_lock);
-
-/*  Commented by Albert 2009/08/13 */
-/*  For the SMC router, the sequence number of first packet of WPS handshake will be 0. */
-/*  In this case, this packet will be dropped by recv_decache function if we use the 0x00 as the default value for tid_rxseq variable. */
-/*  So, we initialize the tid_rxseq variable as the 0xffff. */
-
-               for (i = 0; i < 16; i++)
-                       memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2);
-
-               init_addba_retry_timer(pstapriv->padapter, psta);
-
-               /* for A-MPDU Rx reordering buffer control */
-               for (i = 0; i < 16; i++) {
-                       preorder_ctrl = &psta->recvreorder_ctrl[i];
-
-                       preorder_ctrl->padapter = pstapriv->padapter;
-
-                       preorder_ctrl->enable = false;
-
-                       preorder_ctrl->indicate_seq = 0xffff;
-                       preorder_ctrl->wend_b = 0xffff;
-                       preorder_ctrl->wsize_b = 64;/* 64; */
-
-                       rtw_init_queue(&preorder_ctrl->pending_recvframe_queue);
-
-                       rtw_init_recv_timer(preorder_ctrl);
-               }
-
-               /* init for DM */
-               psta->rssi_stat.UndecoratedSmoothedPWDB = (-1);
-               psta->rssi_stat.UndecoratedSmoothedCCK = (-1);
-
-               /* init for the sequence number of received management frame */
-               psta->RxMgmtFrameSeqNum = 0xffff;
-       }
-
-exit:
-
-       return psta;
-}
-
-/*  using pstapriv->sta_hash_lock to protect */
-void rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta)
-{
-       int i;
-       struct __queue *pfree_sta_queue;
-       struct recv_reorder_ctrl *preorder_ctrl;
-       struct  sta_xmit_priv   *pstaxmitpriv;
-       struct  xmit_priv       *pxmitpriv = &padapter->xmitpriv;
-       struct  sta_priv *pstapriv = &padapter->stapriv;
-
-       if (!psta)
-               return;
-
-       pfree_sta_queue = &pstapriv->free_sta_queue;
-
-       pstaxmitpriv = &psta->sta_xmitpriv;
-
-       spin_lock_bh(&pxmitpriv->lock);
-
-       rtw_free_xmitframe_list(pxmitpriv, get_list_head(&psta->sleep_q));
-       psta->sleepq_len = 0;
-
-       rtw_free_xmitframe_list(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending);
-
-       list_del_init(&pstaxmitpriv->vo_q.tx_pending);
-
-       rtw_free_xmitframe_list(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending);
-
-       list_del_init(&pstaxmitpriv->vi_q.tx_pending);
-
-       rtw_free_xmitframe_list(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending);
-
-       list_del_init(&pstaxmitpriv->bk_q.tx_pending);
-
-       rtw_free_xmitframe_list(pxmitpriv, &pstaxmitpriv->be_q.sta_pending);
-
-       list_del_init(&pstaxmitpriv->be_q.tx_pending);
-
-       spin_unlock_bh(&pxmitpriv->lock);
-
-       list_del_init(&psta->hash_list);
-       pstapriv->asoc_sta_count--;
-
-       /*  re-init sta_info; 20061114 */
-       _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv);
-       _rtw_init_sta_recv_priv(&psta->sta_recvpriv);
-
-       _cancel_timer_ex(&psta->addba_retry_timer);
-
-       /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */
-       for (i = 0; i < 16 ; i++) {
-               struct list_head *phead, *plist;
-               struct recv_frame *prframe;
-               struct __queue *ppending_recvframe_queue;
-               struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
-
-               preorder_ctrl = &psta->recvreorder_ctrl[i];
-
-               _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
-
-               ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
-
-               spin_lock_bh(&ppending_recvframe_queue->lock);
-
-               phead =         get_list_head(ppending_recvframe_queue);
-               plist = phead->next;
-
-               while (!list_empty(phead)) {
-                       prframe = container_of(plist, struct recv_frame, list);
-
-                       plist = plist->next;
-
-                       list_del_init(&prframe->list);
-
-                       rtw_free_recvframe(prframe, pfree_recv_queue);
-               }
-
-               spin_unlock_bh(&ppending_recvframe_queue->lock);
-       }
-
-       if (!(psta->state & WIFI_AP_STATE))
-               rtl8188e_SetHalODMVar(padapter, psta, false);
-
-       spin_lock_bh(&pstapriv->auth_list_lock);
-       if (!list_empty(&psta->auth_list)) {
-               list_del_init(&psta->auth_list);
-               pstapriv->auth_list_cnt--;
-       }
-       spin_unlock_bh(&pstapriv->auth_list_lock);
-
-       psta->expire_to = 0;
-
-       psta->sleepq_ac_len = 0;
-       psta->qos_info = 0;
-
-       psta->max_sp_len = 0;
-       psta->uapsd_bk = 0;
-       psta->uapsd_be = 0;
-       psta->uapsd_vi = 0;
-       psta->uapsd_vo = 0;
-       psta->has_legacy_ac = 0;
-
-       pstapriv->sta_dz_bitmap &= ~BIT(psta->aid);
-       pstapriv->tim_bitmap &= ~BIT(psta->aid);
-
-       if ((psta->aid > 0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) {
-               pstapriv->sta_aid[psta->aid - 1] = NULL;
-               psta->aid = 0;
-       }
-
-       psta->under_exist_checking = 0;
-
-       spin_lock_bh(&pfree_sta_queue->lock);
-       list_add_tail(&psta->list, get_list_head(pfree_sta_queue));
-       spin_unlock_bh(&pfree_sta_queue->lock);
-}
-
-/*  free all stainfo which in sta_hash[all] */
-void rtw_free_all_stainfo(struct adapter *padapter)
-{
-       struct list_head *plist, *phead;
-       s32     index;
-       struct sta_info *psta = NULL;
-       struct  sta_priv *pstapriv = &padapter->stapriv;
-       struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo(padapter);
-
-       if (pstapriv->asoc_sta_count == 1)
-               return;
-
-       spin_lock_bh(&pstapriv->sta_hash_lock);
-
-       for (index = 0; index < NUM_STA; index++) {
-               phead = &pstapriv->sta_hash[index];
-               plist = phead->next;
-
-               while (phead != plist) {
-                       psta = container_of(plist, struct sta_info, hash_list);
-
-                       plist = plist->next;
-
-                       if (pbcmc_stainfo != psta)
-                               rtw_free_stainfo(padapter, psta);
-               }
-       }
-       spin_unlock_bh(&pstapriv->sta_hash_lock);
-}
-
-/* any station allocated can be searched by hash list */
-struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
-{
-       struct sta_info *ploop, *psta = NULL;
-       u32     index;
-       u8 *addr;
-       u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
-       if (!hwaddr)
-               return NULL;
-
-       if (is_multicast_ether_addr(hwaddr))
-               addr = bc_addr;
-       else
-               addr = hwaddr;
-
-       index = wifi_mac_hash(addr);
-
-       spin_lock_bh(&pstapriv->sta_hash_lock);
-
-       list_for_each_entry(ploop, &pstapriv->sta_hash[index], hash_list) {
-               if (!memcmp(ploop->hwaddr, addr, ETH_ALEN)) {
-                       psta = ploop;
-                       break;
-               }
-       }
-
-       spin_unlock_bh(&pstapriv->sta_hash_lock);
-
-       return psta;
-}
-
-u32 rtw_init_bcmc_stainfo(struct adapter *padapter)
-{
-       struct sta_info         *psta;
-       u32 res = _SUCCESS;
-       unsigned char bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-       struct  sta_priv *pstapriv = &padapter->stapriv;
-
-       psta = rtw_alloc_stainfo(pstapriv, bcast_addr);
-
-       if (!psta) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       /*  default broadcast & multicast use macid 1 */
-       psta->mac_id = 1;
-
-exit:
-
-       return res;
-}
-
-struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter)
-{
-       struct sta_info         *psta;
-       struct sta_priv         *pstapriv = &padapter->stapriv;
-       u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
-       psta = rtw_get_stainfo(pstapriv, bc_addr);
-
-       return psta;
-}
-
-u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
-{
-       u8 res = true;
-       struct list_head *plist, *phead;
-       struct rtw_wlan_acl_node *paclnode;
-       u8 match = false;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
-       struct __queue *pacl_node_q = &pacl_list->acl_node_q;
-
-       spin_lock_bh(&pacl_node_q->lock);
-       phead = get_list_head(pacl_node_q);
-       plist = phead->next;
-       while (phead != plist) {
-               paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
-               plist = plist->next;
-
-               if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) {
-                       if (paclnode->valid) {
-                               match = true;
-                               break;
-                       }
-               }
-       }
-       spin_unlock_bh(&pacl_node_q->lock);
-
-       if (pacl_list->mode == 1)/* accept unless in deny list */
-               res = !match;
-       else if (pacl_list->mode == 2)/* deny unless in accept list */
-               res = match;
-       else
-               res = true;
-
-       return res;
-}
diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c
deleted file mode 100644 (file)
index f1ebb53..0000000
+++ /dev/null
@@ -1,1551 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _RTW_WLAN_UTIL_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/wifi.h"
-
-static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f};
-static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74};
-
-static unsigned char BROADCOM_OUI1[] = {0x00, 0x10, 0x18};
-static unsigned char BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7};
-
-static unsigned char CISCO_OUI[] = {0x00, 0x40, 0x96};
-static unsigned char MARVELL_OUI[] = {0x00, 0x50, 0x43};
-static unsigned char RALINK_OUI[] = {0x00, 0x0c, 0x43};
-static unsigned char REALTEK_OUI[] = {0x00, 0xe0, 0x4c};
-static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5};
-static unsigned char EPIGRAM_OUI[] = {0x00, 0x90, 0x4c};
-
-unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20};
-
-#define R2T_PHY_DELAY  (0)
-
-/* define WAIT_FOR_BCN_TO_M    (3000) */
-#define WAIT_FOR_BCN_TO_MIN    (6000)
-#define WAIT_FOR_BCN_TO_MAX    (20000)
-
-static u8 rtw_basic_rate_cck[4] = {
-       IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK,
-       IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK
-};
-
-static u8 rtw_basic_rate_ofdm[3] = {
-       IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK,
-       IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK
-};
-
-static u8 rtw_basic_rate_mix[7] = {
-       IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK,
-       IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK,
-       IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK,
-       IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK
-};
-
-bool cckrates_included(unsigned char *rate, int ratelen)
-{
-       int     i;
-
-       for (i = 0; i < ratelen; i++) {
-               if  ((((rate[i]) & 0x7f) == 2)  || (((rate[i]) & 0x7f) == 4) ||
-                    (((rate[i]) & 0x7f) == 11)  || (((rate[i]) & 0x7f) == 22))
-                       return true;
-       }
-       return false;
-}
-
-bool cckratesonly_included(unsigned char *rate, int ratelen)
-{
-       int     i;
-
-       for (i = 0; i < ratelen; i++) {
-               if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
-                   (((rate[i]) & 0x7f) != 11)  && (((rate[i]) & 0x7f) != 22))
-                       return false;
-       }
-
-       return true;
-}
-
-unsigned char networktype_to_raid(unsigned char network_type)
-{
-       unsigned char raid;
-
-       switch (network_type) {
-       case WIRELESS_11B:
-               raid = RATR_INX_WIRELESS_B;
-               break;
-       case WIRELESS_11G:
-               raid = RATR_INX_WIRELESS_G;
-               break;
-       case WIRELESS_11BG:
-               raid = RATR_INX_WIRELESS_GB;
-               break;
-       case WIRELESS_11_24N:
-               raid = RATR_INX_WIRELESS_N;
-               break;
-       case WIRELESS_11G_24N:
-               raid = RATR_INX_WIRELESS_NG;
-               break;
-       case WIRELESS_11BG_24N:
-               raid = RATR_INX_WIRELESS_NGB;
-               break;
-       default:
-               raid = RATR_INX_WIRELESS_GB;
-               break;
-       }
-       return raid;
-}
-
-u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int ratelen)
-{
-       u8 network_type = 0;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (pmlmeext->cur_channel > 14) {
-               network_type |= WIRELESS_INVALID;
-       } else {
-               if (pmlmeinfo->HT_enable)
-                       network_type = WIRELESS_11_24N;
-
-               if (cckratesonly_included(rate, ratelen))
-                       network_type |= WIRELESS_11B;
-               else if (cckrates_included(rate, ratelen))
-                       network_type |= WIRELESS_11BG;
-               else
-                       network_type |= WIRELESS_11G;
-       }
-       return  network_type;
-}
-
-static unsigned char ratetbl_val_2wifirate(unsigned char rate)
-{
-       unsigned char val = 0;
-
-       switch (rate & 0x7f) {
-       case 0:
-               val = IEEE80211_CCK_RATE_1MB;
-               break;
-       case 1:
-               val = IEEE80211_CCK_RATE_2MB;
-               break;
-       case 2:
-               val = IEEE80211_CCK_RATE_5MB;
-               break;
-       case 3:
-               val = IEEE80211_CCK_RATE_11MB;
-               break;
-       case 4:
-               val = IEEE80211_OFDM_RATE_6MB;
-               break;
-       case 5:
-               val = IEEE80211_OFDM_RATE_9MB;
-               break;
-       case 6:
-               val = IEEE80211_OFDM_RATE_12MB;
-               break;
-       case 7:
-               val = IEEE80211_OFDM_RATE_18MB;
-               break;
-       case 8:
-               val = IEEE80211_OFDM_RATE_24MB;
-               break;
-       case 9:
-               val = IEEE80211_OFDM_RATE_36MB;
-               break;
-       case 10:
-               val = IEEE80211_OFDM_RATE_48MB;
-               break;
-       case 11:
-               val = IEEE80211_OFDM_RATE_54MB;
-               break;
-       }
-       return val;
-}
-
-static bool is_basicrate(struct adapter *padapter, unsigned char rate)
-{
-       int i;
-       unsigned char val;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-
-       for (i = 0; i < NumRates; i++) {
-               val = pmlmeext->basicrate[i];
-
-               if ((val != 0xff) && (val != 0xfe)) {
-                       if (rate == ratetbl_val_2wifirate(val))
-                               return true;
-               }
-       }
-       return false;
-}
-
-static unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rateset)
-{
-       int i;
-       unsigned char rate;
-       unsigned int    len = 0;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-
-       for (i = 0; i < NumRates; i++) {
-               rate = pmlmeext->datarate[i];
-
-               switch (rate) {
-               case 0xff:
-                       return len;
-               case 0xfe:
-                       continue;
-               default:
-                       rate = ratetbl_val_2wifirate(rate);
-
-                       if (is_basicrate(padapter, rate))
-                               rate |= IEEE80211_BASIC_RATE_MASK;
-
-                       rateset[len] = rate;
-                       len++;
-                       break;
-               }
-       }
-       return len;
-}
-
-void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrate_len)
-{
-       unsigned char supportedrates[NumRates];
-
-       memset(supportedrates, 0, NumRates);
-       *bssrate_len = ratetbl2rateset(padapter, supportedrates);
-       memcpy(pbssrate, supportedrates, *bssrate_len);
-}
-
-void Save_DM_Func_Flag(struct adapter *padapter)
-{
-       struct hal_data_8188e *haldata = &padapter->haldata;
-       struct odm_dm_struct *odmpriv = &haldata->odmpriv;
-
-       odmpriv->BK_SupportAbility = odmpriv->SupportAbility;
-}
-
-void Restore_DM_Func_Flag(struct adapter *padapter)
-{
-       struct hal_data_8188e *haldata = &padapter->haldata;
-       struct odm_dm_struct *odmpriv = &haldata->odmpriv;
-
-       odmpriv->SupportAbility = odmpriv->BK_SupportAbility;
-}
-
-void Set_MSR(struct adapter *padapter, u8 type)
-{
-       u8 val8;
-       int res;
-
-       res = rtw_read8(padapter, MSR, &val8);
-       if (res)
-               return;
-
-       val8 &= 0x0c;
-       val8 |= type;
-       rtw_write8(padapter, MSR, val8);
-}
-
-inline u8 rtw_get_oper_ch(struct adapter *adapter)
-{
-       return adapter->mlmeextpriv.oper_channel;
-}
-
-inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch)
-{
-       adapter->mlmeextpriv.oper_channel = ch;
-}
-
-inline void rtw_set_oper_bw(struct adapter *adapter, u8 bw)
-{
-       adapter->mlmeextpriv.oper_bwmode = bw;
-}
-
-inline void rtw_set_oper_choffset(struct adapter *adapter, u8 offset)
-{
-       adapter->mlmeextpriv.oper_ch_offset = offset;
-}
-
-void SelectChannel(struct adapter *padapter, unsigned char channel)
-{
-       /* saved channel info */
-       rtw_set_oper_ch(padapter, channel);
-       PHY_SwChnl8188E(padapter, channel);
-}
-
-void SetBWMode(struct adapter *padapter, unsigned short bwmode,
-              unsigned char channel_offset)
-{
-       /* saved bw info */
-       rtw_set_oper_bw(padapter, bwmode);
-       rtw_set_oper_choffset(padapter, channel_offset);
-
-       PHY_SetBWMode8188E(padapter, (enum ht_channel_width)bwmode, channel_offset);
-}
-
-void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode)
-{
-       u8 center_ch;
-
-       if ((bwmode == HT_CHANNEL_WIDTH_20) ||
-           (channel_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE)) {
-               /* SelectChannel(padapter, channel); */
-               center_ch = channel;
-       } else {
-               /* switch to the proper channel */
-               if (channel_offset == HAL_PRIME_CHNL_OFFSET_LOWER) {
-                       /* SelectChannel(padapter, channel + 2); */
-                       center_ch = channel + 2;
-               } else {
-                       /* SelectChannel(padapter, channel - 2); */
-                       center_ch = channel - 2;
-               }
-       }
-
-       /* set Channel */
-       /* saved channel/bw info */
-       rtw_set_oper_ch(padapter, channel);
-       rtw_set_oper_bw(padapter, bwmode);
-       rtw_set_oper_choffset(padapter, channel_offset);
-
-       PHY_SwChnl8188E(padapter, center_ch); /*  set center channel */
-       SetBWMode(padapter, bwmode, channel_offset);
-}
-
-__inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork)
-{
-       return pnetwork->MacAddress;
-}
-
-u16 get_beacon_interval(struct wlan_bssid_ex *bss)
-{
-       __le16 val;
-       memcpy((unsigned char *)&val, rtw_get_beacon_interval_from_ie(bss->IEs), 2);
-
-       return le16_to_cpu(val);
-}
-
-bool r8188eu_is_client_associated_to_ap(struct adapter *padapter)
-{
-       struct mlme_ext_priv    *pmlmeext;
-       struct mlme_ext_info    *pmlmeinfo;
-
-       if (!padapter)
-               return false;
-
-       pmlmeext = &padapter->mlmeextpriv;
-       pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE))
-               return true;
-
-       return false;
-}
-
-bool r8188eu_is_client_associated_to_ibss(struct adapter *padapter)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE))
-               return true;
-
-       return false;
-}
-
-bool r8188eu_is_ibss_empty(struct adapter *padapter)
-{
-       unsigned int i;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) {
-               if (pmlmeinfo->FW_sta_info[i].status == 1)
-                       return false;
-       }
-       return true;
-}
-
-unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval)
-{
-       if ((bcn_interval << 2) < WAIT_FOR_BCN_TO_MIN)
-               return WAIT_FOR_BCN_TO_MIN;
-       else if ((bcn_interval << 2) > WAIT_FOR_BCN_TO_MAX)
-               return WAIT_FOR_BCN_TO_MAX;
-       else
-               return bcn_interval << 2;
-}
-
-void invalidate_cam_all(struct adapter *padapter)
-{
-       rtw_write32(padapter, RWCAM, BIT(31) | BIT(30));
-}
-
-void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key)
-{
-       unsigned int    i, val, addr;
-       int j;
-       u32     cam_val[2];
-
-       addr = entry << 3;
-
-       for (j = 5; j >= 0; j--) {
-               switch (j) {
-               case 0:
-                       val = (ctrl | (mac[0] << 16) | (mac[1] << 24));
-                       break;
-               case 1:
-                       val = (mac[2] | (mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24));
-                       break;
-               default:
-                       i = (j - 2) << 2;
-                       val = (key[i] | (key[i + 1] << 8) | (key[i + 2] << 16) | (key[i + 3] << 24));
-                       break;
-               }
-
-               cam_val[0] = val;
-               cam_val[1] = addr + (unsigned int)j;
-
-               rtw_write32(padapter, WCAMI, cam_val[0]);
-               rtw_write32(padapter, RWCAM, CAM_POLLINIG | CAM_WRITE | cam_val[1]);
-       }
-}
-
-void clear_cam_entry(struct adapter *padapter, u8 entry)
-{
-       unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-       unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                                   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-       write_cam(padapter, entry, 0, null_sta, null_key);
-}
-
-int allocate_fw_sta_entry(struct adapter *padapter)
-{
-       unsigned int mac_id;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) {
-               if (pmlmeinfo->FW_sta_info[mac_id].status == 0) {
-                       pmlmeinfo->FW_sta_info[mac_id].status = 1;
-                       pmlmeinfo->FW_sta_info[mac_id].retry = 0;
-                       break;
-               }
-       }
-
-       return mac_id;
-}
-
-void flush_all_cam_entry(struct adapter *padapter)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       rtw_write32(padapter, RWCAM, BIT(31) | BIT(30));
-
-       memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info));
-}
-
-int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)
-{
-       /* struct registry_priv *pregpriv = &padapter->registrypriv; */
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (pmlmepriv->qospriv.qos_option == 0) {
-               pmlmeinfo->WMM_enable = 0;
-               return _FAIL;
-       }
-
-       pmlmeinfo->WMM_enable = 1;
-       memcpy(&pmlmeinfo->WMM_param, pIE->data + 6, sizeof(struct WMM_para_element));
-       return true;
-}
-
-static void set_acm_ctrl(struct adapter *adapter, u8 acm_mask)
-{
-       u8 acmctrl;
-       int res = rtw_read8(adapter, REG_ACMHWCTRL, &acmctrl);
-
-       if (res)
-               return;
-
-       if (acm_mask > 1)
-               acmctrl = acmctrl | 0x1;
-
-       if (acm_mask & BIT(3))
-               acmctrl |= ACMHW_VOQEN;
-       else
-               acmctrl &= (~ACMHW_VOQEN);
-
-       if (acm_mask & BIT(2))
-               acmctrl |= ACMHW_VIQEN;
-       else
-               acmctrl &= (~ACMHW_VIQEN);
-
-       if (acm_mask & BIT(1))
-               acmctrl |= ACMHW_BEQEN;
-       else
-               acmctrl &= (~ACMHW_BEQEN);
-
-       rtw_write8(adapter, REG_ACMHWCTRL, acmctrl);
-}
-
-void WMMOnAssocRsp(struct adapter *padapter)
-{
-       u8      ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime;
-       u8      acm_mask;
-       u16     TXOP;
-       u32     acParm, i;
-       u32     edca[4], inx[4];
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct xmit_priv                *pxmitpriv = &padapter->xmitpriv;
-       struct registry_priv    *pregpriv = &padapter->registrypriv;
-       struct hal_data_8188e *haldata = &padapter->haldata;
-
-       if (pmlmeinfo->WMM_enable == 0) {
-               padapter->mlmepriv.acm_mask = 0;
-               return;
-       }
-
-       acm_mask = 0;
-
-       if (pmlmeext->cur_wireless_mode == WIRELESS_11B)
-               aSifsTime = 10;
-       else
-               aSifsTime = 16;
-
-       for (i = 0; i < 4; i++) {
-               ACI = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 5) & 0x03;
-               ACM = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 4) & 0x01;
-
-               /* AIFS = AIFSN * slot time + SIFS - r2t phy delay */
-               AIFS = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN & 0x0f) * pmlmeinfo->slotTime + aSifsTime;
-
-               ECWMin = (pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f);
-               ECWMax = (pmlmeinfo->WMM_param.ac_param[i].CW & 0xf0) >> 4;
-               TXOP = le16_to_cpu(pmlmeinfo->WMM_param.ac_param[i].TXOP_limit);
-
-               acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16);
-
-               switch (ACI) {
-               case 0x0:
-                       haldata->AcParam_BE = acParm;
-                       rtw_write32(padapter, REG_EDCA_BE_PARAM, acParm);
-                       acm_mask |= (ACM ? BIT(1) : 0);
-                       edca[XMIT_BE_QUEUE] = acParm;
-                       break;
-               case 0x1:
-                       rtw_write32(padapter, REG_EDCA_BK_PARAM, acParm);
-                       edca[XMIT_BK_QUEUE] = acParm;
-                       break;
-               case 0x2:
-                       rtw_write32(padapter, REG_EDCA_VI_PARAM, acParm);
-                       acm_mask |= (ACM ? BIT(2) : 0);
-                       edca[XMIT_VI_QUEUE] = acParm;
-                       break;
-               case 0x3:
-                       rtw_write32(padapter, REG_EDCA_VO_PARAM, acParm);
-                       acm_mask |= (ACM ? BIT(3) : 0);
-                       edca[XMIT_VO_QUEUE] = acParm;
-                       break;
-               }
-       }
-
-       if (padapter->registrypriv.acm_method == 1)
-               set_acm_ctrl(padapter, acm_mask);
-       else
-               padapter->mlmepriv.acm_mask = acm_mask;
-
-       inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3;
-
-       if (pregpriv->wifi_spec == 1) {
-               u32 j, change_inx = false;
-
-               /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */
-               for (i = 0; i < 4; i++) {
-                       for (j = i + 1; j < 4; j++) {
-                               /* compare CW and AIFS */
-                               if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) {
-                                       change_inx = true;
-                               } else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) {
-                                       /* compare TXOP */
-                                       if ((edca[j] >> 16) > (edca[i] >> 16))
-                                               change_inx = true;
-                               }
-
-                               if (change_inx) {
-                                       swap(edca[i], edca[j]);
-                                       swap(inx[i], inx[j]);
-
-                                       change_inx = false;
-                               }
-                       }
-               }
-       }
-
-       for (i = 0; i < 4; i++)
-               pxmitpriv->wmm_para_seq[i] = inx[i];
-}
-
-static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)
-{
-       unsigned char    new_bwmode;
-       unsigned char  new_ch_offset;
-       struct HT_info_element   *pHT_info;
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct registry_priv *pregistrypriv = &padapter->registrypriv;
-       struct ht_priv                  *phtpriv = &pmlmepriv->htpriv;
-
-       if (!pIE)
-               return;
-
-       if (!phtpriv)
-               return;
-
-       if (pIE->Length > sizeof(struct HT_info_element))
-               return;
-
-       pHT_info = (struct HT_info_element *)pIE->data;
-
-       if ((pHT_info->infos[0] & BIT(2)) && pregistrypriv->cbw40_enable) {
-               new_bwmode = HT_CHANNEL_WIDTH_40;
-
-               switch (pHT_info->infos[0] & 0x3) {
-               case 1:
-                       new_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
-                       break;
-               case 3:
-                       new_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
-                       break;
-               default:
-                       new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-                       break;
-               }
-       } else {
-               new_bwmode = HT_CHANNEL_WIDTH_20;
-               new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-       }
-
-       if ((new_bwmode != pmlmeext->cur_bwmode) ||
-           (new_ch_offset != pmlmeext->cur_ch_offset)) {
-               pmlmeinfo->bwmode_updated = true;
-
-               pmlmeext->cur_bwmode = new_bwmode;
-               pmlmeext->cur_ch_offset = new_ch_offset;
-
-               /* update HT info also */
-               HT_info_handler(padapter, pIE);
-       } else {
-               pmlmeinfo->bwmode_updated = false;
-       }
-
-       if (pmlmeinfo->bwmode_updated) {
-               struct sta_info *psta;
-               struct wlan_bssid_ex    *cur_network = &pmlmeinfo->network;
-               struct sta_priv *pstapriv = &padapter->stapriv;
-
-               /* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */
-
-               /* update ap's stainfo */
-               psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress);
-               if (psta) {
-                       struct ht_priv  *phtpriv_sta = &psta->htpriv;
-
-                       if (phtpriv_sta->ht_option) {
-                               /*  bwmode */
-                               phtpriv_sta->bwmode = pmlmeext->cur_bwmode;
-                               phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset;
-                       } else {
-                               phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20;
-                               phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-                       }
-               }
-       }
-}
-
-void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)
-{
-       unsigned int    i;
-       u8      max_AMPDU_len, min_MPDU_spacing;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct ht_priv                  *phtpriv = &pmlmepriv->htpriv;
-
-       if (!pIE)
-               return;
-
-       if (!phtpriv->ht_option)
-               return;
-
-       pmlmeinfo->HT_caps_enable = 1;
-
-       for (i = 0; i < (pIE->Length); i++) {
-               if (i != 2) {
-                       /*      Got the endian issue here. */
-                       pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]);
-               } else {
-                       /* modify from  fw by Thomas 2010/11/17 */
-                       max_AMPDU_len = min(pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3,
-                                           pIE->data[i] & 0x3);
-
-                       min_MPDU_spacing = max(pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c,
-                                              pIE->data[i] & 0x1c);
-
-                       pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = max_AMPDU_len | min_MPDU_spacing;
-               }
-       }
-
-       /* update the MCS rates */
-       for (i = 0; i < 16; i++)
-               pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R[i];
-}
-
-void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct ht_priv                  *phtpriv = &pmlmepriv->htpriv;
-
-       if (!pIE)
-               return;
-
-       if (!phtpriv->ht_option)
-               return;
-
-       if (pIE->Length > sizeof(struct HT_info_element))
-               return;
-
-       pmlmeinfo->HT_info_enable = 1;
-       memcpy(&pmlmeinfo->HT_info, pIE->data, pIE->Length);
-}
-
-static void set_min_ampdu_spacing(struct adapter *adapter, u8 spacing)
-{
-       u8 sec_spacing;
-       int res;
-
-       if (spacing <= 7) {
-               switch (adapter->securitypriv.dot11PrivacyAlgrthm) {
-               case _NO_PRIVACY_:
-               case _AES_:
-                       sec_spacing = 0;
-                       break;
-               case _WEP40_:
-               case _WEP104_:
-               case _TKIP_:
-               case _TKIP_WTMIC_:
-                       sec_spacing = 6;
-                       break;
-               default:
-                       sec_spacing = 7;
-                       break;
-               }
-
-               if (spacing < sec_spacing)
-                       spacing = sec_spacing;
-
-               res = rtw_read8(adapter, REG_AMPDU_MIN_SPACE, &sec_spacing);
-               if (res)
-                       return;
-
-               rtw_write8(adapter, REG_AMPDU_MIN_SPACE,
-                          (sec_spacing & 0xf8) | spacing);
-       }
-}
-
-static void set_ampdu_factor(struct adapter *adapter, u8 factor)
-{
-       u8 RegToSet_Normal[4] = {0x41, 0xa8, 0x72, 0xb9};
-       u8 FactorToSet;
-       u8 *pRegToSet;
-       u8 index = 0;
-
-       pRegToSet = RegToSet_Normal; /*  0xb972a841; */
-       FactorToSet = factor;
-       if (FactorToSet <= 3) {
-               FactorToSet = (1 << (FactorToSet + 2));
-               if (FactorToSet > 0xf)
-                       FactorToSet = 0xf;
-
-               for (index = 0; index < 4; index++) {
-                       if ((pRegToSet[index] & 0xf0) > (FactorToSet << 4))
-                               pRegToSet[index] = (pRegToSet[index] & 0x0f) | (FactorToSet << 4);
-
-                       if ((pRegToSet[index] & 0x0f) > FactorToSet)
-                               pRegToSet[index] = (pRegToSet[index] & 0xf0) | (FactorToSet);
-
-                       rtw_write8(adapter, (REG_AGGLEN_LMT + index), pRegToSet[index]);
-               }
-       }
-}
-
-void HTOnAssocRsp(struct adapter *padapter)
-{
-       unsigned char           max_AMPDU_len;
-       unsigned char           min_MPDU_spacing;
-       /* struct registry_priv  *pregpriv = &padapter->registrypriv; */
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) {
-               pmlmeinfo->HT_enable = 1;
-       } else {
-               pmlmeinfo->HT_enable = 0;
-               return;
-       }
-
-       /* handle A-MPDU parameter field */
-       /*
-               AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
-               AMPDU_para [4:2]:Min MPDU Start Spacing
-       */
-       max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03;
-
-       min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2;
-
-       set_min_ampdu_spacing(padapter, min_MPDU_spacing);
-
-       set_ampdu_factor(padapter, max_AMPDU_len);
-}
-
-void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (pIE->Length > 1)
-               return;
-
-       pmlmeinfo->ERP_enable = 1;
-       memcpy(&pmlmeinfo->ERP_IE, pIE->data, pIE->Length);
-}
-
-void VCS_update(struct adapter *padapter, struct sta_info *psta)
-{
-       struct registry_priv     *pregpriv = &padapter->registrypriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       switch (pregpriv->vrtl_carrier_sense) { /* 0:off 1:on 2:auto */
-       case 0: /* off */
-               psta->rtsen = 0;
-               psta->cts2self = 0;
-               break;
-       case 1: /* on */
-               if (pregpriv->vcs_type == 1) { /* 1:RTS/CTS 2:CTS to self */
-                       psta->rtsen = 1;
-                       psta->cts2self = 0;
-               } else {
-                       psta->rtsen = 0;
-                       psta->cts2self = 1;
-               }
-               break;
-       case 2: /* auto */
-       default:
-               if ((pmlmeinfo->ERP_enable) && (pmlmeinfo->ERP_IE & BIT(1))) {
-                       if (pregpriv->vcs_type == 1) {
-                               psta->rtsen = 1;
-                               psta->cts2self = 0;
-                       } else {
-                               psta->rtsen = 0;
-                               psta->cts2self = 1;
-                       }
-               } else {
-                       psta->rtsen = 0;
-                       psta->cts2self = 0;
-               }
-               break;
-       }
-}
-
-int rtw_check_bcn_info(struct adapter  *Adapter, u8 *pframe, u32 packet_len)
-{
-       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)pframe;
-       unsigned int            len;
-       unsigned char           *p;
-       unsigned short  val16;
-       struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network;
-       /* u8 wpa_ie[255], rsn_ie[255]; */
-       u16 wpa_len = 0, rsn_len = 0;
-       u8 encryp_protocol = 0;
-       struct wlan_bssid_ex *bssid;
-       int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0;
-       unsigned char *pbuf;
-       u32 wpa_ielen = 0;
-       u8 *pbssid = GetAddr3Ptr(pframe);
-       u32 hidden_ssid = 0;
-       struct HT_info_element *pht_info = NULL;
-       struct ieee80211_ht_cap *pht_cap = NULL;
-       u32 bcn_channel;
-       unsigned short  ht_cap_info;
-       unsigned char   ht_info_infos_0;
-
-       if (!r8188eu_is_client_associated_to_ap(Adapter))
-               return true;
-
-       len = packet_len - sizeof(struct ieee80211_hdr_3addr);
-
-       if (len > MAX_IE_SZ)
-               return _FAIL;
-
-       if (memcmp(cur_network->network.MacAddress, pbssid, 6))
-               return true;
-
-       bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC);
-       if (!bssid)
-               return _FAIL;
-
-       if (ieee80211_is_beacon(mgmt->frame_control))
-               bssid->Reserved[0] = 1;
-
-       bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len;
-
-       /* below is to copy the information element */
-       bssid->IELength = len;
-       memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength);
-
-       /* check bw and channel offset */
-       /* parsing HT_CAP_IE */
-       p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-       if (p && len > 0) {
-               pht_cap = (struct ieee80211_ht_cap *)(p + 2);
-               ht_cap_info = le16_to_cpu(pht_cap->cap_info);
-       } else {
-               ht_cap_info = 0;
-       }
-       /* parsing HT_INFO_IE */
-       p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-       if (p && len > 0) {
-                       pht_info = (struct HT_info_element *)(p + 2);
-                       ht_info_infos_0 = pht_info->infos[0];
-       } else {
-                       ht_info_infos_0 = 0;
-       }
-       if (ht_cap_info != cur_network->BcnInfo.ht_cap_info ||
-           ((ht_info_infos_0 & 0x03) != (cur_network->BcnInfo.ht_info_infos_0 & 0x03))) {
-                       /* bcn_info_update */
-                       cur_network->BcnInfo.ht_cap_info = ht_cap_info;
-                       cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0;
-                       /* to do : need to check that whether modify related register of BB or not */
-                       /* goto _mismatch; */
-       }
-
-       /* Checking for channel */
-       p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _DSSET_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-       if (p) {
-                       bcn_channel = *(p + 2);
-       } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */
-                       p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-                       if (pht_info)
-                               bcn_channel = pht_info->primary_channel;
-                       else /* we don't find channel IE, so don't check it */
-                               bcn_channel = Adapter->mlmeextpriv.cur_channel;
-       }
-       if (bcn_channel != Adapter->mlmeextpriv.cur_channel)
-               goto _mismatch;
-
-       /* checking SSID */
-       p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-       if (!p)
-               hidden_ssid = true;
-       else
-               hidden_ssid = false;
-
-       if (p && (!hidden_ssid && (*(p + 1)))) {
-               memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1));
-               bssid->Ssid.SsidLength = *(p + 1);
-       } else {
-               bssid->Ssid.SsidLength = 0;
-               bssid->Ssid.Ssid[0] = '\0';
-       }
-
-       if (memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) ||
-           bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) {
-               /* not hidden ssid */
-               if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0)
-                       goto _mismatch;
-       }
-
-       /* check encryption info */
-       val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid);
-
-       if (val16 & BIT(4))
-               bssid->Privacy = 1;
-       else
-               bssid->Privacy = 0;
-
-       if (cur_network->network.Privacy != bssid->Privacy)
-               goto _mismatch;
-
-       rtw_get_sec_ie(bssid->IEs, bssid->IELength, NULL, &rsn_len, NULL, &wpa_len);
-
-       if (rsn_len > 0) {
-               encryp_protocol = ENCRYP_PROTOCOL_WPA2;
-       } else if (wpa_len > 0) {
-               encryp_protocol = ENCRYP_PROTOCOL_WPA;
-       } else {
-               if (bssid->Privacy)
-                       encryp_protocol = ENCRYP_PROTOCOL_WEP;
-       }
-
-       if (cur_network->BcnInfo.encryp_protocol != encryp_protocol)
-               goto _mismatch;
-
-       if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) {
-               pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength - 12);
-               if (pbuf && (wpa_ielen > 0)) {
-                       rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x);
-               } else {
-                       pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength - 12);
-
-                       if (pbuf && (wpa_ielen > 0))
-                               rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x);
-               }
-
-               if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher ||
-                   group_cipher != cur_network->BcnInfo.group_cipher)
-                       goto _mismatch;
-
-               if (is_8021x != cur_network->BcnInfo.is_8021x)
-                       goto _mismatch;
-       }
-
-       kfree(bssid);
-
-       return _SUCCESS;
-
-_mismatch:
-       kfree(bssid);
-
-       return _FAIL;
-}
-
-void update_beacon_info(struct adapter *padapter, u8 *ie_ptr, uint ie_len, struct sta_info *psta)
-{
-       unsigned int i;
-       struct ndis_802_11_var_ie *pIE;
-
-       for (i = 0; i < ie_len;) {
-               pIE = (struct ndis_802_11_var_ie *)(ie_ptr + i);
-
-               switch (pIE->ElementID) {
-               case _HT_EXTRA_INFO_IE_:        /* HT info */
-                       /* HT_info_handler(padapter, pIE); */
-                       bwmode_update_check(padapter, pIE);
-                       break;
-               case _ERPINFO_IE_:
-                       ERP_IE_handler(padapter, pIE);
-                       VCS_update(padapter, psta);
-                       break;
-               default:
-                       break;
-               }
-
-               i += (pIE->Length + 2);
-       }
-}
-
-bool is_ap_in_tkip(struct adapter *padapter)
-{
-       u32 i;
-       struct ndis_802_11_var_ie *pIE;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex            *cur_network = &pmlmeinfo->network;
-
-       if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) {
-               for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) {
-                       pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.IEs + i);
-
-                       switch (pIE->ElementID) {
-                       case _VENDOR_SPECIFIC_IE_:
-                               if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4)))
-                                       return true;
-                               break;
-                       case _RSN_IE_2_:
-                               if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4))
-                                       return true;
-                               break;
-                       default:
-                               break;
-                       }
-
-                       i += (pIE->Length + 2);
-               }
-               return false;
-       } else {
-               return false;
-       }
-}
-
-int wifirate2_ratetbl_inx(unsigned char rate)
-{
-       int     inx = 0;
-       rate = rate & 0x7f;
-
-       switch (rate) {
-       case 54 * 2:
-               inx = 11;
-               break;
-       case 48 * 2:
-               inx = 10;
-               break;
-       case 36 * 2:
-               inx = 9;
-               break;
-       case 24 * 2:
-               inx = 8;
-               break;
-       case 18 * 2:
-               inx = 7;
-               break;
-       case 12 * 2:
-               inx = 6;
-               break;
-       case 9 * 2:
-               inx = 5;
-               break;
-       case 6 * 2:
-               inx = 4;
-               break;
-       case 11 * 2:
-               inx = 3;
-               break;
-       case 11:
-               inx = 2;
-               break;
-       case 2 * 2:
-               inx = 1;
-               break;
-       case 1 * 2:
-               inx = 0;
-               break;
-       }
-       return inx;
-}
-
-unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz)
-{
-       unsigned int i, num_of_rate;
-       unsigned int mask = 0;
-
-       num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz;
-
-       for (i = 0; i < num_of_rate; i++) {
-               if ((*(ptn + i)) & 0x80)
-                       mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i));
-       }
-       return mask;
-}
-
-unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz)
-{
-       unsigned int i, num_of_rate;
-       unsigned int mask = 0;
-
-       num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz;
-
-       for (i = 0; i < num_of_rate; i++)
-               mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i));
-       return mask;
-}
-
-unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps)
-{
-       unsigned int mask = 0;
-
-       mask = ((pHT_caps->u.HT_cap_element.MCS_rate[0] << 12) | (pHT_caps->u.HT_cap_element.MCS_rate[1] << 20));
-
-       return mask;
-}
-
-int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps)
-{
-       unsigned char                                   bit_offset;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (!(pmlmeinfo->HT_enable))
-               return _FAIL;
-
-       if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK)
-               return _FAIL;
-
-       bit_offset = (pmlmeext->cur_bwmode & HT_CHANNEL_WIDTH_40) ? 6 : 5;
-
-       if (__le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info) & (0x1 << bit_offset))
-               return _SUCCESS;
-       else
-               return _FAIL;
-}
-
-unsigned char get_highest_rate_idx(u32 mask)
-{
-       int i;
-       unsigned char rate_idx = 0;
-
-       for (i = 27; i >= 0; i--) {
-               if (mask & BIT(i)) {
-                       rate_idx = i;
-                       break;
-               }
-       }
-       return rate_idx;
-}
-
-void Update_RA_Entry(struct adapter *padapter, u32 mac_id)
-{
-       rtw_hal_update_ra_mask(padapter, mac_id, 0);
-}
-
-static void enable_rate_adaptive(struct adapter *padapter, u32 mac_id)
-{
-       Update_RA_Entry(padapter, mac_id);
-}
-
-void set_sta_rate(struct adapter *padapter, struct sta_info *psta)
-{
-       /* rate adaptive */
-       enable_rate_adaptive(padapter, psta->mac_id);
-}
-
-void rtw_set_basic_rate(struct adapter *adapter, u8 *rates)
-{
-       u16 BrateCfg = 0;
-       u8 RateIndex = 0;
-       int res;
-       u8 reg;
-
-       /*  2007.01.16, by Emily */
-       /*  Select RRSR (in Legacy-OFDM and CCK) */
-       /*  For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, 2M, and 1M from the Basic rate. */
-       /*  We do not use other rates. */
-       HalSetBrateCfg(adapter, rates, &BrateCfg);
-
-       /* 2011.03.30 add by Luke Lee */
-       /* CCK 2M ACK should be disabled for some BCM and Atheros AP IOT */
-       /* because CCK 2M has poor TXEVM */
-       /* CCK 5.5M & 11M ACK should be enabled for better performance */
-
-       BrateCfg = (BrateCfg | 0xd) & 0x15d;
-
-       BrateCfg |= 0x01; /*  default enable 1M ACK rate */
-       /*  Set RRSR rate table. */
-       rtw_write8(adapter, REG_RRSR, BrateCfg & 0xff);
-       rtw_write8(adapter, REG_RRSR + 1, (BrateCfg >> 8) & 0xff);
-       res = rtw_read8(adapter, REG_RRSR + 2, &reg);
-       if (res)
-               return;
-
-       rtw_write8(adapter, REG_RRSR + 2, reg & 0xf0);
-
-       /*  Set RTS initial rate */
-       while (BrateCfg > 0x1) {
-               BrateCfg = (BrateCfg >> 1);
-               RateIndex++;
-       }
-       /*  Ziv - Check */
-       rtw_write8(adapter, REG_INIRTS_RATE_SEL, RateIndex);
-}
-
-/*  Update RRSR and Rate for USERATE */
-void update_tx_basic_rate(struct adapter *padapter, u8 wirelessmode)
-{
-       unsigned char supported_rates[NDIS_802_11_LENGTH_RATES_EX];
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       /*      Added by Albert 2011/03/22 */
-       /*      In the P2P mode, the driver should not support the b mode. */
-       /*      So, the Tx packet shouldn't use the CCK rate */
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-       memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX);
-
-       if ((wirelessmode & WIRELESS_11B) && (wirelessmode == WIRELESS_11B))
-               memcpy(supported_rates, rtw_basic_rate_cck, 4);
-       else if (wirelessmode & WIRELESS_11B)
-               memcpy(supported_rates, rtw_basic_rate_mix, 7);
-       else
-               memcpy(supported_rates, rtw_basic_rate_ofdm, 3);
-
-       if (wirelessmode & WIRELESS_11B)
-               update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB);
-       else
-               update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB);
-
-       rtw_set_basic_rate(padapter, supported_rates);
-}
-
-unsigned char check_assoc_AP(u8 *pframe, uint len)
-{
-       unsigned int i;
-       struct ndis_802_11_var_ie *pIE;
-       u8      epigram_vendor_flag;
-       u8      ralink_vendor_flag;
-       epigram_vendor_flag = 0;
-       ralink_vendor_flag = 0;
-
-       for (i = sizeof(struct ndis_802_11_fixed_ie); i < len;) {
-               pIE = (struct ndis_802_11_var_ie *)(pframe + i);
-
-               switch (pIE->ElementID) {
-               case _VENDOR_SPECIFIC_IE_:
-                       if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) ||
-                           (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) {
-                               return HT_IOT_PEER_ATHEROS;
-                       } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) ||
-                                  (!memcmp(pIE->data, BROADCOM_OUI2, 3))) {
-                               return HT_IOT_PEER_BROADCOM;
-                       } else if (!memcmp(pIE->data, MARVELL_OUI, 3)) {
-                               return HT_IOT_PEER_MARVELL;
-                       } else if (!memcmp(pIE->data, RALINK_OUI, 3)) {
-                               if (!ralink_vendor_flag) {
-                                       ralink_vendor_flag = 1;
-                               } else {
-                                       return HT_IOT_PEER_RALINK;
-                               }
-                       } else if (!memcmp(pIE->data, CISCO_OUI, 3)) {
-                               return HT_IOT_PEER_CISCO;
-                       } else if (!memcmp(pIE->data, REALTEK_OUI, 3)) {
-                               return HT_IOT_PEER_REALTEK;
-                       } else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) {
-                               return HT_IOT_PEER_AIRGO;
-                       } else if (!memcmp(pIE->data, EPIGRAM_OUI, 3)) {
-                               epigram_vendor_flag = 1;
-                               if (ralink_vendor_flag)
-                                       return HT_IOT_PEER_TENDA;
-                       } else {
-                               break;
-                       }
-                       break;
-
-               default:
-                       break;
-               }
-               i += (pIE->Length + 2);
-       }
-
-       if (ralink_vendor_flag && !epigram_vendor_flag)
-               return HT_IOT_PEER_RALINK;
-       else if (ralink_vendor_flag && epigram_vendor_flag)
-               return HT_IOT_PEER_TENDA;
-       else
-               return HT_IOT_PEER_UNKNOWN;
-}
-
-void update_IOT_info(struct adapter *padapter)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       switch (pmlmeinfo->assoc_AP_vendor) {
-       case HT_IOT_PEER_MARVELL:
-               pmlmeinfo->turboMode_cts2self = 1;
-               pmlmeinfo->turboMode_rtsen = 0;
-               break;
-       case HT_IOT_PEER_RALINK:
-               pmlmeinfo->turboMode_cts2self = 0;
-               pmlmeinfo->turboMode_rtsen = 1;
-               break;
-       case HT_IOT_PEER_REALTEK:
-               /* rtw_write16(padapter, 0x4cc, 0xffff); */
-               /* rtw_write16(padapter, 0x546, 0x01c0); */
-               break;
-       default:
-               pmlmeinfo->turboMode_cts2self = 0;
-               pmlmeinfo->turboMode_rtsen = 1;
-               break;
-       }
-}
-
-static void set_ack_preamble(struct adapter *adapter, bool short_preamble)
-{
-       struct hal_data_8188e *haldata = &adapter->haldata;
-       u8 val8;
-
-       /*  Joseph marked out for Netgear 3500 TKIP channel 7 issue.(Temporarily) */
-       val8 = haldata->nCur40MhzPrimeSC << 5;
-       if (short_preamble)
-               val8 |= 0x80;
-
-       rtw_write8(adapter, REG_RRSR + 2, val8);
-};
-
-static void set_slot_time(struct adapter *adapter, u8 slot_time)
-{
-       u8 u1bAIFS, aSifsTime;
-       struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
-       struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       rtw_write8(adapter, REG_SLOT, slot_time);
-
-       if (pmlmeinfo->WMM_enable == 0) {
-               if (pmlmeext->cur_wireless_mode == WIRELESS_11B)
-                       aSifsTime = 10;
-               else
-                       aSifsTime = 16;
-
-               u1bAIFS = aSifsTime + (2 * pmlmeinfo->slotTime);
-
-               /*  <Roger_EXP> Temporary removed, 2008.06.20. */
-               rtw_write8(adapter, REG_EDCA_VO_PARAM, u1bAIFS);
-               rtw_write8(adapter, REG_EDCA_VI_PARAM, u1bAIFS);
-               rtw_write8(adapter, REG_EDCA_BE_PARAM, u1bAIFS);
-               rtw_write8(adapter, REG_EDCA_BK_PARAM, u1bAIFS);
-       }
-}
-
-void update_capinfo(struct adapter *Adapter, u16 updateCap)
-{
-       struct mlme_ext_priv    *pmlmeext = &Adapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       /*  Check preamble mode, 2005.01.06, by rcnjko. */
-       /*  Mark to update preamble value forever, 2008.03.18 by lanhsin */
-
-       if (updateCap & cShortPreamble) { /*  Short Preamble */
-               if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { /*  PREAMBLE_LONG or PREAMBLE_AUTO */
-                       pmlmeinfo->preamble_mode = PREAMBLE_SHORT;
-                       set_ack_preamble(Adapter, true);
-               }
-       } else { /*  Long Preamble */
-               if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) {  /*  PREAMBLE_SHORT or PREAMBLE_AUTO */
-                       pmlmeinfo->preamble_mode = PREAMBLE_LONG;
-                       set_ack_preamble(Adapter, false);
-               }
-       }
-
-       if (updateCap & cIBSS) {
-               /* Filen: See 802.11-2007 p.91 */
-               pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME;
-       } else { /* Filen: See 802.11-2007 p.90 */
-               if (pmlmeext->cur_wireless_mode & (WIRELESS_11G | WIRELESS_11_24N)) {
-                       if (updateCap & cShortSlotTime) { /*  Short Slot Time */
-                               if (pmlmeinfo->slotTime != SHORT_SLOT_TIME)
-                                       pmlmeinfo->slotTime = SHORT_SLOT_TIME;
-                       } else { /*  Long Slot Time */
-                               if (pmlmeinfo->slotTime != NON_SHORT_SLOT_TIME)
-                                       pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME;
-                       }
-               } else {
-                       /* B Mode */
-                       pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME;
-               }
-       }
-
-       set_slot_time(Adapter, pmlmeinfo->slotTime);
-}
-
-void update_wireless_mode(struct adapter *padapter)
-{
-       int ratelen, network_type = 0;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex    *cur_network = &pmlmeinfo->network;
-       unsigned char           *rate = cur_network->SupportedRates;
-
-       ratelen = rtw_get_rateset_len(cur_network->SupportedRates);
-
-       if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable))
-               pmlmeinfo->HT_enable = 1;
-
-       if (pmlmeext->cur_channel > 14) {
-               network_type |= WIRELESS_INVALID;
-       } else {
-               if (pmlmeinfo->HT_enable)
-                       network_type = WIRELESS_11_24N;
-
-               if (cckratesonly_included(rate, ratelen))
-                       network_type |= WIRELESS_11B;
-               else if (cckrates_included(rate, ratelen))
-                       network_type |= WIRELESS_11BG;
-               else
-                       network_type |= WIRELESS_11G;
-       }
-
-       pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode;
-
-       /* RESP_SIFS for CCK */
-       rtw_write8(padapter, REG_R2T_SIFS, 0x08);
-       rtw_write8(padapter, REG_R2T_SIFS + 1, 0x08);
-       /* RESP_SIFS for OFDM */
-       rtw_write8(padapter, REG_T2T_SIFS, 0x0a);
-       rtw_write8(padapter, REG_T2T_SIFS + 1, 0x0a);
-
-       if (pmlmeext->cur_wireless_mode & WIRELESS_11B)
-               update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB);
-        else
-               update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB);
-}
-
-void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (pmlmeext->cur_wireless_mode & WIRELESS_11B) {
-               /*  Only B, B/G, and B/G/N AP could use CCK rate */
-               memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_cck, 4);
-       } else {
-               memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_ofdm, 3);
-       }
-}
-
-int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx)
-{
-       unsigned int    ie_len;
-       struct ndis_802_11_var_ie *pIE;
-       int     supportRateNum = 0;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len);
-       if (!pIE)
-               return _FAIL;
-
-       memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len);
-       supportRateNum = ie_len;
-
-       pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len);
-       if (pIE)
-               memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len);
-
-       return _SUCCESS;
-}
-
-void beacon_timing_control(struct adapter *padapter)
-{
-       SetBeaconRelatedRegisters8188EUsb(padapter);
-}
-
-static struct adapter *pbuddy_padapter;
-
-void rtw_handle_dualmac(struct adapter *adapter, bool init)
-{
-       if (init) {
-               if (!pbuddy_padapter) {
-                       pbuddy_padapter = adapter;
-               } else {
-                       adapter->pbuddy_adapter = pbuddy_padapter;
-                       pbuddy_padapter->pbuddy_adapter = adapter;
-                       /*  clear global value */
-                       pbuddy_padapter = NULL;
-               }
-       } else {
-               pbuddy_padapter = NULL;
-       }
-}
diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c
deleted file mode 100644 (file)
index df88b3e..0000000
+++ /dev/null
@@ -1,2179 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _RTW_XMIT_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/wifi.h"
-#include "../include/osdep_intf.h"
-#include "../include/usb_ops.h"
-#include "../include/usb_osintf.h"
-#include "../include/rtl8188e_xmit.h"
-
-static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
-static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
-
-static void _init_txservq(struct tx_servq *ptxservq)
-{
-       INIT_LIST_HEAD(&ptxservq->tx_pending);
-       INIT_LIST_HEAD(&ptxservq->sta_pending);
-       ptxservq->qcnt = 0;
-}
-
-void   _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv)
-{
-       memset((unsigned char *)psta_xmitpriv, 0, sizeof(struct sta_xmit_priv));
-       spin_lock_init(&psta_xmitpriv->lock);
-       _init_txservq(&psta_xmitpriv->be_q);
-       _init_txservq(&psta_xmitpriv->bk_q);
-       _init_txservq(&psta_xmitpriv->vi_q);
-       _init_txservq(&psta_xmitpriv->vo_q);
-}
-
-static int rtw_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf,
-                                  u32 alloc_sz)
-{
-       pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL);
-       if (!pxmitbuf->pallocated_buf)
-               return -ENOMEM;
-
-       pxmitbuf->pbuf = (u8 *)ALIGN((size_t)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
-
-       pxmitbuf->pxmit_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!pxmitbuf->pxmit_urb) {
-               kfree(pxmitbuf->pallocated_buf);
-               return -ENOMEM;
-       }
-
-       return 0;
-}
-
-static void rtw_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf,
-                                  u32 free_sz)
-{
-       usb_free_urb(pxmitbuf->pxmit_urb);
-       kfree(pxmitbuf->pallocated_buf);
-}
-
-int _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
-{
-       int i;
-       struct xmit_buf *pxmitbuf;
-       struct xmit_frame *pxframe;
-       u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
-       u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
-
-       /*  We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
-
-       spin_lock_init(&pxmitpriv->lock);
-
-       /*
-        * Please insert all the queue initializaiton using rtw_init_queue below
-        */
-
-       pxmitpriv->adapter = padapter;
-
-       INIT_LIST_HEAD(&pxmitpriv->be_pending);
-       INIT_LIST_HEAD(&pxmitpriv->bk_pending);
-       INIT_LIST_HEAD(&pxmitpriv->vi_pending);
-       INIT_LIST_HEAD(&pxmitpriv->vo_pending);
-
-       rtw_init_queue(&pxmitpriv->free_xmit_queue);
-
-       /*
-        * Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME,
-        * and initialize free_xmit_frame below.
-        * Please also apply  free_txobj to link_up all the xmit_frames...
-        */
-
-       pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4);
-
-       if (!pxmitpriv->pallocated_frame_buf) {
-               pxmitpriv->pxmit_frame_buf = NULL;
-               goto exit;
-       }
-       pxmitpriv->pxmit_frame_buf = (u8 *)ALIGN((size_t)(pxmitpriv->pallocated_frame_buf), 4);
-       /* pxmitpriv->pxmit_frame_buf = pxmitpriv->pallocated_frame_buf + 4 - */
-       /*                                              ((size_t) (pxmitpriv->pallocated_frame_buf) &3); */
-
-       pxframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf;
-
-       for (i = 0; i < NR_XMITFRAME; i++) {
-               INIT_LIST_HEAD(&pxframe->list);
-
-               pxframe->padapter = padapter;
-               pxframe->frame_tag = NULL_FRAMETAG;
-
-               pxframe->pkt = NULL;
-
-               pxframe->buf_addr = NULL;
-               pxframe->pxmitbuf = NULL;
-
-               list_add_tail(&pxframe->list, &pxmitpriv->free_xmit_queue.queue);
-
-               pxframe++;
-       }
-
-       pxmitpriv->free_xmitframe_cnt = NR_XMITFRAME;
-
-       pxmitpriv->frag_len = MAX_FRAG_THRESHOLD;
-
-       /* init xmit_buf */
-       rtw_init_queue(&pxmitpriv->free_xmitbuf_queue);
-       rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue);
-
-       pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4);
-
-       if (!pxmitpriv->pallocated_xmitbuf)
-               goto free_frame_buf;
-
-       pxmitpriv->pxmitbuf = (u8 *)ALIGN((size_t)(pxmitpriv->pallocated_xmitbuf), 4);
-       /* pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - */
-       /*                                              ((size_t) (pxmitpriv->pallocated_xmitbuf) &3); */
-
-       pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
-
-       for (i = 0; i < NR_XMITBUFF; i++) {
-               INIT_LIST_HEAD(&pxmitbuf->list);
-
-               pxmitbuf->priv_data = NULL;
-               pxmitbuf->padapter = padapter;
-               pxmitbuf->ext_tag = false;
-
-               /* Tx buf allocation may fail sometimes, so sleep and retry. */
-               if (rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ))) {
-                       msleep(10);
-                       if (rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)))
-                               goto free_xmitbuf;
-               }
-
-               pxmitbuf->high_queue = false;
-
-               list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmitbuf_queue.queue);
-               pxmitbuf++;
-       }
-
-       pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF;
-
-       /*  Init xmit extension buff */
-       rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue);
-
-       pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4);
-
-       if (!pxmitpriv->pallocated_xmit_extbuf)
-               goto free_xmitbuf;
-
-       pxmitpriv->pxmit_extbuf = (u8 *)ALIGN((size_t)(pxmitpriv->pallocated_xmit_extbuf), 4);
-
-       pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
-
-       for (i = 0; i < num_xmit_extbuf; i++) {
-               INIT_LIST_HEAD(&pxmitbuf->list);
-
-               pxmitbuf->priv_data = NULL;
-               pxmitbuf->padapter = padapter;
-               pxmitbuf->ext_tag = true;
-
-               if (rtw_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ))
-                       goto free_xmit_extbuf;
-
-               list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue);
-               pxmitbuf++;
-       }
-
-       pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf;
-
-       if (rtw_alloc_hwxmits(padapter))
-               goto free_xmit_extbuf;
-
-       for (i = 0; i < 4; i++)
-               pxmitpriv->wmm_para_seq[i] = i;
-
-       pxmitpriv->ack_tx = false;
-       mutex_init(&pxmitpriv->ack_tx_mutex);
-       rtw_sctx_init(&pxmitpriv->ack_tx_ops, 0);
-
-       tasklet_init(&pxmitpriv->xmit_tasklet, rtl8188eu_xmit_tasklet, (unsigned long)padapter);
-
-       return 0;
-
-free_xmit_extbuf:
-       pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
-       while (i--) {
-               rtw_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ));
-               pxmitbuf++;
-       }
-       vfree(pxmitpriv->pallocated_xmit_extbuf);
-       i = NR_XMITBUFF;
-free_xmitbuf:
-       pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
-       while (i--) {
-               rtw_xmit_resource_free(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
-               pxmitbuf++;
-       }
-       vfree(pxmitpriv->pallocated_xmitbuf);
-free_frame_buf:
-       vfree(pxmitpriv->pallocated_frame_buf);
-exit:
-       return -ENOMEM;
-}
-
-static void rtw_pkt_complete(struct adapter *padapter, struct sk_buff *pkt)
-{
-       u16 queue;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-
-       queue = skb_get_queue_mapping(pkt);
-       if (padapter->registrypriv.wifi_spec) {
-               if (__netif_subqueue_stopped(padapter->pnetdev, queue) &&
-                   (pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD))
-                       netif_wake_subqueue(padapter->pnetdev, queue);
-       } else {
-               if (__netif_subqueue_stopped(padapter->pnetdev, queue))
-                       netif_wake_subqueue(padapter->pnetdev, queue);
-       }
-
-       dev_kfree_skb_any(pkt);
-}
-
-void rtw_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe)
-{
-       if (pxframe->pkt)
-               rtw_pkt_complete(padapter, pxframe->pkt);
-       pxframe->pkt = NULL;
-}
-
-void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv)
-{
-       int i;
-       struct adapter *padapter = pxmitpriv->adapter;
-       struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf;
-       struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
-       u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
-       u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
-
-       if (!pxmitpriv->pxmit_frame_buf)
-               return;
-
-       for (i = 0; i < NR_XMITFRAME; i++) {
-               rtw_xmit_complete(padapter, pxmitframe);
-
-               pxmitframe++;
-       }
-
-       for (i = 0; i < NR_XMITBUFF; i++) {
-               rtw_xmit_resource_free(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
-               pxmitbuf++;
-       }
-
-       vfree(pxmitpriv->pallocated_frame_buf);
-
-       vfree(pxmitpriv->pallocated_xmitbuf);
-
-       pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
-       for (i = 0; i < num_xmit_extbuf; i++) {
-               rtw_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ));
-               pxmitbuf++;
-       }
-
-       vfree(pxmitpriv->pallocated_xmit_extbuf);
-
-       kfree(pxmitpriv->hwxmits);
-
-       mutex_destroy(&pxmitpriv->ack_tx_mutex);
-}
-
-static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame *pxmitframe)
-{
-       u32     sz;
-       struct pkt_attrib       *pattrib = &pxmitframe->attrib;
-       struct sta_info *psta = pattrib->psta;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (pattrib->nr_frags != 1)
-               sz = padapter->xmitpriv.frag_len;
-       else /* no frag */
-               sz = pattrib->last_txcmdsz;
-
-       /*  (1) RTS_Threshold is compared to the MPDU, not MSDU. */
-       /*  (2) If there are more than one frag in  this MSDU, only the first frag uses protection frame. */
-       /*              Other fragments are protected by previous fragment. */
-       /*              So we only need to check the length of first fragment. */
-       if (pmlmeext->cur_wireless_mode < WIRELESS_11_24N  || padapter->registrypriv.wifi_spec) {
-               if (sz > padapter->registrypriv.rts_thresh) {
-                       pattrib->vcs_mode = RTS_CTS;
-               } else {
-                       if (psta->rtsen)
-                               pattrib->vcs_mode = RTS_CTS;
-                       else if (psta->cts2self)
-                               pattrib->vcs_mode = CTS_TO_SELF;
-                       else
-                               pattrib->vcs_mode = NONE_VCS;
-               }
-       } else {
-               while (true) {
-                       /* IOT action */
-                       if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS) && pattrib->ampdu_en &&
-                           (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) {
-                               pattrib->vcs_mode = CTS_TO_SELF;
-                               break;
-                       }
-
-                       /* check ERP protection */
-                       if (psta->rtsen || psta->cts2self) {
-                               if (psta->rtsen)
-                                       pattrib->vcs_mode = RTS_CTS;
-                               else if (psta->cts2self)
-                                       pattrib->vcs_mode = CTS_TO_SELF;
-
-                               break;
-                       }
-
-                       /* check HT op mode */
-                       if (pattrib->ht_en) {
-                               u8 htopmode = pmlmeinfo->HT_protection;
-
-                               if ((pmlmeext->cur_bwmode && (htopmode == 2 || htopmode == 3)) ||
-                                   (!pmlmeext->cur_bwmode && htopmode == 3)) {
-                                       pattrib->vcs_mode = RTS_CTS;
-                                       break;
-                               }
-                       }
-
-                       /* check rts */
-                       if (sz > padapter->registrypriv.rts_thresh) {
-                               pattrib->vcs_mode = RTS_CTS;
-                               break;
-                       }
-
-                       /* to do list: check MIMO power save condition. */
-
-                       /* check AMPDU aggregation for TXOP */
-                       if (pattrib->ampdu_en) {
-                               pattrib->vcs_mode = RTS_CTS;
-                               break;
-                       }
-
-                       pattrib->vcs_mode = NONE_VCS;
-                       break;
-               }
-       }
-}
-
-static void update_attrib_phy_info(struct pkt_attrib *pattrib, struct sta_info *psta)
-{
-       /*if (psta->rtsen)
-               pattrib->vcs_mode = RTS_CTS;
-       else if (psta->cts2self)
-               pattrib->vcs_mode = CTS_TO_SELF;
-       else
-               pattrib->vcs_mode = NONE_VCS;*/
-
-       pattrib->mdata = 0;
-       pattrib->eosp = 0;
-       pattrib->triggered = 0;
-
-       /* qos_en, ht_en, init rate, , bw, ch_offset, sgi */
-       pattrib->qos_en = psta->qos_option;
-
-       pattrib->raid = psta->raid;
-       pattrib->ht_en = psta->htpriv.ht_option;
-       pattrib->bwmode = psta->htpriv.bwmode;
-       pattrib->ch_offset = psta->htpriv.ch_offset;
-       pattrib->sgi = psta->htpriv.sgi;
-       pattrib->ampdu_en = false;
-       pattrib->retry_ctrl = false;
-}
-
-u8     qos_acm(u8 acm_mask, u8 priority)
-{
-       u8      change_priority = priority;
-
-       switch (priority) {
-       case 0:
-       case 3:
-               if (acm_mask & BIT(1))
-                       change_priority = 1;
-               break;
-       case 1:
-       case 2:
-               break;
-       case 4:
-       case 5:
-               if (acm_mask & BIT(2))
-                       change_priority = 0;
-               break;
-       case 6:
-       case 7:
-               if (acm_mask & BIT(3))
-                       change_priority = 5;
-               break;
-       default:
-               break;
-       }
-
-       return change_priority;
-}
-
-static void rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile)
-{
-       if (!pktptr) {
-               pr_err("8188eu: pktptr is NULL\n");
-               return;
-       }
-       if (!pfile) {
-               pr_err("8188eu: pfile is NULL\n");
-               return;
-       }
-       pfile->pkt = pktptr;
-       pfile->cur_addr = pktptr->data;
-       pfile->buf_start = pktptr->data;
-       pfile->pkt_len = pktptr->len;
-       pfile->buf_len = pktptr->len;
-
-       pfile->cur_buffer = pfile->buf_start;
-}
-
-static uint rtw_remainder_len(struct pkt_file *pfile)
-{
-       return pfile->buf_len - ((size_t)(pfile->cur_addr) -
-              (size_t)(pfile->buf_start));
-}
-
-static uint rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
-{
-       uint len;
-
-       len = min(rtw_remainder_len(pfile), rlen);
-
-       if (rmem)
-               skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len, rmem, len);
-
-       pfile->cur_addr += len;
-       pfile->pkt_len -= len;
-
-       return len;
-}
-
-static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
-{
-       struct ethhdr etherhdr;
-       struct iphdr ip_hdr;
-       s32 user_prio = 0;
-
-       rtw_open_pktfile(ppktfile->pkt, ppktfile);
-       rtw_pktfile_read(ppktfile, (unsigned char *)&etherhdr, ETH_HLEN);
-
-       /*  get user_prio from IP hdr */
-       if (pattrib->ether_type == 0x0800) {
-               rtw_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr));
-/*             user_prio = (ntohs(ip_hdr.tos) >> 5) & 0x3; */
-               user_prio = ip_hdr.tos >> 5;
-       } else if (pattrib->ether_type == 0x888e) {
-               /*  "When priority processing of data frames is supported, */
-               /*  a STA's SME should send EAPOL-Key frames at the highest priority." */
-               user_prio = 7;
-       }
-
-       pattrib->priority = user_prio;
-       pattrib->hdrlen = WLAN_HDR_A3_QOS_LEN;
-       pattrib->subtype = IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA;
-}
-
-static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct pkt_attrib *pattrib)
-{
-       struct pkt_file pktfile;
-       struct sta_info *psta = NULL;
-       struct ethhdr etherhdr;
-
-       bool bmcast;
-       struct sta_priv         *pstapriv = &padapter->stapriv;
-       struct security_priv    *psecuritypriv = &padapter->securitypriv;
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct qos_priv         *pqospriv = &pmlmepriv->qospriv;
-       int res = _SUCCESS;
-
-
-
-       rtw_open_pktfile(pkt, &pktfile);
-       rtw_pktfile_read(&pktfile, (u8 *)&etherhdr, ETH_HLEN);
-
-       pattrib->ether_type = ntohs(etherhdr.h_proto);
-
-       memcpy(pattrib->dst, &etherhdr.h_dest, ETH_ALEN);
-       memcpy(pattrib->src, &etherhdr.h_source, ETH_ALEN);
-
-       pattrib->pctrl = 0;
-
-       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
-           check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
-               memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
-               memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
-       } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-               memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN);
-               memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
-       } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
-               memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN);
-       }
-
-       pattrib->pktlen = pktfile.pkt_len;
-
-       if (pattrib->ether_type == ETH_P_IP) {
-               /*  The following is for DHCP and ARP packet, we use cck1M to tx these packets and let LPS awake some time */
-               /*  to prevent DHCP protocol fail */
-               u8 tmp[24];
-
-               rtw_pktfile_read(&pktfile, &tmp[0], 24);
-               pattrib->dhcp_pkt = 0;
-               if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */
-                       if (((tmp[21] == 68) && (tmp[23] == 67)) ||
-                           ((tmp[21] == 67) && (tmp[23] == 68))) {
-                               /*  68 : UDP BOOTP client */
-                               /*  67 : UDP BOOTP server */
-                               /*  Use low rate to send DHCP packet. */
-                               pattrib->dhcp_pkt = 1;
-                       }
-               }
-       }
-
-       /*  If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */
-       if ((pattrib->ether_type == 0x0806) || (pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1))
-               rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1);
-
-       bmcast = is_multicast_ether_addr(pattrib->ra);
-
-       /*  get sta_info */
-       if (bmcast) {
-               psta = rtw_get_bcmc_stainfo(padapter);
-       } else {
-               psta = rtw_get_stainfo(pstapriv, pattrib->ra);
-               if (!psta) { /*  if we cannot get psta => drrp the pkt */
-                       res = _FAIL;
-                       goto exit;
-               } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) && !(psta->state & _FW_LINKED)) {
-                       res = _FAIL;
-                       goto exit;
-               }
-       }
-
-       if (psta) {
-               pattrib->mac_id = psta->mac_id;
-               pattrib->psta = psta;
-       } else {
-               /*  if we cannot get psta => drop the pkt */
-               res = _FAIL;
-               goto exit;
-       }
-
-       pattrib->ack_policy = 0;
-       /*  get ether_hdr_len */
-       pattrib->pkt_hdrlen = ETH_HLEN;/* pattrib->ether_type == 0x8100) ? (14 + 4): 14; vlan tag */
-
-       pattrib->hdrlen = WLAN_HDR_A3_LEN;
-       pattrib->subtype = IEEE80211_FTYPE_DATA;
-       pattrib->priority = 0;
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE | WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) {
-               if (psta->qos_option)
-                       set_qos(&pktfile, pattrib);
-       } else {
-               if (pqospriv->qos_option) {
-                       set_qos(&pktfile, pattrib);
-
-                       if (pmlmepriv->acm_mask != 0)
-                               pattrib->priority = qos_acm(pmlmepriv->acm_mask, pattrib->priority);
-               }
-       }
-
-       if (psta->ieee8021x_blocked) {
-               pattrib->encrypt = 0;
-
-               if ((pattrib->ether_type != 0x888e) && !check_fwstate(pmlmepriv, WIFI_MP_STATE)) {
-                       res = _FAIL;
-                       goto exit;
-               }
-       } else {
-               GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast);
-
-               switch (psecuritypriv->dot11AuthAlgrthm) {
-               case dot11AuthAlgrthm_Open:
-               case dot11AuthAlgrthm_Shared:
-               case dot11AuthAlgrthm_Auto:
-                       pattrib->key_idx = (u8)psecuritypriv->dot11PrivacyKeyIndex;
-                       break;
-               case dot11AuthAlgrthm_8021X:
-                       if (bmcast)
-                               pattrib->key_idx = (u8)psecuritypriv->dot118021XGrpKeyid;
-                       else
-                               pattrib->key_idx = 0;
-                       break;
-               default:
-                       pattrib->key_idx = 0;
-                       break;
-               }
-       }
-
-       switch (pattrib->encrypt) {
-       case _WEP40_:
-       case _WEP104_:
-               pattrib->iv_len = 4;
-               pattrib->icv_len = 4;
-               break;
-       case _TKIP_:
-               pattrib->iv_len = 8;
-               pattrib->icv_len = 4;
-
-               if (padapter->securitypriv.busetkipkey == _FAIL) {
-                       res = _FAIL;
-                       goto exit;
-               }
-               break;
-       case _AES_:
-               pattrib->iv_len = 8;
-               pattrib->icv_len = 8;
-               break;
-       default:
-               pattrib->iv_len = 0;
-               pattrib->icv_len = 0;
-               break;
-       }
-
-       if (pattrib->encrypt &&
-           (padapter->securitypriv.sw_encrypt || !psecuritypriv->hw_decrypted))
-               pattrib->bswenc = true;
-       else
-               pattrib->bswenc = false;
-
-       update_attrib_phy_info(pattrib, psta);
-
-exit:
-
-       return res;
-}
-
-static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe)
-{
-       int curfragnum, length;
-       u8      *pframe, *payload, mic[8];
-       struct  mic_data micdata;
-       struct  sta_info *stainfo;
-       struct  pkt_attrib *pattrib = &pxmitframe->attrib;
-       struct  security_priv   *psecuritypriv = &padapter->securitypriv;
-       struct  xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
-       u8 hw_hdr_offset = 0;
-
-       if (pattrib->psta)
-               stainfo = pattrib->psta;
-       else
-               stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]);
-
-       hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);
-
-       if (pattrib->encrypt == _TKIP_) {/* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */
-               /* encode mic code */
-               if (stainfo) {
-                       u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-                                          0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-                                          0x0, 0x0};
-
-                       pframe = pxmitframe->buf_addr + hw_hdr_offset;
-
-                       if (is_multicast_ether_addr(pattrib->ra)) {
-                               if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16))
-                                       return _FAIL;
-                               /* start to calculate the mic code */
-                               rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey);
-                       } else {
-                               if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16)) {
-                                       /* msleep(10); */
-                                       return _FAIL;
-                               }
-                               /* start to calculate the mic code */
-                               rtw_secmicsetkey(&micdata, &stainfo->dot11tkiptxmickey.skey[0]);
-                       }
-
-                       if (pframe[1] & 1) {   /* ToDS == 1 */
-                               rtw_secmicappend(&micdata, &pframe[16], 6);  /* DA */
-                               if (pframe[1] & 2)  /* From Ds == 1 */
-                                       rtw_secmicappend(&micdata, &pframe[24], 6);
-                               else
-                                       rtw_secmicappend(&micdata, &pframe[10], 6);
-                       } else {        /* ToDS == 0 */
-                               rtw_secmicappend(&micdata, &pframe[4], 6);   /* DA */
-                               if (pframe[1] & 2)  /* From Ds == 1 */
-                                       rtw_secmicappend(&micdata, &pframe[16], 6);
-                               else
-                                       rtw_secmicappend(&micdata, &pframe[10], 6);
-                       }
-
-                       if (pattrib->qos_en)
-                               priority[0] = (u8)pxmitframe->attrib.priority;
-
-                       rtw_secmicappend(&micdata, &priority[0], 4);
-
-                       payload = pframe;
-
-                       for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
-                               payload = PTR_ALIGN(payload, 4);
-
-                               payload = payload + pattrib->hdrlen + pattrib->iv_len;
-                               if ((curfragnum + 1) == pattrib->nr_frags) {
-                                       length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - ((pattrib->bswenc) ? pattrib->icv_len : 0);
-                                       rtw_secmicappend(&micdata, payload, length);
-                                       payload = payload + length;
-                               } else {
-                                       length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - ((pattrib->bswenc) ? pattrib->icv_len : 0);
-                                       rtw_secmicappend(&micdata, payload, length);
-                                       payload = payload + length + pattrib->icv_len;
-                               }
-                       }
-                       rtw_secgetmic(&micdata, &mic[0]);
-                       /* add mic code  and add the mic code length in last_txcmdsz */
-
-                       memcpy(payload, &mic[0], 8);
-                       pattrib->last_txcmdsz += 8;
-
-                       payload = payload - pattrib->last_txcmdsz + 8;
-               }
-       }
-
-       return _SUCCESS;
-}
-
-static void xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
-{
-       struct  pkt_attrib       *pattrib = &pxmitframe->attrib;
-
-       if (!pattrib->bswenc)
-               return;
-
-       switch (pattrib->encrypt) {
-       case _WEP40_:
-       case _WEP104_:
-               rtw_wep_encrypt(padapter, pxmitframe);
-               break;
-       case _TKIP_:
-               rtw_tkip_encrypt(padapter, pxmitframe);
-               break;
-       case _AES_:
-               rtw_aes_encrypt(padapter, pxmitframe);
-               break;
-       default:
-               break;
-       }
-}
-
-s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib)
-{
-       u16 *qc;
-
-       struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct qos_priv *pqospriv = &pmlmepriv->qospriv;
-       bool qos_option;
-       __le16 *fctrl = &pwlanhdr->frame_control;
-
-       struct sta_info *psta;
-
-       if (pattrib->psta)
-               psta = pattrib->psta;
-       else if (is_multicast_ether_addr(pattrib->ra))
-               psta = rtw_get_bcmc_stainfo(padapter);
-       else
-               psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
-
-       memset(hdr, 0, WLANHDR_OFFSET);
-
-       SetFrameSubType(fctrl, pattrib->subtype);
-
-       if (!(pattrib->subtype & IEEE80211_FTYPE_DATA))
-               return _SUCCESS;
-
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-               /* to_ds = 1, fr_ds = 0; */
-               /* Data transfer to AP */
-               SetToDs(fctrl);
-               memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN);
-               memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
-               memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN);
-               qos_option = pqospriv->qos_option;
-       } else if (check_fwstate(pmlmepriv,  WIFI_AP_STATE)) {
-               /* to_ds = 0, fr_ds = 1; */
-               SetFrDs(fctrl);
-               memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
-               memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN);
-               memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN);
-               qos_option = psta->qos_option;
-       } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
-                  check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
-               memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
-               memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
-               memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN);
-               qos_option = psta->qos_option;
-       } else {
-               return _FAIL;
-       }
-
-       if (pattrib->mdata)
-               SetMData(fctrl);
-
-       if (pattrib->encrypt)
-               SetPrivacy(fctrl);
-
-       if (qos_option) {
-               qc = (unsigned short *)(hdr + pattrib->hdrlen - 2);
-
-               if (pattrib->priority)
-                       SetPriority(qc, pattrib->priority);
-
-               SetEOSP(qc, pattrib->eosp);
-
-               SetAckpolicy(qc, pattrib->ack_policy);
-       }
-
-       /* TODO: fill HT Control Field */
-
-       /* Update Seq Num will be handled by f/w */
-       if (psta) {
-               psta->sta_xmitpriv.txseq_tid[pattrib->priority]++;
-               psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF;
-
-               pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority];
-
-               SetSeqNum(hdr, pattrib->seqnum);
-
-               /* check if enable ampdu */
-               if (pattrib->ht_en && psta->htpriv.ampdu_enable) {
-                       if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority))
-                               pattrib->ampdu_en = true;
-               }
-
-               /* re-check if enable ampdu by BA_starting_seqctrl */
-               if (pattrib->ampdu_en) {
-                       u16 tx_seq;
-
-                       tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f];
-
-                       /* check BA_starting_seqctrl */
-                       if (SN_LESS(pattrib->seqnum, tx_seq)) {
-                               pattrib->ampdu_en = false;/* AGG BK */
-                       } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) {
-                               psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq + 1) & 0xfff;
-
-                               pattrib->ampdu_en = true;/* AGG EN */
-                       } else {
-                               psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum + 1) & 0xfff;
-                               pattrib->ampdu_en = true;/* AGG EN */
-                       }
-               }
-       }
-
-       return _SUCCESS;
-}
-
-s32 rtw_txframes_pending(struct adapter *padapter)
-{
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-
-       return (!list_empty(&pxmitpriv->be_pending) ||
-               !list_empty(&pxmitpriv->bk_pending) ||
-               !list_empty(&pxmitpriv->vi_pending) ||
-               !list_empty(&pxmitpriv->vo_pending));
-}
-
-s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pattrib)
-{
-       struct sta_info *psta;
-       struct tx_servq *ptxservq;
-       int priority = pattrib->priority;
-
-       psta = pattrib->psta;
-
-       switch (priority) {
-       case 1:
-       case 2:
-               ptxservq = &psta->sta_xmitpriv.bk_q;
-               break;
-       case 4:
-       case 5:
-               ptxservq = &psta->sta_xmitpriv.vi_q;
-               break;
-       case 6:
-       case 7:
-               ptxservq = &psta->sta_xmitpriv.vo_q;
-               break;
-       case 0:
-       case 3:
-       default:
-               ptxservq = &psta->sta_xmitpriv.be_q;
-               break;
-       }
-
-       if (ptxservq)
-               return ptxservq->qcnt;
-       return 0;
-}
-
-/*
- * This sub-routine will perform all the following:
- *
- * 1. remove 802.3 header.
- * 2. create wlan_header, based on the info in pxmitframe
- * 3. append sta's iv/ext-iv
- * 4. append LLC
- * 5. move frag chunk from pframe to pxmitframe->mem
- * 6. apply sw-encrypt, if necessary.
- */
-s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe)
-{
-       struct pkt_file pktfile;
-       s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz;
-       u8 *pframe, *mem_start;
-       u8 hw_hdr_offset;
-       struct sta_info         *psta;
-       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
-       struct pkt_attrib       *pattrib = &pxmitframe->attrib;
-       u8 *pbuf_start;
-       bool bmcst = is_multicast_ether_addr(pattrib->ra);
-       s32 res = _SUCCESS;
-
-       if (!pkt)
-               return _FAIL;
-
-       psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
-
-       if (!psta)
-               return _FAIL;
-
-       if (!pxmitframe->buf_addr)
-               return _FAIL;
-
-       pbuf_start = pxmitframe->buf_addr;
-
-       hw_hdr_offset =  TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);
-
-       mem_start = pbuf_start +        hw_hdr_offset;
-
-       if (rtw_make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       rtw_open_pktfile(pkt, &pktfile);
-       rtw_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen);
-
-       frg_inx = 0;
-       frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */
-
-       while (1) {
-               llc_sz = 0;
-
-               mpdu_len = frg_len;
-
-               pframe = mem_start;
-
-               SetMFrag(mem_start);
-
-               pframe += pattrib->hdrlen;
-               mpdu_len -= pattrib->hdrlen;
-
-               /* adding icv, if necessary... */
-               if (pattrib->iv_len) {
-                       switch (pattrib->encrypt) {
-                       case _WEP40_:
-                       case _WEP104_:
-                               WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
-                               break;
-                       case _TKIP_:
-                               if (bmcst)
-                                       TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
-                               else
-                                       TKIP_IV(pattrib->iv, psta->dot11txpn, 0);
-                               break;
-                       case _AES_:
-                               if (bmcst)
-                                       AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
-                               else
-                                       AES_IV(pattrib->iv, psta->dot11txpn, 0);
-                               break;
-                       }
-
-                       memcpy(pframe, pattrib->iv, pattrib->iv_len);
-
-                       pframe += pattrib->iv_len;
-
-                       mpdu_len -= pattrib->iv_len;
-               }
-
-               if (frg_inx == 0) {
-                       llc_sz = rtw_put_snap(pframe, pattrib->ether_type);
-                       pframe += llc_sz;
-                       mpdu_len -= llc_sz;
-               }
-
-               if ((pattrib->icv_len > 0) && (pattrib->bswenc))
-                       mpdu_len -= pattrib->icv_len;
-
-               if (bmcst) {
-                       /*  don't do fragment to broadcast/multicast packets */
-                       mem_sz = rtw_pktfile_read(&pktfile, pframe, pattrib->pktlen);
-               } else {
-                       mem_sz = rtw_pktfile_read(&pktfile, pframe, mpdu_len);
-               }
-
-               pframe += mem_sz;
-
-               if ((pattrib->icv_len > 0) && (pattrib->bswenc)) {
-                       memcpy(pframe, pattrib->icv, pattrib->icv_len);
-                       pframe += pattrib->icv_len;
-               }
-
-               frg_inx++;
-
-               if (bmcst || pktfile.pkt_len == 0) {
-                       pattrib->nr_frags = frg_inx;
-
-                       pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->iv_len + ((pattrib->nr_frags == 1) ? llc_sz : 0) +
-                                               ((pattrib->bswenc) ? pattrib->icv_len : 0) + mem_sz;
-
-                       ClearMFrag(mem_start);
-
-                       break;
-               }
-
-               mem_start = PTR_ALIGN(pframe, 4) + hw_hdr_offset;
-               memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen);
-       }
-
-       if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       xmitframe_swencrypt(padapter, pxmitframe);
-
-       if (!bmcst)
-               update_attrib_vcs_info(padapter, pxmitframe);
-       else
-               pattrib->vcs_mode = NONE_VCS;
-
-exit:
-
-       return res;
-}
-
-/* Logical Link Control(LLC) SubNetwork Attachment Point(SNAP) header
- * IEEE LLC/SNAP header contains 8 octets
- * First 3 octets comprise the LLC portion
- * SNAP portion, 5 octets, is divided into two fields:
- *     Organizationally Unique Identifier(OUI), 3 octets,
- *     type, defined by that organization, 2 octets.
- */
-s32 rtw_put_snap(u8 *data, u16 h_proto)
-{
-       struct ieee80211_snap_hdr *snap;
-       u8 *oui;
-
-       snap = (struct ieee80211_snap_hdr *)data;
-       snap->dsap = 0xaa;
-       snap->ssap = 0xaa;
-       snap->ctrl = 0x03;
-
-       if (h_proto == 0x8137 || h_proto == 0x80f3)
-               oui = P802_1H_OUI;
-       else
-               oui = RFC1042_OUI;
-
-       snap->oui[0] = oui[0];
-       snap->oui[1] = oui[1];
-       snap->oui[2] = oui[2];
-
-       *(__be16 *)(data + SNAP_SIZE) = htons(h_proto);
-
-       return SNAP_SIZE + sizeof(u16);
-}
-
-void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz)
-{
-       struct sta_info *psta = NULL;
-       struct stainfo_stats *pstats = NULL;
-       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-
-       if ((pxmitframe->frame_tag & 0x0f) == DATA_FRAMETAG) {
-               pxmitpriv->tx_bytes += sz;
-               pmlmepriv->LinkDetectInfo.NumTxOkInPeriod += pxmitframe->agg_num;
-
-               psta = pxmitframe->attrib.psta;
-               if (psta) {
-                       pstats = &psta->sta_stats;
-                       pstats->tx_pkts += pxmitframe->agg_num;
-                       pstats->tx_bytes += sz;
-               }
-       }
-}
-
-struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv)
-{
-       struct xmit_buf *pxmitbuf =  NULL;
-       struct list_head *plist, *phead;
-       struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
-       unsigned long flags;
-
-       spin_lock_irqsave(&pfree_queue->lock, flags);
-
-       if (list_empty(&pfree_queue->queue)) {
-               pxmitbuf = NULL;
-       } else {
-               phead = get_list_head(pfree_queue);
-
-               plist = phead->next;
-
-               pxmitbuf = container_of(plist, struct xmit_buf, list);
-
-               list_del_init(&pxmitbuf->list);
-       }
-
-       if (pxmitbuf) {
-               pxmitpriv->free_xmit_extbuf_cnt--;
-
-               pxmitbuf->priv_data = NULL;
-               /* pxmitbuf->ext_tag = true; */
-
-               if (pxmitbuf->sctx)
-                       rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC);
-       }
-
-       spin_unlock_irqrestore(&pfree_queue->lock, flags);
-
-       return pxmitbuf;
-}
-
-s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
-{
-       struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
-       unsigned long flags;
-
-       if (!pxmitbuf)
-               return _FAIL;
-
-       spin_lock_irqsave(&pfree_queue->lock, flags);
-
-       list_del_init(&pxmitbuf->list);
-
-       list_add_tail(&pxmitbuf->list, get_list_head(pfree_queue));
-       pxmitpriv->free_xmit_extbuf_cnt++;
-
-       spin_unlock_irqrestore(&pfree_queue->lock, flags);
-
-       return _SUCCESS;
-}
-
-struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
-{
-       struct xmit_buf *pxmitbuf =  NULL;
-       struct list_head *plist, *phead;
-       struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
-       unsigned long flags;
-
-       spin_lock_irqsave(&pfree_xmitbuf_queue->lock, flags);
-
-       if (list_empty(&pfree_xmitbuf_queue->queue)) {
-               pxmitbuf = NULL;
-       } else {
-               phead = get_list_head(pfree_xmitbuf_queue);
-
-               plist = phead->next;
-
-               pxmitbuf = container_of(plist, struct xmit_buf, list);
-
-               list_del_init(&pxmitbuf->list);
-       }
-
-       if (pxmitbuf) {
-               pxmitpriv->free_xmitbuf_cnt--;
-               pxmitbuf->priv_data = NULL;
-               if (pxmitbuf->sctx)
-                       rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC);
-       }
-       spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, flags);
-
-       return pxmitbuf;
-}
-
-s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
-{
-       struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
-       unsigned long flags;
-
-       if (!pxmitbuf)
-               return _FAIL;
-
-       if (pxmitbuf->sctx)
-               rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_FREE);
-
-       if (pxmitbuf->ext_tag) {
-               rtw_free_xmitbuf_ext(pxmitpriv, pxmitbuf);
-       } else {
-               spin_lock_irqsave(&pfree_xmitbuf_queue->lock, flags);
-
-               list_del_init(&pxmitbuf->list);
-
-               list_add_tail(&pxmitbuf->list, get_list_head(pfree_xmitbuf_queue));
-
-               pxmitpriv->free_xmitbuf_cnt++;
-               spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, flags);
-       }
-
-       return _SUCCESS;
-}
-
-/*
- * Calling context:
- * 1. OS_TXENTRY
- * 2. RXENTRY (rx_thread or RX_ISR/RX_CallBack)
- *
- * If we turn on USE_RXTHREAD, then, no need for critical section.
- * Otherwise, we must use _enter/_exit critical to protect free_xmit_queue...
- *
- * Must be very very cautious...
- */
-struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pfree_xmit_queue) */
-{
-       /*
-        * Please remember to use all the osdep_service api,
-        * and lock/unlock or _enter/_exit critical to protect
-        * pfree_xmit_queue
-        */
-
-       struct xmit_frame *pxframe = NULL;
-       struct list_head *plist, *phead;
-       struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue;
-
-       spin_lock_bh(&pfree_xmit_queue->lock);
-
-       if (list_empty(&pfree_xmit_queue->queue))
-               goto out;
-
-       phead = get_list_head(pfree_xmit_queue);
-       plist = phead->next;
-       pxframe = container_of(plist, struct xmit_frame, list);
-       list_del_init(&pxframe->list);
-
-       pxmitpriv->free_xmitframe_cnt--;
-
-       pxframe->buf_addr = NULL;
-       pxframe->pxmitbuf = NULL;
-
-       memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib));
-       /* pxframe->attrib.psta = NULL; */
-
-       pxframe->frame_tag = DATA_FRAMETAG;
-
-       pxframe->pkt = NULL;
-       pxframe->pkt_offset = 1;/* default use pkt_offset to fill tx desc */
-
-       pxframe->agg_num = 1;
-       pxframe->ack_report = 0;
-
-out:
-       spin_unlock_bh(&pfree_xmit_queue->lock);
-       return pxframe;
-}
-
-s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe)
-{
-       struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue;
-       struct adapter *padapter = pxmitpriv->adapter;
-       struct sk_buff *pndis_pkt = NULL;
-
-       if (!pxmitframe)
-               goto exit;
-
-       spin_lock_bh(&pfree_xmit_queue->lock);
-
-       list_del_init(&pxmitframe->list);
-
-       if (pxmitframe->pkt) {
-               pndis_pkt = pxmitframe->pkt;
-               pxmitframe->pkt = NULL;
-       }
-
-       list_add_tail(&pxmitframe->list, get_list_head(pfree_xmit_queue));
-
-       pxmitpriv->free_xmitframe_cnt++;
-
-       spin_unlock_bh(&pfree_xmit_queue->lock);
-
-       if (pndis_pkt)
-               rtw_pkt_complete(padapter, pndis_pkt);
-
-exit:
-
-       return _SUCCESS;
-}
-
-void rtw_free_xmitframe_list(struct xmit_priv *pxmitpriv, struct list_head *xframe_list)
-{
-       struct  xmit_frame *pxmitframe, *tmp_xmitframe;
-
-       list_for_each_entry_safe(pxmitframe, tmp_xmitframe, xframe_list, list)
-               rtw_free_xmitframe(pxmitpriv, pxmitframe);
-}
-
-struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i)
-{
-       struct hw_xmit *phwxmit;
-       struct tx_servq *ptxservq, *tmp_txservq;
-       struct list_head *xframe_list;
-       struct xmit_frame *pxmitframe = NULL;
-       struct adapter *padapter = pxmitpriv->adapter;
-       struct registry_priv    *pregpriv = &padapter->registrypriv;
-       int i, inx[] = { 0, 1, 2, 3 };
-
-       if (pregpriv->wifi_spec == 1) {
-               for (i = 0; i < ARRAY_SIZE(inx); i++)
-                       inx[i] = pxmitpriv->wmm_para_seq[i];
-       }
-
-       spin_lock_bh(&pxmitpriv->lock);
-
-       for (i = 0; i < HWXMIT_ENTRY; i++) {
-               phwxmit = phwxmit_i + inx[i];
-               list_for_each_entry_safe(ptxservq, tmp_txservq, phwxmit->sta_list, tx_pending) {
-                       xframe_list = &ptxservq->sta_pending;
-                       if (list_empty(xframe_list))
-                               continue;
-
-                       pxmitframe = container_of(xframe_list->next, struct xmit_frame, list);
-                       list_del_init(&pxmitframe->list);
-
-                       phwxmit->accnt--;
-                       ptxservq->qcnt--;
-
-                       /* Remove sta node when there are no pending packets. */
-                       if (list_empty(xframe_list))
-                               list_del_init(&ptxservq->tx_pending);
-
-                       goto exit;
-               }
-       }
-exit:
-       spin_unlock_bh(&pxmitpriv->lock);
-
-       return pxmitframe;
-}
-
-struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, int up, u8 *ac)
-{
-       struct tx_servq *ptxservq;
-
-       switch (up) {
-       case 1:
-       case 2:
-               ptxservq = &psta->sta_xmitpriv.bk_q;
-               *(ac) = 3;
-               break;
-       case 4:
-       case 5:
-               ptxservq = &psta->sta_xmitpriv.vi_q;
-               *(ac) = 1;
-               break;
-       case 6:
-       case 7:
-               ptxservq = &psta->sta_xmitpriv.vo_q;
-               *(ac) = 0;
-               break;
-       case 0:
-       case 3:
-       default:
-               ptxservq = &psta->sta_xmitpriv.be_q;
-               *(ac) = 2;
-       break;
-       }
-
-       return ptxservq;
-}
-
-/*
- * Will enqueue pxmitframe to the proper queue,
- * and indicate it to xx_pending list.....
- */
-s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)
-{
-       u8      ac_index;
-       struct sta_info *psta;
-       struct tx_servq *ptxservq;
-       struct pkt_attrib       *pattrib = &pxmitframe->attrib;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct hw_xmit  *phwxmits =  padapter->xmitpriv.hwxmits;
-       int res = _SUCCESS;
-
-       if (pattrib->psta)
-               psta = pattrib->psta;
-       else
-               psta = rtw_get_stainfo(pstapriv, pattrib->ra);
-
-       if (!psta) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index));
-
-       if (list_empty(&ptxservq->tx_pending))
-               list_add_tail(&ptxservq->tx_pending, phwxmits[ac_index].sta_list);
-
-       list_add_tail(&pxmitframe->list, &ptxservq->sta_pending);
-       ptxservq->qcnt++;
-       phwxmits[ac_index].accnt++;
-exit:
-
-       return res;
-}
-
-int rtw_alloc_hwxmits(struct adapter *padapter)
-{
-       struct hw_xmit *hwxmits;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-
-       pxmitpriv->hwxmits = kcalloc(HWXMIT_ENTRY, sizeof(struct hw_xmit), GFP_KERNEL);
-       if (!pxmitpriv->hwxmits)
-               return -ENOMEM;
-
-       hwxmits = pxmitpriv->hwxmits;
-
-       hwxmits[0].sta_list = &pxmitpriv->vo_pending;
-       hwxmits[1].sta_list = &pxmitpriv->vi_pending;
-       hwxmits[2].sta_list = &pxmitpriv->be_pending;
-       hwxmits[3].sta_list = &pxmitpriv->bk_pending;
-
-       return 0;
-}
-
-static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb)
-{
-       struct sk_buff *skb = *pskb;
-       int res, is_vlan_tag = 0, i, do_nat25 = 1;
-       unsigned short vlan_hdr = 0;
-       void *br_port = NULL;
-
-       rcu_read_lock();
-       br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
-       rcu_read_unlock();
-       spin_lock_bh(&padapter->br_ext_lock);
-       if (!(skb->data[0] & 1) && br_port &&
-           memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) &&
-           *((__be16 *)(skb->data + ETH_ALEN * 2)) != htons(ETH_P_8021Q) &&
-           *((__be16 *)(skb->data + ETH_ALEN * 2)) == htons(ETH_P_IP) &&
-           !memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN) && padapter->scdb_entry) {
-               memcpy(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN);
-               padapter->scdb_entry->ageing_timer = jiffies;
-               spin_unlock_bh(&padapter->br_ext_lock);
-       } else {
-               if (*((__be16 *)(skb->data + ETH_ALEN * 2)) == htons(ETH_P_8021Q)) {
-                       is_vlan_tag = 1;
-                       vlan_hdr = *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2));
-                       for (i = 0; i < 6; i++)
-                               *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2 - i * 2)) = *((unsigned short *)(skb->data + ETH_ALEN * 2 - 2 - i * 2));
-                       skb_pull(skb, 4);
-               }
-               if (!memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) &&
-                   (*((__be16 *)(skb->data + ETH_ALEN * 2)) == htons(ETH_P_IP)))
-                       memcpy(padapter->br_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4);
-
-               if (*((__be16 *)(skb->data + ETH_ALEN * 2)) == htons(ETH_P_IP)) {
-                       if (memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN)) {
-                               padapter->scdb_entry = (struct nat25_network_db_entry *)scdb_findEntry(padapter,
-                                                       skb->data + WLAN_ETHHDR_LEN + 12);
-                               if (padapter->scdb_entry) {
-                                       memcpy(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN);
-                                       memcpy(padapter->scdb_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4);
-                                       padapter->scdb_entry->ageing_timer = jiffies;
-                                       do_nat25 = 0;
-                               }
-                       } else {
-                               if (padapter->scdb_entry) {
-                                       padapter->scdb_entry->ageing_timer = jiffies;
-                                       do_nat25 = 0;
-                               } else {
-                                       memset(padapter->scdb_mac, 0, ETH_ALEN);
-                                       memset(padapter->scdb_ip, 0, 4);
-                               }
-                       }
-               }
-               spin_unlock_bh(&padapter->br_ext_lock);
-               if (do_nat25) {
-                       if (nat25_db_handle(padapter, skb, NAT25_CHECK) == 0) {
-                               struct sk_buff *newskb;
-
-                               if (is_vlan_tag) {
-                                       skb_push(skb, 4);
-                                       for (i = 0; i < 6; i++)
-                                               *((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2));
-                                       *((__be16 *)(skb->data + ETH_ALEN * 2)) = htons(ETH_P_8021Q);
-                                       *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr;
-                               }
-
-                               newskb = skb_copy(skb, GFP_ATOMIC);
-                               if (!newskb)
-                                       return -1;
-                               dev_kfree_skb_any(skb);
-
-                               *pskb = skb = newskb;
-                               if (is_vlan_tag) {
-                                       vlan_hdr = *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2));
-                                       for (i = 0; i < 6; i++)
-                                               *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2 - i * 2)) = *((unsigned short *)(skb->data + ETH_ALEN * 2 - 2 - i * 2));
-                                       skb_pull(skb, 4);
-                               }
-                       }
-
-                       res = skb_linearize(skb);
-                       if (res < 0)
-                               return -1;
-
-                       res = nat25_db_handle(padapter, skb, NAT25_INSERT);
-                       if (res < 0) {
-                               if (res == -2)
-                                       return -1;
-
-                               return 0;
-                       }
-               }
-
-               memcpy(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN);
-
-               dhcp_flag_bcast(padapter, skb);
-
-               if (is_vlan_tag) {
-                       skb_push(skb, 4);
-                       for (i = 0; i < 6; i++)
-                               *((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2));
-                       *((__be16 *)(skb->data + ETH_ALEN * 2)) = htons(ETH_P_8021Q);
-                       *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr;
-               }
-       }
-
-       /*  check if SA is equal to our MAC */
-       if (memcmp(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN))
-               return -1;
-
-       return 0;
-}
-
-u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe)
-{
-       u32 addr;
-       struct pkt_attrib *pattrib = &pxmitframe->attrib;
-
-       switch (pattrib->qsel) {
-       case 0:
-       case 3:
-               addr = BE_QUEUE_INX;
-               break;
-       case 1:
-       case 2:
-               addr = BK_QUEUE_INX;
-               break;
-       case 4:
-       case 5:
-               addr = VI_QUEUE_INX;
-               break;
-       case 6:
-       case 7:
-               addr = VO_QUEUE_INX;
-               break;
-       case 0x10:
-               addr = BCN_QUEUE_INX;
-               break;
-       case 0x11:/* BC/MC in PS (HIQ) */
-               addr = HIGH_QUEUE_INX;
-               break;
-       case 0x12:
-       default:
-               addr = MGT_QUEUE_INX;
-               break;
-       }
-
-       return addr;
-}
-
-/*
- * The main transmit(tx) entry
- *
- * Return
- *     1       enqueue
- *     0       success, hardware will handle this xmit frame(packet)
- *     <0      fail
- */
-s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt)
-{
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct xmit_frame *pxmitframe = NULL;
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       s32 res;
-
-       pxmitframe = rtw_alloc_xmitframe(pxmitpriv);
-       if (!pxmitframe)
-               return -1;
-
-       if (rcu_access_pointer(padapter->pnetdev->rx_handler_data) &&
-           check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) {
-               res = rtw_br_client_tx(padapter, ppkt);
-               if (res == -1) {
-                       rtw_free_xmitframe(pxmitpriv, pxmitframe);
-                       return -1;
-               }
-       }
-
-       res = update_attrib(padapter, *ppkt, &pxmitframe->attrib);
-
-       if (res == _FAIL) {
-               rtw_free_xmitframe(pxmitpriv, pxmitframe);
-               return -1;
-       }
-       pxmitframe->pkt = *ppkt;
-
-       rtw_led_control(padapter, LED_CTL_TX);
-
-       pxmitframe->attrib.qsel = pxmitframe->attrib.priority;
-
-       spin_lock_bh(&pxmitpriv->lock);
-       if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe)) {
-               spin_unlock_bh(&pxmitpriv->lock);
-               return 1;
-       }
-       spin_unlock_bh(&pxmitpriv->lock);
-
-       if (!rtl8188eu_hal_xmit(padapter, pxmitframe))
-               return 1;
-
-       return 0;
-}
-
-int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe)
-{
-       int ret = false;
-       struct sta_info *psta = NULL;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct pkt_attrib *pattrib = &pxmitframe->attrib;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       bool bmcst = is_multicast_ether_addr(pattrib->ra);
-
-       if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
-               return ret;
-
-       if (pattrib->psta)
-               psta = pattrib->psta;
-       else
-               psta = rtw_get_stainfo(pstapriv, pattrib->ra);
-
-       if (!psta)
-               return ret;
-
-       if (pattrib->triggered == 1) {
-               if (bmcst)
-                       pattrib->qsel = 0x11;/* HIQ */
-               return ret;
-       }
-
-       if (bmcst) {
-               spin_lock_bh(&psta->sleep_q.lock);
-
-               if (pstapriv->sta_dz_bitmap) {/* if any one sta is in ps mode */
-                       list_del_init(&pxmitframe->list);
-
-                       list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q));
-
-                       psta->sleepq_len++;
-
-                       pstapriv->tim_bitmap |= BIT(0);/*  */
-                       pstapriv->sta_dz_bitmap |= BIT(0);
-                       /* tx bc/mc packets after update bcn */
-                       update_beacon(padapter, _TIM_IE_, NULL, false);
-
-                       ret = true;
-               }
-
-               spin_unlock_bh(&psta->sleep_q.lock);
-
-               return ret;
-       }
-
-       spin_lock_bh(&psta->sleep_q.lock);
-
-       if (psta->state & WIFI_SLEEP_STATE) {
-               u8 wmmps_ac = 0;
-
-               if (pstapriv->sta_dz_bitmap & BIT(psta->aid)) {
-                       list_del_init(&pxmitframe->list);
-
-                       list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q));
-
-                       psta->sleepq_len++;
-
-                       switch (pattrib->priority) {
-                       case 1:
-                       case 2:
-                               wmmps_ac = psta->uapsd_bk & BIT(0);
-                               break;
-                       case 4:
-                       case 5:
-                               wmmps_ac = psta->uapsd_vi & BIT(0);
-                               break;
-                       case 6:
-                       case 7:
-                               wmmps_ac = psta->uapsd_vo & BIT(0);
-                               break;
-                       case 0:
-                       case 3:
-                       default:
-                               wmmps_ac = psta->uapsd_be & BIT(0);
-                               break;
-                       }
-
-                       if (wmmps_ac)
-                               psta->sleepq_ac_len++;
-
-                       if (((psta->has_legacy_ac) && (!wmmps_ac)) ||
-                           ((!psta->has_legacy_ac) && (wmmps_ac))) {
-                               pstapriv->tim_bitmap |= BIT(psta->aid);
-
-                               if (psta->sleepq_len == 1) {
-                                       /* update BCN for TIM IE */
-                                       update_beacon(padapter, _TIM_IE_, NULL, false);
-                               }
-                       }
-                       ret = true;
-               }
-       }
-
-       spin_unlock_bh(&psta->sleep_q.lock);
-
-       return ret;
-}
-
-static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, struct list_head *phead)
-{
-       struct list_head *plist;
-       u8      ac_index;
-       struct tx_servq *ptxservq;
-       struct pkt_attrib       *pattrib;
-       struct xmit_frame       *pxmitframe;
-       struct hw_xmit *phwxmits =  padapter->xmitpriv.hwxmits;
-
-       plist = phead->next;
-
-       while (phead != plist) {
-               pxmitframe = container_of(plist, struct xmit_frame, list);
-
-               plist = plist->next;
-
-               xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe);
-
-               pattrib = &pxmitframe->attrib;
-
-               ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index));
-
-               ptxservq->qcnt--;
-               phwxmits[ac_index].accnt--;
-       }
-}
-
-void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta)
-{
-       struct sta_info *psta_bmc;
-       struct sta_xmit_priv *pstaxmitpriv;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-
-       pstaxmitpriv = &psta->sta_xmitpriv;
-
-       /* for BC/MC Frames */
-       psta_bmc = rtw_get_bcmc_stainfo(padapter);
-
-       spin_lock_bh(&pxmitpriv->lock);
-
-       psta->state |= WIFI_SLEEP_STATE;
-
-       pstapriv->sta_dz_bitmap |= BIT(psta->aid);
-
-       dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending);
-       list_del_init(&pstaxmitpriv->vo_q.tx_pending);
-
-       dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending);
-       list_del_init(&pstaxmitpriv->vi_q.tx_pending);
-
-       dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending);
-       list_del_init(&pstaxmitpriv->be_q.tx_pending);
-
-       dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending);
-       list_del_init(&pstaxmitpriv->bk_q.tx_pending);
-
-       /* for BC/MC Frames */
-       pstaxmitpriv = &psta_bmc->sta_xmitpriv;
-       dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, &pstaxmitpriv->be_q.sta_pending);
-       list_del_init(&pstaxmitpriv->be_q.tx_pending);
-
-       spin_unlock_bh(&pxmitpriv->lock);
-}
-
-void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
-{
-       u8 update_mask = 0, wmmps_ac = 0;
-       struct sta_info *psta_bmc;
-       struct list_head *xmitframe_plist, *xmitframe_phead;
-       struct xmit_frame *pxmitframe = NULL;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       spin_lock_bh(&psta->sleep_q.lock);
-
-       xmitframe_phead = get_list_head(&psta->sleep_q);
-       xmitframe_plist = xmitframe_phead->next;
-
-       while (xmitframe_phead != xmitframe_plist) {
-               pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
-
-               xmitframe_plist = xmitframe_plist->next;
-
-               list_del_init(&pxmitframe->list);
-
-               switch (pxmitframe->attrib.priority) {
-               case 1:
-               case 2:
-                       wmmps_ac = psta->uapsd_bk & BIT(1);
-                       break;
-               case 4:
-               case 5:
-                       wmmps_ac = psta->uapsd_vi & BIT(1);
-                       break;
-               case 6:
-               case 7:
-                       wmmps_ac = psta->uapsd_vo & BIT(1);
-                       break;
-               case 0:
-               case 3:
-               default:
-                       wmmps_ac = psta->uapsd_be & BIT(1);
-                       break;
-               }
-
-               psta->sleepq_len--;
-               if (psta->sleepq_len > 0)
-                       pxmitframe->attrib.mdata = 1;
-               else
-                       pxmitframe->attrib.mdata = 0;
-
-               if (wmmps_ac) {
-                       psta->sleepq_ac_len--;
-                       if (psta->sleepq_ac_len > 0) {
-                               pxmitframe->attrib.mdata = 1;
-                               pxmitframe->attrib.eosp = 0;
-                       } else {
-                               pxmitframe->attrib.mdata = 0;
-                               pxmitframe->attrib.eosp = 1;
-                       }
-               }
-
-               pxmitframe->attrib.triggered = 1;
-
-               spin_unlock_bh(&psta->sleep_q.lock);
-               if (rtl8188eu_hal_xmit(padapter, pxmitframe))
-                       rtw_xmit_complete(padapter, pxmitframe);
-               spin_lock_bh(&psta->sleep_q.lock);
-       }
-
-       if (psta->sleepq_len == 0) {
-               pstapriv->tim_bitmap &= ~BIT(psta->aid);
-
-               update_mask = BIT(0);
-
-               if (psta->state & WIFI_SLEEP_STATE)
-                       psta->state ^= WIFI_SLEEP_STATE;
-
-               if (psta->state & WIFI_STA_ALIVE_CHK_STATE) {
-                       psta->expire_to = pstapriv->expire_to;
-                       psta->state ^= WIFI_STA_ALIVE_CHK_STATE;
-               }
-
-               pstapriv->sta_dz_bitmap &= ~BIT(psta->aid);
-       }
-
-       spin_unlock_bh(&psta->sleep_q.lock);
-
-       /* for BC/MC Frames */
-       psta_bmc = rtw_get_bcmc_stainfo(padapter);
-       if (!psta_bmc)
-               return;
-
-       if ((pstapriv->sta_dz_bitmap & 0xfffe) == 0x0) { /* no any sta in ps mode */
-               spin_lock_bh(&psta_bmc->sleep_q.lock);
-
-               xmitframe_phead = get_list_head(&psta_bmc->sleep_q);
-               xmitframe_plist = xmitframe_phead->next;
-
-               while (xmitframe_phead != xmitframe_plist) {
-                       pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
-
-                       xmitframe_plist = xmitframe_plist->next;
-
-                       list_del_init(&pxmitframe->list);
-
-                       psta_bmc->sleepq_len--;
-                       if (psta_bmc->sleepq_len > 0)
-                               pxmitframe->attrib.mdata = 1;
-                       else
-                               pxmitframe->attrib.mdata = 0;
-
-                       pxmitframe->attrib.triggered = 1;
-
-                       spin_unlock_bh(&psta_bmc->sleep_q.lock);
-                       if (rtl8188eu_hal_xmit(padapter, pxmitframe))
-                               rtw_xmit_complete(padapter, pxmitframe);
-                       spin_lock_bh(&psta_bmc->sleep_q.lock);
-               }
-
-               if (psta_bmc->sleepq_len == 0) {
-                       pstapriv->tim_bitmap &= ~BIT(0);
-                       pstapriv->sta_dz_bitmap &= ~BIT(0);
-
-                       update_mask |= BIT(1);
-               }
-
-               spin_unlock_bh(&psta_bmc->sleep_q.lock);
-       }
-
-       if (update_mask)
-               update_beacon(padapter, _TIM_IE_, NULL, false);
-}
-
-void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta)
-{
-       u8 wmmps_ac = 0;
-       struct list_head *xmitframe_plist, *xmitframe_phead;
-       struct xmit_frame *pxmitframe = NULL;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       spin_lock_bh(&psta->sleep_q.lock);
-
-       xmitframe_phead = get_list_head(&psta->sleep_q);
-       xmitframe_plist = xmitframe_phead->next;
-
-       while (xmitframe_phead != xmitframe_plist) {
-               pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
-
-               xmitframe_plist = xmitframe_plist->next;
-
-               switch (pxmitframe->attrib.priority) {
-               case 1:
-               case 2:
-                       wmmps_ac = psta->uapsd_bk & BIT(1);
-                       break;
-               case 4:
-               case 5:
-                       wmmps_ac = psta->uapsd_vi & BIT(1);
-                       break;
-               case 6:
-               case 7:
-                       wmmps_ac = psta->uapsd_vo & BIT(1);
-                       break;
-               case 0:
-               case 3:
-               default:
-                       wmmps_ac = psta->uapsd_be & BIT(1);
-                       break;
-               }
-
-               if (!wmmps_ac)
-                       continue;
-
-               list_del_init(&pxmitframe->list);
-
-               psta->sleepq_len--;
-               psta->sleepq_ac_len--;
-
-               if (psta->sleepq_ac_len > 0) {
-                       pxmitframe->attrib.mdata = 1;
-                       pxmitframe->attrib.eosp = 0;
-               } else {
-                       pxmitframe->attrib.mdata = 0;
-                       pxmitframe->attrib.eosp = 1;
-               }
-
-               pxmitframe->attrib.triggered = 1;
-
-               if (rtl8188eu_hal_xmit(padapter, pxmitframe))
-                       rtw_xmit_complete(padapter, pxmitframe);
-
-               if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) {
-                       pstapriv->tim_bitmap &= ~BIT(psta->aid);
-
-                       /* update BCN for TIM IE */
-                       update_beacon(padapter, _TIM_IE_, NULL, false);
-               }
-       }
-
-       spin_unlock_bh(&psta->sleep_q.lock);
-}
-
-void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms)
-{
-       sctx->timeout_ms = timeout_ms;
-       sctx->submit_time = jiffies;
-       init_completion(&sctx->done);
-       sctx->status = RTW_SCTX_SUBMITTED;
-}
-
-int rtw_sctx_wait(struct submit_ctx *sctx)
-{
-       int ret = _FAIL;
-       unsigned long expire;
-       int status = 0;
-
-       expire = sctx->timeout_ms ? msecs_to_jiffies(sctx->timeout_ms) : MAX_SCHEDULE_TIMEOUT;
-       if (!wait_for_completion_timeout(&sctx->done, expire))
-               /* timeout, do something?? */
-               status = RTW_SCTX_DONE_TIMEOUT;
-       else
-               status = sctx->status;
-
-       if (status == RTW_SCTX_DONE_SUCCESS)
-               ret = _SUCCESS;
-
-       return ret;
-}
-
-void rtw_sctx_done_err(struct submit_ctx **sctx, int status)
-{
-       if (*sctx) {
-               (*sctx)->status = status;
-               complete(&((*sctx)->done));
-               *sctx = NULL;
-       }
-}
-
-int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms)
-{
-       struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops;
-
-       pack_tx_ops->submit_time = jiffies;
-       pack_tx_ops->timeout_ms = timeout_ms;
-       pack_tx_ops->status = RTW_SCTX_SUBMITTED;
-
-       return rtw_sctx_wait(pack_tx_ops);
-}
-
-void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status)
-{
-       struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops;
-
-       if (pxmitpriv->ack_tx)
-               rtw_sctx_done_err(&pack_tx_ops, status);
-}
-
-static void rtw_check_xmit_resource(struct adapter *padapter, struct sk_buff *pkt)
-{
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       u16 queue;
-
-       queue = skb_get_queue_mapping(pkt);
-       if (padapter->registrypriv.wifi_spec) {
-               /* No free space for Tx, tx_worker is too slow */
-               if (pxmitpriv->hwxmits[queue].accnt > WMM_XMIT_THRESHOLD)
-                       netif_stop_subqueue(padapter->pnetdev, queue);
-       } else {
-               if (pxmitpriv->free_xmitframe_cnt <= 4) {
-                       if (!netif_tx_queue_stopped(netdev_get_tx_queue(padapter->pnetdev, queue)))
-                               netif_stop_subqueue(padapter->pnetdev, queue);
-               }
-       }
-}
-
-static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
-{
-       struct  sta_priv *pstapriv = &padapter->stapriv;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct list_head *phead, *plist;
-       struct sk_buff *newskb;
-       struct sta_info *psta = NULL;
-       s32 res;
-
-       spin_lock_bh(&pstapriv->asoc_list_lock);
-       phead = &pstapriv->asoc_list;
-       plist = phead->next;
-
-       /* free sta asoc_queue */
-       while (phead != plist) {
-               psta = container_of(plist, struct sta_info, asoc_list);
-
-               plist = plist->next;
-
-               /* avoid   come from STA1 and send back STA1 */
-               if (!memcmp(psta->hwaddr, &skb->data[6], 6))
-                       continue;
-
-               newskb = skb_copy(skb, GFP_ATOMIC);
-
-               if (newskb) {
-                       memcpy(newskb->data, psta->hwaddr, 6);
-                       res = rtw_xmit(padapter, &newskb);
-                       if (res < 0) {
-                               pxmitpriv->tx_drop++;
-                               dev_kfree_skb_any(newskb);
-                       } else {
-                               pxmitpriv->tx_pkts++;
-                       }
-               } else {
-                       pxmitpriv->tx_drop++;
-
-                       spin_unlock_bh(&pstapriv->asoc_list_lock);
-                       return false;   /*  Caller shall tx this multicast frame via normal way. */
-               }
-       }
-
-       spin_unlock_bh(&pstapriv->asoc_list_lock);
-       dev_kfree_skb_any(skb);
-       return true;
-}
-
-netdev_tx_t rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       s32 res = 0;
-
-       if (!rtw_if_up(padapter))
-               goto drop_packet;
-
-       rtw_check_xmit_resource(padapter, pkt);
-
-       if (!rtw_mc2u_disable && check_fwstate(pmlmepriv, WIFI_AP_STATE) &&
-           (IP_MCAST_MAC(pkt->data) || ICMPV6_MCAST_MAC(pkt->data)) &&
-           (padapter->registrypriv.wifi_spec == 0)) {
-               if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME / 4)) {
-                       res = rtw_mlcst2unicst(padapter, pkt);
-                       if (res)
-                               goto exit;
-               }
-       }
-
-       res = rtw_xmit(padapter, &pkt);
-       if (res < 0)
-               goto drop_packet;
-
-       pxmitpriv->tx_pkts++;
-       goto exit;
-
-drop_packet:
-       pxmitpriv->tx_drop++;
-       dev_kfree_skb_any(pkt);
-
-exit:
-       return NETDEV_TX_OK;
-}
diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c
deleted file mode 100644 (file)
index 1e04de3..0000000
+++ /dev/null
@@ -1,654 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright (c) Realtek Semiconductor Corp. */
-
-#include "../include/drv_types.h"
-
-static u8 RETRY_PENALTY[PERENTRY][RETRYSIZE + 1] = {
-               {5, 4, 3, 2, 0, 3},      /* 92 , idx = 0 */
-               {6, 5, 4, 3, 0, 4},      /* 86 , idx = 1 */
-               {6, 5, 4, 2, 0, 4},      /* 81 , idx = 2 */
-               {8, 7, 6, 4, 0, 6},      /* 75 , idx = 3 */
-               {10, 9, 8, 6, 0, 8},     /* 71  , idx = 4 */
-               {10, 9, 8, 4, 0, 8},     /* 66  , idx = 5 */
-               {10, 9, 8, 2, 0, 8},     /* 62  , idx = 6 */
-               {10, 9, 8, 0, 0, 8},     /* 59  , idx = 7 */
-               {18, 17, 16, 8, 0, 16},  /* 53 , idx = 8 */
-               {26, 25, 24, 16, 0, 24}, /* 50  , idx = 9 */
-               {34, 33, 32, 24, 0, 32}, /* 47  , idx = 0x0a */
-               {34, 31, 28, 20, 0, 32}, /* 43  , idx = 0x0b */
-               {34, 31, 27, 18, 0, 32}, /* 40 , idx = 0x0c */
-               {34, 31, 26, 16, 0, 32}, /* 37 , idx = 0x0d */
-               {34, 30, 22, 16, 0, 32}, /* 32 , idx = 0x0e */
-               {34, 30, 24, 16, 0, 32}, /* 26 , idx = 0x0f */
-               {49, 46, 40, 16, 0, 48}, /* 20  , idx = 0x10 */
-               {49, 45, 32, 0, 0, 48},  /* 17 , idx = 0x11 */
-               {49, 45, 22, 18, 0, 48}, /* 15  , idx = 0x12 */
-               {49, 40, 24, 16, 0, 48}, /* 12  , idx = 0x13 */
-               {49, 32, 18, 12, 0, 48}, /* 9 , idx = 0x14 */
-               {49, 22, 18, 14, 0, 48}, /* 6 , idx = 0x15 */
-               {49, 16, 16, 0, 0, 48}
-       }; /* 3, idx = 0x16 */
-
-static u8 PT_PENALTY[RETRYSIZE + 1] = {34, 31, 30, 24, 0, 32};
-
-/*  wilson modify */
-static u8 RETRY_PENALTY_IDX[2][RATESIZE] = {
-               {4, 4, 4, 5, 4, 4, 5, 7, 7, 7, 8, 0x0a,        /*  SS>TH */
-               4, 4, 4, 4, 6, 0x0a, 0x0b, 0x0d,
-               5, 5, 7, 7, 8, 0x0b, 0x0d, 0x0f},                          /*  0329 R01 */
-               {0x0a, 0x0a, 0x0b, 0x0c, 0x0a,
-               0x0a, 0x0b, 0x0c, 0x0d, 0x10, 0x13, 0x14,          /*  SS<TH */
-               0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x11, 0x13, 0x15,
-               9, 9, 9, 9, 0x0c, 0x0e, 0x11, 0x13}
-       };
-
-static u8 RETRY_PENALTY_UP_IDX[RATESIZE] = {
-               0x0c, 0x0d, 0x0d, 0x0f, 0x0d, 0x0e,
-               0x0f, 0x0f, 0x10, 0x12, 0x13, 0x14,            /*  SS>TH */
-               0x0f, 0x10, 0x10, 0x12, 0x12, 0x13, 0x14, 0x15,
-               0x11, 0x11, 0x12, 0x13, 0x13, 0x13, 0x14, 0x15};
-
-static u8 RSSI_THRESHOLD[RATESIZE] = {
-               0, 0, 0, 0,
-               0, 0, 0, 0, 0, 0x24, 0x26, 0x2a,
-               0x18, 0x1a, 0x1d, 0x1f, 0x21, 0x27, 0x29, 0x2a,
-               0, 0, 0, 0x1f, 0x23, 0x28, 0x2a, 0x2c};
-
-static u16 N_THRESHOLD_HIGH[RATESIZE] = {
-               4, 4, 8, 16,
-               24, 36, 48, 72, 96, 144, 192, 216,
-               60, 80, 100, 160, 240, 400, 560, 640,
-               300, 320, 480, 720, 1000, 1200, 1600, 2000};
-static u16 N_THRESHOLD_LOW[RATESIZE] = {
-               2, 2, 4, 8,
-               12, 18, 24, 36, 48, 72, 96, 108,
-               30, 40, 50, 80, 120, 200, 280, 320,
-               150, 160, 240, 360, 500, 600, 800, 1000};
-
-static u8 DROPING_NECESSARY[RATESIZE] = {
-               1, 1, 1, 1,
-               1, 2, 3, 4, 5, 6, 7, 8,
-               1, 2, 3, 4, 5, 6, 7, 8,
-               5, 6, 7, 8, 9, 10, 11, 12};
-
-static u8 PendingForRateUpFail[5] = {2, 10, 24, 40, 60};
-static u16 DynamicTxRPTTiming[6] = {
-       0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12, 0x927c}; /*  200ms-1200ms */
-
-/*  End Rate adaptive parameters */
-
-static void odm_SetTxRPTTiming_8188E(
-               struct odm_dm_struct *dm_odm,
-               struct odm_ra_info *pRaInfo,
-               u8 extend
-       )
-{
-       u8 idx = 0;
-
-       for (idx = 0; idx < 5; idx++)
-               if (DynamicTxRPTTiming[idx] == pRaInfo->RptTime)
-                       break;
-
-       if (extend == 0) { /*  back to default timing */
-               idx = 0;  /* 200ms */
-       } else if (extend == 1) {/*  increase the timing */
-               idx += 1;
-               if (idx > 5)
-                       idx = 5;
-       } else if (extend == 2) {/*  decrease the timing */
-               if (idx != 0)
-                       idx -= 1;
-       }
-       pRaInfo->RptTime = DynamicTxRPTTiming[idx];
-}
-
-static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo)
-{
-       u8 RateID, LowestRate, HighestRate;
-       u8 i;
-
-       if (NULL == pRaInfo)
-               return -1;
-       RateID = pRaInfo->PreRate;
-       LowestRate = pRaInfo->LowestRate;
-       HighestRate = pRaInfo->HighestRate;
-
-       if (RateID > HighestRate) {
-               RateID = HighestRate;
-       } else if (pRaInfo->RateSGI) {
-               pRaInfo->RateSGI = 0;
-       } else if (RateID > LowestRate) {
-               if (RateID > 0) {
-                       for (i = RateID - 1; i > LowestRate; i--) {
-                               if (pRaInfo->RAUseRate & BIT(i)) {
-                                       RateID = i;
-                                       goto RateDownFinish;
-                               }
-                       }
-               }
-       } else if (RateID <= LowestRate) {
-               RateID = LowestRate;
-       }
-RateDownFinish:
-       if (pRaInfo->RAWaitingCounter == 1) {
-               pRaInfo->RAWaitingCounter += 1;
-               pRaInfo->RAPendingCounter += 1;
-       } else if (pRaInfo->RAWaitingCounter == 0) {
-               ;
-       } else {
-               pRaInfo->RAWaitingCounter = 0;
-               pRaInfo->RAPendingCounter = 0;
-       }
-
-       if (pRaInfo->RAPendingCounter >= 4)
-               pRaInfo->RAPendingCounter = 4;
-
-       pRaInfo->DecisionRate = RateID;
-       odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 2);
-       return 0;
-}
-
-static int odm_RateUp_8188E(
-               struct odm_dm_struct *dm_odm,
-               struct odm_ra_info *pRaInfo
-       )
-{
-       u8 RateID, HighestRate;
-       u8 i;
-
-       if (NULL == pRaInfo)
-               return -1;
-       RateID = pRaInfo->PreRate;
-       HighestRate = pRaInfo->HighestRate;
-       if (pRaInfo->RAWaitingCounter == 1) {
-               pRaInfo->RAWaitingCounter = 0;
-               pRaInfo->RAPendingCounter = 0;
-       } else if (pRaInfo->RAWaitingCounter > 1) {
-               pRaInfo->PreRssiStaRA = pRaInfo->RssiStaRA;
-               goto RateUpfinish;
-       }
-       odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 0);
-
-       if (RateID < HighestRate) {
-               for (i = RateID + 1; i <= HighestRate; i++) {
-                       if (pRaInfo->RAUseRate & BIT(i)) {
-                               RateID = i;
-                               goto RateUpfinish;
-                       }
-               }
-       } else if (RateID == HighestRate) {
-               if (pRaInfo->SGIEnable && (pRaInfo->RateSGI != 1))
-                       pRaInfo->RateSGI = 1;
-               else if ((pRaInfo->SGIEnable) != 1)
-                       pRaInfo->RateSGI = 0;
-       } else {
-               RateID = HighestRate;
-       }
-RateUpfinish:
-       if (pRaInfo->RAWaitingCounter == (4 + PendingForRateUpFail[pRaInfo->RAPendingCounter]))
-               pRaInfo->RAWaitingCounter = 0;
-       else
-               pRaInfo->RAWaitingCounter++;
-
-       pRaInfo->DecisionRate = RateID;
-       return 0;
-}
-
-static void odm_ResetRaCounter_8188E(struct odm_ra_info *pRaInfo)
-{
-       u8 RateID;
-
-       RateID = pRaInfo->DecisionRate;
-       pRaInfo->NscUp = (N_THRESHOLD_HIGH[RateID] + N_THRESHOLD_LOW[RateID]) >> 1;
-       pRaInfo->NscDown = (N_THRESHOLD_HIGH[RateID] + N_THRESHOLD_LOW[RateID]) >> 1;
-}
-
-static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm,
-               struct odm_ra_info *pRaInfo
-       )
-{
-       u8 RateID = 0, RtyPtID = 0, PenaltyID1 = 0, PenaltyID2 = 0;
-       /* u32 pool_retry; */
-       static u8 DynamicTxRPTTimingCounter;
-
-       if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) { /*  STA used and data packet exits */
-               if ((pRaInfo->RssiStaRA < (pRaInfo->PreRssiStaRA - 3)) ||
-                   (pRaInfo->RssiStaRA > (pRaInfo->PreRssiStaRA + 3))) {
-                       pRaInfo->RAWaitingCounter = 0;
-                       pRaInfo->RAPendingCounter = 0;
-               }
-               /*  Start RA decision */
-               if (pRaInfo->PreRate > pRaInfo->HighestRate)
-                       RateID = pRaInfo->HighestRate;
-               else
-                       RateID = pRaInfo->PreRate;
-               if (pRaInfo->RssiStaRA > RSSI_THRESHOLD[RateID])
-                       RtyPtID = 0;
-               else
-                       RtyPtID = 1;
-               PenaltyID1 = RETRY_PENALTY_IDX[RtyPtID][RateID]; /* TODO by page */
-
-               pRaInfo->NscDown += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID1][0];
-               pRaInfo->NscDown += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID1][1];
-               pRaInfo->NscDown += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID1][2];
-               pRaInfo->NscDown += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID1][3];
-               pRaInfo->NscDown += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID1][4];
-               if (pRaInfo->NscDown > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]))
-                       pRaInfo->NscDown -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5];
-               else
-                       pRaInfo->NscDown = 0;
-
-               /*  rate up */
-               PenaltyID2 = RETRY_PENALTY_UP_IDX[RateID];
-               pRaInfo->NscUp += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID2][0];
-               pRaInfo->NscUp += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID2][1];
-               pRaInfo->NscUp += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID2][2];
-               pRaInfo->NscUp += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID2][3];
-               pRaInfo->NscUp += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID2][4];
-               if (pRaInfo->NscUp > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]))
-                       pRaInfo->NscUp -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5];
-               else
-                       pRaInfo->NscUp = 0;
-
-               if ((pRaInfo->NscDown < N_THRESHOLD_LOW[RateID]) ||
-                   (pRaInfo->DROP > DROPING_NECESSARY[RateID]))
-                       odm_RateDown_8188E(dm_odm, pRaInfo);
-               else if (pRaInfo->NscUp > N_THRESHOLD_HIGH[RateID])
-                       odm_RateUp_8188E(dm_odm, pRaInfo);
-
-               if (pRaInfo->DecisionRate > pRaInfo->HighestRate)
-                       pRaInfo->DecisionRate = pRaInfo->HighestRate;
-
-               if ((pRaInfo->DecisionRate) == (pRaInfo->PreRate))
-                       DynamicTxRPTTimingCounter += 1;
-               else
-                       DynamicTxRPTTimingCounter = 0;
-
-               if (DynamicTxRPTTimingCounter >= 4) {
-                       odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 1);
-                       DynamicTxRPTTimingCounter = 0;
-               }
-
-               pRaInfo->PreRate = pRaInfo->DecisionRate;  /* YJ, add, 120120 */
-
-               odm_ResetRaCounter_8188E(pRaInfo);
-       }
-}
-
-static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo)
-{  /*  Wilson 2011/10/26 */
-       u32 MaskFromReg;
-       s8 i;
-       int res;
-
-       switch (pRaInfo->RateID) {
-       case RATR_INX_WIRELESS_NGB:
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x0f8ff015;
-               break;
-       case RATR_INX_WIRELESS_NG:
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x0f8ff010;
-               break;
-       case RATR_INX_WIRELESS_NB:
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x0f8ff005;
-               break;
-       case RATR_INX_WIRELESS_N:
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x0f8ff000;
-               break;
-       case RATR_INX_WIRELESS_GB:
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x00000ff5;
-               break;
-       case RATR_INX_WIRELESS_G:
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x00000ff0;
-               break;
-       case RATR_INX_WIRELESS_B:
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x0000000d;
-               break;
-       case 12:
-               res = rtw_read32(dm_odm->Adapter, REG_ARFR0, &MaskFromReg);
-               if (res)
-                       return res;
-
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg;
-               break;
-       case 13:
-               res = rtw_read32(dm_odm->Adapter, REG_ARFR1, &MaskFromReg);
-               if (res)
-                       return res;
-
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg;
-               break;
-       case 14:
-               res = rtw_read32(dm_odm->Adapter, REG_ARFR2, &MaskFromReg);
-               if (res)
-                       return res;
-
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg;
-               break;
-       case 15:
-               res = rtw_read32(dm_odm->Adapter, REG_ARFR3, &MaskFromReg);
-               if (res)
-                       return res;
-
-               pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg;
-               break;
-       default:
-               pRaInfo->RAUseRate = (pRaInfo->RateMask);
-               break;
-       }
-       /*  Highest rate */
-       if (pRaInfo->RAUseRate) {
-               for (i = RATESIZE; i >= 0; i--) {
-                       if ((pRaInfo->RAUseRate) & BIT(i)) {
-                               pRaInfo->HighestRate = i;
-                               break;
-                       }
-               }
-       } else {
-               pRaInfo->HighestRate = 0;
-       }
-       /*  Lowest rate */
-       if (pRaInfo->RAUseRate) {
-               for (i = 0; i < RATESIZE; i++) {
-                       if ((pRaInfo->RAUseRate) & BIT(i)) {
-                               pRaInfo->LowestRate = i;
-                               break;
-                       }
-               }
-       } else {
-               pRaInfo->LowestRate = 0;
-       }
-       if (pRaInfo->HighestRate > 0x13)
-               pRaInfo->PTModeSS = 3;
-       else if (pRaInfo->HighestRate > 0x0b)
-               pRaInfo->PTModeSS = 2;
-       else if (pRaInfo->HighestRate > 0x03)
-               pRaInfo->PTModeSS = 1;
-       else
-               pRaInfo->PTModeSS = 0;
-
-       if (pRaInfo->DecisionRate > pRaInfo->HighestRate)
-               pRaInfo->DecisionRate = pRaInfo->HighestRate;
-
-       return 0;
-}
-
-static void odm_PTTryState_8188E(struct odm_ra_info *pRaInfo)
-{
-       pRaInfo->PTTryState = 0;
-       switch (pRaInfo->PTModeSS) {
-       case 3:
-               if (pRaInfo->DecisionRate >= 0x19)
-                       pRaInfo->PTTryState = 1;
-               break;
-       case 2:
-               if (pRaInfo->DecisionRate >= 0x11)
-                       pRaInfo->PTTryState = 1;
-               break;
-       case 1:
-               if (pRaInfo->DecisionRate >= 0x0a)
-                       pRaInfo->PTTryState = 1;
-               break;
-       case 0:
-               if (pRaInfo->DecisionRate >= 0x03)
-                       pRaInfo->PTTryState = 1;
-               break;
-       default:
-               pRaInfo->PTTryState = 0;
-               break;
-       }
-
-       if (pRaInfo->RssiStaRA < 48) {
-               pRaInfo->PTStage = 0;
-       } else if (pRaInfo->PTTryState == 1) {
-               if ((pRaInfo->PTStopCount >= 10) ||
-                   (pRaInfo->PTPreRssi > pRaInfo->RssiStaRA + 5) ||
-                   (pRaInfo->PTPreRssi < pRaInfo->RssiStaRA - 5) ||
-                   (pRaInfo->DecisionRate != pRaInfo->PTPreRate)) {
-                       if (pRaInfo->PTStage == 0)
-                               pRaInfo->PTStage = 1;
-                       else if (pRaInfo->PTStage == 1)
-                               pRaInfo->PTStage = 3;
-                       else
-                               pRaInfo->PTStage = 5;
-
-                       pRaInfo->PTPreRssi = pRaInfo->RssiStaRA;
-                       pRaInfo->PTStopCount = 0;
-               } else {
-                       pRaInfo->RAstage = 0;
-                       pRaInfo->PTStopCount++;
-               }
-       } else {
-               pRaInfo->PTStage = 0;
-               pRaInfo->RAstage = 0;
-       }
-       pRaInfo->PTPreRate = pRaInfo->DecisionRate;
-}
-
-static void odm_PTDecision_8188E(struct odm_ra_info *pRaInfo)
-{
-       u8 j;
-       u8 temp_stage;
-       u32 numsc;
-       u32 num_total;
-       u8 stage_id;
-
-       numsc  = 0;
-       num_total = pRaInfo->TOTAL * PT_PENALTY[5];
-       for (j = 0; j <= 4; j++) {
-               numsc += pRaInfo->RTY[j] * PT_PENALTY[j];
-               if (numsc > num_total)
-                       break;
-       }
-
-       j = j >> 1;
-       temp_stage = (pRaInfo->PTStage + 1) >> 1;
-       if (temp_stage > j)
-               stage_id = temp_stage - j;
-       else
-               stage_id = 0;
-
-       pRaInfo->PTSmoothFactor = (pRaInfo->PTSmoothFactor >> 1) + (pRaInfo->PTSmoothFactor >> 2) + stage_id * 16 + 2;
-       if (pRaInfo->PTSmoothFactor > 192)
-               pRaInfo->PTSmoothFactor = 192;
-       stage_id = pRaInfo->PTSmoothFactor >> 6;
-       temp_stage = stage_id * 2;
-       if (temp_stage != 0)
-               temp_stage -= 1;
-       if (pRaInfo->DROP > 3)
-               temp_stage = 0;
-       pRaInfo->PTStage = temp_stage;
-}
-
-static void
-odm_RATxRPTTimerSetting(
-               struct odm_dm_struct *dm_odm,
-               u16 minRptTime
-)
-{
-       if (dm_odm->CurrminRptTime != minRptTime) {
-               rtw_rpt_timer_cfg_cmd(dm_odm->Adapter, minRptTime);
-               dm_odm->CurrminRptTime = minRptTime;
-       }
-}
-
-int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid)
-{
-       struct odm_ra_info *pRaInfo = &dm_odm->RAInfo[macid];
-       u8 WirelessMode = 0xFF; /* invalid value */
-       u8 max_rate_idx = 0x13; /* MCS7 */
-       if (dm_odm->pWirelessMode)
-               WirelessMode = *dm_odm->pWirelessMode;
-
-       if (WirelessMode != 0xFF) {
-               if (WirelessMode & ODM_WM_N24G)
-                       max_rate_idx = 0x13;
-               else if (WirelessMode & ODM_WM_G)
-                       max_rate_idx = 0x0b;
-               else if (WirelessMode & ODM_WM_B)
-                       max_rate_idx = 0x03;
-       }
-
-       pRaInfo->DecisionRate = max_rate_idx;
-       pRaInfo->PreRate = max_rate_idx;
-       pRaInfo->HighestRate = max_rate_idx;
-       pRaInfo->LowestRate = 0;
-       pRaInfo->RateID = 0;
-       pRaInfo->RateMask = 0xffffffff;
-       pRaInfo->RssiStaRA = 0;
-       pRaInfo->PreRssiStaRA = 0;
-       pRaInfo->SGIEnable = 0;
-       pRaInfo->RAUseRate = 0xffffffff;
-       pRaInfo->NscDown = (N_THRESHOLD_HIGH[0x13] + N_THRESHOLD_LOW[0x13]) / 2;
-       pRaInfo->NscUp = (N_THRESHOLD_HIGH[0x13] + N_THRESHOLD_LOW[0x13]) / 2;
-       pRaInfo->RateSGI = 0;
-       pRaInfo->Active = 1;    /* Active is not used at present. by page, 110819 */
-       pRaInfo->RptTime = 0x927c;
-       pRaInfo->DROP = 0;
-       pRaInfo->RTY[0] = 0;
-       pRaInfo->RTY[1] = 0;
-       pRaInfo->RTY[2] = 0;
-       pRaInfo->RTY[3] = 0;
-       pRaInfo->RTY[4] = 0;
-       pRaInfo->TOTAL = 0;
-       pRaInfo->RAWaitingCounter = 0;
-       pRaInfo->RAPendingCounter = 0;
-       pRaInfo->PTActive = 1;   /*  Active when this STA is use */
-       pRaInfo->PTTryState = 0;
-       pRaInfo->PTStage = 5; /*  Need to fill into HW_PWR_STATUS */
-       pRaInfo->PTSmoothFactor = 192;
-       pRaInfo->PTStopCount = 0;
-       pRaInfo->PTPreRate = 0;
-       pRaInfo->PTPreRssi = 0;
-       pRaInfo->PTModeSS = 0;
-       pRaInfo->RAstage = 0;
-       return 0;
-}
-
-int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm)
-{
-       u8 macid = 0;
-
-       dm_odm->CurrminRptTime = 0;
-
-       for (macid = 0; macid < ODM_ASSOCIATE_ENTRY_NUM; macid++)
-               ODM_RAInfo_Init(dm_odm, macid);
-
-       return 0;
-}
-
-u8 ODM_RA_GetShortGI_8188E(struct odm_dm_struct *dm_odm, u8 macid)
-{
-       if ((NULL == dm_odm) || (macid >= ODM_ASSOCIATE_ENTRY_NUM))
-               return 0;
-       return dm_odm->RAInfo[macid].RateSGI;
-}
-
-u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 macid)
-{
-       u8 DecisionRate = 0;
-
-       if ((NULL == dm_odm) || (macid >= ODM_ASSOCIATE_ENTRY_NUM))
-               return 0;
-       DecisionRate = (dm_odm->RAInfo[macid].DecisionRate);
-       return DecisionRate;
-}
-
-u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 macid)
-{
-       u8 PTStage = 5;
-
-       if ((NULL == dm_odm) || (macid >= ODM_ASSOCIATE_ENTRY_NUM))
-               return 0;
-       PTStage = (dm_odm->RAInfo[macid].PTStage);
-       return PTStage;
-}
-
-void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 RateID, u32 RateMask, u8 SGIEnable)
-{
-       struct odm_ra_info *pRaInfo = NULL;
-
-       if ((NULL == dm_odm) || (macid >= ODM_ASSOCIATE_ENTRY_NUM))
-               return;
-
-       pRaInfo = &dm_odm->RAInfo[macid];
-       pRaInfo->RateID = RateID;
-       pRaInfo->RateMask = RateMask;
-       pRaInfo->SGIEnable = SGIEnable;
-       odm_ARFBRefresh_8188E(dm_odm, pRaInfo);
-}
-
-void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rssi)
-{
-       struct odm_ra_info *pRaInfo = NULL;
-
-       if ((NULL == dm_odm) || (macid >= ODM_ASSOCIATE_ENTRY_NUM))
-               return;
-
-       pRaInfo = &dm_odm->RAInfo[macid];
-       pRaInfo->RssiStaRA = Rssi;
-}
-
-void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime)
-{
-       rtw_write16(dm_odm->Adapter, REG_TX_RPT_TIME, minRptTime);
-}
-
-void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 TxRPT_Len, u32 macid_entry0, u32 macid_entry1)
-{
-       struct odm_ra_info *pRAInfo = NULL;
-       u8 MacId = 0;
-       u8 *pBuffer = NULL;
-       u32 valid = 0, ItemNum = 0;
-       u16 minRptTime = 0x927c;
-
-       ItemNum = TxRPT_Len >> 3;
-       pBuffer = TxRPT_Buf;
-
-       do {
-               if (MacId >= ODM_ASSOCIATE_ENTRY_NUM)
-                       valid = 0;
-               else if (MacId >= 32)
-                       valid = (1 << (MacId - 32)) & macid_entry1;
-               else
-                       valid = (1 << MacId) & macid_entry0;
-
-               pRAInfo = &dm_odm->RAInfo[MacId];
-               if (valid) {
-                       pRAInfo->RTY[0] = le16_to_cpup((__le16 *)pBuffer);
-                       pRAInfo->RTY[1] = pBuffer[2];
-                       pRAInfo->RTY[2] = pBuffer[3];
-                       pRAInfo->RTY[3] = pBuffer[4];
-                       pRAInfo->RTY[4] = pBuffer[5];
-                       pRAInfo->DROP = pBuffer[6];
-                       pRAInfo->TOTAL = pRAInfo->RTY[0] + pRAInfo->RTY[1] +
-                                        pRAInfo->RTY[2] + pRAInfo->RTY[3] +
-                                        pRAInfo->RTY[4] + pRAInfo->DROP;
-                       if (pRAInfo->TOTAL != 0) {
-                               if (pRAInfo->PTActive) {
-                                       if (pRAInfo->RAstage < 5)
-                                               odm_RateDecision_8188E(dm_odm, pRAInfo);
-                                       else if (pRAInfo->RAstage == 5) /*  Power training try state */
-                                               odm_PTTryState_8188E(pRAInfo);
-                                       else /*  RAstage == 6 */
-                                               odm_PTDecision_8188E(pRAInfo);
-
-                                       /*  Stage_RA counter */
-                                       if (pRAInfo->RAstage <= 5)
-                                               pRAInfo->RAstage++;
-                                       else
-                                               pRAInfo->RAstage = 0;
-                               } else {
-                                       odm_RateDecision_8188E(dm_odm, pRAInfo);
-                               }
-                       }
-               }
-
-               if (minRptTime > pRAInfo->RptTime)
-                       minRptTime = pRAInfo->RptTime;
-
-               pBuffer += TX_RPT2_ITEM_SIZE;
-               MacId++;
-       } while (MacId < ItemNum);
-
-       odm_RATxRPTTimerSetting(dm_odm, minRptTime);
-}
diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
deleted file mode 100644 (file)
index 23b7205..0000000
+++ /dev/null
@@ -1,733 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/rtw_iol.h"
-
-#define read_next_pair(array, v1, v2, i)               \
-        do {                                           \
-                i += 2;                                \
-                v1 = array[i];                         \
-                v2 = array[i + 1];                     \
-        } while (0)
-
-static bool CheckCondition(const u32  condition, const u32  hex)
-{
-       u32 _interface = (hex & 0x0000FF00) >> 8;
-       u32 _platform  = (hex & 0x00FF0000) >> 16;
-       u32 cond = condition;
-
-       if (condition == 0xCDCDCDCD)
-               return true;
-
-       cond = condition & 0x0000FF00;
-       cond = cond >> 8;
-       if ((_interface & cond) == 0 && cond != 0x07)
-               return false;
-
-       cond = condition & 0x00FF0000;
-       cond = cond >> 16;
-       if ((_platform & cond) == 0 && cond != 0x0F)
-               return false;
-       return true;
-}
-
-/******************************************************************************
-*                           AGC_TAB_1T.TXT
-******************************************************************************/
-
-static u32 array_agc_tab_1t_8188e[] = {
-               0xC78, 0xFB000001,
-               0xC78, 0xFB010001,
-               0xC78, 0xFB020001,
-               0xC78, 0xFB030001,
-               0xC78, 0xFB040001,
-               0xC78, 0xFB050001,
-               0xC78, 0xFA060001,
-               0xC78, 0xF9070001,
-               0xC78, 0xF8080001,
-               0xC78, 0xF7090001,
-               0xC78, 0xF60A0001,
-               0xC78, 0xF50B0001,
-               0xC78, 0xF40C0001,
-               0xC78, 0xF30D0001,
-               0xC78, 0xF20E0001,
-               0xC78, 0xF10F0001,
-               0xC78, 0xF0100001,
-               0xC78, 0xEF110001,
-               0xC78, 0xEE120001,
-               0xC78, 0xED130001,
-               0xC78, 0xEC140001,
-               0xC78, 0xEB150001,
-               0xC78, 0xEA160001,
-               0xC78, 0xE9170001,
-               0xC78, 0xE8180001,
-               0xC78, 0xE7190001,
-               0xC78, 0xE61A0001,
-               0xC78, 0xE51B0001,
-               0xC78, 0xE41C0001,
-               0xC78, 0xE31D0001,
-               0xC78, 0xE21E0001,
-               0xC78, 0xE11F0001,
-               0xC78, 0x8A200001,
-               0xC78, 0x89210001,
-               0xC78, 0x88220001,
-               0xC78, 0x87230001,
-               0xC78, 0x86240001,
-               0xC78, 0x85250001,
-               0xC78, 0x84260001,
-               0xC78, 0x83270001,
-               0xC78, 0x82280001,
-               0xC78, 0x6B290001,
-               0xC78, 0x6A2A0001,
-               0xC78, 0x692B0001,
-               0xC78, 0x682C0001,
-               0xC78, 0x672D0001,
-               0xC78, 0x662E0001,
-               0xC78, 0x652F0001,
-               0xC78, 0x64300001,
-               0xC78, 0x63310001,
-               0xC78, 0x62320001,
-               0xC78, 0x61330001,
-               0xC78, 0x46340001,
-               0xC78, 0x45350001,
-               0xC78, 0x44360001,
-               0xC78, 0x43370001,
-               0xC78, 0x42380001,
-               0xC78, 0x41390001,
-               0xC78, 0x403A0001,
-               0xC78, 0x403B0001,
-               0xC78, 0x403C0001,
-               0xC78, 0x403D0001,
-               0xC78, 0x403E0001,
-               0xC78, 0x403F0001,
-               0xC78, 0xFB400001,
-               0xC78, 0xFB410001,
-               0xC78, 0xFB420001,
-               0xC78, 0xFB430001,
-               0xC78, 0xFB440001,
-               0xC78, 0xFB450001,
-               0xC78, 0xFB460001,
-               0xC78, 0xFB470001,
-               0xC78, 0xFB480001,
-               0xC78, 0xFA490001,
-               0xC78, 0xF94A0001,
-               0xC78, 0xF84B0001,
-               0xC78, 0xF74C0001,
-               0xC78, 0xF64D0001,
-               0xC78, 0xF54E0001,
-               0xC78, 0xF44F0001,
-               0xC78, 0xF3500001,
-               0xC78, 0xF2510001,
-               0xC78, 0xF1520001,
-               0xC78, 0xF0530001,
-               0xC78, 0xEF540001,
-               0xC78, 0xEE550001,
-               0xC78, 0xED560001,
-               0xC78, 0xEC570001,
-               0xC78, 0xEB580001,
-               0xC78, 0xEA590001,
-               0xC78, 0xE95A0001,
-               0xC78, 0xE85B0001,
-               0xC78, 0xE75C0001,
-               0xC78, 0xE65D0001,
-               0xC78, 0xE55E0001,
-               0xC78, 0xE45F0001,
-               0xC78, 0xE3600001,
-               0xC78, 0xE2610001,
-               0xC78, 0xC3620001,
-               0xC78, 0xC2630001,
-               0xC78, 0xC1640001,
-               0xC78, 0x8B650001,
-               0xC78, 0x8A660001,
-               0xC78, 0x89670001,
-               0xC78, 0x88680001,
-               0xC78, 0x87690001,
-               0xC78, 0x866A0001,
-               0xC78, 0x856B0001,
-               0xC78, 0x846C0001,
-               0xC78, 0x676D0001,
-               0xC78, 0x666E0001,
-               0xC78, 0x656F0001,
-               0xC78, 0x64700001,
-               0xC78, 0x63710001,
-               0xC78, 0x62720001,
-               0xC78, 0x61730001,
-               0xC78, 0x60740001,
-               0xC78, 0x46750001,
-               0xC78, 0x45760001,
-               0xC78, 0x44770001,
-               0xC78, 0x43780001,
-               0xC78, 0x42790001,
-               0xC78, 0x417A0001,
-               0xC78, 0x407B0001,
-               0xC78, 0x407C0001,
-               0xC78, 0x407D0001,
-               0xC78, 0x407E0001,
-               0xC78, 0x407F0001,
-};
-
-static void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data)
-{
-       rtl8188e_PHY_SetBBReg(pDM_Odm->Adapter, Addr, Bitmask, Data);
-       /*  Add 1us delay between BB/RF register setting. */
-       udelay(1);
-}
-
-int ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm)
-{
-       u32     hex         = 0;
-       u32     i           = 0;
-       u32     arraylen    = ARRAY_SIZE(array_agc_tab_1t_8188e);
-       u32    *array       = array_agc_tab_1t_8188e;
-       bool            biol = false;
-       struct adapter *adapter =  dm_odm->Adapter;
-       struct xmit_frame *pxmit_frame = NULL;
-       u8 bndy_cnt = 1;
-
-       hex += ODM_ITRF_USB << 8;
-       hex += ODM_CE << 16;
-       hex += 0xFF000000;
-       biol = rtw_IOL_applied(adapter);
-
-       if (biol) {
-               pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter);
-               if (!pxmit_frame) {
-                       pr_info("rtw_IOL_accquire_xmit_frame failed\n");
-                       return -ENOMEM;
-               }
-       }
-
-       for (i = 0; i < arraylen; i += 2) {
-               u32 v1 = array[i];
-               u32 v2 = array[i + 1];
-
-               /*  This (offset, data) pair meets the condition. */
-               if (v1 < 0xCDCDCDCD) {
-                       if (biol) {
-                               if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
-                                       bndy_cnt++;
-                               rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord);
-                       } else {
-                               odm_ConfigBB_AGC_8188E(dm_odm, v1, bMaskDWord, v2);
-                       }
-                       continue;
-               } else {
-                       /*  This line is the start line of branch. */
-                       if (!CheckCondition(array[i], hex)) {
-                               /*  Discard the following (offset, data) pairs. */
-                               read_next_pair(array, v1, v2, i);
-                               while (v2 != 0xDEAD &&
-                                      v2 != 0xCDEF &&
-                                      v2 != 0xCDCD && i < arraylen - 2)
-                                       read_next_pair(array, v1, v2, i);
-                               i -= 2; /*  prevent from for-loop += 2 */
-                       } else { /*  Configure matched pairs and skip to end of if-else. */
-                               read_next_pair(array, v1, v2, i);
-                               while (v2 != 0xDEAD &&
-                                      v2 != 0xCDEF &&
-                                      v2 != 0xCDCD && i < arraylen - 2) {
-                                       if (biol) {
-                                               if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
-                                                       bndy_cnt++;
-                                               rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord);
-                                       } else {
-                                               odm_ConfigBB_AGC_8188E(dm_odm, v1, bMaskDWord, v2);
-                                       }
-                                       read_next_pair(array, v1, v2, i);
-                               }
-
-                               while (v2 != 0xDEAD && i < arraylen - 2)
-                                       read_next_pair(array, v1, v2, i);
-                       }
-               }
-       }
-       if (biol) {
-               if (!rtl8188e_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) {
-                       printk("~~~ %s IOL_exec_cmds Failed !!!\n", __func__);
-                       return -1;
-               }
-       }
-       return 0;
-}
-
-/******************************************************************************
-*                           PHY_REG_1T.TXT
-******************************************************************************/
-
-static u32 array_phy_reg_1t_8188e[] = {
-               0x800, 0x80040000,
-               0x804, 0x00000003,
-               0x808, 0x0000FC00,
-               0x80C, 0x0000000A,
-               0x810, 0x10001331,
-               0x814, 0x020C3D10,
-               0x818, 0x02200385,
-               0x81C, 0x00000000,
-               0x820, 0x01000100,
-               0x824, 0x00390204,
-               0x828, 0x00000000,
-               0x82C, 0x00000000,
-               0x830, 0x00000000,
-               0x834, 0x00000000,
-               0x838, 0x00000000,
-               0x83C, 0x00000000,
-               0x840, 0x00010000,
-               0x844, 0x00000000,
-               0x848, 0x00000000,
-               0x84C, 0x00000000,
-               0x850, 0x00000000,
-               0x854, 0x00000000,
-               0x858, 0x569A11A9,
-               0x85C, 0x01000014,
-               0x860, 0x66F60110,
-               0x864, 0x061F0649,
-               0x868, 0x00000000,
-               0x86C, 0x27272700,
-               0x870, 0x07000760,
-               0x874, 0x25004000,
-               0x878, 0x00000808,
-               0x87C, 0x00000000,
-               0x880, 0xB0000C1C,
-               0x884, 0x00000001,
-               0x888, 0x00000000,
-               0x88C, 0xCCC000C0,
-               0x890, 0x00000800,
-               0x894, 0xFFFFFFFE,
-               0x898, 0x40302010,
-               0x89C, 0x00706050,
-               0x900, 0x00000000,
-               0x904, 0x00000023,
-               0x908, 0x00000000,
-               0x90C, 0x81121111,
-               0x910, 0x00000002,
-               0x914, 0x00000201,
-               0xA00, 0x00D047C8,
-               0xA04, 0x80FF000C,
-               0xA08, 0x8C838300,
-               0xA0C, 0x2E7F120F,
-               0xA10, 0x9500BB78,
-               0xA14, 0x1114D028,
-               0xA18, 0x00881117,
-               0xA1C, 0x89140F00,
-               0xA20, 0x1A1B0000,
-               0xA24, 0x090E1317,
-               0xA28, 0x00000204,
-               0xA2C, 0x00D30000,
-               0xA70, 0x101FBF00,
-               0xA74, 0x00000007,
-               0xA78, 0x00000900,
-               0xA7C, 0x225B0606,
-               0xA80, 0x218075B1,
-               0xB2C, 0x80000000,
-               0xC00, 0x48071D40,
-               0xC04, 0x03A05611,
-               0xC08, 0x000000E4,
-               0xC0C, 0x6C6C6C6C,
-               0xC10, 0x08800000,
-               0xC14, 0x40000100,
-               0xC18, 0x08800000,
-               0xC1C, 0x40000100,
-               0xC20, 0x00000000,
-               0xC24, 0x00000000,
-               0xC28, 0x00000000,
-               0xC2C, 0x00000000,
-               0xC30, 0x69E9AC47,
-               0xC34, 0x469652AF,
-               0xC38, 0x49795994,
-               0xC3C, 0x0A97971C,
-               0xC40, 0x1F7C403F,
-               0xC44, 0x000100B7,
-               0xC48, 0xEC020107,
-               0xC4C, 0x007F037F,
-               0xC50, 0x69553420,
-               0xC54, 0x43BC0094,
-               0xC58, 0x00013169,
-               0xC5C, 0x00250492,
-               0xC60, 0x00000000,
-               0xC64, 0x7112848B,
-               0xC68, 0x47C00BFF,
-               0xC6C, 0x00000036,
-               0xC70, 0x2C7F000D,
-               0xC74, 0x020610DB,
-               0xC78, 0x0000001F,
-               0xC7C, 0x00B91612,
-               0xC80, 0x390000E4,
-               0xC84, 0x20F60000,
-               0xC88, 0x40000100,
-               0xC8C, 0x20200000,
-               0xC90, 0x00091521,
-               0xC94, 0x00000000,
-               0xC98, 0x00121820,
-               0xC9C, 0x00007F7F,
-               0xCA0, 0x00000000,
-               0xCA4, 0x000300A0,
-               0xCA8, 0x00000000,
-               0xCAC, 0x00000000,
-               0xCB0, 0x00000000,
-               0xCB4, 0x00000000,
-               0xCB8, 0x00000000,
-               0xCBC, 0x28000000,
-               0xCC0, 0x00000000,
-               0xCC4, 0x00000000,
-               0xCC8, 0x00000000,
-               0xCCC, 0x00000000,
-               0xCD0, 0x00000000,
-               0xCD4, 0x00000000,
-               0xCD8, 0x64B22427,
-               0xCDC, 0x00766932,
-               0xCE0, 0x00222222,
-               0xCE4, 0x00000000,
-               0xCE8, 0x37644302,
-               0xCEC, 0x2F97D40C,
-               0xD00, 0x00000740,
-               0xD04, 0x00020401,
-               0xD08, 0x0000907F,
-               0xD0C, 0x20010201,
-               0xD10, 0xA0633333,
-               0xD14, 0x3333BC43,
-               0xD18, 0x7A8F5B6F,
-               0xD2C, 0xCC979975,
-               0xD30, 0x00000000,
-               0xD34, 0x80608000,
-               0xD38, 0x00000000,
-               0xD3C, 0x00127353,
-               0xD40, 0x00000000,
-               0xD44, 0x00000000,
-               0xD48, 0x00000000,
-               0xD4C, 0x00000000,
-               0xD50, 0x6437140A,
-               0xD54, 0x00000000,
-               0xD58, 0x00000282,
-               0xD5C, 0x30032064,
-               0xD60, 0x4653DE68,
-               0xD64, 0x04518A3C,
-               0xD68, 0x00002101,
-               0xD6C, 0x2A201C16,
-               0xD70, 0x1812362E,
-               0xD74, 0x322C2220,
-               0xD78, 0x000E3C24,
-               0xE00, 0x2D2D2D2D,
-               0xE04, 0x2D2D2D2D,
-               0xE08, 0x0390272D,
-               0xE10, 0x2D2D2D2D,
-               0xE14, 0x2D2D2D2D,
-               0xE18, 0x2D2D2D2D,
-               0xE1C, 0x2D2D2D2D,
-               0xE28, 0x00000000,
-               0xE30, 0x1000DC1F,
-               0xE34, 0x10008C1F,
-               0xE38, 0x02140102,
-               0xE3C, 0x681604C2,
-               0xE40, 0x01007C00,
-               0xE44, 0x01004800,
-               0xE48, 0xFB000000,
-               0xE4C, 0x000028D1,
-               0xE50, 0x1000DC1F,
-               0xE54, 0x10008C1F,
-               0xE58, 0x02140102,
-               0xE5C, 0x28160D05,
-               0xE60, 0x00000008,
-               0xE68, 0x001B25A4,
-               0xE6C, 0x00C00014,
-               0xE70, 0x00C00014,
-               0xE74, 0x01000014,
-               0xE78, 0x01000014,
-               0xE7C, 0x01000014,
-               0xE80, 0x01000014,
-               0xE84, 0x00C00014,
-               0xE88, 0x01000014,
-               0xE8C, 0x00C00014,
-               0xED0, 0x00C00014,
-               0xED4, 0x00C00014,
-               0xED8, 0x00C00014,
-               0xEDC, 0x00000014,
-               0xEE0, 0x00000014,
-               0xEEC, 0x01C00014,
-               0xF14, 0x00000003,
-               0xF4C, 0x00000000,
-               0xF00, 0x00000300,
-};
-
-static void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data)
-{
-       if (Addr == 0xfe) {
-               msleep(50);
-       } else if (Addr == 0xfd) {
-               mdelay(5);
-       } else if (Addr == 0xfc) {
-               mdelay(1);
-       } else if (Addr == 0xfb) {
-               udelay(50);
-       } else if (Addr == 0xfa) {
-               udelay(5);
-       } else if (Addr == 0xf9) {
-               udelay(1);
-       } else {
-               if (Addr == 0xa24)
-                       pDM_Odm->RFCalibrateInfo.RegA24 = Data;
-               rtl8188e_PHY_SetBBReg(pDM_Odm->Adapter, Addr, Bitmask, Data);
-
-               /*  Add 1us delay between BB/RF register setting. */
-               udelay(1);
-       }
-}
-
-int ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm)
-{
-       u32     hex         = 0;
-       u32     i           = 0;
-       u32     arraylen    = ARRAY_SIZE(array_phy_reg_1t_8188e);
-       u32    *array       = array_phy_reg_1t_8188e;
-       bool    biol = false;
-       struct adapter *adapter =  dm_odm->Adapter;
-       struct xmit_frame *pxmit_frame = NULL;
-       u8 bndy_cnt = 1;
-       hex += ODM_ITRF_USB << 8;
-       hex += ODM_CE << 16;
-       hex += 0xFF000000;
-       biol = rtw_IOL_applied(adapter);
-
-       if (biol) {
-               pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter);
-               if (!pxmit_frame) {
-                       pr_info("rtw_IOL_accquire_xmit_frame failed\n");
-                       return -ENOMEM;
-               }
-       }
-
-       for (i = 0; i < arraylen; i += 2) {
-               u32 v1 = array[i];
-               u32 v2 = array[i + 1];
-
-               /*  This (offset, data) pair meets the condition. */
-               if (v1 < 0xCDCDCDCD) {
-                       if (biol) {
-                               if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
-                                       bndy_cnt++;
-                               if (v1 == 0xfe) {
-                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50);
-                               } else if (v1 == 0xfd) {
-                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5);
-                               } else if (v1 == 0xfc) {
-                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1);
-                               } else if (v1 == 0xfb) {
-                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50);
-                               } else if (v1 == 0xfa) {
-                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5);
-                               } else if (v1 == 0xf9) {
-                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1);
-                               } else {
-                                       if (v1 == 0xa24)
-                                               dm_odm->RFCalibrateInfo.RegA24 = v2;
-                                       rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord);
-                               }
-                       } else {
-                               odm_ConfigBB_PHY_8188E(dm_odm, v1, bMaskDWord, v2);
-                       }
-                       continue;
-               } else { /*  This line is the start line of branch. */
-                       if (!CheckCondition(array[i], hex)) {
-                               /*  Discard the following (offset, data) pairs. */
-                               read_next_pair(array, v1, v2, i);
-                               while (v2 != 0xDEAD &&
-                                      v2 != 0xCDEF &&
-                                      v2 != 0xCDCD && i < arraylen - 2)
-                                       read_next_pair(array, v1, v2, i);
-                               i -= 2; /*  prevent from for-loop += 2 */
-                       } else { /*  Configure matched pairs and skip to end of if-else. */
-                               read_next_pair(array, v1, v2, i);
-                               while (v2 != 0xDEAD &&
-                                      v2 != 0xCDEF &&
-                                      v2 != 0xCDCD && i < arraylen - 2) {
-                                       if (biol) {
-                                               if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
-                                                       bndy_cnt++;
-                                               if (v1 == 0xfe) {
-                                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50);
-                                               } else if (v1 == 0xfd) {
-                                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5);
-                                               } else if (v1 == 0xfc) {
-                                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1);
-                                               } else if (v1 == 0xfb) {
-                                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50);
-                                               } else if (v1 == 0xfa) {
-                                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5);
-                                               } else if (v1 == 0xf9) {
-                                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1);
-                                               } else {
-                                                       if (v1 == 0xa24)
-                                                               dm_odm->RFCalibrateInfo.RegA24 = v2;
-
-                                                       rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord);
-                                               }
-                                       } else {
-                                               odm_ConfigBB_PHY_8188E(dm_odm, v1, bMaskDWord, v2);
-                                       }
-                                       read_next_pair(array, v1, v2, i);
-                               }
-
-                               while (v2 != 0xDEAD && i < arraylen - 2)
-                                       read_next_pair(array, v1, v2, i);
-                       }
-               }
-       }
-       if (biol) {
-               if (!rtl8188e_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) {
-                       pr_info("~~~ IOL Config %s Failed !!!\n", __func__);
-                       return -1;
-               }
-       }
-       return 0;
-}
-
-/******************************************************************************
-*                           PHY_REG_PG.TXT
-******************************************************************************/
-
-static u32 array_phy_reg_pg_8188e[] = {
-               0xE00, 0xFFFFFFFF, 0x06070809,
-               0xE04, 0xFFFFFFFF, 0x02020405,
-               0xE08, 0x0000FF00, 0x00000006,
-               0x86C, 0xFFFFFF00, 0x00020400,
-               0xE10, 0xFFFFFFFF, 0x08090A0B,
-               0xE14, 0xFFFFFFFF, 0x01030607,
-               0xE18, 0xFFFFFFFF, 0x08090A0B,
-               0xE1C, 0xFFFFFFFF, 0x01030607,
-               0xE00, 0xFFFFFFFF, 0x00000000,
-               0xE04, 0xFFFFFFFF, 0x00000000,
-               0xE08, 0x0000FF00, 0x00000000,
-               0x86C, 0xFFFFFF00, 0x00000000,
-               0xE10, 0xFFFFFFFF, 0x00000000,
-               0xE14, 0xFFFFFFFF, 0x00000000,
-               0xE18, 0xFFFFFFFF, 0x00000000,
-               0xE1C, 0xFFFFFFFF, 0x00000000,
-               0xE00, 0xFFFFFFFF, 0x02020202,
-               0xE04, 0xFFFFFFFF, 0x00020202,
-               0xE08, 0x0000FF00, 0x00000000,
-               0x86C, 0xFFFFFF00, 0x00000000,
-               0xE10, 0xFFFFFFFF, 0x04040404,
-               0xE14, 0xFFFFFFFF, 0x00020404,
-               0xE18, 0xFFFFFFFF, 0x00000000,
-               0xE1C, 0xFFFFFFFF, 0x00000000,
-               0xE00, 0xFFFFFFFF, 0x02020202,
-               0xE04, 0xFFFFFFFF, 0x00020202,
-               0xE08, 0x0000FF00, 0x00000000,
-               0x86C, 0xFFFFFF00, 0x00000000,
-               0xE10, 0xFFFFFFFF, 0x04040404,
-               0xE14, 0xFFFFFFFF, 0x00020404,
-               0xE18, 0xFFFFFFFF, 0x00000000,
-               0xE1C, 0xFFFFFFFF, 0x00000000,
-               0xE00, 0xFFFFFFFF, 0x00000000,
-               0xE04, 0xFFFFFFFF, 0x00000000,
-               0xE08, 0x0000FF00, 0x00000000,
-               0x86C, 0xFFFFFF00, 0x00000000,
-               0xE10, 0xFFFFFFFF, 0x00000000,
-               0xE14, 0xFFFFFFFF, 0x00000000,
-               0xE18, 0xFFFFFFFF, 0x00000000,
-               0xE1C, 0xFFFFFFFF, 0x00000000,
-               0xE00, 0xFFFFFFFF, 0x02020202,
-               0xE04, 0xFFFFFFFF, 0x00020202,
-               0xE08, 0x0000FF00, 0x00000000,
-               0x86C, 0xFFFFFF00, 0x00000000,
-               0xE10, 0xFFFFFFFF, 0x04040404,
-               0xE14, 0xFFFFFFFF, 0x00020404,
-               0xE18, 0xFFFFFFFF, 0x00000000,
-               0xE1C, 0xFFFFFFFF, 0x00000000,
-               0xE00, 0xFFFFFFFF, 0x00000000,
-               0xE04, 0xFFFFFFFF, 0x00000000,
-               0xE08, 0x0000FF00, 0x00000000,
-               0x86C, 0xFFFFFF00, 0x00000000,
-               0xE10, 0xFFFFFFFF, 0x00000000,
-               0xE14, 0xFFFFFFFF, 0x00000000,
-               0xE18, 0xFFFFFFFF, 0x00000000,
-               0xE1C, 0xFFFFFFFF, 0x00000000,
-               0xE00, 0xFFFFFFFF, 0x00000000,
-               0xE04, 0xFFFFFFFF, 0x00000000,
-               0xE08, 0x0000FF00, 0x00000000,
-               0x86C, 0xFFFFFF00, 0x00000000,
-               0xE10, 0xFFFFFFFF, 0x00000000,
-               0xE14, 0xFFFFFFFF, 0x00000000,
-               0xE18, 0xFFFFFFFF, 0x00000000,
-               0xE1C, 0xFFFFFFFF, 0x00000000,
-               0xE00, 0xFFFFFFFF, 0x00000000,
-               0xE04, 0xFFFFFFFF, 0x00000000,
-               0xE08, 0x0000FF00, 0x00000000,
-               0x86C, 0xFFFFFF00, 0x00000000,
-               0xE10, 0xFFFFFFFF, 0x00000000,
-               0xE14, 0xFFFFFFFF, 0x00000000,
-               0xE18, 0xFFFFFFFF, 0x00000000,
-               0xE1C, 0xFFFFFFFF, 0x00000000,
-               0xE00, 0xFFFFFFFF, 0x00000000,
-               0xE04, 0xFFFFFFFF, 0x00000000,
-               0xE08, 0x0000FF00, 0x00000000,
-               0x86C, 0xFFFFFF00, 0x00000000,
-               0xE10, 0xFFFFFFFF, 0x00000000,
-               0xE14, 0xFFFFFFFF, 0x00000000,
-               0xE18, 0xFFFFFFFF, 0x00000000,
-               0xE1C, 0xFFFFFFFF, 0x00000000,
-               0xE00, 0xFFFFFFFF, 0x00000000,
-               0xE04, 0xFFFFFFFF, 0x00000000,
-               0xE08, 0x0000FF00, 0x00000000,
-               0x86C, 0xFFFFFF00, 0x00000000,
-               0xE10, 0xFFFFFFFF, 0x00000000,
-               0xE14, 0xFFFFFFFF, 0x00000000,
-               0xE18, 0xFFFFFFFF, 0x00000000,
-               0xE1C, 0xFFFFFFFF, 0x00000000,
-
-};
-
-static void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask,
-                                         u32 Data)
-{
-       if (Addr == 0xfe)
-               msleep(50);
-       else if (Addr == 0xfd)
-               mdelay(5);
-       else if (Addr == 0xfc)
-               mdelay(1);
-       else if (Addr == 0xfb)
-               udelay(50);
-       else if (Addr == 0xfa)
-               udelay(5);
-       else if (Addr == 0xf9)
-               udelay(1);
-       else
-               storePwrIndexDiffRateOffset(pDM_Odm->Adapter, Addr, Bitmask, Data);
-}
-
-void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm)
-{
-       u32  hex;
-       u32  i           = 0;
-       u32  arraylen    = ARRAY_SIZE(array_phy_reg_pg_8188e);
-       u32 *array       = array_phy_reg_pg_8188e;
-
-       hex = ODM_ITRF_USB << 8;
-       hex += (ODM_CE << 16) + 0xFF000000;
-
-       for (i = 0; i < arraylen; i += 3) {
-               u32 v1 = array[i];
-               u32 v2 = array[i + 1];
-               u32 v3 = array[i + 2];
-
-               /*  this line is a line of pure_body */
-               if (v1 < 0xCDCDCDCD) {
-                       odm_ConfigBB_PHY_REG_PG_8188E(dm_odm, v1, v2, v3);
-                       continue;
-               } else { /*  this line is the start of branch */
-                       if (!CheckCondition(array[i], hex)) {
-                               /*  don't need the hw_body */
-                               i += 2; /*  skip the pair of expression */
-                               v1 = array[i];
-                               v2 = array[i + 1];
-                               v3 = array[i + 2];
-                               while (v2 != 0xDEAD) {
-                                       i += 3;
-                                       v1 = array[i];
-                                       v2 = array[i + 1];
-                                       v3 = array[i + 1];
-                               }
-                       }
-               }
-       }
-}
diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c
deleted file mode 100644 (file)
index da71867..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/rtw_iol.h"
-
-static bool Checkcondition(const u32  condition, const u32  hex)
-{
-       u32 _board     = (hex & 0x000000FF);
-       u32 _interface = (hex & 0x0000FF00) >> 8;
-       u32 _platform  = (hex & 0x00FF0000) >> 16;
-       u32 cond = condition;
-
-       if (condition == 0xCDCDCDCD)
-               return true;
-
-       cond = condition & 0x000000FF;
-       if ((_board == cond) && cond != 0x00)
-               return false;
-
-       cond = condition & 0x0000FF00;
-       cond = cond >> 8;
-       if ((_interface & cond) == 0 && cond != 0x07)
-               return false;
-
-       cond = condition & 0x00FF0000;
-       cond = cond >> 16;
-       if ((_platform & cond) == 0 && cond != 0x0F)
-               return false;
-       return true;
-}
-
-/******************************************************************************
-*                           MAC_REG.TXT
-******************************************************************************/
-
-static u32 array_MAC_REG_8188E[] = {
-               0x026, 0x00000041,
-               0x027, 0x00000035,
-               0x428, 0x0000000A,
-               0x429, 0x00000010,
-               0x430, 0x00000000,
-               0x431, 0x00000001,
-               0x432, 0x00000002,
-               0x433, 0x00000004,
-               0x434, 0x00000005,
-               0x435, 0x00000006,
-               0x436, 0x00000007,
-               0x437, 0x00000008,
-               0x438, 0x00000000,
-               0x439, 0x00000000,
-               0x43A, 0x00000001,
-               0x43B, 0x00000002,
-               0x43C, 0x00000004,
-               0x43D, 0x00000005,
-               0x43E, 0x00000006,
-               0x43F, 0x00000007,
-               0x440, 0x0000005D,
-               0x441, 0x00000001,
-               0x442, 0x00000000,
-               0x444, 0x00000015,
-               0x445, 0x000000F0,
-               0x446, 0x0000000F,
-               0x447, 0x00000000,
-               0x458, 0x00000041,
-               0x459, 0x000000A8,
-               0x45A, 0x00000072,
-               0x45B, 0x000000B9,
-               0x460, 0x00000066,
-               0x461, 0x00000066,
-               0x480, 0x00000008,
-               0x4C8, 0x000000FF,
-               0x4C9, 0x00000008,
-               0x4CC, 0x000000FF,
-               0x4CD, 0x000000FF,
-               0x4CE, 0x00000001,
-               0x4D3, 0x00000001,
-               0x500, 0x00000026,
-               0x501, 0x000000A2,
-               0x502, 0x0000002F,
-               0x503, 0x00000000,
-               0x504, 0x00000028,
-               0x505, 0x000000A3,
-               0x506, 0x0000005E,
-               0x507, 0x00000000,
-               0x508, 0x0000002B,
-               0x509, 0x000000A4,
-               0x50A, 0x0000005E,
-               0x50B, 0x00000000,
-               0x50C, 0x0000004F,
-               0x50D, 0x000000A4,
-               0x50E, 0x00000000,
-               0x50F, 0x00000000,
-               0x512, 0x0000001C,
-               0x514, 0x0000000A,
-               0x516, 0x0000000A,
-               0x525, 0x0000004F,
-               0x550, 0x00000010,
-               0x551, 0x00000010,
-               0x559, 0x00000002,
-               0x55D, 0x000000FF,
-               0x605, 0x00000030,
-               0x608, 0x0000000E,
-               0x609, 0x0000002A,
-               0x620, 0x000000FF,
-               0x621, 0x000000FF,
-               0x622, 0x000000FF,
-               0x623, 0x000000FF,
-               0x624, 0x000000FF,
-               0x625, 0x000000FF,
-               0x626, 0x000000FF,
-               0x627, 0x000000FF,
-               0x652, 0x00000020,
-               0x63C, 0x0000000A,
-               0x63D, 0x0000000A,
-               0x63E, 0x0000000E,
-               0x63F, 0x0000000E,
-               0x640, 0x00000040,
-               0x66E, 0x00000005,
-               0x700, 0x00000021,
-               0x701, 0x00000043,
-               0x702, 0x00000065,
-               0x703, 0x00000087,
-               0x708, 0x00000021,
-               0x709, 0x00000043,
-               0x70A, 0x00000065,
-               0x70B, 0x00000087,
-};
-
-static void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data)
-{
-       rtw_write8(pDM_Odm->Adapter, Addr, Data);
-}
-
-int ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm)
-{
-       #define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = array[i]; v2 = array[i + 1]; } while (0)
-
-       u32     hex         = 0;
-       u32     i;
-       u32     array_len    = ARRAY_SIZE(array_MAC_REG_8188E);
-       u32    *array       = array_MAC_REG_8188E;
-       bool    biol = false;
-
-       struct adapter *adapt =  dm_odm->Adapter;
-       struct xmit_frame       *pxmit_frame = NULL;
-       u8 bndy_cnt = 1;
-       hex += ODM_ITRF_USB << 8;
-       hex += ODM_CE << 16;
-       hex += 0xFF000000;
-
-       biol = rtw_IOL_applied(adapt);
-
-       if (biol) {
-               pxmit_frame = rtw_IOL_accquire_xmit_frame(adapt);
-               if (!pxmit_frame) {
-                       pr_info("rtw_IOL_accquire_xmit_frame failed\n");
-                       return -ENOMEM;
-               }
-       }
-
-       for (i = 0; i < array_len; i += 2) {
-               u32 v1 = array[i];
-               u32 v2 = array[i + 1];
-
-               /*  This (offset, data) pair meets the condition. */
-               if (v1 < 0xCDCDCDCD) {
-                               if (biol) {
-                                       if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
-                                               bndy_cnt++;
-                                       rtw_IOL_append_WB_cmd(pxmit_frame, (u16)v1, (u8)v2, 0xFF);
-                               } else {
-                                       odm_ConfigMAC_8188E(dm_odm, v1, (u8)v2);
-                               }
-                               continue;
-               } else { /*  This line is the start line of branch. */
-                       if (!Checkcondition(array[i], hex)) {
-                               /*  Discard the following (offset, data) pairs. */
-                               READ_NEXT_PAIR(v1, v2, i);
-                               while (v2 != 0xDEAD &&
-                                      v2 != 0xCDEF &&
-                                      v2 != 0xCDCD && i < array_len - 2) {
-                                       READ_NEXT_PAIR(v1, v2, i);
-                               }
-                               i -= 2; /*  prevent from for-loop += 2 */
-                       } else { /*  Configure matched pairs and skip to end of if-else. */
-                               READ_NEXT_PAIR(v1, v2, i);
-                               while (v2 != 0xDEAD &&
-                                      v2 != 0xCDEF &&
-                                      v2 != 0xCDCD && i < array_len - 2) {
-                                       if (biol) {
-                                               if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
-                                                       bndy_cnt++;
-                                               rtw_IOL_append_WB_cmd(pxmit_frame, (u16)v1, (u8)v2, 0xFF);
-                                       } else {
-                                               odm_ConfigMAC_8188E(dm_odm, v1, (u8)v2);
-                                       }
-
-                                       READ_NEXT_PAIR(v1, v2, i);
-                               }
-                               while (v2 != 0xDEAD && i < array_len - 2)
-                                       READ_NEXT_PAIR(v1, v2, i);
-                       }
-               }
-       }
-       if (biol) {
-               if (!rtl8188e_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) {
-                       pr_info("~~~ MAC IOL_exec_cmds Failed !!!\n");
-                       return -1;
-               }
-       }
-       return 0;
-}
diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c
deleted file mode 100644 (file)
index a4c3d3d..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/rtw_iol.h"
-
-static bool CheckCondition(const u32  Condition, const u32  Hex)
-{
-       u32 _interface = (Hex & 0x0000FF00) >> 8;
-       u32 _platform  = (Hex & 0x00FF0000) >> 16;
-       u32 cond = Condition;
-
-       if (Condition == 0xCDCDCDCD)
-               return true;
-
-       cond = Condition & 0x0000FF00;
-       cond = cond >> 8;
-       if ((_interface & cond) == 0 && cond != 0x07)
-               return false;
-
-       cond = Condition & 0x00FF0000;
-       cond = cond >> 16;
-       if ((_platform & cond) == 0 && cond != 0x0F)
-               return false;
-       return true;
-}
-
-/******************************************************************************
-*                           RadioA_1T.TXT
-******************************************************************************/
-
-static u32 Array_RadioA_1T_8188E[] = {
-               0x000, 0x00030000,
-               0x008, 0x00084000,
-               0x018, 0x00000407,
-               0x019, 0x00000012,
-               0x01E, 0x00080009,
-               0x01F, 0x00000880,
-               0x02F, 0x0001A060,
-               0x03F, 0x00000000,
-               0x042, 0x000060C0,
-               0x057, 0x000D0000,
-               0x058, 0x000BE180,
-               0x067, 0x00001552,
-               0x083, 0x00000000,
-               0x0B0, 0x000FF8FC,
-               0x0B1, 0x00054400,
-               0x0B2, 0x000CCC19,
-               0x0B4, 0x00043003,
-               0x0B6, 0x0004953E,
-               0x0B7, 0x0001C718,
-               0x0B8, 0x000060FF,
-               0x0B9, 0x00080001,
-               0x0BA, 0x00040000,
-               0x0BB, 0x00000400,
-               0x0BF, 0x000C0000,
-               0x0C2, 0x00002400,
-               0x0C3, 0x00000009,
-               0x0C4, 0x00040C91,
-               0x0C5, 0x00099999,
-               0x0C6, 0x000000A3,
-               0x0C7, 0x00088820,
-               0x0C8, 0x00076C06,
-               0x0C9, 0x00000000,
-               0x0CA, 0x00080000,
-               0x0DF, 0x00000180,
-               0x0EF, 0x000001A0,
-               0x051, 0x0006B27D,
-               0xFF0F041F, 0xABCD,
-               0x052, 0x0007E4DD,
-               0xCDCDCDCD, 0xCDCD,
-               0x052, 0x0007E49D,
-               0xFF0F041F, 0xDEAD,
-               0x053, 0x00000073,
-               0x056, 0x00051FF3,
-               0x035, 0x00000086,
-               0x035, 0x00000186,
-               0x035, 0x00000286,
-               0x036, 0x00001C25,
-               0x036, 0x00009C25,
-               0x036, 0x00011C25,
-               0x036, 0x00019C25,
-               0x0B6, 0x00048538,
-               0x018, 0x00000C07,
-               0x05A, 0x0004BD00,
-               0x019, 0x000739D0,
-               0x034, 0x0000ADF3,
-               0x034, 0x00009DF0,
-               0x034, 0x00008DED,
-               0x034, 0x00007DEA,
-               0x034, 0x00006DE7,
-               0x034, 0x000054EE,
-               0x034, 0x000044EB,
-               0x034, 0x000034E8,
-               0x034, 0x0000246B,
-               0x034, 0x00001468,
-               0x034, 0x0000006D,
-               0x000, 0x00030159,
-               0x084, 0x00068200,
-               0x086, 0x000000CE,
-               0x087, 0x00048A00,
-               0x08E, 0x00065540,
-               0x08F, 0x00088000,
-               0x0EF, 0x000020A0,
-               0x03B, 0x000F02B0,
-               0x03B, 0x000EF7B0,
-               0x03B, 0x000D4FB0,
-               0x03B, 0x000CF060,
-               0x03B, 0x000B0090,
-               0x03B, 0x000A0080,
-               0x03B, 0x00090080,
-               0x03B, 0x0008F780,
-               0x03B, 0x000722B0,
-               0x03B, 0x0006F7B0,
-               0x03B, 0x00054FB0,
-               0x03B, 0x0004F060,
-               0x03B, 0x00030090,
-               0x03B, 0x00020080,
-               0x03B, 0x00010080,
-               0x03B, 0x0000F780,
-               0x0EF, 0x000000A0,
-               0x000, 0x00010159,
-               0x018, 0x0000F407,
-               0xFFE, 0x00000000,
-               0xFFE, 0x00000000,
-               0x01F, 0x00080003,
-               0xFFE, 0x00000000,
-               0xFFE, 0x00000000,
-               0x01E, 0x00000001,
-               0x01F, 0x00080000,
-               0x000, 0x00033E60,
-};
-
-static void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr,
-                                 u32 Data, u32 RegAddr)
-{
-       if (Addr == 0xffe) {
-               msleep(50);
-       } else if (Addr == 0xfd) {
-               mdelay(5);
-       } else if (Addr == 0xfc) {
-               mdelay(1);
-       } else if (Addr == 0xfb) {
-               udelay(50);
-       } else if (Addr == 0xfa) {
-               udelay(5);
-       } else if (Addr == 0xf9) {
-               udelay(1);
-       } else {
-               rtl8188e_PHY_SetRFReg(pDM_Odm->Adapter, RegAddr, bRFRegOffsetMask, Data);
-               /*  Add 1us delay between BB/RF register setting. */
-               udelay(1);
-       }
-}
-
-static void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data)
-{
-       u32  content = 0x1000; /*  RF_Content: radioa_txt */
-       u32 maskforPhySet = (u32)(content & 0xE000);
-
-       odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, Addr | maskforPhySet);
-}
-
-int ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm)
-{
-       #define READ_NEXT_PAIR(v1, v2, i) do    \
-                { i += 2; v1 = Array[i];       \
-                v2 = Array[i + 1]; } while (0)
-
-       u32     hex         = 0;
-       u32     i           = 0;
-       u32     ArrayLen    = ARRAY_SIZE(Array_RadioA_1T_8188E);
-       u32    *Array       = Array_RadioA_1T_8188E;
-       bool            biol = false;
-       struct adapter *Adapter =  pDM_Odm->Adapter;
-       struct xmit_frame *pxmit_frame = NULL;
-       u8 bndy_cnt = 1;
-
-       hex += ODM_ITRF_USB << 8;
-       hex += ODM_CE << 16;
-       hex += 0xFF000000;
-       biol = rtw_IOL_applied(Adapter);
-
-       if (biol) {
-               pxmit_frame = rtw_IOL_accquire_xmit_frame(Adapter);
-               if (!pxmit_frame) {
-                       pr_info("rtw_IOL_accquire_xmit_frame failed\n");
-                       return -ENOMEM;
-               }
-       }
-
-       for (i = 0; i < ArrayLen; i += 2) {
-               u32 v1 = Array[i];
-               u32 v2 = Array[i + 1];
-
-               /*  This (offset, data) pair meets the condition. */
-               if (v1 < 0xCDCDCDCD) {
-                       if (biol) {
-                               if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
-                                       bndy_cnt++;
-
-                               if (v1 == 0xffe)
-                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50);
-                               else if (v1 == 0xfd)
-                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5);
-                               else if (v1 == 0xfc)
-                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1);
-                               else if (v1 == 0xfb)
-                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50);
-                               else if (v1 == 0xfa)
-                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5);
-                               else if (v1 == 0xf9)
-                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1);
-                               else
-                                       rtw_IOL_append_WRF_cmd(pxmit_frame, RF_PATH_A, (u16)v1, v2, bRFRegOffsetMask);
-                       } else {
-                               odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2);
-                       }
-                       continue;
-               } else { /*  This line is the start line of branch. */
-                       if (!CheckCondition(Array[i], hex)) {
-                               /*  Discard the following (offset, data) pairs. */
-                               READ_NEXT_PAIR(v1, v2, i);
-                               while (v2 != 0xDEAD &&
-                                      v2 != 0xCDEF &&
-                                      v2 != 0xCDCD && i < ArrayLen - 2)
-                                       READ_NEXT_PAIR(v1, v2, i);
-                               i -= 2; /*  prevent from for-loop += 2 */
-                       } else { /*  Configure matched pairs and skip to end of if-else. */
-                       READ_NEXT_PAIR(v1, v2, i);
-                               while (v2 != 0xDEAD &&
-                                      v2 != 0xCDEF &&
-                                      v2 != 0xCDCD && i < ArrayLen - 2) {
-                                       if (biol) {
-                                               if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
-                                                       bndy_cnt++;
-
-                                               if (v1 == 0xffe)
-                                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50);
-                                               else if (v1 == 0xfd)
-                                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5);
-                                               else if (v1 == 0xfc)
-                                                       rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1);
-                                               else if (v1 == 0xfb)
-                                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50);
-                                               else if (v1 == 0xfa)
-                                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5);
-                                               else if (v1 == 0xf9)
-                                                       rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1);
-                                               else
-                                                       rtw_IOL_append_WRF_cmd(pxmit_frame, RF_PATH_A, (u16)v1, v2, bRFRegOffsetMask);
-                                       } else {
-                                               odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2);
-                                       }
-                                       READ_NEXT_PAIR(v1, v2, i);
-                               }
-
-                               while (v2 != 0xDEAD && i < ArrayLen - 2)
-                                       READ_NEXT_PAIR(v1, v2, i);
-                       }
-               }
-       }
-       if (biol) {
-               if (!rtl8188e_IOL_exec_cmds_sync(pDM_Odm->Adapter, pxmit_frame, 1000, bndy_cnt)) {
-                       pr_info("~~~ IOL Config %s Failed !!!\n", __func__);
-                       return -1;
-               }
-       }
-       return 0;
-}
diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c
deleted file mode 100644 (file)
index 26e710e..0000000
+++ /dev/null
@@ -1,900 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/drv_types.h"
-
-/*---------------------------Define Local Constant---------------------------*/
-/*  2010/04/25 MH Define the max tx power tracking tx agc power. */
-#define                ODM_TXPWRTRACK_MAX_IDX_88E              6
-
-/*---------------------------Define Local Constant---------------------------*/
-
-/* 3============================================================ */
-/* 3 Tx Power Tracking */
-/* 3============================================================ */
-/*-----------------------------------------------------------------------------
- * Function:   ODM_TxPwrTrackAdjust88E()
- *
- * Overview:   88E we can not write 0xc80/c94/c4c/ 0xa2x. Instead of write TX agc.
- *                             No matter OFDM & CCK use the same method.
- *
- * Input:              NONE
- *
- * Output:             NONE
- *
- * Return:             NONE
- *
- * Revised History:
- *     When            Who             Remark
- *     04/23/2012      MHC             Create Version 0.
- *     04/23/2012      MHC             Adjust TX agc directly not throughput BB digital.
- *
- *---------------------------------------------------------------------------*/
-void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *dm_odm, u8 Type,/*  0 = OFDM, 1 = CCK */
-       u8 *pDirection,                 /*  1 = +(increase) 2 = -(decrease) */
-       u32 *pOutWriteVal               /*  Tx tracking CCK/OFDM BB swing index adjust */
-       )
-{
-       u8 pwr_value = 0;
-       /*  Tx power tracking BB swing table. */
-       /*  The base index = 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */
-       if (Type == 0) {                /*  For OFDM afjust */
-               if (dm_odm->BbSwingIdxOfdm <= dm_odm->BbSwingIdxOfdmBase) {
-                       *pDirection     = 1;
-                       pwr_value               = (dm_odm->BbSwingIdxOfdmBase - dm_odm->BbSwingIdxOfdm);
-               } else {
-                       *pDirection     = 2;
-                       pwr_value               = (dm_odm->BbSwingIdxOfdm - dm_odm->BbSwingIdxOfdmBase);
-               }
-       } else if (Type == 1) { /*  For CCK adjust. */
-               if (dm_odm->BbSwingIdxCck <= dm_odm->BbSwingIdxCckBase) {
-                       *pDirection     = 1;
-                       pwr_value               = (dm_odm->BbSwingIdxCckBase - dm_odm->BbSwingIdxCck);
-               } else {
-                       *pDirection     = 2;
-                       pwr_value               = (dm_odm->BbSwingIdxCck - dm_odm->BbSwingIdxCckBase);
-               }
-       }
-
-       /*  */
-       /*  2012/04/25 MH According to Ed/Luke.Lees estimate for EVM the max tx power tracking */
-       /*  need to be less than 6 power index for 88E. */
-       /*  */
-       if (pwr_value >= ODM_TXPWRTRACK_MAX_IDX_88E && *pDirection == 1)
-               pwr_value = ODM_TXPWRTRACK_MAX_IDX_88E;
-
-       *pOutWriteVal = pwr_value | (pwr_value << 8) | (pwr_value << 16) | (pwr_value << 24);
-}      /*  ODM_TxPwrTrackAdjust88E */
-
-/*-----------------------------------------------------------------------------
- * Function:   odm_TxPwrTrackSetPwr88E()
- *
- * Overview:   88E change all channel tx power according to flag.
- *                             OFDM & CCK are all different.
- *
- * Input:              NONE
- *
- * Output:             NONE
- *
- * Return:             NONE
- *
- * Revised History:
- *     When            Who             Remark
- *     04/23/2012      MHC             Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-static void odm_TxPwrTrackSetPwr88E(struct odm_dm_struct *dm_odm)
-{
-       if (dm_odm->BbSwingFlagOfdm || dm_odm->BbSwingFlagCck) {
-               PHY_SetTxPowerLevel8188E(dm_odm->Adapter, *dm_odm->pChannel);
-               dm_odm->BbSwingFlagOfdm = false;
-               dm_odm->BbSwingFlagCck  = false;
-       }
-}      /*  odm_TxPwrTrackSetPwr88E */
-
-/* 091212 chiyokolin */
-void
-odm_TXPowerTrackingCallback_ThermalMeter_8188E(
-       struct adapter *Adapter
-       )
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       u8 ThermalValue = 0, delta, delta_LCK, delta_IQK, offset;
-       u8 ThermalValue_AVG_count = 0;
-       u32 ThermalValue_AVG = 0;
-       s32 ele_D, TempCCk;
-       s8 OFDM_index, CCK_index = 0;
-       s8 OFDM_index_old = 0, CCK_index_old = 0;
-       u32 i = 0, j = 0;
-
-       u8 OFDM_min_index = 6; /* OFDM BB Swing should be less than +3.0dB, which is required by Arthur */
-       s8 OFDM_index_mapping[2][index_mapping_NUM_88E] = {
-               {0, 0, 2, 3, 4, 4,              /* 2.4G, decrease power */
-               5, 6, 7, 7, 8, 9,
-               10, 10, 11}, /*  For lower temperature, 20120220 updated on 20120220. */
-               {0, 0, -1, -2, -3, -4,          /* 2.4G, increase power */
-               -4, -4, -4, -5, -7, -8,
-               -9, -9, -10},
-       };
-       u8 Thermal_mapping[2][index_mapping_NUM_88E] = {
-               {0, 2, 4, 6, 8, 10,             /* 2.4G, decrease power */
-               12, 14, 16, 18, 20, 22,
-               24, 26, 27},
-               {0, 2, 4, 6, 8, 10,             /* 2.4G,, increase power */
-               12, 14, 16, 18, 20, 22,
-               25, 25, 25},
-       };
-       struct odm_dm_struct *dm_odm = &pHalData->odmpriv;
-
-       /*  2012/04/25 MH Add for tx power tracking to set tx power in tx agc for 88E. */
-       odm_TxPwrTrackSetPwr88E(dm_odm);
-
-       /*  <Kordan> RFCalibrateInfo.RegA24 will be initialized when ODM HW configuring, but MP configures with para files. */
-       dm_odm->RFCalibrateInfo.RegA24 = 0x090e1317;
-
-       ThermalValue = (u8)rtl8188e_PHY_QueryRFReg(Adapter, RF_T_METER_88E, 0xfc00); /* 0x42: RF Reg[15:10] 88E */
-
-       if (ThermalValue) {
-               /* Query OFDM path A default setting */
-               ele_D = rtl8188e_PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance, bMaskDWord) & bMaskOFDM_D;
-               for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) {     /* find the index */
-                       if (ele_D == (OFDMSwingTable[i] & bMaskOFDM_D)) {
-                               OFDM_index_old = (u8)i;
-                               dm_odm->BbSwingIdxOfdmBase = (u8)i;
-                               break;
-                       }
-               }
-
-               /* Query CCK default setting From 0xa24 */
-               TempCCk = dm_odm->RFCalibrateInfo.RegA24;
-
-               for (i = 0; i < CCK_TABLE_SIZE; i++) {
-                       if (memcmp((void *)&TempCCk, (void *)&cck_swing_table[i][2], 4)) {
-                               CCK_index_old = (u8)i;
-                               dm_odm->BbSwingIdxCckBase = (u8)i;
-                               break;
-                       }
-               }
-
-               if (!dm_odm->RFCalibrateInfo.ThermalValue) {
-                       dm_odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
-                       dm_odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue;
-                       dm_odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue;
-
-                       dm_odm->RFCalibrateInfo.OFDM_index = OFDM_index_old;
-                       dm_odm->RFCalibrateInfo.CCK_index = CCK_index_old;
-               }
-
-               /* calculate average thermal meter */
-               dm_odm->RFCalibrateInfo.ThermalValue_AVG[dm_odm->RFCalibrateInfo.ThermalValue_AVG_index] = ThermalValue;
-               dm_odm->RFCalibrateInfo.ThermalValue_AVG_index++;
-               if (dm_odm->RFCalibrateInfo.ThermalValue_AVG_index == AVG_THERMAL_NUM_88E)
-                       dm_odm->RFCalibrateInfo.ThermalValue_AVG_index = 0;
-
-               for (i = 0; i < AVG_THERMAL_NUM_88E; i++) {
-                       if (dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]) {
-                               ThermalValue_AVG += dm_odm->RFCalibrateInfo.ThermalValue_AVG[i];
-                               ThermalValue_AVG_count++;
-                       }
-               }
-
-               if (ThermalValue_AVG_count)
-                       ThermalValue = (u8)(ThermalValue_AVG / ThermalValue_AVG_count);
-
-               if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) {
-                       delta = ThermalValue > pHalData->EEPROMThermalMeter ?
-                               (ThermalValue - pHalData->EEPROMThermalMeter) :
-                               (pHalData->EEPROMThermalMeter - ThermalValue);
-                       dm_odm->RFCalibrateInfo.bReloadtxpowerindex = false;
-                       dm_odm->RFCalibrateInfo.bDoneTxpower = false;
-               } else if (dm_odm->RFCalibrateInfo.bDoneTxpower) {
-                       delta = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue) ?
-                               (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue) :
-                               (dm_odm->RFCalibrateInfo.ThermalValue - ThermalValue);
-               } else {
-                       delta = ThermalValue > pHalData->EEPROMThermalMeter ?
-                               (ThermalValue - pHalData->EEPROMThermalMeter) :
-                               (pHalData->EEPROMThermalMeter - ThermalValue);
-               }
-               delta_LCK = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue_LCK) ?
-                           (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue_LCK) :
-                           (dm_odm->RFCalibrateInfo.ThermalValue_LCK - ThermalValue);
-               delta_IQK = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue_IQK) ?
-                           (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue_IQK) :
-                           (dm_odm->RFCalibrateInfo.ThermalValue_IQK - ThermalValue);
-
-               if ((delta_LCK >= 8)) { /*  Delta temperature is equal to or larger than 20 centigrade. */
-                       dm_odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue;
-                       PHY_LCCalibrate_8188E(Adapter);
-               }
-
-               if (delta > 0 && dm_odm->RFCalibrateInfo.TxPowerTrackControl) {
-                       delta = ThermalValue > pHalData->EEPROMThermalMeter ?
-                               (ThermalValue - pHalData->EEPROMThermalMeter) :
-                               (pHalData->EEPROMThermalMeter - ThermalValue);
-                       /* calculate new OFDM / CCK offset */
-                       if (ThermalValue > pHalData->EEPROMThermalMeter)
-                               j = 1;
-                       else
-                               j = 0;
-                       for (offset = 0; offset < index_mapping_NUM_88E; offset++) {
-                               if (delta < Thermal_mapping[j][offset]) {
-                                       if (offset != 0)
-                                               offset--;
-                                       break;
-                               }
-                       }
-                       if (offset >= index_mapping_NUM_88E)
-                               offset = index_mapping_NUM_88E - 1;
-                       OFDM_index = dm_odm->RFCalibrateInfo.OFDM_index + OFDM_index_mapping[j][offset];
-                       CCK_index = dm_odm->RFCalibrateInfo.CCK_index + OFDM_index_mapping[j][offset];
-
-                       if (OFDM_index > OFDM_TABLE_SIZE_92D - 1)
-                               OFDM_index = OFDM_TABLE_SIZE_92D - 1;
-                       else if (OFDM_index < OFDM_min_index)
-                               OFDM_index = OFDM_min_index;
-
-                       if (CCK_index > CCK_TABLE_SIZE - 1)
-                               CCK_index = CCK_TABLE_SIZE - 1;
-                       else if (CCK_index < 0)
-                               CCK_index = 0;
-
-                       /* 2 temporarily remove bNOPG */
-                       /* Config by SwingTable */
-                       if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) {
-                               dm_odm->RFCalibrateInfo.bDoneTxpower = true;
-
-                               /*  Revse TX power table. */
-                               dm_odm->BbSwingIdxOfdm          = (u8)OFDM_index;
-                               dm_odm->BbSwingIdxCck           = (u8)CCK_index;
-
-                               if (dm_odm->BbSwingIdxOfdmCurrent != dm_odm->BbSwingIdxOfdm) {
-                                       dm_odm->BbSwingIdxOfdmCurrent = dm_odm->BbSwingIdxOfdm;
-                                       dm_odm->BbSwingFlagOfdm = true;
-                               }
-
-                               if (dm_odm->BbSwingIdxCckCurrent != dm_odm->BbSwingIdxCck) {
-                                       dm_odm->BbSwingIdxCckCurrent = dm_odm->BbSwingIdxCck;
-                                       dm_odm->BbSwingFlagCck = true;
-                               }
-                       }
-               }
-
-               if (delta_IQK >= 8) { /*  Delta temperature is equal to or larger than 20 centigrade. */
-                       dm_odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue;
-                       PHY_IQCalibrate_8188E(Adapter, false);
-               }
-               /* update thermal meter value */
-               if (dm_odm->RFCalibrateInfo.TxPowerTrackControl)
-                       dm_odm->RFCalibrateInfo.ThermalValue = ThermalValue;
-       }
-}
-
-/* 1 7.        IQK */
-#define MAX_TOLERANCE          5
-#define IQK_DELAY_TIME         1               /* ms */
-
-static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */
-phy_PathA_IQK_8188E(struct adapter *adapt)
-{
-       u32 regeac, regE94, regE9C;
-       u8 result = 0x00;
-
-       /* 1 Tx IQK */
-       /* path-A IQK setting */
-       rtl8188e_PHY_SetBBReg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c);
-       rtl8188e_PHY_SetBBReg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c);
-       rtl8188e_PHY_SetBBReg(adapt, rTx_IQK_PI_A, bMaskDWord, 0x8214032a);
-       rtl8188e_PHY_SetBBReg(adapt, rRx_IQK_PI_A, bMaskDWord, 0x28160000);
-
-       /* LO calibration setting */
-       rtl8188e_PHY_SetBBReg(adapt, rIQK_AGC_Rsp, bMaskDWord, 0x00462911);
-
-       /* One shot, path A LOK & IQK */
-       rtl8188e_PHY_SetBBReg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf9000000);
-       rtl8188e_PHY_SetBBReg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf8000000);
-
-       /*  delay x ms */
-       /* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */
-       mdelay(IQK_DELAY_TIME_88E);
-
-       /*  Check failed */
-       regeac = rtl8188e_PHY_QueryBBReg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord);
-       regE94 = rtl8188e_PHY_QueryBBReg(adapt, rTx_Power_Before_IQK_A, bMaskDWord);
-       regE9C = rtl8188e_PHY_QueryBBReg(adapt, rTx_Power_After_IQK_A, bMaskDWord);
-
-       if (!(regeac & BIT(28)) &&
-           (((regE94 & 0x03FF0000) >> 16) != 0x142) &&
-           (((regE9C & 0x03FF0000) >> 16) != 0x42))
-               result |= 0x01;
-       return result;
-}
-
-static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */
-phy_PathA_RxIQK(struct adapter *adapt)
-{
-       u32 regeac, regE94, regE9C, regEA4, u4tmp;
-       u8 result = 0x00;
-
-       /* 1 Get TXIMR setting */
-       /* modify RXIQK mode table */
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_IQK, bMaskDWord, 0x00000000);
-       rtl8188e_PHY_SetRFReg(adapt, RF_WE_LUT, bRFRegOffsetMask, 0x800a0);
-       rtl8188e_PHY_SetRFReg(adapt, RF_RCK_OS, bRFRegOffsetMask, 0x30000);
-       rtl8188e_PHY_SetRFReg(adapt, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f);
-       rtl8188e_PHY_SetRFReg(adapt, RF_TXPA_G2, bRFRegOffsetMask, 0xf117B);
-
-       /* PA,PAD off */
-       rtl8188e_PHY_SetRFReg(adapt, 0xdf, bRFRegOffsetMask, 0x980);
-       rtl8188e_PHY_SetRFReg(adapt, 0x56, bRFRegOffsetMask, 0x51000);
-
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000);
-
-       /* IQK setting */
-       rtl8188e_PHY_SetBBReg(adapt, rTx_IQK, bMaskDWord, 0x01007c00);
-       rtl8188e_PHY_SetBBReg(adapt, rRx_IQK, bMaskDWord, 0x81004800);
-
-       /* path-A IQK setting */
-       rtl8188e_PHY_SetBBReg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c);
-       rtl8188e_PHY_SetBBReg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c);
-       rtl8188e_PHY_SetBBReg(adapt, rTx_IQK_PI_A, bMaskDWord, 0x82160c1f);
-       rtl8188e_PHY_SetBBReg(adapt, rRx_IQK_PI_A, bMaskDWord, 0x28160000);
-
-       /* LO calibration setting */
-       rtl8188e_PHY_SetBBReg(adapt, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911);
-
-       /* One shot, path A LOK & IQK */
-       rtl8188e_PHY_SetBBReg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf9000000);
-       rtl8188e_PHY_SetBBReg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf8000000);
-
-       /*  delay x ms */
-       mdelay(IQK_DELAY_TIME_88E);
-
-       /*  Check failed */
-       regeac = rtl8188e_PHY_QueryBBReg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord);
-       regE94 = rtl8188e_PHY_QueryBBReg(adapt, rTx_Power_Before_IQK_A, bMaskDWord);
-       regE9C = rtl8188e_PHY_QueryBBReg(adapt, rTx_Power_After_IQK_A, bMaskDWord);
-
-       if (!(regeac & BIT(28)) &&
-           (((regE94 & 0x03FF0000) >> 16) != 0x142) &&
-           (((regE9C & 0x03FF0000) >> 16) != 0x42))
-               result |= 0x01;
-       else                                                    /* if Tx not OK, ignore Rx */
-               return result;
-
-       u4tmp = 0x80007C00 | (regE94 & 0x3FF0000)  | ((regE9C & 0x3FF0000) >> 16);
-       rtl8188e_PHY_SetBBReg(adapt, rTx_IQK, bMaskDWord, u4tmp);
-
-       /* 1 RX IQK */
-       /* modify RXIQK mode table */
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_IQK, bMaskDWord, 0x00000000);
-       rtl8188e_PHY_SetRFReg(adapt, RF_WE_LUT, bRFRegOffsetMask, 0x800a0);
-       rtl8188e_PHY_SetRFReg(adapt, RF_RCK_OS, bRFRegOffsetMask, 0x30000);
-       rtl8188e_PHY_SetRFReg(adapt, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f);
-       rtl8188e_PHY_SetRFReg(adapt, RF_TXPA_G2, bRFRegOffsetMask, 0xf7ffa);
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000);
-
-       /* IQK setting */
-       rtl8188e_PHY_SetBBReg(adapt, rRx_IQK, bMaskDWord, 0x01004800);
-
-       /* path-A IQK setting */
-       rtl8188e_PHY_SetBBReg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x38008c1c);
-       rtl8188e_PHY_SetBBReg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x18008c1c);
-       rtl8188e_PHY_SetBBReg(adapt, rTx_IQK_PI_A, bMaskDWord, 0x82160c05);
-       rtl8188e_PHY_SetBBReg(adapt, rRx_IQK_PI_A, bMaskDWord, 0x28160c1f);
-
-       /* LO calibration setting */
-       rtl8188e_PHY_SetBBReg(adapt, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911);
-
-       /* One shot, path A LOK & IQK */
-       rtl8188e_PHY_SetBBReg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf9000000);
-       rtl8188e_PHY_SetBBReg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf8000000);
-
-       /*  delay x ms */
-       /* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */
-       mdelay(IQK_DELAY_TIME_88E);
-
-       /*  Check failed */
-       regeac = rtl8188e_PHY_QueryBBReg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord);
-       regE94 = rtl8188e_PHY_QueryBBReg(adapt, rTx_Power_Before_IQK_A, bMaskDWord);
-       regE9C = rtl8188e_PHY_QueryBBReg(adapt, rTx_Power_After_IQK_A, bMaskDWord);
-       regEA4 = rtl8188e_PHY_QueryBBReg(adapt, rRx_Power_Before_IQK_A_2, bMaskDWord);
-
-       /* reload RF 0xdf */
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_IQK, bMaskDWord, 0x00000000);
-       rtl8188e_PHY_SetRFReg(adapt, 0xdf, bRFRegOffsetMask, 0x180);
-
-       if (!(regeac & BIT(27)) &&              /* if Tx is OK, check whether Rx is OK */
-           (((regEA4 & 0x03FF0000) >> 16) != 0x132) &&
-           (((regeac & 0x03FF0000) >> 16) != 0x36))
-               result |= 0x02;
-
-       return result;
-}
-
-static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u8 final_candidate, bool txonly)
-{
-       u32 Oldval_0, X, TX0_A, reg;
-       s32 Y, TX0_C;
-
-       if (final_candidate == 0xFF) {
-               return;
-       } else if (iqkok) {
-               Oldval_0 = (rtl8188e_PHY_QueryBBReg(adapt, rOFDM0_XATxIQImbalance, bMaskDWord) >> 22) & 0x3FF;
-
-               X = result[final_candidate][0];
-               if ((X & 0x00000200) != 0)
-                       X = X | 0xFFFFFC00;
-               TX0_A = (X * Oldval_0) >> 8;
-               rtl8188e_PHY_SetBBReg(adapt, rOFDM0_XATxIQImbalance, 0x3FF, TX0_A);
-
-               rtl8188e_PHY_SetBBReg(adapt, rOFDM0_ECCAThreshold, BIT(31), ((X * Oldval_0 >> 7) & 0x1));
-
-               Y = result[final_candidate][1];
-               if ((Y & 0x00000200) != 0)
-                       Y = Y | 0xFFFFFC00;
-
-               TX0_C = (Y * Oldval_0) >> 8;
-               rtl8188e_PHY_SetBBReg(adapt, rOFDM0_XCTxAFE, 0xF0000000, ((TX0_C & 0x3C0) >> 6));
-               rtl8188e_PHY_SetBBReg(adapt, rOFDM0_XATxIQImbalance, 0x003F0000, (TX0_C & 0x3F));
-
-               rtl8188e_PHY_SetBBReg(adapt, rOFDM0_ECCAThreshold, BIT(29), ((Y * Oldval_0 >> 7) & 0x1));
-
-               if (txonly)
-                       return;
-
-               reg = result[final_candidate][2];
-               rtl8188e_PHY_SetBBReg(adapt, rOFDM0_XARxIQImbalance, 0x3FF, reg);
-
-               reg = result[final_candidate][3] & 0x3F;
-               rtl8188e_PHY_SetBBReg(adapt, rOFDM0_XARxIQImbalance, 0xFC00, reg);
-
-               reg = (result[final_candidate][3] >> 6) & 0xF;
-               rtl8188e_PHY_SetBBReg(adapt, rOFDM0_RxIQExtAnta, 0xF0000000, reg);
-       }
-}
-
-void _PHY_SaveADDARegisters(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup, u32 RegisterNum)
-{
-       u32 i;
-
-       for (i = 0; i < RegisterNum; i++) {
-               ADDABackup[i] = rtl8188e_PHY_QueryBBReg(adapt, ADDAReg[i], bMaskDWord);
-       }
-}
-
-/* FIXME: return an error to caller */
-static void _PHY_SaveMACRegisters(
-               struct adapter *adapt,
-               u32 *MACReg,
-               u32 *MACBackup
-       )
-{
-       u32 i;
-       int res;
-
-       for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) {
-               u8 reg;
-
-               res = rtw_read8(adapt, MACReg[i], &reg);
-               if (res)
-                       return;
-
-               MACBackup[i] = reg;
-       }
-
-       res = rtw_read32(adapt, MACReg[i], MACBackup + i);
-       (void)res;
-}
-
-static void reload_adda_reg(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup, u32 RegiesterNum)
-{
-       u32 i;
-
-       for (i = 0; i < RegiesterNum; i++)
-               rtl8188e_PHY_SetBBReg(adapt, ADDAReg[i], bMaskDWord, ADDABackup[i]);
-}
-
-static void
-_PHY_ReloadMACRegisters(
-               struct adapter *adapt,
-               u32 *MACReg,
-               u32 *MACBackup
-       )
-{
-       u32 i;
-
-       for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++)
-               rtw_write8(adapt, MACReg[i], (u8)MACBackup[i]);
-
-       rtw_write32(adapt, MACReg[i], MACBackup[i]);
-}
-
-static void
-_PHY_PathADDAOn(
-               struct adapter *adapt,
-               u32 *ADDAReg)
-{
-       u32 i;
-
-       rtl8188e_PHY_SetBBReg(adapt, ADDAReg[0], bMaskDWord, 0x0b1b25a0);
-
-       for (i = 1; i < IQK_ADDA_REG_NUM; i++)
-               rtl8188e_PHY_SetBBReg(adapt, ADDAReg[i], bMaskDWord, 0x0bdb25a0);
-}
-
-void
-_PHY_MACSettingCalibration(
-               struct adapter *adapt,
-               u32 *MACReg,
-               u32 *MACBackup
-       )
-{
-       u32 i = 0;
-
-       rtw_write8(adapt, MACReg[i], 0x3F);
-
-       for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++)
-               rtw_write8(adapt, MACReg[i], (u8)(MACBackup[i] & (~BIT(3))));
-
-       rtw_write8(adapt, MACReg[i], (u8)(MACBackup[i] & (~BIT(5))));
-}
-
-static void _PHY_PIModeSwitch(
-               struct adapter *adapt,
-               bool PIMode
-       )
-{
-       u32 mode;
-
-       mode = PIMode ? 0x01000100 : 0x01000000;
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_XA_HSSIParameter1, bMaskDWord, mode);
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_XB_HSSIParameter1, bMaskDWord, mode);
-}
-
-static bool phy_SimularityCompare_8188E(
-               struct adapter *adapt,
-               s32 resulta[][8],
-               u8  c1,
-               u8  c2
-       )
-{
-       u32 i, j, diff, sim_bitmap, bound = 0;
-       u8 final_candidate[2] = {0xFF, 0xFF};   /* for path A and path B */
-       bool result = true;
-       s32 tmp1 = 0, tmp2 = 0;
-
-       bound = 4;
-       sim_bitmap = 0;
-
-       for (i = 0; i < bound; i++) {
-               if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) {
-                       if ((resulta[c1][i] & 0x00000200) != 0)
-                               tmp1 = resulta[c1][i] | 0xFFFFFC00;
-                       else
-                               tmp1 = resulta[c1][i];
-
-                       if ((resulta[c2][i] & 0x00000200) != 0)
-                               tmp2 = resulta[c2][i] | 0xFFFFFC00;
-                       else
-                               tmp2 = resulta[c2][i];
-               } else {
-                       tmp1 = resulta[c1][i];
-                       tmp2 = resulta[c2][i];
-               }
-
-               diff = abs(tmp1 - tmp2);
-
-               if (diff > MAX_TOLERANCE) {
-                       if ((i == 2 || i == 6) && !sim_bitmap) {
-                               if (resulta[c1][i] + resulta[c1][i + 1] == 0)
-                                       final_candidate[(i / 4)] = c2;
-                               else if (resulta[c2][i] + resulta[c2][i + 1] == 0)
-                                       final_candidate[(i / 4)] = c1;
-                               else
-                                       sim_bitmap = sim_bitmap | (1 << i);
-                       } else {
-                               sim_bitmap = sim_bitmap | (1 << i);
-                       }
-               }
-       }
-
-       if (sim_bitmap == 0) {
-               for (i = 0; i < (bound / 4); i++) {
-                       if (final_candidate[i] != 0xFF) {
-                               for (j = i * 4; j < (i + 1) * 4 - 2; j++)
-                                       resulta[3][j] = resulta[final_candidate[i]][j];
-                               result = false;
-                       }
-               }
-               return result;
-       } else {
-               if (!(sim_bitmap & 0x03)) {                /* path A TX OK */
-                       for (i = 0; i < 2; i++)
-                               resulta[3][i] = resulta[c1][i];
-               }
-               if (!(sim_bitmap & 0x0c)) {                /* path A RX OK */
-                       for (i = 2; i < 4; i++)
-                               resulta[3][i] = resulta[c1][i];
-               }
-
-               if (!(sim_bitmap & 0x30)) { /* path B TX OK */
-                       for (i = 4; i < 6; i++)
-                               resulta[3][i] = resulta[c1][i];
-               }
-
-               if (!(sim_bitmap & 0xc0)) { /* path B RX OK */
-                       for (i = 6; i < 8; i++)
-                               resulta[3][i] = resulta[c1][i];
-               }
-               return false;
-       }
-}
-
-static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t)
-{
-       struct hal_data_8188e *pHalData = &adapt->haldata;
-       struct odm_dm_struct *dm_odm = &pHalData->odmpriv;
-       u32 i;
-       u8 PathAOK;
-       u32 ADDA_REG[IQK_ADDA_REG_NUM] = {
-                                               rFPGA0_XCD_SwitchControl, rBlue_Tooth,
-                                               rRx_Wait_CCA,   rTx_CCK_RFON,
-                                               rTx_CCK_BBON, rTx_OFDM_RFON,
-                                               rTx_OFDM_BBON, rTx_To_Rx,
-                                               rTx_To_Tx,      rRx_CCK,
-                                               rRx_OFDM,       rRx_Wait_RIFS,
-                                               rRx_TO_Rx,      rStandby,
-                                               rSleep,                         rPMPD_ANAEN };
-       u32 IQK_MAC_REG[IQK_MAC_REG_NUM] = {
-                                               REG_TXPAUSE,    REG_BCN_CTRL,
-                                               REG_BCN_CTRL_1, REG_GPIO_MUXCFG};
-
-       /* since 92C & 92D have the different define in IQK_BB_REG */
-       u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = {
-                                                       rOFDM0_TRxPathEnable,   rOFDM0_TRMuxPar,
-                                                       rFPGA0_XCD_RFInterfaceSW, rConfig_AntA, rConfig_AntB,
-                                                       rFPGA0_XAB_RFInterfaceSW, rFPGA0_XA_RFInterfaceOE,
-                                                       rFPGA0_XB_RFInterfaceOE, rFPGA0_RFMOD
-                                                       };
-       u32 retryCount = 2;
-       /*  Note: IQ calibration must be performed after loading */
-       /*              PHY_REG.txt , and radio_a, radio_b.txt */
-
-       if (t == 0) {
-               /*  Save ADDA parameters, turn Path A ADDA on */
-               _PHY_SaveADDARegisters(adapt, ADDA_REG, dm_odm->RFCalibrateInfo.ADDA_backup, IQK_ADDA_REG_NUM);
-               _PHY_SaveMACRegisters(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup);
-               _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM);
-       }
-
-       _PHY_PathADDAOn(adapt, ADDA_REG);
-       if (t == 0)
-               dm_odm->RFCalibrateInfo.bRfPiEnable = (u8)rtl8188e_PHY_QueryBBReg(adapt, rFPGA0_XA_HSSIParameter1, BIT(8));
-
-       if (!dm_odm->RFCalibrateInfo.bRfPiEnable) {
-               /*  Switch BB to PI mode to do IQ Calibration. */
-               _PHY_PIModeSwitch(adapt, true);
-       }
-
-       /* BB setting */
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_RFMOD, BIT(24), 0x00);
-       rtl8188e_PHY_SetBBReg(adapt, rOFDM0_TRxPathEnable, bMaskDWord, 0x03a05600);
-       rtl8188e_PHY_SetBBReg(adapt, rOFDM0_TRMuxPar, bMaskDWord, 0x000800e4);
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22204000);
-
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_XAB_RFInterfaceSW, BIT(10), 0x01);
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_XAB_RFInterfaceSW, BIT(26), 0x01);
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_XA_RFInterfaceOE, BIT(10), 0x00);
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_XB_RFInterfaceOE, BIT(10), 0x00);
-
-       /* MAC settings */
-       _PHY_MACSettingCalibration(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup);
-
-       /* Page B init */
-       /* AP or IQK */
-       rtl8188e_PHY_SetBBReg(adapt, rConfig_AntA, bMaskDWord, 0x0f600000);
-
-
-       /*  IQ calibration setting */
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000);
-       rtl8188e_PHY_SetBBReg(adapt, rTx_IQK, bMaskDWord, 0x01007c00);
-       rtl8188e_PHY_SetBBReg(adapt, rRx_IQK, bMaskDWord, 0x81004800);
-
-       for (i = 0; i < retryCount; i++) {
-               PathAOK = phy_PathA_IQK_8188E(adapt);
-               if (PathAOK == 0x01) {
-                       result[t][0] = (rtl8188e_PHY_QueryBBReg(adapt, rTx_Power_Before_IQK_A, bMaskDWord) & 0x3FF0000) >> 16;
-                       result[t][1] = (rtl8188e_PHY_QueryBBReg(adapt, rTx_Power_After_IQK_A, bMaskDWord) & 0x3FF0000) >> 16;
-                       break;
-               }
-       }
-
-       for (i = 0; i < retryCount; i++) {
-               PathAOK = phy_PathA_RxIQK(adapt);
-               if (PathAOK == 0x03) {
-                       result[t][2] = (rtl8188e_PHY_QueryBBReg(adapt, rRx_Power_Before_IQK_A_2, bMaskDWord) & 0x3FF0000) >> 16;
-                       result[t][3] = (rtl8188e_PHY_QueryBBReg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord) & 0x3FF0000) >> 16;
-                       break;
-               }
-       }
-
-       /* Back to BB mode, load original value */
-       rtl8188e_PHY_SetBBReg(adapt, rFPGA0_IQK, bMaskDWord, 0);
-
-       if (t != 0) {
-               if (!dm_odm->RFCalibrateInfo.bRfPiEnable) {
-                       /*  Switch back BB to SI mode after finish IQ Calibration. */
-                       _PHY_PIModeSwitch(adapt, false);
-               }
-
-               /*  Reload ADDA power saving parameters */
-               reload_adda_reg(adapt, ADDA_REG, dm_odm->RFCalibrateInfo.ADDA_backup, IQK_ADDA_REG_NUM);
-
-               /*  Reload MAC parameters */
-               _PHY_ReloadMACRegisters(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup);
-
-               reload_adda_reg(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM);
-
-               /*  Restore RX initial gain */
-               rtl8188e_PHY_SetBBReg(adapt, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00032ed3);
-
-               /* load 0xe30 IQC default value */
-               rtl8188e_PHY_SetBBReg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00);
-               rtl8188e_PHY_SetBBReg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00);
-       }
-}
-
-static void phy_LCCalibrate_8188E(struct adapter *adapt)
-{
-       u8 tmpreg;
-       u32 RF_Amode = 0, LC_Cal;
-       int res;
-
-       /* Check continuous TX and Packet TX */
-       res = rtw_read8(adapt, 0xd03, &tmpreg);
-       if (res)
-               return;
-
-       if ((tmpreg & 0x70) != 0)                       /* Deal with contisuous TX case */
-               rtw_write8(adapt, 0xd03, tmpreg & 0x8F);        /* disable all continuous TX */
-       else                                                    /*  Deal with Packet TX case */
-               rtw_write8(adapt, REG_TXPAUSE, 0xFF);           /*  block all queues */
-
-       if ((tmpreg & 0x70) != 0) {
-               /* 1. Read original RF mode */
-               /* Path-A */
-               RF_Amode = rtl8188e_PHY_QueryRFReg(adapt, RF_AC, bMask12Bits);
-
-               /* 2. Set RF mode = standby mode */
-               /* Path-A */
-               rtl8188e_PHY_SetRFReg(adapt, RF_AC, bMask12Bits, (RF_Amode & 0x8FFFF) | 0x10000);
-       }
-
-       /* 3. Read RF reg18 */
-       LC_Cal = rtl8188e_PHY_QueryRFReg(adapt, RF_CHNLBW, bMask12Bits);
-
-       /* 4. Set LC calibration begin  bit15 */
-       rtl8188e_PHY_SetRFReg(adapt, RF_CHNLBW, bMask12Bits, LC_Cal | 0x08000);
-
-       msleep(100);
-
-       /* Restore original situation */
-       if ((tmpreg & 0x70) != 0) {
-               /* Deal with continuous TX case */
-               /* Path-A */
-               rtw_write8(adapt, 0xd03, tmpreg);
-               rtl8188e_PHY_SetRFReg(adapt, RF_AC, bMask12Bits, RF_Amode);
-       } else {
-               /*  Deal with Packet TX case */
-               rtw_write8(adapt, REG_TXPAUSE, 0x00);
-       }
-}
-
-void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery)
-{
-       struct hal_data_8188e *pHalData = &adapt->haldata;
-       struct odm_dm_struct *dm_odm = &pHalData->odmpriv;
-       s32 result[4][8];       /* last is final result */
-       u8 i, final_candidate;
-       bool pathaok;
-       s32 RegE94, RegE9C, RegEA4, RegEB4, RegEBC;
-       bool is12simular, is13simular, is23simular;
-       u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = {
-               rOFDM0_XARxIQImbalance, rOFDM0_XBRxIQImbalance,
-               rOFDM0_ECCAThreshold, rOFDM0_AGCRSSITable,
-               rOFDM0_XATxIQImbalance, rOFDM0_XBTxIQImbalance,
-               rOFDM0_XCTxAFE, rOFDM0_XDTxAFE,
-               rOFDM0_RxIQExtAnta};
-
-       if (recovery) {
-               reload_adda_reg(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9);
-               return;
-       }
-
-       for (i = 0; i < 8; i++) {
-               result[0][i] = 0;
-               result[1][i] = 0;
-               result[2][i] = 0;
-               if ((i == 0) || (i == 2) || (i == 4)  || (i == 6))
-                       result[3][i] = 0x100;
-               else
-                       result[3][i] = 0;
-       }
-       final_candidate = 0xff;
-       pathaok = false;
-       is12simular = false;
-       is23simular = false;
-       is13simular = false;
-
-       for (i = 0; i < 3; i++) {
-               phy_IQCalibrate_8188E(adapt, result, i);
-
-               if (i == 1) {
-                       is12simular = phy_SimularityCompare_8188E(adapt, result, 0, 1);
-                       if (is12simular) {
-                               final_candidate = 0;
-                               break;
-                       }
-               }
-
-               if (i == 2) {
-                       is13simular = phy_SimularityCompare_8188E(adapt, result, 0, 2);
-                       if (is13simular) {
-                               final_candidate = 0;
-
-                               break;
-                       }
-                       is23simular = phy_SimularityCompare_8188E(adapt, result, 1, 2);
-                       if (is23simular) {
-                               final_candidate = 1;
-                       } else {
-                               final_candidate = 3;
-                       }
-               }
-       }
-
-       for (i = 0; i < 4; i++) {
-               RegE94 = result[i][0];
-               RegE9C = result[i][1];
-               RegEA4 = result[i][2];
-               RegEB4 = result[i][4];
-               RegEBC = result[i][5];
-       }
-
-       if (final_candidate != 0xff) {
-               RegE94 = result[final_candidate][0];
-               RegE9C = result[final_candidate][1];
-               RegEA4 = result[final_candidate][2];
-               RegEB4 = result[final_candidate][4];
-               RegEBC = result[final_candidate][5];
-               dm_odm->RFCalibrateInfo.RegE94 = RegE94;
-               dm_odm->RFCalibrateInfo.RegE9C = RegE9C;
-               dm_odm->RFCalibrateInfo.RegEB4 = RegEB4;
-               dm_odm->RFCalibrateInfo.RegEBC = RegEBC;
-               pathaok = true;
-       } else {
-               dm_odm->RFCalibrateInfo.RegE94 = 0x100;
-               dm_odm->RFCalibrateInfo.RegEB4 = 0x100; /* X default value */
-               dm_odm->RFCalibrateInfo.RegE9C = 0x0;
-               dm_odm->RFCalibrateInfo.RegEBC = 0x0;   /* Y default value */
-       }
-       if (RegE94 != 0)
-               patha_fill_iqk(adapt, pathaok, result, final_candidate, (RegEA4 == 0));
-
-       _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9);
-}
-
-void PHY_LCCalibrate_8188E(struct adapter *adapt)
-{
-       u32 timeout = 2000, timecount = 0;
-       struct hal_data_8188e *pHalData = &adapt->haldata;
-       struct odm_dm_struct *dm_odm = &pHalData->odmpriv;
-
-       while (*dm_odm->pbScanInProcess && timecount < timeout) {
-               mdelay(50);
-               timecount += 50;
-       }
-
-       phy_LCCalibrate_8188E(adapt);
-}
diff --git a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c
deleted file mode 100644 (file)
index 6c0b136..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/HalPwrSeqCmd.h"
-
-#define PWR_CMD_WRITE                  0x01
-     /*  offset: the read register offset */
-     /*  msk: the mask of the write bits */
-     /*  value: write value */
-     /*  note: driver shall implement this cmd by read & msk after write */
-
-#define PWR_CMD_POLLING                        0x02
-     /*  offset: the read register offset */
-     /*  msk: the mask of the polled value */
-     /*  value: the value to be polled, masked by the msd field. */
-     /*  note: driver shall implement this cmd by */
-     /*  do{ */
-     /*  if ( (Read(offset) & msk) == (value & msk) ) */
-     /*  break; */
-     /*  } while (not timeout); */
-
-#define PWR_CMD_DELAY                  0x03
-     /*  offset: the value to delay (in us) */
-     /*  msk: N/A */
-     /*  value: N/A */
-
-struct wl_pwr_cfg {
-       u16 offset;
-       u8 cmd:4;
-       u8 msk;
-       u8 value;
-};
-
-#define GET_PWR_CFG_OFFSET(__PWR_CMD)          __PWR_CMD.offset
-#define GET_PWR_CFG_CMD(__PWR_CMD)             __PWR_CMD.cmd
-#define GET_PWR_CFG_MASK(__PWR_CMD)            __PWR_CMD.msk
-#define GET_PWR_CFG_VALUE(__PWR_CMD)           __PWR_CMD.value
-
-static struct wl_pwr_cfg rtl8188E_power_on_flow[] = {
-       { 0x0006, PWR_CMD_POLLING, BIT(1), BIT(1) },
-       { 0x0002, PWR_CMD_WRITE, BIT(0) | BIT(1), 0 }, /* reset BB */
-       { 0x0026, PWR_CMD_WRITE, BIT(7), BIT(7) }, /* schmitt trigger */
-       { 0x0005, PWR_CMD_WRITE, BIT(7), 0 }, /* disable HWPDN (control by DRV)*/
-       { 0x0005, PWR_CMD_WRITE, BIT(4) | BIT(3), 0 }, /* disable WL suspend*/
-       { 0x0005, PWR_CMD_WRITE, BIT(0), BIT(0) },
-       { 0x0005, PWR_CMD_POLLING, BIT(0), 0 },
-       { 0x0023, PWR_CMD_WRITE, BIT(4), 0 },
-};
-
-static struct wl_pwr_cfg rtl8188E_card_disable_flow[] = {
-       { 0x001F, PWR_CMD_WRITE, 0xFF, 0 }, /* turn off RF */
-       { 0x0023, PWR_CMD_WRITE, BIT(4), BIT(4) }, /* LDO Sleep mode */
-       { 0x0005, PWR_CMD_WRITE, BIT(1), BIT(1) }, /* turn off MAC by HW state machine */
-       { 0x0005, PWR_CMD_POLLING, BIT(1), 0 },
-       { 0x0026, PWR_CMD_WRITE, BIT(7), BIT(7) }, /* schmitt trigger */
-       { 0x0005, PWR_CMD_WRITE, BIT(3) | BIT(4), BIT(3) }, /* enable WL suspend */
-       { 0x0007, PWR_CMD_WRITE, 0xFF, 0 }, /* enable bandgap mbias in suspend */
-       { 0x0041, PWR_CMD_WRITE, BIT(4), 0 }, /* Clear SIC_EN register */
-       { 0xfe10, PWR_CMD_WRITE, BIT(4), BIT(4) }, /* Set USB suspend enable local register */
-};
-
-/* This is used by driver for LPSRadioOff Procedure, not for FW LPS Step */
-static struct wl_pwr_cfg rtl8188E_enter_lps_flow[] = {
-       { 0x0522, PWR_CMD_WRITE, 0xFF, 0x7F },/* Tx Pause */
-       { 0x05F8, PWR_CMD_POLLING, 0xFF, 0 }, /* Should be zero if no packet is transmitted */
-       { 0x05F9, PWR_CMD_POLLING, 0xFF, 0 }, /* Should be zero if no packet is transmitted */
-       { 0x05FA, PWR_CMD_POLLING, 0xFF, 0 }, /* Should be zero if no packet is transmitted */
-       { 0x05FB, PWR_CMD_POLLING, 0xFF, 0 }, /* Should be zero if no packet is transmitted */
-       { 0x0002, PWR_CMD_WRITE, BIT(0), 0 }, /* CCK and OFDM are disabled, clocks are gated */
-       { 0x0002, PWR_CMD_DELAY, 0, 0 },
-       { 0x0100, PWR_CMD_WRITE, 0xFF, 0x3F }, /* Reset MAC TRX */
-       { 0x0101, PWR_CMD_WRITE, BIT(1), 0 }, /* check if removed later */
-       { 0x0553, PWR_CMD_WRITE, BIT(5), BIT(5) }, /* Respond TxOK to scheduler */
-};
-
-u8 HalPwrSeqCmdParsing(struct adapter *padapter, enum r8188eu_pwr_seq seq)
-{
-       struct wl_pwr_cfg pwrcfgcmd = {0};
-       struct wl_pwr_cfg *pwrseqcmd;
-       u8 poll_bit = false;
-       u8 idx, num_steps;
-       u8 value = 0;
-       u32 offset = 0;
-       u32 poll_count = 0; /*  polling autoload done. */
-       u32 max_poll_count = 5000;
-       int res;
-
-       switch (seq) {
-       case PWR_ON_FLOW:
-               pwrseqcmd = rtl8188E_power_on_flow;
-               num_steps = ARRAY_SIZE(rtl8188E_power_on_flow);
-               break;
-       case DISABLE_FLOW:
-               pwrseqcmd = rtl8188E_card_disable_flow;
-               num_steps = ARRAY_SIZE(rtl8188E_card_disable_flow);
-               break;
-       case LPS_ENTER_FLOW:
-               pwrseqcmd = rtl8188E_enter_lps_flow;
-               num_steps = ARRAY_SIZE(rtl8188E_enter_lps_flow);
-               break;
-       default:
-               return false;
-       }
-
-       for (idx = 0; idx < num_steps; idx++) {
-               pwrcfgcmd = pwrseqcmd[idx];
-
-               switch (GET_PWR_CFG_CMD(pwrcfgcmd)) {
-               case PWR_CMD_WRITE:
-                       offset = GET_PWR_CFG_OFFSET(pwrcfgcmd);
-
-                       /*  Read the value from system register */
-                       res = rtw_read8(padapter, offset, &value);
-                       if (res)
-                               return false;
-
-                       value &= ~(GET_PWR_CFG_MASK(pwrcfgcmd));
-                       value |= (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd));
-
-                       /*  Write the value back to system register */
-                       rtw_write8(padapter, offset, value);
-                       break;
-               case PWR_CMD_POLLING:
-                       poll_bit = false;
-                       offset = GET_PWR_CFG_OFFSET(pwrcfgcmd);
-                       do {
-                               res = rtw_read8(padapter, offset, &value);
-                               if (res)
-                                       return false;
-
-                               value &= GET_PWR_CFG_MASK(pwrcfgcmd);
-                               if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd)))
-                                       poll_bit = true;
-                               else
-                                       udelay(10);
-
-                               if (poll_count++ > max_poll_count)
-                                       return false;
-                       } while (!poll_bit);
-                       break;
-               case PWR_CMD_DELAY:
-                       udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd));
-                       break;
-               default:
-                       break;
-               }
-       }
-       return true;
-}
diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c
deleted file mode 100644 (file)
index 33967eb..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-
-#include "../include/hal_intf.h"
-#include "../include/hal_com.h"
-#include "../include/rtl8188e_hal.h"
-
-#define _HAL_INIT_C_
-
-#define        CHAN_PLAN_HW    0x80
-
-u8 /* return the final channel plan decision */
-hal_com_get_channel_plan(struct adapter *padapter, u8 hw_channel_plan,
-                        u8 sw_channel_plan, u8 def_channel_plan,
-                        bool load_fail)
-{
-       u8 sw_cfg;
-       u8 chnlplan;
-
-       sw_cfg = true;
-       if (!load_fail) {
-               if (!rtw_is_channel_plan_valid(sw_channel_plan))
-                       sw_cfg = false;
-               if (hw_channel_plan & CHAN_PLAN_HW)
-                       sw_cfg = false;
-       }
-
-       if (sw_cfg)
-               chnlplan = sw_channel_plan;
-       else
-               chnlplan = hw_channel_plan & (~CHAN_PLAN_HW);
-
-       if (!rtw_is_channel_plan_valid(chnlplan))
-               chnlplan = def_channel_plan;
-
-       return chnlplan;
-}
-
-u8 MRateToHwRate(u8 rate)
-{
-       u8 ret = DESC_RATE1M;
-
-       switch (rate) {
-               /*  CCK and OFDM non-HT rates */
-       case IEEE80211_CCK_RATE_1MB:
-               ret = DESC_RATE1M;
-               break;
-       case IEEE80211_CCK_RATE_2MB:
-               ret = DESC_RATE2M;
-               break;
-       case IEEE80211_CCK_RATE_5MB:
-               ret = DESC_RATE5_5M;
-               break;
-       case IEEE80211_CCK_RATE_11MB:
-               ret = DESC_RATE11M;
-               break;
-       case IEEE80211_OFDM_RATE_6MB:
-               ret = DESC_RATE6M;
-               break;
-       case IEEE80211_OFDM_RATE_9MB:
-               ret = DESC_RATE9M;
-               break;
-       case IEEE80211_OFDM_RATE_12MB:
-               ret = DESC_RATE12M;
-               break;
-       case IEEE80211_OFDM_RATE_18MB:
-               ret = DESC_RATE18M;
-               break;
-       case IEEE80211_OFDM_RATE_24MB:
-               ret = DESC_RATE24M;
-               break;
-       case IEEE80211_OFDM_RATE_36MB:
-               ret = DESC_RATE36M;
-               break;
-       case IEEE80211_OFDM_RATE_48MB:
-               ret = DESC_RATE48M;
-               break;
-       case IEEE80211_OFDM_RATE_54MB:
-               ret = DESC_RATE54M;
-               break;
-       default:
-               break;
-       }
-       return ret;
-}
-
-void HalSetBrateCfg(struct adapter *adapt, u8 *brates, u16 *rate_cfg)
-{
-       u8 i, is_brate, brate;
-
-       for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) {
-               is_brate = brates[i] & IEEE80211_BASIC_RATE_MASK;
-               brate = brates[i] & 0x7f;
-
-               if (is_brate) {
-                       switch (brate) {
-                       case IEEE80211_CCK_RATE_1MB:
-                               *rate_cfg |= RATE_1M;
-                               break;
-                       case IEEE80211_CCK_RATE_2MB:
-                               *rate_cfg |= RATE_2M;
-                               break;
-                       case IEEE80211_CCK_RATE_5MB:
-                               *rate_cfg |= RATE_5_5M;
-                               break;
-                       case IEEE80211_CCK_RATE_11MB:
-                               *rate_cfg |= RATE_11M;
-                               break;
-                       case IEEE80211_OFDM_RATE_6MB:
-                               *rate_cfg |= RATE_6M;
-                               break;
-                       case IEEE80211_OFDM_RATE_9MB:
-                               *rate_cfg |= RATE_9M;
-                               break;
-                       case IEEE80211_OFDM_RATE_12MB:
-                               *rate_cfg |= RATE_12M;
-                               break;
-                       case IEEE80211_OFDM_RATE_18MB:
-                               *rate_cfg |= RATE_18M;
-                               break;
-                       case IEEE80211_OFDM_RATE_24MB:
-                               *rate_cfg |= RATE_24M;
-                               break;
-                       case IEEE80211_OFDM_RATE_36MB:
-                               *rate_cfg |= RATE_36M;
-                               break;
-                       case IEEE80211_OFDM_RATE_48MB:
-                               *rate_cfg |= RATE_48M;
-                               break;
-                       case IEEE80211_OFDM_RATE_54MB:
-                               *rate_cfg |= RATE_54M;
-                               break;
-                       }
-               }
-       }
-}
diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c
deleted file mode 100644 (file)
index 13790e3..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _HAL_INTF_C_
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/hal_intf.h"
-
-uint rtw_hal_init(struct adapter *adapt)
-{
-       adapt->hw_init_completed = false;
-
-       if (rtl8188eu_hal_init(adapt) != _SUCCESS)
-               return _FAIL;
-
-       adapt->hw_init_completed = true;
-
-       if (adapt->registrypriv.notch_filter == 1)
-               hal_notch_filter_8188e(adapt, 1);
-
-       return _SUCCESS;
-}
-
-uint rtw_hal_deinit(struct adapter *adapt)
-{
-       uint    status = _SUCCESS;
-
-       status = rtl8188eu_hal_deinit(adapt);
-
-       if (status == _SUCCESS)
-               adapt->hw_init_completed = false;
-
-       return status;
-}
-
-void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level)
-{
-       struct mlme_priv *pmlmepriv = &adapt->mlmepriv;
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               struct sta_info *psta = NULL;
-               struct sta_priv *pstapriv = &adapt->stapriv;
-               if (mac_id >= 2)
-                       psta = pstapriv->sta_aid[(mac_id - 1) - 1];
-               if (psta)
-                       add_RATid(adapt, psta, 0);/* todo: based on rssi_level*/
-       } else {
-               UpdateHalRAMask8188EUsb(adapt, mac_id, rssi_level);
-       }
-}
diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c
deleted file mode 100644 (file)
index 94f9b12..0000000
+++ /dev/null
@@ -1,821 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/drv_types.h"
-
-/* avoid to warn in FreeBSD ==> To DO modify */
-static u32 EDCAParam[HT_IOT_PEER_MAX][3] = {
-       /*  UL                  DL */
-       {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 0:unknown AP */
-       {0xa44f, 0x5ea44f, 0x5e431c}, /*  1:realtek AP */
-       {0x5ea42b, 0x5ea42b, 0x5ea42b}, /*  2:unknown AP => realtek_92SE */
-       {0x5ea32b, 0x5ea42b, 0x5e4322}, /*  3:broadcom AP */
-       {0x5ea422, 0x00a44f, 0x00a44f}, /*  4:ralink AP */
-       {0x5ea322, 0x00a630, 0x00a44f}, /*  5:atheros AP */
-       {0x5e4322, 0x5e4322, 0x5e4322},/*  6:cisco AP */
-       {0x5ea44f, 0x00a44f, 0x5ea42b}, /*  8:marvell AP */
-       {0x5ea42b, 0x5ea42b, 0x5ea42b}, /*  10:unknown AP=> 92U AP */
-       {0x5ea42b, 0xa630, 0x5e431c}, /*  11:airgocap AP */
-};
-
-/*  Global var */
-u32 OFDMSwingTable[OFDM_TABLE_SIZE_92D] = {
-       0x7f8001fe, /*  0, +6.0dB */
-       0x788001e2, /*  1, +5.5dB */
-       0x71c001c7, /*  2, +5.0dB */
-       0x6b8001ae, /*  3, +4.5dB */
-       0x65400195, /*  4, +4.0dB */
-       0x5fc0017f, /*  5, +3.5dB */
-       0x5a400169, /*  6, +3.0dB */
-       0x55400155, /*  7, +2.5dB */
-       0x50800142, /*  8, +2.0dB */
-       0x4c000130, /*  9, +1.5dB */
-       0x47c0011f, /*  10, +1.0dB */
-       0x43c0010f, /*  11, +0.5dB */
-       0x40000100, /*  12, +0dB */
-       0x3c8000f2, /*  13, -0.5dB */
-       0x390000e4, /*  14, -1.0dB */
-       0x35c000d7, /*  15, -1.5dB */
-       0x32c000cb, /*  16, -2.0dB */
-       0x300000c0, /*  17, -2.5dB */
-       0x2d4000b5, /*  18, -3.0dB */
-       0x2ac000ab, /*  19, -3.5dB */
-       0x288000a2, /*  20, -4.0dB */
-       0x26000098, /*  21, -4.5dB */
-       0x24000090, /*  22, -5.0dB */
-       0x22000088, /*  23, -5.5dB */
-       0x20000080, /*  24, -6.0dB */
-       0x1e400079, /*  25, -6.5dB */
-       0x1c800072, /*  26, -7.0dB */
-       0x1b00006c, /*  27. -7.5dB */
-       0x19800066, /*  28, -8.0dB */
-       0x18000060, /*  29, -8.5dB */
-       0x16c0005b, /*  30, -9.0dB */
-       0x15800056, /*  31, -9.5dB */
-       0x14400051, /*  32, -10.0dB */
-       0x1300004c, /*  33, -10.5dB */
-       0x12000048, /*  34, -11.0dB */
-       0x11000044, /*  35, -11.5dB */
-       0x10000040, /*  36, -12.0dB */
-       0x0f00003c,/*  37, -12.5dB */
-       0x0e400039,/*  38, -13.0dB */
-       0x0d800036,/*  39, -13.5dB */
-       0x0cc00033,/*  40, -14.0dB */
-       0x0c000030,/*  41, -14.5dB */
-       0x0b40002d,/*  42, -15.0dB */
-};
-
-u8 cck_swing_table[CCK_TABLE_SIZE][8] = {
-       {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, /*  0, +0dB */
-       {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /*  1, -0.5dB */
-       {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /*  2, -1.0dB */
-       {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /*  3, -1.5dB */
-       {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /*  4, -2.0dB */
-       {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /*  5, -2.5dB */
-       {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /*  6, -3.0dB */
-       {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /*  7, -3.5dB */
-       {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /*  8, -4.0dB */
-       {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /*  9, -4.5dB */
-       {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /*  10, -5.0dB */
-       {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /*  11, -5.5dB */
-       {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /*  12, -6.0dB */
-       {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /*  13, -6.5dB */
-       {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /*  14, -7.0dB */
-       {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /*  15, -7.5dB */
-       {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /*  16, -8.0dB */
-       {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /*  17, -8.5dB */
-       {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /*  18, -9.0dB */
-       {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /*  19, -9.5dB */
-       {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /*  20, -10.0dB */
-       {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /*  21, -10.5dB */
-       {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /*  22, -11.0dB */
-       {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /*  23, -11.5dB */
-       {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /*  24, -12.0dB */
-       {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /*  25, -12.5dB */
-       {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /*  26, -13.0dB */
-       {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /*  27, -13.5dB */
-       {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /*  28, -14.0dB */
-       {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /*  29, -14.5dB */
-       {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /*  30, -15.0dB */
-       {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /*  31, -15.5dB */
-       {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}        /*  32, -16.0dB */
-};
-
-#define                RxDefaultAnt1           0x65a9
-#define        RxDefaultAnt2           0x569a
-
-static void odm_DIGInit(struct odm_dm_struct *pDM_Odm)
-{
-       struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable;
-       struct adapter *adapter = pDM_Odm->Adapter;
-
-       pDM_DigTable->CurIGValue = (u8)rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_IGI_A_11N, ODM_BIT_IGI_11N);
-       pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC;
-       pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC;
-       pDM_DigTable->CurCCK_CCAThres = 0x83;
-       pDM_DigTable->ForbiddenIGI = DM_DIG_MIN_NIC;
-       pDM_DigTable->LargeFAHit = 0;
-       pDM_DigTable->Recover_cnt = 0;
-       pDM_DigTable->DIG_Dynamic_MIN_0 = DM_DIG_MIN_NIC;
-       pDM_DigTable->bMediaConnect_0 = false;
-
-       /* To Initialize pDM_Odm->bDMInitialGainEnable == false to avoid DIG error */
-       pDM_Odm->bDMInitialGainEnable = true;
-}
-
-static void odm_DIG(struct odm_dm_struct *pDM_Odm)
-{
-       struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable;
-       struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
-       u8 DIG_Dynamic_MIN;
-       u8 DIG_MaxOfMin;
-       bool FirstConnect, FirstDisConnect;
-       u8 dm_dig_max, dm_dig_min;
-       u8 CurrentIGI = pDM_DigTable->CurIGValue;
-
-       if (*pDM_Odm->pbScanInProcess)
-               return;
-
-       /* add by Neil Chen to avoid PSD is processing */
-       if (!pDM_Odm->bDMInitialGainEnable)
-               return;
-
-       DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0;
-       FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0);
-       FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0);
-
-       /* 1 Boundary Decision */
-       dm_dig_max = DM_DIG_MAX_NIC;
-       dm_dig_min = DM_DIG_MIN_NIC;
-       DIG_MaxOfMin = DM_DIG_MAX_AP;
-
-       if (pDM_Odm->bLinked) {
-               /* 2 8723A Series, offset need to be 10 */
-               /* 2 Modify DIG upper bound */
-               if ((pDM_Odm->RSSI_Min + 20) > dm_dig_max)
-                       pDM_DigTable->rx_gain_range_max = dm_dig_max;
-               else if ((pDM_Odm->RSSI_Min + 20) < dm_dig_min)
-                       pDM_DigTable->rx_gain_range_max = dm_dig_min;
-               else
-                       pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 20;
-               /* 2 Modify DIG lower bound */
-               if (pDM_Odm->bOneEntryOnly) {
-                       if (pDM_Odm->RSSI_Min < dm_dig_min)
-                               DIG_Dynamic_MIN = dm_dig_min;
-                       else if (pDM_Odm->RSSI_Min > DIG_MaxOfMin)
-                               DIG_Dynamic_MIN = DIG_MaxOfMin;
-                       else
-                               DIG_Dynamic_MIN = pDM_Odm->RSSI_Min;
-               } else if (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV) {
-                       /* 1 Lower Bound for 88E AntDiv */
-                       if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV)
-                               DIG_Dynamic_MIN = (u8)pDM_DigTable->AntDiv_RSSI_max;
-               } else {
-                       DIG_Dynamic_MIN = dm_dig_min;
-               }
-       } else {
-               pDM_DigTable->rx_gain_range_max = dm_dig_max;
-               DIG_Dynamic_MIN = dm_dig_min;
-       }
-
-       /* 1 Modify DIG lower bound, deal with abnormally large false alarm */
-       if (pFalseAlmCnt->Cnt_all > 10000) {
-               if (pDM_DigTable->LargeFAHit != 3)
-                       pDM_DigTable->LargeFAHit++;
-               if (pDM_DigTable->ForbiddenIGI < CurrentIGI) {
-                       pDM_DigTable->ForbiddenIGI = CurrentIGI;
-                       pDM_DigTable->LargeFAHit = 1;
-               }
-
-               if (pDM_DigTable->LargeFAHit >= 3) {
-                       if ((pDM_DigTable->ForbiddenIGI + 1) > pDM_DigTable->rx_gain_range_max)
-                               pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max;
-                       else
-                               pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1);
-                       pDM_DigTable->Recover_cnt = 3600; /* 3600=2hr */
-               }
-
-       } else {
-               /* Recovery mechanism for IGI lower bound */
-               if (pDM_DigTable->Recover_cnt != 0) {
-                       pDM_DigTable->Recover_cnt--;
-               } else {
-                       if (pDM_DigTable->LargeFAHit < 3) {
-                               if ((pDM_DigTable->ForbiddenIGI - 1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */
-                                       pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; /* DM_DIG_MIN; */
-                                       pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; /* DM_DIG_MIN; */
-                               } else {
-                                       pDM_DigTable->ForbiddenIGI--;
-                                       pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1);
-                               }
-                       } else {
-                               pDM_DigTable->LargeFAHit = 0;
-                       }
-               }
-       }
-
-       /* 1 Adjust initial gain by false alarm */
-       if (pDM_Odm->bLinked) {
-               if (FirstConnect) {
-                       CurrentIGI = pDM_Odm->RSSI_Min;
-               } else {
-                       if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2)
-                               CurrentIGI = CurrentIGI + 4;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */
-                       else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1)
-                               CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */
-                       else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0)
-                               CurrentIGI = CurrentIGI - 2;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */
-               }
-       } else {
-               if (FirstDisConnect) {
-                       CurrentIGI = pDM_DigTable->rx_gain_range_min;
-               } else {
-                       /* 2012.03.30 LukeLee: enable DIG before link but with very high thresholds */
-                       if (pFalseAlmCnt->Cnt_all > 10000)
-                               CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */
-                       else if (pFalseAlmCnt->Cnt_all > 8000)
-                               CurrentIGI = CurrentIGI + 1;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */
-                       else if (pFalseAlmCnt->Cnt_all < 500)
-                               CurrentIGI = CurrentIGI - 1;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */
-               }
-       }
-       /* 1 Check initial gain by upper/lower bound */
-       if (CurrentIGI > pDM_DigTable->rx_gain_range_max)
-               CurrentIGI = pDM_DigTable->rx_gain_range_max;
-       if (CurrentIGI < pDM_DigTable->rx_gain_range_min)
-               CurrentIGI = pDM_DigTable->rx_gain_range_min;
-
-       /* 2 High power RSSI threshold */
-
-       ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */
-       pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked;
-       pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN;
-}
-
-static void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm)
-{
-       struct adapter *adapter = pDM_Odm->Adapter;
-
-       pDM_Odm->bCckHighPower = (bool)rtl8188e_PHY_QueryBBReg(adapter, 0x824, BIT(9));
-       pDM_Odm->RFPathRxEnable = (u8)rtl8188e_PHY_QueryBBReg(adapter, 0xc04, 0x0F);
-}
-
-static void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm)
-{
-       u8 EntryCnt = 0;
-       u8 i;
-       struct sta_info *pEntry;
-
-       if (*pDM_Odm->pBandWidth == HT_CHANNEL_WIDTH_40) {
-               if (*pDM_Odm->pSecChOffset == 1)
-                       pDM_Odm->ControlChannel = *pDM_Odm->pChannel - 2;
-               else if (*pDM_Odm->pSecChOffset == 2)
-                       pDM_Odm->ControlChannel = *pDM_Odm->pChannel + 2;
-       } else {
-               pDM_Odm->ControlChannel = *pDM_Odm->pChannel;
-       }
-
-       for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
-               pEntry = pDM_Odm->pODM_StaInfo[i];
-               if (IS_STA_VALID(pEntry))
-                       EntryCnt++;
-       }
-       if (EntryCnt == 1)
-               pDM_Odm->bOneEntryOnly = true;
-       else
-               pDM_Odm->bOneEntryOnly = false;
-}
-
-static void odm_RateAdaptiveMaskInit(struct odm_dm_struct *pDM_Odm)
-{
-       struct odm_rate_adapt *pOdmRA = &pDM_Odm->RateAdaptive;
-
-       pOdmRA->RATRState = DM_RATR_STA_INIT;
-       pOdmRA->HighRSSIThresh = 50;
-       pOdmRA->LowRSSIThresh = 20;
-}
-
-static void odm_RefreshRateAdaptiveMask(struct odm_dm_struct *pDM_Odm)
-{
-       u8 i;
-       struct adapter *pAdapter = pDM_Odm->Adapter;
-
-       if (pAdapter->bDriverStopped)
-               return;
-
-       for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
-               struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i];
-
-               if (IS_STA_VALID(pstat)) {
-                       if (ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level))
-                               rtw_hal_update_ra_mask(pAdapter, i, pstat->rssi_level);
-               }
-       }
-}
-
-static void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm)
-{
-       struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable;
-
-       pDM_PSTable->pre_rf_state = RF_MAX;
-       pDM_PSTable->cur_rf_state = RF_MAX;
-       pDM_PSTable->initialize = 0;
-}
-
-static void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm)
-{
-       u32 ret_value;
-       struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt;
-       struct adapter *adapter = pDM_Odm->Adapter;
-
-       /* hold ofdm counter */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 1); /* hold page C counter */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 1); /* hold page D counter */
-
-       ret_value = rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord);
-       FalseAlmCnt->Cnt_Fast_Fsync = (ret_value & 0xffff);
-       FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value & 0xffff0000) >> 16);
-       ret_value = rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord);
-       FalseAlmCnt->Cnt_OFDM_CCA = (ret_value & 0xffff);
-       FalseAlmCnt->Cnt_Parity_Fail = ((ret_value & 0xffff0000) >> 16);
-       ret_value = rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord);
-       FalseAlmCnt->Cnt_Rate_Illegal = (ret_value & 0xffff);
-       FalseAlmCnt->Cnt_Crc8_fail = ((ret_value & 0xffff0000) >> 16);
-       ret_value = rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord);
-       FalseAlmCnt->Cnt_Mcs_fail = (ret_value & 0xffff);
-
-       FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal +
-                                    FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail +
-                                    FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail;
-
-       ret_value = rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_SC_CNT_11N, bMaskDWord);
-       FalseAlmCnt->Cnt_BW_LSC = (ret_value & 0xffff);
-       FalseAlmCnt->Cnt_BW_USC = ((ret_value & 0xffff0000) >> 16);
-
-       /* hold cck counter */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_CCK_FA_RST_11N, BIT(12), 1);
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_CCK_FA_RST_11N, BIT(14), 1);
-
-       ret_value = rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_CCK_FA_LSB_11N, bMaskByte0);
-       FalseAlmCnt->Cnt_Cck_fail = ret_value;
-       ret_value = rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_CCK_FA_MSB_11N, bMaskByte3);
-       FalseAlmCnt->Cnt_Cck_fail +=  (ret_value & 0xff) << 8;
-
-       ret_value = rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord);
-       FalseAlmCnt->Cnt_CCK_CCA = ((ret_value & 0xFF) << 8) | ((ret_value & 0xFF00) >> 8);
-
-       FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Fast_Fsync +
-                               FalseAlmCnt->Cnt_SB_Search_fail +
-                               FalseAlmCnt->Cnt_Parity_Fail +
-                               FalseAlmCnt->Cnt_Rate_Illegal +
-                               FalseAlmCnt->Cnt_Crc8_fail +
-                               FalseAlmCnt->Cnt_Mcs_fail +
-                               FalseAlmCnt->Cnt_Cck_fail);
-
-       FalseAlmCnt->Cnt_CCA_all = FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA;
-}
-
-static void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm)
-{
-       u8 CurCCK_CCAThres;
-       struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt;
-
-       if (pDM_Odm->bLinked) {
-               if (pDM_Odm->RSSI_Min > 25) {
-                       CurCCK_CCAThres = 0xcd;
-               } else if ((pDM_Odm->RSSI_Min <= 25) && (pDM_Odm->RSSI_Min > 10)) {
-                       CurCCK_CCAThres = 0x83;
-               } else {
-                       if (FalseAlmCnt->Cnt_Cck_fail > 1000)
-                               CurCCK_CCAThres = 0x83;
-                       else
-                               CurCCK_CCAThres = 0x40;
-               }
-       } else {
-               if (FalseAlmCnt->Cnt_Cck_fail > 1000)
-                       CurCCK_CCAThres = 0x83;
-               else
-                       CurCCK_CCAThres = 0x40;
-       }
-       ODM_Write_CCK_CCA_Thres(pDM_Odm, CurCCK_CCAThres);
-}
-
-static void FindMinimumRSSI(struct adapter *pAdapter)
-{
-       struct hal_data_8188e *pHalData = &pAdapter->haldata;
-       struct dm_priv  *pdmpriv = &pHalData->dmpriv;
-       struct mlme_priv        *pmlmepriv = &pAdapter->mlmepriv;
-
-       /* 1 1.Determine the minimum RSSI */
-       if (!check_fwstate(pmlmepriv, _FW_LINKED) &&
-           pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)
-               pdmpriv->MinUndecoratedPWDBForDM = 0;
-
-       pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
-}
-
-static void odm_RSSIMonitorCheck(struct odm_dm_struct *pDM_Odm)
-{
-       struct adapter *Adapter = pDM_Odm->Adapter;
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       struct dm_priv  *pdmpriv = &pHalData->dmpriv;
-       int     i;
-       int     tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff;
-       u8      sta_cnt = 0;
-       u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */
-       struct sta_info *psta;
-
-       if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
-               return;
-
-       if (!check_fwstate(&Adapter->mlmepriv, _FW_LINKED))
-               return;
-
-       for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
-               psta = pDM_Odm->pODM_StaInfo[i];
-               if (IS_STA_VALID(psta) &&
-                   (psta->state & WIFI_ASOC_STATE) &&
-                   !is_broadcast_ether_addr(psta->hwaddr) &&
-                   memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN)) {
-                       if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
-                               tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
-
-                       if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
-                               tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
-                       if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1))
-                               PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB << 16));
-               }
-       }
-
-       for (i = 0; i < sta_cnt; i++) {
-               if (PWDB_rssi[i] != (0)) {
-                       if (pHalData->fw_ractrl) {
-                               /*  Report every sta's RSSI to FW */
-                       } else {
-                               ODM_RA_SetRSSI_8188E(
-                               &pHalData->odmpriv, (PWDB_rssi[i] & 0xFF), (u8)((PWDB_rssi[i] >> 16) & 0xFF));
-                       }
-               }
-       }
-
-       if (tmpEntryMinPWDB != 0xff) /*  If associated entry is found */
-               pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
-       else
-               pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
-
-       FindMinimumRSSI(Adapter);
-       pHalData->odmpriv.RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM;
-}
-
-static void odm_TXPowerTrackingThermalMeterInit(struct odm_dm_struct *pDM_Odm)
-{
-       pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true;
-}
-
-static void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm)
-{
-       if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV))
-               return;
-
-       ODM_AntennaDiversityInit_88E(pDM_Odm);
-}
-
-static void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm)
-{
-       if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV))
-               return;
-
-       ODM_AntennaDiversity_88E(pDM_Odm);
-}
-
-static void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm)
-{
-       struct adapter *Adapter = pDM_Odm->Adapter;
-       pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false;
-       pDM_Odm->DM_EDCA_Table.bIsCurRDLState = false;
-       Adapter->recvpriv.bIsAnyNonBEPkts = false;
-}
-
-static void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm)
-{
-       struct adapter *Adapter = pDM_Odm->Adapter;
-       u32     trafficIndex;
-       u32     edca_param;
-       u64     cur_tx_bytes = 0;
-       u64     cur_rx_bytes = 0;
-       u8      bbtchange = false;
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       struct xmit_priv                *pxmitpriv = &Adapter->xmitpriv;
-       struct recv_priv                *precvpriv = &Adapter->recvpriv;
-       struct registry_priv    *pregpriv = &Adapter->registrypriv;
-       struct mlme_ext_priv    *pmlmeext = &Adapter->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       if (pregpriv->wifi_spec == 1)
-               goto dm_CheckEdcaTurbo_EXIT;
-
-       if (pmlmeinfo->assoc_AP_vendor >=  HT_IOT_PEER_MAX)
-               goto dm_CheckEdcaTurbo_EXIT;
-
-       /*  Check if the status needs to be changed. */
-       if ((bbtchange) || (!precvpriv->bIsAnyNonBEPkts)) {
-               cur_tx_bytes = pxmitpriv->tx_bytes - pxmitpriv->last_tx_bytes;
-               cur_rx_bytes = precvpriv->rx_bytes - precvpriv->last_rx_bytes;
-
-               /* traffic, TX or RX */
-               if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK) ||
-                   (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS)) {
-                       if (cur_tx_bytes > (cur_rx_bytes << 2)) {
-                               /*  Uplink TP is present. */
-                               trafficIndex = UP_LINK;
-                       } else {
-                               /*  Balance TP is present. */
-                               trafficIndex = DOWN_LINK;
-                       }
-               } else {
-                       if (cur_rx_bytes > (cur_tx_bytes << 2)) {
-                               /*  Downlink TP is present. */
-                               trafficIndex = DOWN_LINK;
-                       } else {
-                               /*  Balance TP is present. */
-                               trafficIndex = UP_LINK;
-                       }
-               }
-
-               if ((pDM_Odm->DM_EDCA_Table.prv_traffic_idx != trafficIndex) || (!pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA)) {
-                       if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_CISCO) && (pmlmeext->cur_wireless_mode & WIRELESS_11_24N))
-                               edca_param = EDCAParam[pmlmeinfo->assoc_AP_vendor][trafficIndex];
-                       else
-                               edca_param = EDCAParam[HT_IOT_PEER_UNKNOWN][trafficIndex];
-
-                       rtw_write32(Adapter, REG_EDCA_BE_PARAM, edca_param);
-
-                       pDM_Odm->DM_EDCA_Table.prv_traffic_idx = trafficIndex;
-               }
-
-               pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = true;
-       } else {
-               /*  Turn Off EDCA turbo here. */
-               /*  Restore original EDCA according to the declaration of AP. */
-               if (pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA) {
-                       rtw_write32(Adapter, REG_EDCA_BE_PARAM, pHalData->AcParam_BE);
-                       pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false;
-               }
-       }
-
-dm_CheckEdcaTurbo_EXIT:
-       /*  Set variables for next time. */
-       precvpriv->bIsAnyNonBEPkts = false;
-       pxmitpriv->last_tx_bytes = pxmitpriv->tx_bytes;
-       precvpriv->last_rx_bytes = precvpriv->rx_bytes;
-}
-
-/*  2011/09/21 MH Add to describe different team necessary resource allocate?? */
-void ODM_DMInit(struct odm_dm_struct *pDM_Odm)
-{
-       /* 2012.05.03 Luke: For all IC series */
-       odm_CommonInfoSelfInit(pDM_Odm);
-       odm_DIGInit(pDM_Odm);
-       odm_RateAdaptiveMaskInit(pDM_Odm);
-
-       odm_DynamicBBPowerSavingInit(pDM_Odm);
-       odm_TXPowerTrackingThermalMeterInit(pDM_Odm);
-       ODM_EdcaTurboInit(pDM_Odm);
-       ODM_RAInfo_Init_all(pDM_Odm);
-       if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV)   ||
-           (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) ||
-           (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV))
-               odm_InitHybridAntDiv(pDM_Odm);
-}
-
-/*  2011/09/20 MH This is the entry pointer for all team to execute HW out source DM. */
-/*  You can not add any dummy function here, be care, you can only use DM structure */
-/*  to perform any new ODM_DM. */
-void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm)
-{
-       /* 2012.05.03 Luke: For all IC series */
-       odm_CommonInfoSelfUpdate(pDM_Odm);
-       odm_FalseAlarmCounterStatistics(pDM_Odm);
-       odm_RSSIMonitorCheck(pDM_Odm);
-
-       odm_DIG(pDM_Odm);
-       odm_CCKPacketDetectionThresh(pDM_Odm);
-
-       if (*pDM_Odm->pbPowerSaving)
-               return;
-
-       odm_RefreshRateAdaptiveMask(pDM_Odm);
-
-       if ((pDM_Odm->AntDivType ==  CG_TRX_HW_ANTDIV)  ||
-           (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV)  ||
-           (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV))
-               odm_HwAntDiv(pDM_Odm);
-
-       ODM_TXPowerTrackingCheck(pDM_Odm);
-       odm_EdcaTurboCheck(pDM_Odm);
-}
-
-/*  Init /.. Fixed HW value. Only init time. */
-void ODM_CmnInfoInit(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, u32 Value)
-{
-       /*  This section is used for init value */
-       switch  (CmnInfo) {
-       /*  Fixed ODM value. */
-       case    ODM_CMNINFO_MP_TEST_CHIP:
-               pDM_Odm->bIsMPChip = (u8)Value;
-               break;
-       case    ODM_CMNINFO_RF_ANTENNA_TYPE:
-               pDM_Odm->AntDivType = (u8)Value;
-               break;
-       default:
-               /* do nothing */
-               break;
-       }
-
-       /*  Tx power tracking BB swing table. */
-       /*  The base index = 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */
-       pDM_Odm->BbSwingIdxOfdm                 = 12; /*  Set defalut value as index 12. */
-       pDM_Odm->BbSwingIdxOfdmCurrent  = 12;
-       pDM_Odm->BbSwingFlagOfdm                = false;
-}
-
-void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI)
-{
-       struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable;
-       struct adapter *adapter = pDM_Odm->Adapter;
-
-       if (pDM_DigTable->CurIGValue != CurrentIGI) {
-               rtl8188e_PHY_SetBBReg(adapter, ODM_REG_IGI_A_11N, ODM_BIT_IGI_11N, CurrentIGI);
-               pDM_DigTable->CurIGValue = CurrentIGI;
-       }
-}
-
-void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres)
-{
-       struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable;
-
-       if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres)           /* modify by Guo.Mingzhi 2012-01-03 */
-               rtw_write8(pDM_Odm->Adapter, ODM_REG_CCK_CCA_11N, CurCCK_CCAThres);
-       pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres;
-}
-
-void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal)
-{
-       struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable;
-       struct adapter *adapter = pDM_Odm->Adapter;
-       u8 Rssi_Up_bound = 30;
-       u8 Rssi_Low_bound = 25;
-
-       if (pDM_PSTable->initialize == 0) {
-               pDM_PSTable->reg_874 = (rtl8188e_PHY_QueryBBReg(adapter, 0x874, bMaskDWord) & 0x1CC000) >> 14;
-               pDM_PSTable->reg_c70 = (rtl8188e_PHY_QueryBBReg(adapter, 0xc70, bMaskDWord) & BIT(3)) >> 3;
-               pDM_PSTable->reg_85c = (rtl8188e_PHY_QueryBBReg(adapter, 0x85c, bMaskDWord) & 0xFF000000) >> 24;
-               pDM_PSTable->reg_a74 = (rtl8188e_PHY_QueryBBReg(adapter, 0xa74, bMaskDWord) & 0xF000) >> 12;
-               pDM_PSTable->initialize = 1;
-       }
-
-       if (!bForceInNormal) {
-               if (pDM_Odm->RSSI_Min != 0xFF) {
-                       if (pDM_PSTable->pre_rf_state == RF_Normal) {
-                               if (pDM_Odm->RSSI_Min >= Rssi_Up_bound)
-                                       pDM_PSTable->cur_rf_state = RF_Save;
-                               else
-                                       pDM_PSTable->cur_rf_state = RF_Normal;
-                       } else {
-                               if (pDM_Odm->RSSI_Min <= Rssi_Low_bound)
-                                       pDM_PSTable->cur_rf_state = RF_Normal;
-                               else
-                                       pDM_PSTable->cur_rf_state = RF_Save;
-                       }
-               } else {
-                       pDM_PSTable->cur_rf_state = RF_MAX;
-               }
-       } else {
-               pDM_PSTable->cur_rf_state = RF_Normal;
-       }
-
-       if (pDM_PSTable->pre_rf_state != pDM_PSTable->cur_rf_state) {
-               if (pDM_PSTable->cur_rf_state == RF_Save) {
-                       rtl8188e_PHY_SetBBReg(adapter, 0x874, 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */
-                       rtl8188e_PHY_SetBBReg(adapter, 0xc70, BIT(3), 0); /* RegC70[3]=1'b0 */
-                       rtl8188e_PHY_SetBBReg(adapter, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]=0x63 */
-                       rtl8188e_PHY_SetBBReg(adapter, 0x874, 0xC000, 0x2); /* Reg874[15:14]=2'b10 */
-                       rtl8188e_PHY_SetBBReg(adapter, 0xa74, 0xF000, 0x3); /* RegA75[7:4]=0x3 */
-                       rtl8188e_PHY_SetBBReg(adapter, 0x818, BIT(28), 0x0); /* Reg818[28]=1'b0 */
-                       rtl8188e_PHY_SetBBReg(adapter, 0x818, BIT(28), 0x1); /* Reg818[28]=1'b1 */
-               } else {
-                       rtl8188e_PHY_SetBBReg(adapter, 0x874, 0x1CC000, pDM_PSTable->reg_874);
-                       rtl8188e_PHY_SetBBReg(adapter, 0xc70, BIT(3), pDM_PSTable->reg_c70);
-                       rtl8188e_PHY_SetBBReg(adapter, 0x85c, 0xFF000000, pDM_PSTable->reg_85c);
-                       rtl8188e_PHY_SetBBReg(adapter, 0xa74, 0xF000, pDM_PSTable->reg_a74);
-                       rtl8188e_PHY_SetBBReg(adapter, 0x818, BIT(28), 0x0);
-               }
-               pDM_PSTable->pre_rf_state = pDM_PSTable->cur_rf_state;
-       }
-}
-
-u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u8 rssi_level)
-{
-       struct sta_info *pEntry;
-       u32 rate_bitmap = 0x0fffffff;
-       u8 WirelessMode;
-
-       pEntry = pDM_Odm->pODM_StaInfo[macid];
-       if (!IS_STA_VALID(pEntry))
-               return ra_mask;
-
-       WirelessMode = pEntry->wireless_mode;
-
-       switch (WirelessMode) {
-       case ODM_WM_B:
-               if (ra_mask & 0x0000000c)               /* 11M or 5.5M enable */
-                       rate_bitmap = 0x0000000d;
-               else
-                       rate_bitmap = 0x0000000f;
-               break;
-       case (ODM_WM_B | ODM_WM_G):
-               if (rssi_level == DM_RATR_STA_HIGH)
-                       rate_bitmap = 0x00000f00;
-               else if (rssi_level == DM_RATR_STA_MIDDLE)
-                       rate_bitmap = 0x00000ff0;
-               else
-                       rate_bitmap = 0x00000ff5;
-               break;
-       case (ODM_WM_B | ODM_WM_G | ODM_WM_N24G):
-               if (rssi_level == DM_RATR_STA_HIGH) {
-                       rate_bitmap = 0x000f0000;
-               } else if (rssi_level == DM_RATR_STA_MIDDLE) {
-                       rate_bitmap = 0x000ff000;
-               } else {
-                       if (*pDM_Odm->pBandWidth == HT_CHANNEL_WIDTH_40)
-                               rate_bitmap = 0x000ff015;
-                       else
-                               rate_bitmap = 0x000ff005;
-               }
-               break;
-       default:
-               /* case WIRELESS_11_24N: */
-               rate_bitmap = 0x0fffffff;
-               break;
-       }
-
-       return rate_bitmap;
-}
-
-/*  Return Value: bool */
-/*  - true: RATRState is changed. */
-bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, bool bForceUpdate, u8 *pRATRState)
-{
-       struct odm_rate_adapt *pRA = &pDM_Odm->RateAdaptive;
-       const u8 GoUpGap = 5;
-       u8 HighRSSIThreshForRA = pRA->HighRSSIThresh;
-       u8 LowRSSIThreshForRA = pRA->LowRSSIThresh;
-       u8 RATRState;
-
-       /*  Threshold Adjustment: */
-       /*  when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */
-       /*  Here GoUpGap is added to solve the boundary's level alternation issue. */
-       switch (*pRATRState) {
-       case DM_RATR_STA_INIT:
-       case DM_RATR_STA_HIGH:
-               break;
-       case DM_RATR_STA_MIDDLE:
-               HighRSSIThreshForRA += GoUpGap;
-               break;
-       case DM_RATR_STA_LOW:
-               HighRSSIThreshForRA += GoUpGap;
-               LowRSSIThreshForRA += GoUpGap;
-               break;
-       default:
-               break;
-       }
-
-       /*  Decide RATRState by RSSI. */
-       if (RSSI > HighRSSIThreshForRA)
-               RATRState = DM_RATR_STA_HIGH;
-       else if (RSSI > LowRSSIThreshForRA)
-               RATRState = DM_RATR_STA_MIDDLE;
-       else
-               RATRState = DM_RATR_STA_LOW;
-
-       if (*pRATRState != RATRState || bForceUpdate) {
-               *pRATRState = RATRState;
-               return true;
-       }
-       return false;
-}
-
-void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm)
-{
-       struct adapter *Adapter = pDM_Odm->Adapter;
-
-       if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) {             /* at least delay 1 sec */
-               rtl8188e_PHY_SetRFReg(Adapter, RF_T_METER_88E, BIT(17) | BIT(16), 0x03);
-
-               pDM_Odm->RFCalibrateInfo.TM_Trigger = 1;
-               return;
-       } else {
-               odm_TXPowerTrackingCallback_ThermalMeter_8188E(Adapter);
-               pDM_Odm->RFCalibrateInfo.TM_Trigger = 0;
-       }
-}
diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c
deleted file mode 100644 (file)
index 38f357e..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/drv_types.h"
-
-static u8 odm_query_rxpwrpercentage(s8 antpower)
-{
-       if ((antpower <= -100) || (antpower >= 20))
-               return 0;
-       else if (antpower >= 0)
-               return 100;
-       else
-               return 100 + antpower;
-}
-
-static s32 odm_signal_scale_mapping(struct odm_dm_struct *dm_odm, s32 currsig)
-{
-       s32 retsig;
-
-       if (currsig >= 51 && currsig <= 100)
-               retsig = 100;
-       else if (currsig >= 41 && currsig <= 50)
-               retsig = 80 + ((currsig - 40) * 2);
-       else if (currsig >= 31 && currsig <= 40)
-               retsig = 66 + (currsig - 30);
-       else if (currsig >= 21 && currsig <= 30)
-               retsig = 54 + (currsig - 20);
-       else if (currsig >= 10 && currsig <= 20)
-               retsig = 42 + (((currsig - 10) * 2) / 3);
-       else if (currsig >= 5 && currsig <= 9)
-               retsig = 22 + (((currsig - 5) * 3) / 2);
-       else if (currsig >= 1 && currsig <= 4)
-               retsig = 6 + (((currsig - 1) * 3) / 2);
-       else
-               retsig = currsig;
-
-       return retsig;
-}
-
-static u8 odm_evm_db_to_percentage(s8 value)
-{
-       /*  -33dB~0dB to 0%~99% */
-       s8 ret_val = clamp(-value, 0, 33) * 3;
-
-       if (ret_val == 99)
-               ret_val = 100;
-
-       return ret_val;
-}
-
-static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm,
-                       struct phy_info *pPhyInfo,
-                       u8 *pPhyStatus,
-                       struct odm_per_pkt_info *pPktinfo,
-                       struct adapter *adapt)
-{
-       u8 i, Max_spatial_stream;
-       s8 rx_pwr[4], rx_pwr_all = 0;
-       u8 EVM, PWDB_ALL = 0;
-       u8 RSSI, total_rssi = 0;
-       u8 isCCKrate = 0;
-       u8 rf_rx_num = 0;
-       u8 cck_highpwr = 0;
-       u8 LNA_idx, VGA_idx;
-
-       struct phy_status_rpt *pPhyStaRpt = (struct phy_status_rpt *)pPhyStatus;
-
-       isCCKrate = pPktinfo->Rate >= DESC92C_RATE1M && pPktinfo->Rate <= DESC92C_RATE11M;
-
-       if (isCCKrate) {
-               u8 cck_agc_rpt;
-
-               /*  (1)Hardware does not provide RSSI for CCK */
-               /*  (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */
-
-               cck_highpwr = dm_odm->bCckHighPower;
-
-               cck_agc_rpt =  pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a;
-
-               /* 2011.11.28 LukeLee: 88E use different LNA & VGA gain table */
-               /* The RSSI formula should be modified according to the gain table */
-               /* In 88E, cck_highpwr is always set to 1 */
-               LNA_idx = ((cck_agc_rpt & 0xE0) >> 5);
-               VGA_idx = (cck_agc_rpt & 0x1F);
-               switch (LNA_idx) {
-               case 7:
-                       if (VGA_idx <= 27)
-                               rx_pwr_all = -100 + 2 * (27 - VGA_idx); /* VGA_idx = 27~2 */
-                       else
-                               rx_pwr_all = -100;
-                       break;
-               case 6:
-                       rx_pwr_all = -48 + 2 * (2 - VGA_idx); /* VGA_idx = 2~0 */
-                       break;
-               case 5:
-                       rx_pwr_all = -42 + 2 * (7 - VGA_idx); /* VGA_idx = 7~5 */
-                       break;
-               case 4:
-                       rx_pwr_all = -36 + 2 * (7 - VGA_idx); /* VGA_idx = 7~4 */
-                       break;
-               case 3:
-                       rx_pwr_all = -24 + 2 * (7 - VGA_idx); /* VGA_idx = 7~0 */
-                       break;
-               case 2:
-                       if (cck_highpwr)
-                               rx_pwr_all = -12 + 2 * (5 - VGA_idx); /* VGA_idx = 5~0 */
-                       else
-                               rx_pwr_all = -6 + 2 * (5 - VGA_idx);
-                       break;
-               case 1:
-                               rx_pwr_all = 8 - 2 * VGA_idx;
-                       break;
-               case 0:
-                               rx_pwr_all = 14 - 2 * VGA_idx;
-                       break;
-               default:
-                       break;
-               }
-               rx_pwr_all += 6;
-               PWDB_ALL = odm_query_rxpwrpercentage(rx_pwr_all);
-               if (!cck_highpwr) {
-                       if (PWDB_ALL >= 80)
-                               PWDB_ALL = ((PWDB_ALL - 80) << 1) + ((PWDB_ALL - 80) >> 1) + 80;
-                       else if ((PWDB_ALL <= 78) && (PWDB_ALL >= 20))
-                               PWDB_ALL += 3;
-                       if (PWDB_ALL > 100)
-                               PWDB_ALL = 100;
-               }
-
-               pPhyInfo->RxPWDBAll = PWDB_ALL;
-               pPhyInfo->recvpower = rx_pwr_all;
-               /*  (3) Get Signal Quality (EVM) */
-               if (pPktinfo->bPacketMatchBSSID) {
-                       u8 SQ, SQ_rpt;
-
-                       if (pPhyInfo->RxPWDBAll > 40) {
-                               SQ = 100;
-                       } else {
-                               SQ_rpt = pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all;
-
-                               if (SQ_rpt > 64)
-                                       SQ = 0;
-                               else if (SQ_rpt < 20)
-                                       SQ = 100;
-                               else
-                                       SQ = ((64 - SQ_rpt) * 100) / 44;
-                       }
-                       pPhyInfo->SignalQuality = SQ;
-               }
-       } else { /* is OFDM rate */
-               /*  (1)Get RSSI for HT rate */
-
-               for (i = RF_PATH_A; i < RF_PATH_MAX; i++) {
-                       /*  2008/01/30 MH we will judge RF RX path now. */
-                       if (dm_odm->RFPathRxEnable & BIT(i))
-                               rf_rx_num++;
-
-                       rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain & 0x3F) * 2) - 110;
-                       if (i == RF_PATH_A)
-                               adapt->signal_strength = rx_pwr[i];
-
-                       pPhyInfo->RxPwr[i] = rx_pwr[i];
-
-                       /* Translate DBM to percentage. */
-                       RSSI = odm_query_rxpwrpercentage(rx_pwr[i]);
-                       total_rssi += RSSI;
-
-                       pPhyInfo->RxMIMOSignalStrength[i] = (u8)RSSI;
-
-                       /* Get Rx snr value in DB */
-                       dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i] / 2);
-               }
-               /*  (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */
-               rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1) & 0x7f) - 110;
-
-               PWDB_ALL = odm_query_rxpwrpercentage(rx_pwr_all);
-
-               pPhyInfo->RxPWDBAll = PWDB_ALL;
-               pPhyInfo->RxPower = rx_pwr_all;
-               pPhyInfo->recvpower = rx_pwr_all;
-
-               /*  (3)EVM of HT rate */
-               if (pPktinfo->Rate >= DESC92C_RATEMCS8 && pPktinfo->Rate <= DESC92C_RATEMCS15)
-                       Max_spatial_stream = 2; /* both spatial stream make sense */
-               else
-                       Max_spatial_stream = 1; /* only spatial stream 1 makes sense */
-
-               for (i = 0; i < Max_spatial_stream; i++) {
-                       /*  Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */
-                       /*  fill most significant bit to "zero" when doing shifting operation which may change a negative */
-                       /*  value to positive one, then the dbm value (which is supposed to be negative)  is not correct anymore. */
-                       EVM = odm_evm_db_to_percentage((pPhyStaRpt->stream_rxevm[i]));  /* dbm */
-
-                       if (pPktinfo->bPacketMatchBSSID) {
-                               if (i == RF_PATH_A) /*  Fill value in RFD, Get the first spatial stream only */
-                                       pPhyInfo->SignalQuality = (u8)(EVM & 0xff);
-                       }
-               }
-       }
-       /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */
-       /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */
-       if (isCCKrate) {
-               pPhyInfo->SignalStrength = (u8)(odm_signal_scale_mapping(dm_odm, PWDB_ALL));/* PWDB_ALL; */
-       } else {
-               if (rf_rx_num != 0)
-                       pPhyInfo->SignalStrength = (u8)(odm_signal_scale_mapping(dm_odm, total_rssi /= rf_rx_num));
-       }
-
-       /* For 88E HW Antenna Diversity */
-       dm_odm->DM_FatTable.antsel_rx_keep_0 = pPhyStaRpt->ant_sel;
-       dm_odm->DM_FatTable.antsel_rx_keep_1 = pPhyStaRpt->ant_sel_b;
-       dm_odm->DM_FatTable.antsel_rx_keep_2 = pPhyStaRpt->antsel_rx_keep_2;
-}
-
-static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm,
-                                 struct phy_info *pPhyInfo,
-                                 struct odm_per_pkt_info *pPktinfo)
-{
-       s32 UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK;
-       s32 UndecoratedSmoothedOFDM, RSSI_Ave;
-       u8 isCCKrate = 0;
-       u8 RSSI_max, RSSI_min, i;
-       u32 OFDM_pkt = 0;
-       u32 Weighting = 0;
-       struct sta_info *pEntry;
-       u8 antsel_tr_mux;
-       struct fast_ant_train *pDM_FatTable = &dm_odm->DM_FatTable;
-
-       if (pPktinfo->StationID == 0xFF)
-               return;
-       pEntry = dm_odm->pODM_StaInfo[pPktinfo->StationID];
-       if (!IS_STA_VALID(pEntry))
-               return;
-       if ((!pPktinfo->bPacketMatchBSSID))
-               return;
-
-       isCCKrate = pPktinfo->Rate >= DESC92C_RATE1M && pPktinfo->Rate <= DESC92C_RATE11M;
-
-       /* Smart Antenna Debug Message------------------  */
-       if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) {
-               if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) {
-                       antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2 << 2) |
-                                       (pDM_FatTable->antsel_rx_keep_1 << 1) | pDM_FatTable->antsel_rx_keep_0;
-                       ODM_AntselStatistics_88E(dm_odm, antsel_tr_mux, pPktinfo->StationID, pPhyInfo->RxPWDBAll);
-               }
-       }
-
-       /* Smart Antenna Debug Message------------------ */
-
-       UndecoratedSmoothedCCK =  pEntry->rssi_stat.UndecoratedSmoothedCCK;
-       UndecoratedSmoothedOFDM = pEntry->rssi_stat.UndecoratedSmoothedOFDM;
-       UndecoratedSmoothedPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB;
-
-       if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) {
-               if (!isCCKrate) { /* ofdm rate */
-                       if (pPhyInfo->RxMIMOSignalStrength[RF_PATH_B] == 0) {
-                               RSSI_Ave = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A];
-                       } else {
-                               if (pPhyInfo->RxMIMOSignalStrength[RF_PATH_A] > pPhyInfo->RxMIMOSignalStrength[RF_PATH_B]) {
-                                       RSSI_max = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A];
-                                       RSSI_min = pPhyInfo->RxMIMOSignalStrength[RF_PATH_B];
-                               } else {
-                                       RSSI_max = pPhyInfo->RxMIMOSignalStrength[RF_PATH_B];
-                                       RSSI_min = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A];
-                               }
-                               if ((RSSI_max - RSSI_min) < 3)
-                                       RSSI_Ave = RSSI_max;
-                               else if ((RSSI_max - RSSI_min) < 6)
-                                       RSSI_Ave = RSSI_max - 1;
-                               else if ((RSSI_max - RSSI_min) < 10)
-                                       RSSI_Ave = RSSI_max - 2;
-                               else
-                                       RSSI_Ave = RSSI_max - 3;
-                       }
-
-                       /* 1 Process OFDM RSSI */
-                       if (UndecoratedSmoothedOFDM <= 0) {     /*  initialize */
-                               UndecoratedSmoothedOFDM = pPhyInfo->RxPWDBAll;
-                       } else {
-                               if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedOFDM) {
-                                       UndecoratedSmoothedOFDM =
-                                                       (((UndecoratedSmoothedOFDM) * (Rx_Smooth_Factor - 1)) +
-                                                       (RSSI_Ave)) / (Rx_Smooth_Factor);
-                                       UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM + 1;
-                               } else {
-                                       UndecoratedSmoothedOFDM =
-                                                       (((UndecoratedSmoothedOFDM) * (Rx_Smooth_Factor - 1)) +
-                                                       (RSSI_Ave)) / (Rx_Smooth_Factor);
-                               }
-                       }
-
-                       pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap << 1) | BIT(0);
-
-               } else {
-                       RSSI_Ave = pPhyInfo->RxPWDBAll;
-
-                       /* 1 Process CCK RSSI */
-                       if (UndecoratedSmoothedCCK <= 0) {      /*  initialize */
-                               UndecoratedSmoothedCCK = pPhyInfo->RxPWDBAll;
-                       } else {
-                               if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedCCK) {
-                                       UndecoratedSmoothedCCK =
-                                                       ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor - 1)) +
-                                                       pPhyInfo->RxPWDBAll) / Rx_Smooth_Factor;
-                                       UndecoratedSmoothedCCK = UndecoratedSmoothedCCK + 1;
-                               } else {
-                                       UndecoratedSmoothedCCK =
-                                                       ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor - 1)) +
-                                                       pPhyInfo->RxPWDBAll) / Rx_Smooth_Factor;
-                               }
-                       }
-                       pEntry->rssi_stat.PacketMap = pEntry->rssi_stat.PacketMap << 1;
-               }
-               /* 2011.07.28 LukeLee: modified to prevent unstable CCK RSSI */
-               if (pEntry->rssi_stat.ValidBit >= 64)
-                       pEntry->rssi_stat.ValidBit = 64;
-               else
-                       pEntry->rssi_stat.ValidBit++;
-
-               for (i = 0; i < pEntry->rssi_stat.ValidBit; i++)
-                       OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap >> i) & BIT(0);
-
-               if (pEntry->rssi_stat.ValidBit == 64) {
-                       Weighting = ((OFDM_pkt << 4) > 64) ? 64 : (OFDM_pkt << 4);
-                       UndecoratedSmoothedPWDB = (Weighting * UndecoratedSmoothedOFDM + (64 - Weighting) * UndecoratedSmoothedCCK) >> 6;
-               } else {
-                       if (pEntry->rssi_stat.ValidBit != 0)
-                               UndecoratedSmoothedPWDB = (OFDM_pkt * UndecoratedSmoothedOFDM +
-                                                         (pEntry->rssi_stat.ValidBit - OFDM_pkt) *
-                                                         UndecoratedSmoothedCCK) / pEntry->rssi_stat.ValidBit;
-                       else
-                               UndecoratedSmoothedPWDB = 0;
-               }
-               pEntry->rssi_stat.UndecoratedSmoothedCCK = UndecoratedSmoothedCCK;
-               pEntry->rssi_stat.UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM;
-               pEntry->rssi_stat.UndecoratedSmoothedPWDB = UndecoratedSmoothedPWDB;
-       }
-}
-
-/*  Endianness before calling this API */
-void ODM_PhyStatusQuery(struct odm_dm_struct *dm_odm,
-                       struct phy_info *pPhyInfo,
-                       u8 *pPhyStatus,
-                       struct odm_per_pkt_info *pPktinfo,
-                       struct adapter *adapt)
-{
-       odm_RxPhyStatus92CSeries_Parsing(dm_odm, pPhyInfo, pPhyStatus, pPktinfo, adapt);
-       odm_Process_RSSIForDM(dm_odm, pPhyInfo, pPktinfo);
-}
diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c
deleted file mode 100644 (file)
index f3f4074..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/drv_types.h"
-
-static void odm_RX_HWAntDivInit(struct odm_dm_struct *dm_odm)
-{
-       struct adapter *adapter = dm_odm->Adapter;
-       u32     value32;
-
-       /* MAC Setting */
-       value32 = rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord);
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32 | (BIT(23) | BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */
-       /* Pin Settings */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_PIN_CTRL_11N, BIT(9) | BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0      antsel antselb by HW */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_RX_ANT_CTRL_11N, BIT(10), 0);    /* Reg864[10]=1'b0      antsel2 by HW */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_LNA_SWITCH_11N, BIT(22), 1);     /* Regb2c[22]=1'b0      disable CS/CG switch */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_LNA_SWITCH_11N, BIT(31), 1);     /* Regb2c[31]=1'b1      output at CG only */
-       /* OFDM Settings */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, 0x000000a0);
-       /* CCK Settings */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_BB_PWR_SAV4_11N, BIT(7), 1); /* Fix CCK PHY status report issue */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT(4), 1); /* CCK complete HW AntDiv within 64 samples */
-       ODM_UpdateRxIdleAnt_88E(dm_odm, MAIN_ANT);
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_ANT_MAPPING1_11N, 0xFFFF, 0x0201);       /* antenna mapping table */
-}
-
-static void odm_TRX_HWAntDivInit(struct odm_dm_struct *dm_odm)
-{
-       struct adapter *adapter = dm_odm->Adapter;
-       u32     value32;
-
-       /* MAC Setting */
-       value32 = rtl8188e_PHY_QueryBBReg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord);
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32 | (BIT(23) | BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */
-       /* Pin Settings */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_PIN_CTRL_11N, BIT(9) | BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0              antsel antselb by HW */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_RX_ANT_CTRL_11N, BIT(10), 0);    /* Reg864[10]=1'b0      antsel2 by HW */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_LNA_SWITCH_11N, BIT(22), 0);     /* Regb2c[22]=1'b0      disable CS/CG switch */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_LNA_SWITCH_11N, BIT(31), 1);     /* Regb2c[31]=1'b1      output at CG only */
-       /* OFDM Settings */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, 0x000000a0);
-       /* CCK Settings */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_BB_PWR_SAV4_11N, BIT(7), 1); /* Fix CCK PHY status report issue */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT(4), 1); /* CCK complete HW AntDiv within 64 samples */
-       /* Tx Settings */
-       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_TX_ANT_CTRL_11N, BIT(21), 0); /* Reg80c[21]=1'b0         from TX Reg */
-       ODM_UpdateRxIdleAnt_88E(dm_odm, MAIN_ANT);
-
-       /* antenna mapping table */
-       if (!dm_odm->bIsMPChip) { /* testchip */
-               rtl8188e_PHY_SetBBReg(adapter, ODM_REG_RX_DEFUALT_A_11N, BIT(10) | BIT(9) | BIT(8), 1); /* Reg858[10:8]=3'b001 */
-               rtl8188e_PHY_SetBBReg(adapter, ODM_REG_RX_DEFUALT_A_11N, BIT(13) | BIT(12) | BIT(11), 2);       /* Reg858[13:11]=3'b010 */
-       } else { /* MPchip */
-               rtl8188e_PHY_SetBBReg(adapter, ODM_REG_ANT_MAPPING1_11N, bMaskDWord, 0x0201);   /* Reg914=3'b010, Reg915=3'b001 */
-       }
-}
-
-static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm)
-{
-       struct adapter *adapter = dm_odm->Adapter;
-       u32     value32;
-
-       /* MAC Setting */
-       value32 = rtl8188e_PHY_QueryBBReg(adapter, 0x4c, bMaskDWord);
-       rtl8188e_PHY_SetBBReg(adapter, 0x4c, bMaskDWord, value32 | (BIT(23) | BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */
-       value32 = rtl8188e_PHY_QueryBBReg(adapter,  0x7B4, bMaskDWord);
-       rtl8188e_PHY_SetBBReg(adapter, 0x7b4, bMaskDWord, value32 | (BIT(16) | BIT(17))); /* Reg7B4[16]=1 enable antenna training, Reg7B4[17]=1 enable A2 match */
-
-       /* Match MAC ADDR */
-       rtl8188e_PHY_SetBBReg(adapter, 0x7b4, 0xFFFF, 0);
-       rtl8188e_PHY_SetBBReg(adapter, 0x7b0, bMaskDWord, 0);
-
-       rtl8188e_PHY_SetBBReg(adapter, 0x870, BIT(9) | BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0             antsel antselb by HW */
-       rtl8188e_PHY_SetBBReg(adapter, 0x864, BIT(10), 0);      /* Reg864[10]=1'b0      antsel2 by HW */
-       rtl8188e_PHY_SetBBReg(adapter, 0xb2c, BIT(22), 0);      /* Regb2c[22]=1'b0      disable CS/CG switch */
-       rtl8188e_PHY_SetBBReg(adapter, 0xb2c, BIT(31), 1);      /* Regb2c[31]=1'b1      output at CG only */
-       rtl8188e_PHY_SetBBReg(adapter, 0xca4, bMaskDWord, 0x000000a0);
-
-       if (!dm_odm->bIsMPChip) { /* testchip */
-               rtl8188e_PHY_SetBBReg(adapter, 0x858, BIT(10) | BIT(9) | BIT(8), 1);    /* Reg858[10:8]=3'b001 */
-               rtl8188e_PHY_SetBBReg(adapter, 0x858, BIT(13) | BIT(12) | BIT(11), 2);  /* Reg858[13:11]=3'b010 */
-       } else { /* MPchip */
-               rtl8188e_PHY_SetBBReg(adapter, 0x914, bMaskByte0, 1);
-               rtl8188e_PHY_SetBBReg(adapter, 0x914, bMaskByte1, 2);
-       }
-
-       /* Default Ant Setting when no fast training */
-       rtl8188e_PHY_SetBBReg(adapter, 0x80c, BIT(21), 1); /* Reg80c[21]=1'b1           from TX Info */
-       rtl8188e_PHY_SetBBReg(adapter, 0x864, BIT(5) | BIT(4) | BIT(3), 0);     /* Default RX */
-       rtl8188e_PHY_SetBBReg(adapter, 0x864, BIT(8) | BIT(7) | BIT(6), 1);     /* Optional RX */
-
-       /* Enter Training state */
-       rtl8188e_PHY_SetBBReg(adapter, 0x864, BIT(2) | BIT(1) | BIT(0), 1);
-       rtl8188e_PHY_SetBBReg(adapter, 0xc50, BIT(7), 1);       /* RegC50[7]=1'b1               enable HW AntDiv */
-}
-
-void ODM_AntennaDiversityInit_88E(struct odm_dm_struct *dm_odm)
-{
-       if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)
-               odm_RX_HWAntDivInit(dm_odm);
-       else if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV)
-               odm_TRX_HWAntDivInit(dm_odm);
-       else if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV)
-               odm_FastAntTrainingInit(dm_odm);
-}
-
-void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant)
-{
-       struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable;
-       struct adapter *adapter = dm_odm->Adapter;
-       u32     DefaultAnt, OptionalAnt;
-
-       if (dm_fat_tbl->RxIdleAnt != Ant) {
-               if (Ant == MAIN_ANT) {
-                       DefaultAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX;
-                       OptionalAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX;
-               } else {
-                       DefaultAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX;
-                       OptionalAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX;
-               }
-
-               if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) {
-                       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_RX_ANT_CTRL_11N, BIT(5) | BIT(4) | BIT(3), DefaultAnt);  /* Default RX */
-                       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_RX_ANT_CTRL_11N, BIT(8) | BIT(7) | BIT(6), OptionalAnt);         /* Optional RX */
-                       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_ANTSEL_CTRL_11N, BIT(14) | BIT(13) | BIT(12), DefaultAnt);       /* Default TX */
-                       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_RESP_TX_11N, BIT(6) | BIT(7), DefaultAnt);       /* Resp Tx */
-               } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) {
-                       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_RX_ANT_CTRL_11N, BIT(5) | BIT(4) | BIT(3), DefaultAnt);  /* Default RX */
-                       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_RX_ANT_CTRL_11N, BIT(8) | BIT(7) | BIT(6), OptionalAnt);         /* Optional RX */
-               }
-       }
-       dm_fat_tbl->RxIdleAnt = Ant;
-       if (Ant != MAIN_ANT)
-               pr_info("RxIdleAnt=AUX_ANT\n");
-}
-
-static void odm_UpdateTxAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant, u32 MacId)
-{
-       struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable;
-       u8      TargetAnt;
-
-       if (Ant == MAIN_ANT)
-               TargetAnt = MAIN_ANT_CG_TRX;
-       else
-               TargetAnt = AUX_ANT_CG_TRX;
-       dm_fat_tbl->antsel_a[MacId] = TargetAnt & BIT(0);
-       dm_fat_tbl->antsel_b[MacId] = (TargetAnt & BIT(1)) >> 1;
-       dm_fat_tbl->antsel_c[MacId] = (TargetAnt & BIT(2)) >> 2;
-}
-
-void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *dm_odm, u8 *pDesc, u8 macId)
-{
-       struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable;
-
-       if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV)) {
-               SET_TX_DESC_ANTSEL_A_88E(pDesc, dm_fat_tbl->antsel_a[macId]);
-               SET_TX_DESC_ANTSEL_B_88E(pDesc, dm_fat_tbl->antsel_b[macId]);
-               SET_TX_DESC_ANTSEL_C_88E(pDesc, dm_fat_tbl->antsel_c[macId]);
-       }
-}
-
-void ODM_AntselStatistics_88E(struct odm_dm_struct *dm_odm, u8 antsel_tr_mux, u32 MacId, u8 RxPWDBAll)
-{
-       struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable;
-       if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) {
-               if (antsel_tr_mux == MAIN_ANT_CG_TRX) {
-                       dm_fat_tbl->MainAnt_Sum[MacId] += RxPWDBAll;
-                       dm_fat_tbl->MainAnt_Cnt[MacId]++;
-               } else {
-                       dm_fat_tbl->AuxAnt_Sum[MacId] += RxPWDBAll;
-                       dm_fat_tbl->AuxAnt_Cnt[MacId]++;
-               }
-       } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) {
-               if (antsel_tr_mux == MAIN_ANT_CGCS_RX) {
-                       dm_fat_tbl->MainAnt_Sum[MacId] += RxPWDBAll;
-                       dm_fat_tbl->MainAnt_Cnt[MacId]++;
-               } else {
-                       dm_fat_tbl->AuxAnt_Sum[MacId] += RxPWDBAll;
-                       dm_fat_tbl->AuxAnt_Cnt[MacId]++;
-               }
-       }
-}
-
-static void odm_HWAntDiv(struct odm_dm_struct *dm_odm)
-{
-       u32     i, MinRSSI = 0xFF, AntDivMaxRSSI = 0, MaxRSSI = 0, LocalMinRSSI, LocalMaxRSSI;
-       u32     Main_RSSI, Aux_RSSI;
-       u8      RxIdleAnt = 0, TargetAnt = 7;
-       struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable;
-       struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable;
-       struct sta_info *pEntry;
-
-       for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
-               pEntry = dm_odm->pODM_StaInfo[i];
-               if (IS_STA_VALID(pEntry)) {
-                       /* 2 Calculate RSSI per Antenna */
-                       Main_RSSI = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? (dm_fat_tbl->MainAnt_Sum[i] / dm_fat_tbl->MainAnt_Cnt[i]) : 0;
-                       Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i] / dm_fat_tbl->AuxAnt_Cnt[i]) : 0;
-                       TargetAnt = (Main_RSSI >= Aux_RSSI) ? MAIN_ANT : AUX_ANT;
-                       /* 2 Select MaxRSSI for DIG */
-                       LocalMaxRSSI = max(Main_RSSI, Aux_RSSI);
-                       if ((LocalMaxRSSI > AntDivMaxRSSI) && (LocalMaxRSSI < 40))
-                               AntDivMaxRSSI = LocalMaxRSSI;
-                       if (LocalMaxRSSI > MaxRSSI)
-                               MaxRSSI = LocalMaxRSSI;
-
-                       /* 2 Select RX Idle Antenna */
-                       if ((dm_fat_tbl->RxIdleAnt == MAIN_ANT) && (Main_RSSI == 0))
-                               Main_RSSI = Aux_RSSI;
-                       else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && (Aux_RSSI == 0))
-                               Aux_RSSI = Main_RSSI;
-
-                       LocalMinRSSI = min(Main_RSSI, Aux_RSSI);
-                       if (LocalMinRSSI < MinRSSI) {
-                               MinRSSI = LocalMinRSSI;
-                               RxIdleAnt = TargetAnt;
-                       }
-                       /* 2 Select TRX Antenna */
-                       if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV)
-                               odm_UpdateTxAnt_88E(dm_odm, TargetAnt, i);
-               }
-               dm_fat_tbl->MainAnt_Sum[i] = 0;
-               dm_fat_tbl->AuxAnt_Sum[i] = 0;
-               dm_fat_tbl->MainAnt_Cnt[i] = 0;
-               dm_fat_tbl->AuxAnt_Cnt[i] = 0;
-       }
-
-       /* 2 Set RX Idle Antenna */
-       ODM_UpdateRxIdleAnt_88E(dm_odm, RxIdleAnt);
-
-       pDM_DigTable->AntDiv_RSSI_max = AntDivMaxRSSI;
-       pDM_DigTable->RSSI_max = MaxRSSI;
-}
-
-void ODM_AntennaDiversity_88E(struct odm_dm_struct *dm_odm)
-{
-       struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable;
-       struct adapter *adapter = dm_odm->Adapter;
-
-       if (!(dm_odm->SupportAbility & ODM_BB_ANT_DIV))
-               return;
-       if (!dm_odm->bLinked) {
-               if (dm_fat_tbl->bBecomeLinked) {
-                       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_IGI_A_11N, BIT(7), 0);   /* RegC50[7]=1'b1               enable HW AntDiv */
-                       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT(15), 0); /* Enable CCK AntDiv */
-                       if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV)
-                               rtl8188e_PHY_SetBBReg(adapter, ODM_REG_TX_ANT_CTRL_11N, BIT(21), 0); /* Reg80c[21]=1'b0         from TX Reg */
-                       dm_fat_tbl->bBecomeLinked = dm_odm->bLinked;
-               }
-               return;
-       } else {
-               if (!dm_fat_tbl->bBecomeLinked) {
-                       /* Because HW AntDiv is disabled before Link, we enable HW AntDiv after link */
-                       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_IGI_A_11N, BIT(7), 1);   /* RegC50[7]=1'b1               enable HW AntDiv */
-                       rtl8188e_PHY_SetBBReg(adapter, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT(15), 1); /* Enable CCK AntDiv */
-                       if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV)
-                               rtl8188e_PHY_SetBBReg(adapter, ODM_REG_TX_ANT_CTRL_11N, BIT(21), 1); /* Reg80c[21]=1'b1         from TX Info */
-                       dm_fat_tbl->bBecomeLinked = dm_odm->bLinked;
-               }
-       }
-       if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV))
-               odm_HWAntDiv(dm_odm);
-}
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c
deleted file mode 100644 (file)
index 788904d..0000000
+++ /dev/null
@@ -1,694 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _RTL8188E_CMD_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/rtw_ioctl_set.h"
-
-#include "../include/rtl8188e_hal.h"
-
-#define RTL88E_MAX_H2C_BOX_NUMS                4
-#define RTL88E_MAX_CMD_LEN             7
-#define RTL88E_MESSAGE_BOX_SIZE                4
-#define RTL88E_EX_MESSAGE_BOX_SIZE     4
-
-static u8 _is_fw_read_cmd_down(struct adapter *adapt, u8 msgbox_num)
-{
-       u8 read_down = false, reg;
-       int     retry_cnts = 100;
-       int res;
-
-       u8 valid;
-
-       do {
-               res = rtw_read8(adapt, REG_HMETFR, &reg);
-               if (res)
-                       continue;
-
-               valid = reg & BIT(msgbox_num);
-               if (0 == valid)
-                       read_down = true;
-       } while ((!read_down) && (retry_cnts--));
-
-       return read_down;
-}
-
-/*****************************************
-* H2C Msg format :
-* 0x1DF - 0x1D0
-*| 31 - 8      | 7-5    4 - 0  |
-*| h2c_msg     |Class_ID CMD_ID        |
-*
-* Extend 0x1FF - 0x1F0
-*|31 - 0         |
-*|ext_msg|
-******************************************/
-static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer)
-{
-       u8 bcmd_down = false;
-       s32 retry_cnts = 100;
-       u8 h2c_box_num;
-       u32 msgbox_addr;
-       u32 msgbox_ex_addr;
-       struct hal_data_8188e *haldata = &adapt->haldata;
-       u8 cmd_idx, ext_cmd_len;
-       u32 h2c_cmd = 0;
-       u32 h2c_cmd_ex = 0;
-
-       if (!adapt->bFWReady)
-               return _FAIL;
-
-       if (!pCmdBuffer || CmdLen > RTL88E_MAX_CMD_LEN || adapt->bSurpriseRemoved)
-               return _FAIL;
-
-       /* pay attention to if  race condition happened in  H2C cmd setting. */
-       do {
-               h2c_box_num = haldata->LastHMEBoxNum;
-
-               if (!_is_fw_read_cmd_down(adapt, h2c_box_num))
-                       return _FAIL;
-
-               *(u8 *)(&h2c_cmd) = ElementID;
-
-               if (CmdLen <= 3) {
-                       memcpy((u8 *)(&h2c_cmd) + 1, pCmdBuffer, CmdLen);
-               } else {
-                       memcpy((u8 *)(&h2c_cmd) + 1, pCmdBuffer, 3);
-                       ext_cmd_len = CmdLen - 3;
-                       memcpy((u8 *)(&h2c_cmd_ex), pCmdBuffer + 3, ext_cmd_len);
-
-                       /* Write Ext command */
-                       msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * RTL88E_EX_MESSAGE_BOX_SIZE);
-                       for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) {
-                               rtw_write8(adapt, msgbox_ex_addr + cmd_idx, *((u8 *)(&h2c_cmd_ex) + cmd_idx));
-                       }
-               }
-               /*  Write command */
-               msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * RTL88E_MESSAGE_BOX_SIZE);
-               for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) {
-                       rtw_write8(adapt, msgbox_addr + cmd_idx, *((u8 *)(&h2c_cmd) + cmd_idx));
-               }
-               bcmd_down = true;
-
-               haldata->LastHMEBoxNum = (h2c_box_num + 1) % RTL88E_MAX_H2C_BOX_NUMS;
-
-       } while ((!bcmd_down) && (retry_cnts--));
-
-       return _SUCCESS;
-}
-
-u8 rtl8188e_set_raid_cmd(struct adapter *adapt, u32 mask)
-{
-       u8 buf[3];
-       u8 res = _SUCCESS;
-       struct hal_data_8188e *haldata = &adapt->haldata;
-
-       if (haldata->fw_ractrl) {
-               __le32 lmask;
-
-               memset(buf, 0, 3);
-               lmask = cpu_to_le32(mask);
-               memcpy(buf, &lmask, 3);
-
-               FillH2CCmd_88E(adapt, H2C_DM_MACID_CFG, 3, buf);
-       } else {
-               res = _FAIL;
-       }
-
-       return res;
-}
-
-/* bitmap[0:27] = tx_rate_bitmap */
-/* bitmap[28:31]= Rate Adaptive id */
-/* arg[0:4] = macid */
-/* arg[5] = Short GI */
-void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi_level)
-{
-       struct hal_data_8188e *haldata = &pAdapter->haldata;
-
-       u8 macid, raid, short_gi_rate = false;
-
-       macid = arg & 0x1f;
-
-       raid = (bitmap >> 28) & 0x0f;
-       bitmap &= 0x0fffffff;
-
-       if (rssi_level != DM_RATR_STA_INIT)
-               bitmap = ODM_Get_Rate_Bitmap(&haldata->odmpriv, macid, bitmap, rssi_level);
-
-       bitmap |= ((raid << 28) & 0xf0000000);
-
-       short_gi_rate = (arg & BIT(5)) ? true : false;
-
-       raid = (bitmap >> 28) & 0x0f;
-
-       bitmap &= 0x0fffffff;
-
-       ODM_RA_UpdateRateInfo_8188E(&haldata->odmpriv, macid, raid, bitmap, short_gi_rate);
-}
-
-void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode)
-{
-       struct setpwrmode_parm H2CSetPwrMode;
-       struct pwrctrl_priv *pwrpriv = &adapt->pwrctrlpriv;
-       u8 RLBM = 0; /*  0:Min, 1:Max, 2:User define */
-
-       switch (Mode) {
-       case PS_MODE_ACTIVE:
-               H2CSetPwrMode.Mode = 0;
-               break;
-       case PS_MODE_MIN:
-               H2CSetPwrMode.Mode = 1;
-               break;
-       case PS_MODE_MAX:
-               RLBM = 1;
-               H2CSetPwrMode.Mode = 1;
-               break;
-       case PS_MODE_DTIM:
-               RLBM = 2;
-               H2CSetPwrMode.Mode = 1;
-               break;
-       case PS_MODE_UAPSD_WMM:
-               H2CSetPwrMode.Mode = 2;
-               break;
-       default:
-               H2CSetPwrMode.Mode = 0;
-               break;
-       }
-
-       H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps << 4) & 0xf0) | (RLBM & 0x0f));
-
-       H2CSetPwrMode.AwakeInterval = 1;
-
-       H2CSetPwrMode.bAllQueueUAPSD = adapt->registrypriv.uapsd_enable;
-
-       if (Mode > 0)
-               H2CSetPwrMode.PwrState = 0x00;/*  AllON(0x0C), RFON(0x04), RFOFF(0x00) */
-       else
-               H2CSetPwrMode.PwrState = 0x0C;/*  AllON(0x0C), RFON(0x04), RFOFF(0x00) */
-
-       FillH2CCmd_88E(adapt, H2C_PS_PWR_MODE, sizeof(H2CSetPwrMode), (u8 *)&H2CSetPwrMode);
-
-}
-
-void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, u16 mstatus_rpt)
-{
-       __le16 mst_rpt = cpu_to_le16(mstatus_rpt);
-
-       FillH2CCmd_88E(adapt, H2C_COM_MEDIA_STATUS_RPT, sizeof(mst_rpt), (u8 *)&mst_rpt);
-}
-
-static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength)
-{
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       u32 rate_len, pktlen;
-       struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex            *cur_network = &pmlmeinfo->network;
-
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       eth_broadcast_addr(pwlanhdr->addr1);
-       memcpy(pwlanhdr->addr2, myid(&adapt->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/);
-       SetFrameSubType(pframe, WIFI_BEACON);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       /* timestamp will be inserted by hardware */
-       pframe += 8;
-       pktlen += 8;
-
-       /*  beacon interval: 2 bytes */
-       memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2);
-
-       pframe += 2;
-       pktlen += 2;
-
-       /*  capability info: 2 bytes */
-       memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2);
-
-       pframe += 2;
-       pktlen += 2;
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
-               pktlen += cur_network->IELength - sizeof(struct ndis_802_11_fixed_ie);
-               memcpy(pframe, cur_network->IEs + sizeof(struct ndis_802_11_fixed_ie), pktlen);
-
-               goto _ConstructBeacon;
-       }
-
-       /* below for ad-hoc mode */
-
-       /*  SSID */
-       pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pktlen);
-
-       /*  supported rates... */
-       rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
-       pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen);
-
-       /*  DS parameter set */
-       pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pktlen);
-
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) {
-               u32 ATIMWindow;
-               /*  IBSS Parameter Set... */
-               ATIMWindow = 0;
-               pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pktlen);
-       }
-
-       /* todo: ERP IE */
-
-       /*  EXTERNDED SUPPORTED RATE */
-       if (rate_len > 8)
-               pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen);
-
-       /* todo:HT for adhoc */
-
-_ConstructBeacon:
-
-       if ((pktlen + TXDESC_SIZE) > 512)
-               return;
-
-       *pLength = pktlen;
-}
-
-static void ConstructPSPoll(struct adapter *adapt, u8 *pframe, u32 *pLength)
-{
-       struct ieee80211_hdr *pwlanhdr;
-       struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       __le16 *fctrl;
-
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       /*  Frame control. */
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-       SetPwrMgt(fctrl);
-       SetFrameSubType(pframe, WIFI_PSPOLL);
-
-       /*  AID. */
-       SetDuration(pframe, (pmlmeinfo->aid | 0xc000));
-
-       /*  BSSID. */
-       memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-
-       /*  TA. */
-       memcpy(pwlanhdr->addr2, myid(&adapt->eeprompriv), ETH_ALEN);
-
-       *pLength = 16;
-}
-
-static void ConstructNullFunctionData(struct adapter *adapt, u8 *pframe,
-       u32 *pLength,
-       u8 *StaAddr,
-       u8 bQoS,
-       u8 AC,
-       u8 bEosp,
-       u8 bForcePowerSave)
-{
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       u32 pktlen;
-       struct mlme_priv *pmlmepriv = &adapt->mlmepriv;
-       struct wlan_network             *cur_network = &pmlmepriv->cur_network;
-       struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-       if (bForcePowerSave)
-               SetPwrMgt(fctrl);
-
-       switch (cur_network->network.InfrastructureMode) {
-       case Ndis802_11Infrastructure:
-               SetToDs(fctrl);
-               memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-               memcpy(pwlanhdr->addr2, myid(&adapt->eeprompriv), ETH_ALEN);
-               memcpy(pwlanhdr->addr3, StaAddr, ETH_ALEN);
-               break;
-       case Ndis802_11APMode:
-               SetFrDs(fctrl);
-               memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN);
-               memcpy(pwlanhdr->addr2, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-               memcpy(pwlanhdr->addr3, myid(&adapt->eeprompriv), ETH_ALEN);
-               break;
-       case Ndis802_11IBSS:
-       default:
-               memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN);
-               memcpy(pwlanhdr->addr2, myid(&adapt->eeprompriv), ETH_ALEN);
-               memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN);
-               break;
-       }
-
-       SetSeqNum(pwlanhdr, 0);
-
-       if (bQoS) {
-               struct ieee80211_qos_hdr *pwlanqoshdr;
-
-               SetFrameSubType(pframe, WIFI_QOS_DATA_NULL);
-
-               pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe;
-               SetPriority(&pwlanqoshdr->qos_ctrl, AC);
-               SetEOSP(&pwlanqoshdr->qos_ctrl, bEosp);
-
-               pktlen = sizeof(struct ieee80211_qos_hdr);
-       } else {
-               SetFrameSubType(pframe, WIFI_DATA_NULL);
-
-               pktlen = sizeof(struct ieee80211_qos_hdr);
-       }
-
-       *pLength = pktlen;
-}
-
-static void ConstructProbeRsp(struct adapter *adapt, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID)
-{
-       struct ieee80211_hdr *pwlanhdr;
-       __le16 *fctrl;
-       u8 *mac, *bssid;
-       u32 pktlen;
-       struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex    *cur_network = &pmlmeinfo->network;
-
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       mac = myid(&adapt->eeprompriv);
-       bssid = cur_network->MacAddress;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-       memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
-       memcpy(pwlanhdr->addr3, bssid, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, 0);
-       SetFrameSubType(fctrl, WIFI_PROBERSP);
-
-       pktlen = sizeof(struct ieee80211_hdr_3addr);
-       pframe += pktlen;
-
-       if (cur_network->IELength > MAX_IE_SZ)
-               return;
-
-       memcpy(pframe, cur_network->IEs, cur_network->IELength);
-       pframe += cur_network->IELength;
-       pktlen += cur_network->IELength;
-
-       *pLength = pktlen;
-}
-
-/*  To check if reserved page content is destroyed by beacon because beacon is too large. */
-/*  2010.06.23. Added by tynli. */
-void CheckFwRsvdPageContent(struct adapter *Adapter)
-{
-}
-
-/*  */
-/*  Description: Fill the reserved packets that FW will use to RSVD page. */
-/*                     Now we just send 4 types packet to rsvd page. */
-/*                     (1)Beacon, (2)Ps-poll, (3)Null data, (4)ProbeRsp. */
-/*     Input: */
-/*         bDLFinished - false: At the first time we will send all the packets as a large packet to Hw, */
-/*                                             so we need to set the packet length to total length. */
-/*                           true: At the second time, we should send the first packet (default:beacon) */
-/*                                             to Hw again and set the length in descriptor to the real beacon length. */
-/*  2009.10.15 by tynli. */
-static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished)
-{
-       struct xmit_frame       *pmgntframe;
-       struct pkt_attrib       *pattrib;
-       struct xmit_priv *pxmitpriv;
-       struct mlme_ext_priv *pmlmeext;
-       struct mlme_ext_info    *pmlmeinfo;
-       u32 BeaconLength = 0, ProbeRspLength = 0, PSPollLength;
-       u32 NullDataLength, QosNullLength;
-       u8 *ReservedPagePacket;
-       u8 PageNum, PageNeed, TxDescLen;
-       u16 BufIndex;
-       u32 TotalPacketLen;
-       struct rsvdpage_loc RsvdPageLoc;
-
-       ReservedPagePacket = kzalloc(1000, GFP_KERNEL);
-       if (!ReservedPagePacket)
-               return;
-
-       pxmitpriv = &adapt->xmitpriv;
-       pmlmeext = &adapt->mlmeextpriv;
-       pmlmeinfo = &pmlmeext->mlmext_info;
-
-       TxDescLen = TXDESC_SIZE;
-       PageNum = 0;
-
-       /* 3 (1) beacon * 2 pages */
-       BufIndex = TXDESC_OFFSET;
-       ConstructBeacon(adapt, &ReservedPagePacket[BufIndex], &BeaconLength);
-
-       /*  When we count the first page size, we need to reserve description size for the RSVD */
-       /*  packet, it will be filled in front of the packet in TXPKTBUF. */
-       PageNeed = (u8)PageNum_128(TxDescLen + BeaconLength);
-       /*  To reserved 2 pages for beacon buffer. 2010.06.24. */
-       if (PageNeed == 1)
-               PageNeed += 1;
-       PageNum += PageNeed;
-
-       BufIndex += PageNeed * 128;
-
-       /* 3 (2) ps-poll *1 page */
-       RsvdPageLoc.LocPsPoll = PageNum;
-       ConstructPSPoll(adapt, &ReservedPagePacket[BufIndex], &PSPollLength);
-       rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], PSPollLength, true, false);
-
-       PageNeed = (u8)PageNum_128(TxDescLen + PSPollLength);
-       PageNum += PageNeed;
-
-       BufIndex += PageNeed * 128;
-
-       /* 3 (3) null data * 1 page */
-       RsvdPageLoc.LocNullData = PageNum;
-       ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], &NullDataLength, get_my_bssid(&pmlmeinfo->network), false, 0, 0, false);
-       rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], NullDataLength, false, false);
-
-       PageNeed = (u8)PageNum_128(TxDescLen + NullDataLength);
-       PageNum += PageNeed;
-
-       BufIndex += PageNeed * 128;
-
-       /* 3 (4) probe response * 1page */
-       RsvdPageLoc.LocProbeRsp = PageNum;
-       ConstructProbeRsp(adapt, &ReservedPagePacket[BufIndex], &ProbeRspLength, get_my_bssid(&pmlmeinfo->network), false);
-       rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], ProbeRspLength, false, false);
-
-       PageNeed = (u8)PageNum_128(TxDescLen + ProbeRspLength);
-       PageNum += PageNeed;
-
-       BufIndex += PageNeed * 128;
-
-       /* 3 (5) Qos null data */
-       RsvdPageLoc.LocQosNull = PageNum;
-       ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex],
-                                 &QosNullLength, get_my_bssid(&pmlmeinfo->network), true, 0, 0, false);
-       rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], QosNullLength, false, false);
-
-       PageNeed = (u8)PageNum_128(TxDescLen + QosNullLength);
-       PageNum += PageNeed;
-
-       TotalPacketLen = BufIndex + QosNullLength;
-       pmgntframe = alloc_mgtxmitframe(pxmitpriv);
-       if (!pmgntframe)
-               goto exit;
-
-       /*  update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib(adapt, pattrib);
-       pattrib->qsel = 0x10;
-       pattrib->last_txcmdsz = TotalPacketLen - TXDESC_OFFSET;
-       pattrib->pktlen = pattrib->last_txcmdsz;
-       memcpy(pmgntframe->buf_addr, ReservedPagePacket, TotalPacketLen);
-
-       rtl8188eu_mgnt_xmit(adapt, pmgntframe);
-
-       FillH2CCmd_88E(adapt, H2C_COM_RSVD_PAGE, sizeof(RsvdPageLoc), (u8 *)&RsvdPageLoc);
-
-exit:
-       kfree(ReservedPagePacket);
-}
-
-void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus)
-{
-       struct hal_data_8188e *haldata = &adapt->haldata;
-       struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       bool    bSendBeacon = false;
-       bool    bcn_valid = false;
-       u8 DLBcnCount = 0;
-       u32 poll = 0;
-       u8 reg;
-       int res;
-
-       if (mstatus == 1) {
-               /*  We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. */
-               /*  Suggested by filen. Added by tynli. */
-               rtw_write16(adapt, REG_BCN_PSR_RPT, (0xC000 | pmlmeinfo->aid));
-               /*  Do not set TSF again here or vWiFi beacon DMA INT will not work. */
-
-               /* Set REG_CR bit 8. DMA beacon by SW. */
-               haldata->RegCR_1 |= BIT(0);
-               rtw_write8(adapt,  REG_CR + 1, haldata->RegCR_1);
-
-               /*  Disable Hw protection for a time which revserd for Hw sending beacon. */
-               /*  Fix download reserved page packet fail that access collision with the protection time. */
-               /*  2010.05.11. Added by tynli. */
-               res = rtw_read8(adapt, REG_BCN_CTRL, &reg);
-               if (res)
-                       return;
-
-               rtw_write8(adapt, REG_BCN_CTRL, reg & (~BIT(3)));
-
-               res = rtw_read8(adapt, REG_BCN_CTRL, &reg);
-               if (res)
-                       return;
-
-               rtw_write8(adapt, REG_BCN_CTRL, reg | BIT(4));
-
-               if (haldata->RegFwHwTxQCtrl & BIT(6))
-                       bSendBeacon = true;
-
-               /*  Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame. */
-               rtw_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl & (~BIT(6))));
-               haldata->RegFwHwTxQCtrl &= (~BIT(6));
-
-               clear_beacon_valid_bit(adapt);
-               DLBcnCount = 0;
-               poll = 0;
-               do {
-                       /*  download rsvd page. */
-                       SetFwRsvdPagePkt(adapt, false);
-                       DLBcnCount++;
-                       do {
-                               yield();
-                               /* mdelay(10); */
-                               /*  check rsvd page download OK. */
-                               bcn_valid = get_beacon_valid_bit(adapt);
-                               poll++;
-                       } while (!bcn_valid && (poll % 10) != 0 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped);
-               } while (!bcn_valid && DLBcnCount <= 100 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped);
-
-               /*  */
-               /*  We just can send the reserved page twice during the time that Tx thread is stopped (e.g. pnpsetpower) */
-               /*  because we need to free the Tx BCN Desc which is used by the first reserved page packet. */
-               /*  At run time, we cannot get the Tx Desc until it is released in TxHandleInterrupt() so we will return */
-               /*  the beacon TCB in the following code. 2011.11.23. by tynli. */
-               /*  */
-
-               /*  Enable Bcn */
-               res = rtw_read8(adapt, REG_BCN_CTRL, &reg);
-               if (res)
-                       return;
-
-               rtw_write8(adapt, REG_BCN_CTRL, reg | BIT(3));
-
-               res = rtw_read8(adapt, REG_BCN_CTRL, &reg);
-               if (res)
-                       return;
-
-               rtw_write8(adapt, REG_BCN_CTRL, reg & (~BIT(4)));
-
-               /*  To make sure that if there exists an adapter which would like to send beacon. */
-               /*  If exists, the origianl value of 0x422[6] will be 1, we should check this to */
-               /*  prevent from setting 0x422[6] to 0 after download reserved page, or it will cause */
-               /*  the beacon cannot be sent by HW. */
-               /*  2010.06.23. Added by tynli. */
-               if (bSendBeacon) {
-                       rtw_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl | BIT(6)));
-                       haldata->RegFwHwTxQCtrl |= BIT(6);
-               }
-
-               /*  Update RSVD page location H2C to Fw. */
-               if (bcn_valid)
-                       clear_beacon_valid_bit(adapt);
-
-               /*  Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli. */
-               /*  Clear CR[8] or beacon packet will not be send to TxBuf anymore. */
-               haldata->RegCR_1 &= (~BIT(0));
-               rtw_write8(adapt,  REG_CR + 1, haldata->RegCR_1);
-       }
-
-}
-
-void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state)
-{
-       struct hal_data_8188e *haldata = &adapt->haldata;
-       struct wifidirect_info  *pwdinfo = &adapt->wdinfo;
-       struct P2P_PS_Offload_t *p2p_ps_offload = &haldata->p2p_ps_offload;
-       u8 i;
-
-       switch (p2p_ps_state) {
-       case P2P_PS_DISABLE:
-               memset(p2p_ps_offload, 0, 1);
-               break;
-       case P2P_PS_ENABLE:
-               /*  update CTWindow value. */
-               if (pwdinfo->ctwindow > 0) {
-                       p2p_ps_offload->CTWindow_En = 1;
-                       rtw_write8(adapt, REG_P2P_CTWIN, pwdinfo->ctwindow);
-               }
-
-               /*  hw only support 2 set of NoA */
-               for (i = 0; i < pwdinfo->noa_num; i++) {
-                       /*  To control the register setting for which NOA */
-                       rtw_write8(adapt, REG_NOA_DESC_SEL, (i << 4));
-                       if (i == 0)
-                               p2p_ps_offload->NoA0_En = 1;
-                       else
-                               p2p_ps_offload->NoA1_En = 1;
-
-                       /*  config P2P NoA Descriptor Register */
-                       rtw_write32(adapt, REG_NOA_DESC_DURATION, pwdinfo->noa_duration[i]);
-                       rtw_write32(adapt, REG_NOA_DESC_INTERVAL, pwdinfo->noa_interval[i]);
-                       rtw_write32(adapt, REG_NOA_DESC_START, pwdinfo->noa_start_time[i]);
-                       rtw_write8(adapt, REG_NOA_DESC_COUNT, pwdinfo->noa_count[i]);
-               }
-
-               if ((pwdinfo->opp_ps == 1) || (pwdinfo->noa_num > 0)) {
-                       /*  rst p2p circuit */
-                       rtw_write8(adapt, REG_DUAL_TSF_RST, BIT(4));
-
-                       p2p_ps_offload->Offload_En = 1;
-
-                       if (pwdinfo->role == P2P_ROLE_GO) {
-                               p2p_ps_offload->role = 1;
-                               p2p_ps_offload->AllStaSleep = 0;
-                       } else {
-                               p2p_ps_offload->role = 0;
-                       }
-
-                       p2p_ps_offload->discovery = 0;
-               }
-               break;
-       case P2P_PS_SCAN:
-               p2p_ps_offload->discovery = 1;
-               break;
-       case P2P_PS_SCAN_DONE:
-               p2p_ps_offload->discovery = 0;
-               pwdinfo->p2p_ps_state = P2P_PS_ENABLE;
-               break;
-       default:
-               break;
-       }
-
-       FillH2CCmd_88E(adapt, H2C_PS_P2P_OFFLOAD, 1, (u8 *)p2p_ps_offload);
-}
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_dm.c b/drivers/staging/r8188eu/hal/rtl8188e_dm.c
deleted file mode 100644 (file)
index 0399872..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-/*  This file is for 92CE/92CU dynamic mechanism only */
-#define _RTL8188E_DM_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/rtl8188e_hal.h"
-
-/*  Initialize GPIO setting registers */
-static void dm_InitGPIOSetting(struct adapter *Adapter)
-{
-       u8      tmp1byte;
-       int res;
-
-       res = rtw_read8(Adapter, REG_GPIO_MUXCFG, &tmp1byte);
-       if (res)
-               return;
-
-       tmp1byte &= (GPIOSEL_GPIO | ~GPIOSEL_ENBT);
-
-       rtw_write8(Adapter, REG_GPIO_MUXCFG, tmp1byte);
-}
-
-/*  */
-/*  functions */
-/*  */
-static void Update_ODM_ComInfo_88E(struct adapter *Adapter)
-{
-       struct mlme_ext_priv    *pmlmeext = &Adapter->mlmeextpriv;
-       struct mlme_priv        *pmlmepriv = &Adapter->mlmepriv;
-       struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv;
-       struct hal_data_8188e *hal_data = &Adapter->haldata;
-       struct odm_dm_struct *dm_odm = &hal_data->odmpriv;
-       struct dm_priv  *pdmpriv = &hal_data->dmpriv;
-       int i;
-
-       pdmpriv->InitODMFlag = ODM_BB_RSSI_MONITOR;
-       if (hal_data->AntDivCfg)
-               pdmpriv->InitODMFlag |= ODM_BB_ANT_DIV;
-
-       dm_odm->SupportAbility = pdmpriv->InitODMFlag;
-
-       dm_odm->pWirelessMode = &pmlmeext->cur_wireless_mode;
-       dm_odm->pSecChOffset = &hal_data->nCur40MhzPrimeSC;
-       dm_odm->pBandWidth = &hal_data->CurrentChannelBW;
-       dm_odm->pChannel = &hal_data->CurrentChannel;
-       dm_odm->pbScanInProcess = &pmlmepriv->bScanInProcess;
-       dm_odm->pbPowerSaving = &pwrctrlpriv->bpower_saving;
-
-       ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType);
-
-       for (i = 0; i < NUM_STA; i++)
-               dm_odm->pODM_StaInfo[i] = NULL;
-}
-
-void rtl8188e_InitHalDm(struct adapter *Adapter)
-{
-       struct hal_data_8188e *hal_data = &Adapter->haldata;
-       struct odm_dm_struct *dm_odm = &hal_data->odmpriv;
-
-       dm_InitGPIOSetting(Adapter);
-       Update_ODM_ComInfo_88E(Adapter);
-       ODM_DMInit(dm_odm);
-}
-
-void rtl8188e_HalDmWatchDog(struct adapter *Adapter)
-{
-       u8 hw_init_completed = Adapter->hw_init_completed;
-       struct hal_data_8188e *hal_data = &Adapter->haldata;
-       struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
-       u8 bLinked = false;
-
-       if (!hw_init_completed)
-               return;
-
-       if ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) ||
-           (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE))) {
-               if (Adapter->stapriv.asoc_sta_count > 2)
-                       bLinked = true;
-       } else {/* Station mode */
-               if (check_fwstate(pmlmepriv, _FW_LINKED))
-                       bLinked = true;
-       }
-
-       hal_data->odmpriv.bLinked = bLinked;
-       ODM_DMWatchdog(&hal_data->odmpriv);
-}
-
-void rtl8188e_init_dm_priv(struct adapter *Adapter)
-{
-       struct hal_data_8188e *hal_data = &Adapter->haldata;
-       struct dm_priv  *pdmpriv = &hal_data->dmpriv;
-       struct odm_dm_struct *dm_odm = &hal_data->odmpriv;
-
-       memset(pdmpriv, 0, sizeof(struct dm_priv));
-       memset(dm_odm, 0, sizeof(*dm_odm));
-
-       dm_odm->Adapter = Adapter;
-       ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_MP_TEST_CHIP, IS_NORMAL_CHIP(hal_data->VersionID));
-       ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType);
-}
-
-/*  Add new function to reset the state of antenna diversity before link. */
-/*  Compare RSSI for deciding antenna */
-void AntDivCompare8188E(struct adapter *Adapter, struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src)
-{
-       struct hal_data_8188e *hal_data = &Adapter->haldata;
-
-       if (0 != hal_data->AntDivCfg) {
-               /* select optimum_antenna for before linked =>For antenna diversity */
-               if (dst->Rssi >=  src->Rssi) {/* keep org parameter */
-                       src->Rssi = dst->Rssi;
-                       src->PhyInfo.Optimum_antenna = dst->PhyInfo.Optimum_antenna;
-               }
-       }
-}
-
-/*  Add new function to reset the state of antenna diversity before link. */
-u8 AntDivBeforeLink8188E(struct adapter *Adapter)
-{
-       struct hal_data_8188e *hal_data = &Adapter->haldata;
-       struct odm_dm_struct *dm_odm = &hal_data->odmpriv;
-       struct sw_ant_switch *dm_swat_tbl = &dm_odm->DM_SWAT_Table;
-       struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
-
-       /*  Condition that does not need to use antenna diversity. */
-       if (hal_data->AntDivCfg == 0)
-               return false;
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED))
-               return false;
-
-       if (dm_swat_tbl->SWAS_NoLink_State == 0) {
-               /* switch channel */
-               dm_swat_tbl->SWAS_NoLink_State = 1;
-               dm_swat_tbl->CurAntenna = (dm_swat_tbl->CurAntenna == Antenna_A) ? Antenna_B : Antenna_A;
-
-               rtw_antenna_select_cmd(Adapter, dm_swat_tbl->CurAntenna, false);
-               return true;
-       } else {
-               dm_swat_tbl->SWAS_NoLink_State = 0;
-               return false;
-       }
-}
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
deleted file mode 100644 (file)
index 73855bc..0000000
+++ /dev/null
@@ -1,922 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _HAL_INIT_C_
-
-#include "../include/drv_types.h"
-#include "../include/rtw_efuse.h"
-#include "../include/rtl8188e_hal.h"
-#include "../include/rtw_iol.h"
-#include "../include/usb_ops.h"
-#include "../include/rtw_fw.h"
-
-static void iol_mode_enable(struct adapter *padapter, u8 enable)
-{
-       u8 reg_0xf0 = 0;
-       int res;
-
-       if (enable) {
-               /* Enable initial offload */
-               res = rtw_read8(padapter, REG_SYS_CFG, &reg_0xf0);
-               if (res)
-                       return;
-
-               rtw_write8(padapter, REG_SYS_CFG, reg_0xf0 | SW_OFFLOAD_EN);
-
-               if (!padapter->bFWReady)
-                       rtw_reset_8051(padapter);
-
-       } else {
-               /* disable initial offload */
-               res = rtw_read8(padapter, REG_SYS_CFG, &reg_0xf0);
-               if (res)
-                       return;
-
-               rtw_write8(padapter, REG_SYS_CFG, reg_0xf0 & ~SW_OFFLOAD_EN);
-       }
-}
-
-static s32 iol_execute(struct adapter *padapter, u8 control)
-{
-       s32 status = _FAIL;
-       u8 reg_0x88 = 0;
-       unsigned long timeout;
-       int res;
-
-       control = control & 0x0f;
-       res = rtw_read8(padapter, REG_HMEBOX_E0, &reg_0x88);
-       if (res)
-               return _FAIL;
-
-       rtw_write8(padapter, REG_HMEBOX_E0,  reg_0x88 | control);
-
-       timeout = jiffies + msecs_to_jiffies(1000);
-
-       do {
-               res = rtw_read8(padapter, REG_HMEBOX_E0, &reg_0x88);
-               if (res)
-                       continue;
-
-               if (!(reg_0x88 & control))
-                       break;
-
-       } while (time_before(jiffies, timeout));
-
-       res = rtw_read8(padapter, REG_HMEBOX_E0, &reg_0x88);
-       if (res)
-               return _FAIL;
-
-       status = (reg_0x88 & control) ? _FAIL : _SUCCESS;
-       if (reg_0x88 & control << 4)
-               status = _FAIL;
-       return status;
-}
-
-static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy)
-{
-       s32 rst = _SUCCESS;
-       iol_mode_enable(padapter, 1);
-       rtw_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy);
-       rst = iol_execute(padapter, CMD_INIT_LLT);
-       iol_mode_enable(padapter, 0);
-       return rst;
-}
-
-static void
-efuse_phymap_to_logical(u8 *phymap, u16 _size_byte, u8  *pbuf)
-{
-       u8 *efuseTbl = NULL;
-       u8 rtemp8;
-       u16     eFuse_Addr = 0;
-       u8 offset, wren;
-       u16     i, j;
-       u16     **eFuseWord = NULL;
-       u8 u1temp = 0;
-
-       efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
-       if (!efuseTbl)
-               goto exit;
-
-       eFuseWord = rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
-       if (!eFuseWord)
-               goto exit;
-
-       /*  0. Refresh efuse init map as all oxFF. */
-       for (i = 0; i < EFUSE_MAX_SECTION_88E; i++)
-               for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++)
-                       eFuseWord[i][j] = 0xFFFF;
-
-       /*  */
-       /*  1. Read the first byte to check if efuse is empty!!! */
-       /*  */
-       /*  */
-       rtemp8 = *(phymap + eFuse_Addr);
-       if (rtemp8 != 0xFF) {
-               eFuse_Addr++;
-       } else {
-               goto exit;
-       }
-
-       /*  */
-       /*  2. Read real efuse content. Filter PG header and every section data. */
-       /*  */
-       while ((rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) {
-               /*  Check PG header for section num. */
-               if ((rtemp8 & 0x1F) == 0x0F) {          /* extended header */
-                       u1temp = ((rtemp8 & 0xE0) >> 5);
-                       rtemp8 = *(phymap + eFuse_Addr);
-                       if ((rtemp8 & 0x0F) == 0x0F) {
-                               eFuse_Addr++;
-                               rtemp8 = *(phymap + eFuse_Addr);
-
-                               if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E))
-                                       eFuse_Addr++;
-                               continue;
-                       } else {
-                               offset = ((rtemp8 & 0xF0) >> 1) | u1temp;
-                               wren = (rtemp8 & 0x0F);
-                               eFuse_Addr++;
-                       }
-               } else {
-                       offset = ((rtemp8 >> 4) & 0x0f);
-                       wren = (rtemp8 & 0x0f);
-               }
-
-               if (offset < EFUSE_MAX_SECTION_88E) {
-                       /*  Get word enable value from PG header */
-                       for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
-                               /*  Check word enable condition in the section */
-                               if (!(wren & 0x01)) {
-                                       rtemp8 = *(phymap + eFuse_Addr);
-                                       eFuse_Addr++;
-                                       eFuseWord[offset][i] = (rtemp8 & 0xff);
-                                       if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E)
-                                               break;
-                                       rtemp8 = *(phymap + eFuse_Addr);
-                                       eFuse_Addr++;
-                                       eFuseWord[offset][i] |= (((u16)rtemp8 << 8) & 0xff00);
-
-                                       if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E)
-                                               break;
-                               }
-                               wren >>= 1;
-                       }
-               }
-               /*  Read next PG header */
-               rtemp8 = *(phymap + eFuse_Addr);
-
-               if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) {
-                       eFuse_Addr++;
-               }
-       }
-
-       /*  */
-       /*  3. Collect 16 sections and 4 word unit into Efuse map. */
-       /*  */
-       for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) {
-               for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) {
-                       efuseTbl[(i * 8) + (j * 2)] = (eFuseWord[i][j] & 0xff);
-                       efuseTbl[(i * 8) + ((j * 2) + 1)] = ((eFuseWord[i][j] >> 8) & 0xff);
-               }
-       }
-
-       /*  */
-       /*  4. Copy from Efuse map to output pointer memory!!! */
-       /*  */
-       memcpy(pbuf, efuseTbl, _size_byte);
-
-exit:
-       kfree(efuseTbl);
-       kfree(eFuseWord);
-}
-
-/* FIXME: add error handling in callers */
-static int efuse_read_phymap_from_txpktbuf(
-       struct adapter  *adapter,
-       u8 *content,    /* buffer to store efuse physical map */
-       u16 *size       /* for efuse content: the max byte to read. will update to byte read */
-       )
-{
-       unsigned long timeout;
-       __le32 lo32 = 0, hi32 = 0;
-       u16 len = 0, count = 0;
-       int i = 0, res;
-       u16 limit = *size;
-       u8 reg;
-       u8 *pos = content;
-       u32 reg32;
-
-       rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT);
-
-       while (1) {
-               rtw_write16(adapter, REG_PKTBUF_DBG_ADDR, i);
-
-               rtw_write8(adapter, REG_TXPKTBUF_DBG, 0);
-               timeout = jiffies + msecs_to_jiffies(1000);
-               do {
-                       res = rtw_read8(adapter, REG_TXPKTBUF_DBG, &reg);
-                       if (res)
-                               continue;
-
-                       if (reg)
-                               break;
-
-                       msleep(1);
-               } while (time_before(jiffies, timeout));
-
-               /* data from EEPROM needs to be in LE */
-               res = rtw_read32(adapter, REG_PKTBUF_DBG_DATA_L, &reg32);
-               if (res)
-                       return res;
-
-               lo32 = cpu_to_le32(reg32);
-
-               res = rtw_read32(adapter, REG_PKTBUF_DBG_DATA_H, &reg32);
-               if (res)
-                       return res;
-
-               hi32 = cpu_to_le32(reg32);
-
-               if (i == 0) {
-                       u16 reg;
-
-                       /* Although lenc is only used in a debug statement,
-                        * do not remove it as the rtw_read16() call consumes
-                        * 2 bytes from the EEPROM source.
-                        */
-                       res = rtw_read16(adapter, REG_PKTBUF_DBG_DATA_L, &reg);
-                       if (res)
-                               return res;
-
-                       len = le32_to_cpu(lo32) & 0x0000ffff;
-
-                       limit = (len - 2 < limit) ? len - 2 : limit;
-
-                       memcpy(pos, ((u8 *)&lo32) + 2, (limit >= count + 2) ? 2 : limit - count);
-                       count += (limit >= count + 2) ? 2 : limit - count;
-                       pos = content + count;
-               } else {
-                       memcpy(pos, ((u8 *)&lo32), (limit >= count + 4) ? 4 : limit - count);
-                       count += (limit >= count + 4) ? 4 : limit - count;
-                       pos = content + count;
-               }
-
-               if (limit > count && len - 2 > count) {
-                       memcpy(pos, (u8 *)&hi32, (limit >= count + 4) ? 4 : limit - count);
-                       count += (limit >= count + 4) ? 4 : limit - count;
-                       pos = content + count;
-               }
-
-               if (limit <= count || len - 2 <= count)
-                       break;
-               i++;
-       }
-       rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, DISABLE_TRXPKT_BUF_ACCESS);
-       *size = count;
-
-       return 0;
-}
-
-static s32 iol_read_efuse(struct adapter *padapter, u16 size_byte, u8 *logical_map)
-{
-       s32 status = _FAIL;
-       u8 physical_map[512];
-       u16 size = 512;
-
-       rtw_write8(padapter, REG_TDECTRL + 1, 0);
-       memset(physical_map, 0xFF, 512);
-       rtw_write8(padapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT);
-       status = iol_execute(padapter, CMD_READ_EFUSE_MAP);
-       if (status == _SUCCESS)
-               efuse_read_phymap_from_txpktbuf(padapter, physical_map, &size);
-       efuse_phymap_to_logical(physical_map, size_byte, logical_map);
-       return status;
-}
-
-s32 rtl8188e_iol_efuse_patch(struct adapter *padapter)
-{
-       s32     result = _SUCCESS;
-
-       if (rtw_IOL_applied(padapter)) {
-               iol_mode_enable(padapter, 1);
-               result = iol_execute(padapter, CMD_READ_EFUSE_MAP);
-               if (result == _SUCCESS)
-                       result = iol_execute(padapter, CMD_EFUSE_PATCH);
-
-               iol_mode_enable(padapter, 0);
-       }
-       return result;
-}
-
-static s32 iol_ioconfig(struct adapter *padapter, u8 iocfg_bndy)
-{
-       s32 rst = _SUCCESS;
-
-       rtw_write8(padapter, REG_TDECTRL + 1, iocfg_bndy);
-       rst = iol_execute(padapter, CMD_IOCONFIG);
-       return rst;
-}
-
-int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt)
-{
-       struct pkt_attrib *pattrib = &xmit_frame->attrib;
-       u8 i;
-       int ret = _FAIL;
-
-       if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS)
-               goto exit;
-       if (rtw_usb_bulk_size_boundary(adapter, TXDESC_SIZE + pattrib->last_txcmdsz)) {
-               if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS)
-                       goto exit;
-       }
-
-       dump_mgntframe_and_wait(adapter, xmit_frame, max_wating_ms);
-
-       iol_mode_enable(adapter, 1);
-       for (i = 0; i < bndy_cnt; i++) {
-               u8 page_no = 0;
-               page_no = i * 2;
-               ret = iol_ioconfig(adapter, page_no);
-               if (ret != _SUCCESS)
-                       break;
-       }
-       iol_mode_enable(adapter, 0);
-exit:
-       /* restore BCN_HEAD */
-       rtw_write8(adapter, REG_TDECTRL + 1, 0);
-       return ret;
-}
-
-void rtl8188e_EfusePowerSwitch(struct adapter *pAdapter, u8 PwrState)
-{
-       u16     tmpV16;
-       int res;
-
-       if (PwrState) {
-               rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON);
-
-               /*  1.2V Power: From VDDON with Power Cut(0x0000h[15]), default valid */
-               res = rtw_read16(pAdapter, REG_SYS_ISO_CTRL, &tmpV16);
-               if (res)
-                       return;
-
-               if (!(tmpV16 & PWC_EV12V)) {
-                       tmpV16 |= PWC_EV12V;
-                       rtw_write16(pAdapter, REG_SYS_ISO_CTRL, tmpV16);
-               }
-               /*  Reset: 0x0000h[28], default valid */
-               res = rtw_read16(pAdapter, REG_SYS_FUNC_EN, &tmpV16);
-               if (res)
-                       return;
-
-               if (!(tmpV16 & FEN_ELDR)) {
-                       tmpV16 |= FEN_ELDR;
-                       rtw_write16(pAdapter, REG_SYS_FUNC_EN, tmpV16);
-               }
-
-               /*  Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */
-               res = rtw_read16(pAdapter, REG_SYS_CLKR, &tmpV16);
-               if (res)
-                       return;
-
-               if ((!(tmpV16 & LOADER_CLK_EN))  || (!(tmpV16 & ANA8M))) {
-                       tmpV16 |= (LOADER_CLK_EN | ANA8M);
-                       rtw_write16(pAdapter, REG_SYS_CLKR, tmpV16);
-               }
-       } else {
-               rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF);
-       }
-}
-
-static void Hal_EfuseReadEFuse88E(struct adapter *Adapter,
-       u16                     _offset,
-       u16                     _size_byte,
-       u8 *pbuf)
-{
-       u8 *efuseTbl = NULL;
-       u8 rtemp8[1];
-       u16     eFuse_Addr = 0;
-       u8 offset, wren;
-       u16     i, j;
-       u16     **eFuseWord = NULL;
-       u16     efuse_utilized = 0;
-       u8 u1temp = 0;
-
-       /*  */
-       /*  Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */
-       /*  */
-       if ((_offset + _size_byte) > EFUSE_MAP_LEN_88E) /*  total E-Fuse table is 512bytes */
-               goto exit;
-
-       efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
-       if (!efuseTbl)
-               goto exit;
-
-       eFuseWord = rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
-       if (!eFuseWord)
-               goto exit;
-
-       /*  0. Refresh efuse init map as all oxFF. */
-       for (i = 0; i < EFUSE_MAX_SECTION_88E; i++)
-               for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++)
-                       eFuseWord[i][j] = 0xFFFF;
-
-       /*  */
-       /*  1. Read the first byte to check if efuse is empty!!! */
-       /*  */
-       /*  */
-       ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
-       if (*rtemp8 != 0xFF) {
-               efuse_utilized++;
-               eFuse_Addr++;
-       } else {
-               goto exit;
-       }
-
-       /*  */
-       /*  2. Read real efuse content. Filter PG header and every section data. */
-       /*  */
-       while ((*rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) {
-               /*  Check PG header for section num. */
-               if ((*rtemp8 & 0x1F) == 0x0F) {         /* extended header */
-                       u1temp = ((*rtemp8 & 0xE0) >> 5);
-
-                       ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
-
-                       if ((*rtemp8 & 0x0F) == 0x0F) {
-                               eFuse_Addr++;
-                               ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
-
-                               if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E))
-                                       eFuse_Addr++;
-                               continue;
-                       } else {
-                               offset = ((*rtemp8 & 0xF0) >> 1) | u1temp;
-                               wren = (*rtemp8 & 0x0F);
-                               eFuse_Addr++;
-                       }
-               } else {
-                       offset = ((*rtemp8 >> 4) & 0x0f);
-                       wren = (*rtemp8 & 0x0f);
-               }
-
-               if (offset < EFUSE_MAX_SECTION_88E) {
-                       /*  Get word enable value from PG header */
-
-                       for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
-                               /*  Check word enable condition in the section */
-                               if (!(wren & 0x01)) {
-                                       ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
-                                       eFuse_Addr++;
-                                       efuse_utilized++;
-                                       eFuseWord[offset][i] = (*rtemp8 & 0xff);
-                                       if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E)
-                                               break;
-                                       ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
-                                       eFuse_Addr++;
-                                       efuse_utilized++;
-                                       eFuseWord[offset][i] |= (((u16)*rtemp8 << 8) & 0xff00);
-                                       if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E)
-                                               break;
-                               }
-                               wren >>= 1;
-                       }
-               }
-
-               /*  Read next PG header */
-               ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
-
-               if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) {
-                       efuse_utilized++;
-                       eFuse_Addr++;
-               }
-       }
-
-       /*  3. Collect 16 sections and 4 word unit into Efuse map. */
-       for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) {
-               for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) {
-                       efuseTbl[(i * 8) + (j * 2)] = (eFuseWord[i][j] & 0xff);
-                       efuseTbl[(i * 8) + ((j * 2) + 1)] = ((eFuseWord[i][j] >> 8) & 0xff);
-               }
-       }
-
-       /*  4. Copy from Efuse map to output pointer memory!!! */
-       for (i = 0; i < _size_byte; i++)
-               pbuf[i] = efuseTbl[_offset + i];
-
-exit:
-       kfree(efuseTbl);
-       kfree(eFuseWord);
-}
-
-void rtl8188e_ReadEFuse(struct adapter *Adapter, u16 _size_byte, u8 *pbuf)
-{
-       int ret = _FAIL;
-       if (rtw_IOL_applied(Adapter)) {
-               rtl8188eu_InitPowerOn(Adapter);
-
-               iol_mode_enable(Adapter, 1);
-               ret = iol_read_efuse(Adapter, _size_byte, pbuf);
-               iol_mode_enable(Adapter, 0);
-
-               if (_SUCCESS == ret)
-                       return;
-       }
-
-       Hal_EfuseReadEFuse88E(Adapter, 0, _size_byte, pbuf);
-}
-
-static void dump_chip_info(struct adapter *adapter, struct HAL_VERSION chip_vers)
-{
-       struct net_device *netdev = adapter->pnetdev;
-       char *cut = NULL;
-       char buf[25];
-
-       switch (chip_vers.CUTVersion) {
-       case A_CUT_VERSION:
-               cut = "A_CUT";
-               break;
-       case B_CUT_VERSION:
-               cut = "B_CUT";
-               break;
-       case C_CUT_VERSION:
-               cut = "C_CUT";
-               break;
-       case D_CUT_VERSION:
-               cut = "D_CUT";
-               break;
-       case E_CUT_VERSION:
-               cut = "E_CUT";
-               break;
-       default:
-               snprintf(buf, sizeof(buf), "UNKNOWN_CUT(%d)", chip_vers.CUTVersion);
-               cut = buf;
-               break;
-       }
-
-       netdev_dbg(netdev, "Chip Version Info: CHIP_8188E_%s_%s_%s_1T1R_RomVer(%d)\n",
-                  IS_NORMAL_CHIP(chip_vers) ? "Normal_Chip" : "Test_Chip",
-                  IS_CHIP_VENDOR_TSMC(chip_vers) ? "TSMC" : "UMC",
-                  cut, 0);
-}
-
-void rtl8188e_read_chip_version(struct adapter *padapter)
-{
-       u32                             value32;
-       struct HAL_VERSION              ChipVersion;
-       struct hal_data_8188e *pHalData = &padapter->haldata;
-       int res;
-
-       res = rtw_read32(padapter, REG_SYS_CFG, &value32);
-       if (res)
-               return;
-
-       ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP);
-
-       ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC);
-       ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK) >> CHIP_VER_RTL_SHIFT; /*  IC version (CUT) */
-
-       dump_chip_info(padapter, ChipVersion);
-
-       pHalData->VersionID = ChipVersion;
-}
-
-void rtl8188e_SetHalODMVar(struct adapter *Adapter, void *pValue1, bool bSet)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       struct odm_dm_struct *podmpriv = &pHalData->odmpriv;
-       struct sta_info *psta = (struct sta_info *)pValue1;
-
-       if (bSet) {
-               podmpriv->pODM_StaInfo[psta->mac_id] = psta;
-               ODM_RAInfo_Init(podmpriv, psta->mac_id);
-       } else {
-               podmpriv->pODM_StaInfo[psta->mac_id] = NULL;
-       }
-}
-
-void hal_notch_filter_8188e(struct adapter *adapter, bool enable)
-{
-       int res;
-       u8 reg;
-
-       res = rtw_read8(adapter, rOFDM0_RxDSP + 1, &reg);
-       if (res)
-               return;
-
-       if (enable)
-               rtw_write8(adapter, rOFDM0_RxDSP + 1, reg | BIT(1));
-       else
-               rtw_write8(adapter, rOFDM0_RxDSP + 1, reg & ~BIT(1));
-}
-
-/*  */
-/*  */
-/*  LLT R/W/Init function */
-/*  */
-/*  */
-static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data)
-{
-       s32     count;
-       u32     value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS);
-       u16     LLTReg = REG_LLT_INIT;
-       int res;
-
-       rtw_write32(padapter, LLTReg, value);
-
-       /* polling */
-       for (count = 0; count <= POLLING_LLT_THRESHOLD; count++) {
-               res = rtw_read32(padapter, LLTReg, &value);
-               if (res)
-                       continue;
-
-               if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value))
-                       break;
-       }
-
-       return count > POLLING_LLT_THRESHOLD ? _FAIL : _SUCCESS;
-}
-
-s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy)
-{
-       s32     status = _FAIL;
-       u32     i;
-       u32     Last_Entry_Of_TxPktBuf = LAST_ENTRY_OF_TX_PKT_BUFFER;/*  176, 22k */
-
-       if (rtw_IOL_applied(padapter)) {
-               status = iol_InitLLTTable(padapter, txpktbuf_bndy);
-       } else {
-               for (i = 0; i < (txpktbuf_bndy - 1); i++) {
-                       status = _LLTWrite(padapter, i, i + 1);
-                       if (_SUCCESS != status)
-                               return status;
-               }
-
-               /*  end of list */
-               status = _LLTWrite(padapter, (txpktbuf_bndy - 1), 0xFF);
-               if (_SUCCESS != status)
-                       return status;
-
-               /*  Make the other pages as ring buffer */
-               /*  This ring buffer is used as beacon buffer if we config this MAC as two MAC transfer. */
-               /*  Otherwise used as local loopback buffer. */
-               for (i = txpktbuf_bndy; i < Last_Entry_Of_TxPktBuf; i++) {
-                       status = _LLTWrite(padapter, i, (i + 1));
-                       if (_SUCCESS != status)
-                               return status;
-               }
-
-               /*  Let last entry point to the start entry of ring buffer */
-               status = _LLTWrite(padapter, Last_Entry_Of_TxPktBuf, txpktbuf_bndy);
-               if (_SUCCESS != status) {
-                       return status;
-               }
-       }
-
-       return status;
-}
-
-void Hal_EfuseParseIDCode88E(struct adapter *padapter, u8 *hwinfo)
-{
-       struct eeprom_priv *pEEPROM = &padapter->eeprompriv;
-       struct net_device *netdev = padapter->pnetdev;
-       u16                     EEPROMId;
-
-       /*  Check 0x8129 again for making sure autoload status!! */
-       EEPROMId = le16_to_cpu(*((__le16 *)hwinfo));
-       if (EEPROMId != RTL_EEPROM_ID) {
-               pr_err("EEPROM ID(%#x) is invalid!!\n", EEPROMId);
-               pEEPROM->bautoload_fail_flag = true;
-       } else {
-               pEEPROM->bautoload_fail_flag = false;
-       }
-
-       netdev_dbg(netdev, "EEPROM ID = 0x%04x\n", EEPROMId);
-}
-
-static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, u8 *PROMContent, bool AutoLoadFail)
-{
-       u32 rfPath, eeAddr = EEPROM_TX_PWR_INX_88E, group, TxCount = 0;
-
-       memset(pwrInfo24G, 0, sizeof(struct txpowerinfo24g));
-
-       if (AutoLoadFail) {
-               for (rfPath = 0; rfPath < RF_PATH_MAX; rfPath++) {
-                       /* 2.4G default value */
-                       for (group = 0; group < MAX_CHNL_GROUP_24G; group++) {
-                               pwrInfo24G->IndexCCK_Base[rfPath][group] =      EEPROM_DEFAULT_24G_INDEX;
-                               pwrInfo24G->IndexBW40_Base[rfPath][group] =     EEPROM_DEFAULT_24G_INDEX;
-                       }
-                       for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) {
-                               if (TxCount == 0) {
-                                       pwrInfo24G->BW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF;
-                                       pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF;
-                               } else {
-                                       pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
-                                       pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
-                                       pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
-                                       pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
-                               }
-                       }
-               }
-               return;
-       }
-
-       for (rfPath = 0; rfPath < RF_PATH_MAX; rfPath++) {
-               /* 2.4G default value */
-               for (group = 0; group < MAX_CHNL_GROUP_24G; group++) {
-                       pwrInfo24G->IndexCCK_Base[rfPath][group] =      PROMContent[eeAddr++];
-                       if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF)
-                               pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX;
-               }
-               for (group = 0; group < MAX_CHNL_GROUP_24G - 1; group++) {
-                       pwrInfo24G->IndexBW40_Base[rfPath][group] =     PROMContent[eeAddr++];
-                       if (pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF)
-                               pwrInfo24G->IndexBW40_Base[rfPath][group] =     EEPROM_DEFAULT_24G_INDEX;
-               }
-               for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) {
-                       if (TxCount == 0) {
-                               pwrInfo24G->BW40_Diff[rfPath][TxCount] = 0;
-                               if (PROMContent[eeAddr] == 0xFF) {
-                                       pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF;
-                               } else {
-                                       pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0xf0) >> 4;
-                                       if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT(3))            /* 4bit sign number to 8 bit sign number */
-                                               pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0;
-                               }
-
-                               if (PROMContent[eeAddr] == 0xFF) {
-                                       pwrInfo24G->OFDM_Diff[rfPath][TxCount] =        EEPROM_DEFAULT_24G_OFDM_DIFF;
-                               } else {
-                                       pwrInfo24G->OFDM_Diff[rfPath][TxCount] =        (PROMContent[eeAddr] & 0x0f);
-                                       if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT(3))            /* 4bit sign number to 8 bit sign number */
-                                               pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0;
-                               }
-                               pwrInfo24G->CCK_Diff[rfPath][TxCount] = 0;
-                               eeAddr++;
-                       } else {
-                               if (PROMContent[eeAddr] == 0xFF) {
-                                       pwrInfo24G->BW40_Diff[rfPath][TxCount] =        EEPROM_DEFAULT_DIFF;
-                               } else {
-                                       pwrInfo24G->BW40_Diff[rfPath][TxCount] =        (PROMContent[eeAddr] & 0xf0) >> 4;
-                                       if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT(3))            /* 4bit sign number to 8 bit sign number */
-                                               pwrInfo24G->BW40_Diff[rfPath][TxCount] |= 0xF0;
-                               }
-
-                               if (PROMContent[eeAddr] == 0xFF) {
-                                       pwrInfo24G->BW20_Diff[rfPath][TxCount] =        EEPROM_DEFAULT_DIFF;
-                               } else {
-                                       pwrInfo24G->BW20_Diff[rfPath][TxCount] =        (PROMContent[eeAddr] & 0x0f);
-                                       if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT(3))            /* 4bit sign number to 8 bit sign number */
-                                               pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0;
-                               }
-                               eeAddr++;
-
-                               if (PROMContent[eeAddr] == 0xFF) {
-                                       pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
-                               } else {
-                                       pwrInfo24G->OFDM_Diff[rfPath][TxCount] =        (PROMContent[eeAddr] & 0xf0) >> 4;
-                                       if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT(3))            /* 4bit sign number to 8 bit sign number */
-                                               pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0;
-                               }
-
-                               if (PROMContent[eeAddr] == 0xFF) {
-                                       pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
-                               } else {
-                                       pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0x0f);
-                                       if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT(3))             /* 4bit sign number to 8 bit sign number */
-                                               pwrInfo24G->CCK_Diff[rfPath][TxCount] |= 0xF0;
-                               }
-                               eeAddr++;
-                       }
-               }
-       }
-}
-
-static void hal_get_chnl_group_88e(u8 chnl, u8 *group)
-{
-       if (chnl < 3)                   /*  Channel 1-2 */
-               *group = 0;
-       else if (chnl < 6)              /*  Channel 3-5 */
-               *group = 1;
-       else if (chnl < 9)              /*  Channel 6-8 */
-               *group = 2;
-       else if (chnl < 12)             /*  Channel 9-11 */
-               *group = 3;
-       else if (chnl < 14)             /*  Channel 12-13 */
-               *group = 4;
-       else if (chnl == 14)            /*  Channel 14 */
-               *group = 5;
-}
-
-void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail)
-{
-       if (AutoLoadFail)
-               padapter->pwrctrlpriv.bSupportRemoteWakeup = false;
-       else
-               /* hw power down mode selection , 0:rf-off / 1:power down */
-
-               /*  decide hw if support remote wakeup function */
-               /*  if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */
-               padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT(1)) ? true : false;
-}
-
-void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool AutoLoadFail)
-{
-       struct hal_data_8188e *pHalData = &padapter->haldata;
-       struct txpowerinfo24g pwrInfo24G;
-       u8 ch, group;
-       u8 TxCount;
-
-       Hal_ReadPowerValueFromPROM_8188E(&pwrInfo24G, PROMContent, AutoLoadFail);
-
-       for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) {
-               hal_get_chnl_group_88e(ch, &group);
-
-               pHalData->Index24G_CCK_Base[ch] = pwrInfo24G.IndexCCK_Base[0][group];
-               if (ch == 14)
-                       pHalData->Index24G_BW40_Base[ch] = pwrInfo24G.IndexBW40_Base[0][4];
-               else
-                       pHalData->Index24G_BW40_Base[ch] = pwrInfo24G.IndexBW40_Base[0][group];
-       }
-       for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) {
-               pHalData->OFDM_24G_Diff[TxCount] = pwrInfo24G.OFDM_Diff[0][TxCount];
-               pHalData->BW20_24G_Diff[TxCount] = pwrInfo24G.BW20_Diff[0][TxCount];
-       }
-
-       /*  2010/10/19 MH Add Regulator recognize for CU. */
-       if (!AutoLoadFail) {
-               pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_88E] & 0x7);   /* bit0~2 */
-               if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF)
-                       pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION & 0x7);       /* bit0~2 */
-       } else {
-               pHalData->EEPROMRegulatory = 0;
-       }
-}
-
-void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail)
-{
-       struct hal_data_8188e *pHalData = &pAdapter->haldata;
-
-       if (!AutoLoadFail) {
-               pHalData->CrystalCap = hwinfo[EEPROM_XTAL_88E];
-               if (pHalData->CrystalCap == 0xFF)
-                       pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E;
-       } else {
-               pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E;
-       }
-}
-
-void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail)
-{
-       padapter->mlmepriv.ChannelPlan =
-                hal_com_get_channel_plan(padapter,
-                                         hwinfo ? hwinfo[EEPROM_ChannelPlan_88E] : 0xFF,
-                                         padapter->registrypriv.channel_plan,
-                                         RT_CHANNEL_DOMAIN_WORLD_WIDE_13, AutoLoadFail);
-}
-
-void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool AutoLoadFail)
-{
-       struct hal_data_8188e *pHalData = &pAdapter->haldata;
-       struct registry_priv    *registry_par = &pAdapter->registrypriv;
-
-       if (!AutoLoadFail) {
-               /*  Antenna Diversity setting. */
-               if (registry_par->antdiv_cfg == 2) { /*  2:By EFUSE */
-                       pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E] & 0x18) >> 3;
-                       if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF)
-                               pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION & 0x18) >> 3;
-               } else {
-                       pHalData->AntDivCfg = registry_par->antdiv_cfg;  /*  0:OFF , 1:ON, 2:By EFUSE */
-               }
-
-               if (registry_par->antdiv_type == 0) {
-                       /* If TRxAntDivType is AUTO in advanced setting, use EFUSE value instead. */
-                       pHalData->TRxAntDivType = PROMContent[EEPROM_RF_ANTENNA_OPT_88E];
-                       if (pHalData->TRxAntDivType == 0xFF)
-                               pHalData->TRxAntDivType = CG_TRX_HW_ANTDIV; /*  For 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */
-               } else {
-                       pHalData->TRxAntDivType = registry_par->antdiv_type;
-               }
-
-               if (pHalData->TRxAntDivType == CG_TRX_HW_ANTDIV || pHalData->TRxAntDivType == CGCS_RX_HW_ANTDIV)
-                       pHalData->AntDivCfg = 1; /*  0xC1[3] is ignored. */
-       } else {
-               pHalData->AntDivCfg = 0;
-       }
-}
-
-void Hal_ReadThermalMeter_88E(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-
-       /*  ThermalMeter from EEPROM */
-       if (!AutoloadFail)
-               pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_88E];
-       else
-               pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E;
-
-       if (pHalData->EEPROMThermalMeter == 0xff || AutoloadFail)
-               pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E;
-}
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
deleted file mode 100644 (file)
index f4edf4a..0000000
+++ /dev/null
@@ -1,705 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _RTL8188E_PHYCFG_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/rtw_iol.h"
-#include "../include/rtl8188e_hal.h"
-
-/*  */
-/*  1. BB register R/W API */
-/*  */
-
-/* Get shifted position of the bit mask */
-static u32 phy_calculate_bit_shift(u32 bitmask)
-{
-       u32 i = ffs(bitmask);
-
-       return i ? i - 1 : 32;
-}
-
-/**
-* Function:    PHY_QueryBBReg
-*
-* Overview:    Read "sepcific bits" from BB register
-*
-* Input:
-*                      struct adapter *Adapter,
-*                      u32                     RegAddr,        The target address to be readback
-*                      u32                     BitMask         The target bit position in the target address
-*                                                              to be readback
-* Output:      None
-* Return:              u32                     Data            The readback register value
-* Note:                This function is equal to "GetRegSetting" in PHY programming guide
-*/
-u32
-rtl8188e_PHY_QueryBBReg(
-               struct adapter *Adapter,
-               u32 RegAddr,
-               u32 BitMask
-       )
-{
-       u32 ReturnValue = 0, OriginalValue, BitShift;
-       int res;
-
-       res = rtw_read32(Adapter, RegAddr, &OriginalValue);
-       if (res)
-               return 0;
-
-       BitShift = phy_calculate_bit_shift(BitMask);
-       ReturnValue = (OriginalValue & BitMask) >> BitShift;
-       return ReturnValue;
-}
-
-/**
-* Function:    PHY_SetBBReg
-*
-* Overview:    Write "Specific bits" to BB register (page 8~)
-*
-* Input:
-*                      struct adapter *Adapter,
-*                      u32                     RegAddr,        The target address to be modified
-*                      u32                     BitMask         The target bit position in the target address
-*                                                                      to be modified
-*                      u32                     Data            The new register value in the target bit position
-*                                                                      of the target address
-*
-* Output:      None
-* Return:              None
-* Note:                This function is equal to "PutRegSetting" in PHY programming guide
-*/
-
-void rtl8188e_PHY_SetBBReg(struct adapter *Adapter, u32 RegAddr, u32 BitMask, u32 Data)
-{
-       u32 OriginalValue, BitShift;
-       int res;
-
-       if (BitMask != bMaskDWord) { /* if not "double word" write */
-               res = rtw_read32(Adapter, RegAddr, &OriginalValue);
-               if (res)
-                       return;
-
-               BitShift = phy_calculate_bit_shift(BitMask);
-               Data = ((OriginalValue & (~BitMask)) | (Data << BitShift));
-       }
-
-       rtw_write32(Adapter, RegAddr, Data);
-}
-
-/*  */
-/*  2. RF register R/W API */
-/*  */
-/**
-* Function:    phy_RFSerialRead
-*
-* Overview:    Read register from RF chips
-*
-* Input:
-*                      struct adapter *Adapter,
-*                      u32                     Offset,         The target address to be read
-*
-* Output:      None
-* Return:              u32                     reback value
-* Note:                Threre are three types of serial operations:
-*                      1. Software serial write
-*                      2. Hardware LSSI-Low Speed Serial Interface
-*                      3. Hardware HSSI-High speed
-*                      serial write. Driver need to implement (1) and (2).
-*                      This function is equal to the combination of RF_ReadReg() and  RFLSSIRead()
-*/
-static u32
-phy_RFSerialRead(
-               struct adapter *Adapter,
-               u32 Offset
-       )
-{
-       u32 retValue = 0;
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       struct bb_reg_def *pPhyReg = &pHalData->PHYRegDef;
-       u32 NewOffset;
-       u32 tmplong, tmplong2;
-       u8      RfPiEnable = 0;
-       /*  */
-       /*  Make sure RF register offset is correct */
-       /*  */
-       Offset &= 0xff;
-
-       /*  */
-       /*  Switch page for 8256 RF IC */
-       /*  */
-       NewOffset = Offset;
-
-       /*  For 92S LSSI Read RFLSSIRead */
-       /*  For RF A/B write 0x824/82c(does not work in the future) */
-       /*  We must use 0x824 for RF A and B to execute read trigger */
-       tmplong = rtl8188e_PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord);
-       tmplong2 = tmplong;
-
-       tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | (NewOffset << 23) | bLSSIReadEdge;        /* T65 RF */
-
-       rtl8188e_PHY_SetBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord, tmplong & (~bLSSIReadEdge));
-       udelay(10);/*  PlatformStallExecution(10); */
-
-       rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord, tmplong2);
-       udelay(100);/* PlatformStallExecution(100); */
-
-       udelay(10);/* PlatformStallExecution(10); */
-
-       RfPiEnable = (u8)rtl8188e_PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter1, BIT(8));
-
-       if (RfPiEnable) {       /*  Read from BBreg8b8, 12 bits for 8190, 20bits for T65 RF */
-               retValue = rtl8188e_PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBackPi, bLSSIReadBackData);
-       } else {        /* Read from BBreg8a0, 12 bits for 8190, 20 bits for T65 RF */
-               retValue = rtl8188e_PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBack, bLSSIReadBackData);
-       }
-       return retValue;
-}
-
-/**
-* Function:    phy_RFSerialWrite
-*
-* Overview:    Write data to RF register (page 8~)
-*
-* Input:
-*                      struct adapter *Adapter,
-*                      enum rf_radio_path eRFPath,     Radio path of A/B/C/D
-*                      u32                     Offset,         The target address to be read
-*                      u32                     Data            The new register Data in the target bit position
-*                                                                      of the target to be read
-*
-* Output:      None
-* Return:              None
-* Note:                Threre are three types of serial operations:
-*                      1. Software serial write
-*                      2. Hardware LSSI-Low Speed Serial Interface
-*                      3. Hardware HSSI-High speed
-*                      serial write. Driver need to implement (1) and (2).
-*                      This function is equal to the combination of RF_ReadReg() and  RFLSSIRead()
- *
- * Note:                 For RF8256 only
- *                      The total count of RTL8256(Zebra4) register is around 36 bit it only employs
- *                      4-bit RF address. RTL8256 uses "register mode control bit" (Reg00[12], Reg00[10])
- *                      to access register address bigger than 0xf. See "Appendix-4 in PHY Configuration
- *                      programming guide" for more details.
- *                      Thus, we define a sub-finction for RTL8526 register address conversion
- *                    ===========================================================
- *                      Register Mode          RegCTL[1]               RegCTL[0]               Note
- *                                                             (Reg00[12])             (Reg00[10])
- *                    ===========================================================
- *                      Reg_Mode0                              0                               x                       Reg 0 ~15(0x0 ~ 0xf)
- *                    ------------------------------------------------------------------
- *                      Reg_Mode1                              1                               0                       Reg 16 ~30(0x1 ~ 0xf)
- *                    ------------------------------------------------------------------
- *                      Reg_Mode2                              1                               1                       Reg 31 ~ 45(0x1 ~ 0xf)
- *                    ------------------------------------------------------------------
- *
- *     2008/09/02      MH      Add 92S RF definition
- *
- *
- *
-*/
-static void
-phy_RFSerialWrite(
-               struct adapter *Adapter,
-               u32 Offset,
-               u32 Data
-       )
-{
-       u32 DataAndAddr = 0;
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       struct bb_reg_def *pPhyReg = &pHalData->PHYRegDef;
-       u32 NewOffset;
-
-       /*  2009/06/17 MH We can not execute IO for power save or other accident mode. */
-
-       Offset &= 0xff;
-
-       /*  */
-       /*  Switch page for 8256 RF IC */
-       /*  */
-       NewOffset = Offset;
-
-       /*  */
-       /*  Put write addr in [5:0]  and write data in [31:16] */
-       /*  */
-       DataAndAddr = ((NewOffset << 20) | (Data & 0x000fffff)) & 0x0fffffff;   /*  T65 RF */
-
-       /*  */
-       /*  Write Operation */
-       /*  */
-       rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr);
-}
-
-/**
-* Function:    PHY_QueryRFReg
-*
-* Overview:    Query "Specific bits" to RF register (page 8~)
-*
-* Input:
-*                      struct adapter *Adapter,
-*                      u32                     RegAddr,        The target address to be read
-*                      u32                     BitMask         The target bit position in the target address
-*                                                                      to be read
-*
-* Output:      None
-* Return:              u32                     Readback value
-* Note:                This function is equal to "GetRFRegSetting" in PHY programming guide
-*/
-u32 rtl8188e_PHY_QueryRFReg(struct adapter *Adapter, u32 RegAddr, u32 BitMask)
-{
-       u32 Original_Value, Readback_Value, BitShift;
-
-       Original_Value = phy_RFSerialRead(Adapter, RegAddr);
-
-       BitShift =  phy_calculate_bit_shift(BitMask);
-       Readback_Value = (Original_Value & BitMask) >> BitShift;
-       return Readback_Value;
-}
-
-/**
-* Function:    PHY_SetRFReg
-*
-* Overview:    Write "Specific bits" to RF register (page 8~)
-*
-* Input:
-*                      struct adapter *Adapter,
-*                      u32                     RegAddr,        The target address to be modified
-*                      u32                     BitMask         The target bit position in the target address
-*                                                                      to be modified
-*                      u32                     Data            The new register Data in the target bit position
-*                                                                      of the target address
-*
-* Output:      None
-* Return:              None
-* Note:                This function is equal to "PutRFRegSetting" in PHY programming guide
-*/
-void
-rtl8188e_PHY_SetRFReg(
-               struct adapter *Adapter,
-               u32 RegAddr,
-               u32 BitMask,
-               u32 Data
-       )
-{
-       u32 Original_Value, BitShift;
-
-       /*  RF data is 12 bits only */
-       if (BitMask != bRFRegOffsetMask) {
-               Original_Value = phy_RFSerialRead(Adapter, RegAddr);
-               BitShift =  phy_calculate_bit_shift(BitMask);
-               Data = ((Original_Value & (~BitMask)) | (Data << BitShift));
-       }
-
-       phy_RFSerialWrite(Adapter, RegAddr, Data);
-}
-
-/*  */
-/*  3. Initial MAC/BB/RF config by reading MAC/BB/RF txt. */
-/*  */
-
-/*-----------------------------------------------------------------------------
- * Function:    PHY_MACConfig8192C
- *
- * Overview:   Condig MAC by header file or parameter file.
- *
- * Input:       NONE
- *
- * Output:      NONE
- *
- * Return:      NONE
- *
- * Revised History:
- *  When               Who             Remark
- *  08/12/2008 MHC             Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-int PHY_MACConfig8188E(struct adapter *Adapter)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       int err;
-
-       /*  */
-       /*  Config MAC */
-       /*  */
-       err = ODM_ReadAndConfig_MAC_REG_8188E(&pHalData->odmpriv);
-
-       /*  2010.07.13 AMPDU aggregation number B */
-       rtw_write16(Adapter, REG_MAX_AGGR_NUM, MAX_AGGR_NUM);
-
-       return err;
-}
-
-/**
-* Function:    phy_InitBBRFRegisterDefinition
-*
-* Overview:    Initialize Register definition offset for Radio Path A/B/C/D
-*
-* Input:
-*                      struct adapter *Adapter,
-*
-* Output:      None
-* Return:              None
-* Note:                The initialization value is constant and it should never be changes
-*/
-static void
-phy_InitBBRFRegisterDefinition(
-               struct adapter *Adapter
-)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-
-       /*  RF Interface Sowrtware Control */
-       pHalData->PHYRegDef.rfintfs = rFPGA0_XAB_RFInterfaceSW; /*  16 LSBs if read 32-bit from 0x870 */
-
-       /*  RF Interface Readback Value */
-       pHalData->PHYRegDef.rfintfi = rFPGA0_XAB_RFInterfaceRB; /*  16 LSBs if read 32-bit from 0x8E0 */
-
-       /*  RF Interface Output (and Enable) */
-       pHalData->PHYRegDef.rfintfo = rFPGA0_XA_RFInterfaceOE; /*  16 LSBs if read 32-bit from 0x860 */
-
-       /*  RF Interface (Output and)  Enable */
-       pHalData->PHYRegDef.rfintfe = rFPGA0_XA_RFInterfaceOE; /*  16 MSBs if read 32-bit from 0x860 (16-bit for 0x862) */
-
-       /* Addr of LSSI. Write RF register by driver */
-       pHalData->PHYRegDef.rf3wireOffset = rFPGA0_XA_LSSIParameter; /* LSSI Parameter */
-
-       /*  RF parameter */
-       pHalData->PHYRegDef.rfLSSI_Select = rFPGA0_XAB_RFParameter;  /* BB Band Select */
-
-       /*  Tx AGC Gain Stage (same for all path. Should we remove this?) */
-       pHalData->PHYRegDef.rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */
-
-       /*  Transceiver A~D HSSI Parameter-1 */
-       pHalData->PHYRegDef.rfHSSIPara1 = rFPGA0_XA_HSSIParameter1;  /* wire control parameter1 */
-
-       /*  Transceiver A~D HSSI Parameter-2 */
-       pHalData->PHYRegDef.rfHSSIPara2 = rFPGA0_XA_HSSIParameter2;  /* wire control parameter2 */
-
-       /*  RF switch Control */
-       pHalData->PHYRegDef.rfSwitchControl = rFPGA0_XAB_SwitchControl; /* TR/Ant switch control */
-
-       /*  AGC control 1 */
-       pHalData->PHYRegDef.rfAGCControl1 = rOFDM0_XAAGCCore1;
-
-       /*  AGC control 2 */
-       pHalData->PHYRegDef.rfAGCControl2 = rOFDM0_XAAGCCore2;
-
-       /*  RX AFE control 1 */
-       pHalData->PHYRegDef.rfRxIQImbalance = rOFDM0_XARxIQImbalance;
-
-       /*  RX AFE control 1 */
-       pHalData->PHYRegDef.rfRxAFE = rOFDM0_XARxAFE;
-
-       /*  Tx AFE control 1 */
-       pHalData->PHYRegDef.rfTxIQImbalance = rOFDM0_XATxIQImbalance;
-
-       /*  Tx AFE control 2 */
-       pHalData->PHYRegDef.rfTxAFE = rOFDM0_XATxAFE;
-
-       /*  Transceiver LSSI Readback SI mode */
-       pHalData->PHYRegDef.rfLSSIReadBack = rFPGA0_XA_LSSIReadBack;
-
-       /*  Transceiver LSSI Readback PI mode */
-       pHalData->PHYRegDef.rfLSSIReadBackPi = TransceiverA_HSPI_Readback;
-}
-
-void storePwrIndexDiffRateOffset(struct adapter *Adapter, u32 RegAddr, u32 BitMask, u32 Data)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-
-       if (RegAddr == rTxAGC_A_Rate18_06)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][0] = Data;
-       if (RegAddr == rTxAGC_A_Rate54_24)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][1] = Data;
-       if (RegAddr == rTxAGC_A_CCK1_Mcs32)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][6] = Data;
-       if (RegAddr == rTxAGC_B_CCK11_A_CCK2_11 && BitMask == 0xffffff00)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][7] = Data;
-       if (RegAddr == rTxAGC_A_Mcs03_Mcs00)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][2] = Data;
-       if (RegAddr == rTxAGC_A_Mcs07_Mcs04)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][3] = Data;
-       if (RegAddr == rTxAGC_A_Mcs11_Mcs08)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][4] = Data;
-       if (RegAddr == rTxAGC_A_Mcs15_Mcs12) {
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][5] = Data;
-               pHalData->pwrGroupCnt++;
-       }
-       if (RegAddr == rTxAGC_B_Rate18_06)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][8] = Data;
-       if (RegAddr == rTxAGC_B_Rate54_24)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][9] = Data;
-       if (RegAddr == rTxAGC_B_CCK1_55_Mcs32)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][14] = Data;
-       if (RegAddr == rTxAGC_B_CCK11_A_CCK2_11 && BitMask == 0x000000ff)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][15] = Data;
-       if (RegAddr == rTxAGC_B_Mcs03_Mcs00)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][10] = Data;
-       if (RegAddr == rTxAGC_B_Mcs07_Mcs04)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][11] = Data;
-       if (RegAddr == rTxAGC_B_Mcs11_Mcs08)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][12] = Data;
-       if (RegAddr == rTxAGC_B_Mcs15_Mcs12)
-               pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][13] = Data;
-}
-
-static int phy_BB8188E_Config_ParaFile(struct adapter *Adapter)
-{
-       struct eeprom_priv *pEEPROM = &Adapter->eeprompriv;
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       int err;
-
-       /*  */
-       /*  1. Read PHY_REG.TXT BB INIT!! */
-       /*  We will separate as 88C / 92C according to chip version */
-       /*  */
-       err = ODM_ReadAndConfig_PHY_REG_1T_8188E(&pHalData->odmpriv);
-       if (err)
-               return err;
-
-       /*  2. If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */
-       if (!pEEPROM->bautoload_fail_flag) {
-               pHalData->pwrGroupCnt = 0;
-               ODM_ReadAndConfig_PHY_REG_PG_8188E(&pHalData->odmpriv);
-       }
-
-       /*  3. BB AGC table Initialization */
-       err = ODM_ReadAndConfig_AGC_TAB_1T_8188E(&pHalData->odmpriv);
-       if (err)
-               return err;
-
-       return 0;
-}
-
-int
-PHY_BBConfig8188E(
-               struct adapter *Adapter
-       )
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       u16 RegVal;
-       u8 CrystalCap;
-       int err;
-
-       phy_InitBBRFRegisterDefinition(Adapter);
-
-       /*  Enable BB and RF */
-       err = rtw_read16(Adapter, REG_SYS_FUNC_EN, &RegVal);
-       if (err)
-               return err;
-
-       rtw_write16(Adapter, REG_SYS_FUNC_EN, (u16)(RegVal | BIT(13) | BIT(0) | BIT(1)));
-
-       /*  20090923 Joseph: Advised by Steven and Jenyu. Power sequence before init RF. */
-
-       rtw_write8(Adapter, REG_RF_CTRL, RF_EN | RF_RSTB | RF_SDMRSTB);
-
-       rtw_write8(Adapter, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB);
-
-       /*  Config BB and AGC */
-       err = phy_BB8188E_Config_ParaFile(Adapter);
-
-       /*  write 0x24[16:11] = 0x24[22:17] = CrystalCap */
-       CrystalCap = pHalData->CrystalCap & 0x3F;
-       rtl8188e_PHY_SetBBReg(Adapter, REG_AFE_XTAL_CTRL, 0x7ff800, (CrystalCap | (CrystalCap << 6)));
-
-       return err;
-}
-
-static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel,
-                              u8 *ofdmPowerLevel, u8 *BW20PowerLevel,
-                              u8 *BW40PowerLevel)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       u8 index = (channel - 1);
-
-       /*  1. CCK */
-       cckPowerLevel[RF_PATH_A] = pHalData->Index24G_CCK_Base[index];
-       /* 2. OFDM */
-       ofdmPowerLevel[RF_PATH_A] = pHalData->Index24G_BW40_Base[index] +
-               pHalData->OFDM_24G_Diff[RF_PATH_A];
-       /*  1. BW20 */
-       BW20PowerLevel[RF_PATH_A] = pHalData->Index24G_BW40_Base[index] +
-               pHalData->BW20_24G_Diff[RF_PATH_A];
-       /* 2. BW40 */
-       BW40PowerLevel[RF_PATH_A] = pHalData->Index24G_BW40_Base[index];
-}
-
-/*-----------------------------------------------------------------------------
- * Function:    SetTxPowerLevel8190()
- *
- * Overview:    This function is export to "HalCommon" moudule
- *                     We must consider RF path later!!!!!!!
- *
- * Input:       struct adapter *Adapter
- *                     u8              channel
- *
- * Output:      NONE
- *
- * Return:      NONE
- *     2008/11/04      MHC             We remove EEPROM_93C56.
- *                                             We need to move CCX relative code to independet file.
- *     2009/01/21      MHC             Support new EEPROM format from SD3 requirement.
- *
- *---------------------------------------------------------------------------*/
-void
-PHY_SetTxPowerLevel8188E(
-               struct adapter *Adapter,
-               u8 channel
-       )
-{
-       u8 cckPowerLevel[MAX_TX_COUNT] = {0};
-       u8 ofdmPowerLevel[MAX_TX_COUNT] = {0};/*  [0]:RF-A, [1]:RF-B */
-       u8 BW20PowerLevel[MAX_TX_COUNT] = {0};
-       u8 BW40PowerLevel[MAX_TX_COUNT] = {0};
-
-       getTxPowerIndex88E(Adapter, channel, &cckPowerLevel[0], &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0]);
-
-       rtl8188e_PHY_RF6052SetCckTxPower(Adapter, &cckPowerLevel[0]);
-       rtl8188e_PHY_RF6052SetOFDMTxPower(Adapter, &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0], channel);
-}
-
-/*-----------------------------------------------------------------------------
- * Function:    PHY_SetBWModeCallback8192C()
- *
- * Overview:    Timer callback function for SetSetBWMode
- *
- * Input:              PRT_TIMER               pTimer
- *
- * Output:      NONE
- *
- * Return:      NONE
- *
- * Note:               (1) We do not take j mode into consideration now
- *                     (2) Will two workitem of "switch channel" and "switch channel bandwidth" run
- *                          concurrently?
- *---------------------------------------------------------------------------*/
-static void
-_PHY_SetBWMode92C(
-               struct adapter *Adapter
-)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       u8 regBwOpMode;
-       u8 regRRSR_RSC;
-       int res;
-
-       if (Adapter->bDriverStopped)
-               return;
-
-       /* 3 */
-       /* 3<1>Set MAC register */
-       /* 3 */
-
-       res = rtw_read8(Adapter, REG_BWOPMODE, &regBwOpMode);
-       if (res)
-               return;
-
-       res = rtw_read8(Adapter, REG_RRSR + 2, &regRRSR_RSC);
-       if (res)
-               return;
-
-       switch (pHalData->CurrentChannelBW) {
-       case HT_CHANNEL_WIDTH_20:
-               regBwOpMode |= BW_OPMODE_20MHZ;
-               /*  2007/02/07 Mark by Emily because we have not verify whether this register works */
-               rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode);
-               break;
-       case HT_CHANNEL_WIDTH_40:
-               regBwOpMode &= ~BW_OPMODE_20MHZ;
-               /*  2007/02/07 Mark by Emily because we have not verify whether this register works */
-               rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode);
-               regRRSR_RSC = (regRRSR_RSC & 0x90) | (pHalData->nCur40MhzPrimeSC << 5);
-               rtw_write8(Adapter, REG_RRSR + 2, regRRSR_RSC);
-               break;
-       default:
-               break;
-       }
-
-       /* 3  */
-       /* 3 <2>Set PHY related register */
-       /* 3 */
-       switch (pHalData->CurrentChannelBW) {
-       /* 20 MHz channel*/
-       case HT_CHANNEL_WIDTH_20:
-               rtl8188e_PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x0);
-               rtl8188e_PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x0);
-               break;
-       /* 40 MHz channel*/
-       case HT_CHANNEL_WIDTH_40:
-               rtl8188e_PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x1);
-               rtl8188e_PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x1);
-               /*  Set Control channel to upper or lower. These settings are required only for 40MHz */
-               rtl8188e_PHY_SetBBReg(Adapter, rCCK0_System, bCCKSideBand, (pHalData->nCur40MhzPrimeSC >> 1));
-               rtl8188e_PHY_SetBBReg(Adapter, rOFDM1_LSTF, 0xC00, pHalData->nCur40MhzPrimeSC);
-               rtl8188e_PHY_SetBBReg(Adapter, 0x818, (BIT(26) | BIT(27)),
-                            (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1);
-               break;
-       default:
-               break;
-       }
-       /* Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315 */
-
-       rtl8188e_PHY_RF6052SetBandwidth(Adapter, pHalData->CurrentChannelBW);
-}
-
- /*-----------------------------------------------------------------------------
- * Function:   SetBWMode8190Pci()
- *
- * Overview:  This function is export to "HalCommon" moudule
- *
- * Input:              struct adapter *Adapter
- *                     enum ht_channel_width Bandwidth 20M or 40M
- *
- * Output:      NONE
- *
- * Return:      NONE
- *
- * Note:               We do not take j mode into consideration now
- *---------------------------------------------------------------------------*/
-void PHY_SetBWMode8188E(struct adapter *Adapter, enum ht_channel_width Bandwidth,      /*  20M or 40M */
-                       unsigned char   Offset)         /*  Upper, Lower, or Don't care */
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       enum ht_channel_width tmpBW = pHalData->CurrentChannelBW;
-
-       pHalData->CurrentChannelBW = Bandwidth;
-
-       pHalData->nCur40MhzPrimeSC = Offset;
-
-       if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved))
-               _PHY_SetBWMode92C(Adapter);
-       else
-               pHalData->CurrentChannelBW = tmpBW;
-}
-
-static void _PHY_SwChnl8192C(struct adapter *Adapter, u8 channel)
-{
-       u32 param1, param2;
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-
-       /* s1. pre common command - CmdID_SetTxPowerLevel */
-       PHY_SetTxPowerLevel8188E(Adapter, channel);
-
-       /* s2. RF dependent command - CmdID_RF_WriteReg, param1=RF_CHNLBW, param2=channel */
-       param1 = RF_CHNLBW;
-       param2 = channel;
-       pHalData->RfRegChnlVal = ((pHalData->RfRegChnlVal & 0xfffffc00) | param2);
-       rtl8188e_PHY_SetRFReg(Adapter, param1, bRFRegOffsetMask, pHalData->RfRegChnlVal);
-}
-
-void PHY_SwChnl8188E(struct adapter *Adapter, u8 channel)
-{
-       /*  Call after initialization */
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-
-       if (channel == 0)
-               channel = 1;
-
-       if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved)) {
-               pHalData->CurrentChannel = channel;
-               _PHY_SwChnl8192C(Adapter, channel);
-       }
-}
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
deleted file mode 100644 (file)
index 1988fb6..0000000
+++ /dev/null
@@ -1,405 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-/******************************************************************************
- *
- *
- * Module:     rtl8192c_rf6052.c       ( Source C File)
- *
- * Note:       Provide RF 6052 series relative API.
- *
- * Function:
- *
- * Export:
- *
- * Abbrev:
- *
- * History:
- * Data                        Who             Remark
- *
- * 09/25/2008  MHC             Create initial version.
- * 11/05/2008  MHC             Add API for tw power setting.
- *
- *
-******************************************************************************/
-
-#define _RTL8188E_RF6052_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/rtl8188e_hal.h"
-
-/*-----------------------------------------------------------------------------
- * Function:    PHY_RF6052SetBandwidth()
- *
- * Overview:    This function is called by SetBWModeCallback8190Pci() only
- *
- * Input:       struct adapter *Adapter
- *                     WIRELESS_BANDWIDTH_E    Bandwidth       20M or 40M
- *
- * Output:      NONE
- *
- * Return:      NONE
- *
- * Note:               For RF type 0222D
- *---------------------------------------------------------------------------*/
-void rtl8188e_PHY_RF6052SetBandwidth(struct adapter *Adapter,
-                                    enum ht_channel_width Bandwidth)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-
-       switch (Bandwidth) {
-       case HT_CHANNEL_WIDTH_20:
-               pHalData->RfRegChnlVal = ((pHalData->RfRegChnlVal & 0xfffff3ff) | BIT(10) | BIT(11));
-               rtl8188e_PHY_SetRFReg(Adapter, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal);
-               break;
-       case HT_CHANNEL_WIDTH_40:
-               pHalData->RfRegChnlVal = ((pHalData->RfRegChnlVal & 0xfffff3ff) | BIT(10));
-               rtl8188e_PHY_SetRFReg(Adapter, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal);
-               break;
-       default:
-               break;
-       }
-}
-
-/*-----------------------------------------------------------------------------
- * Function:   PHY_RF6052SetCckTxPower
- *
- * Overview:
- *
- * Input:       NONE
- *
- * Output:      NONE
- *
- * Return:      NONE
- *
- * Revised History:
- * When                        Who             Remark
- * 11/05/2008  MHC             Simulate 8192series..
- *
- *---------------------------------------------------------------------------*/
-
-void
-rtl8188e_PHY_RF6052SetCckTxPower(
-               struct adapter *Adapter,
-               u8 *pPowerlevel)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
-       u32 TxAGC[2] = {0, 0}, tmpval = 0, pwrtrac_value;
-       u8 idx1, idx2;
-       u8 *ptr;
-       u8 direction;
-
-       if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
-               TxAGC[RF_PATH_A] = 0x3f3f3f3f;
-               TxAGC[RF_PATH_B] = 0x3f3f3f3f;
-
-               for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
-                       TxAGC[idx1] =
-                               pPowerlevel[idx1] | (pPowerlevel[idx1] << 8) |
-                               (pPowerlevel[idx1] << 16) | (pPowerlevel[idx1] << 24);
-               }
-       } else {
-               for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
-                       TxAGC[idx1] =
-                               pPowerlevel[idx1] | (pPowerlevel[idx1] << 8) |
-                               (pPowerlevel[idx1] << 16) | (pPowerlevel[idx1] << 24);
-               }
-               if (pHalData->EEPROMRegulatory == 0) {
-                       tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][6]) +
-                                       (pHalData->MCSTxPowerLevelOriginalOffset[0][7] << 8);
-                       TxAGC[RF_PATH_A] += tmpval;
-
-                       tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][14]) +
-                                       (pHalData->MCSTxPowerLevelOriginalOffset[0][15] << 24);
-                       TxAGC[RF_PATH_B] += tmpval;
-               }
-       }
-       for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
-               ptr = (u8 *)(&TxAGC[idx1]);
-               for (idx2 = 0; idx2 < 4; idx2++) {
-                       if (*ptr > RF6052_MAX_TX_PWR)
-                               *ptr = RF6052_MAX_TX_PWR;
-                       ptr++;
-               }
-       }
-       ODM_TxPwrTrackAdjust88E(&pHalData->odmpriv, 1, &direction, &pwrtrac_value);
-
-       if (direction == 1) {
-               /*  Increase TX power */
-               TxAGC[0] += pwrtrac_value;
-               TxAGC[1] += pwrtrac_value;
-       } else if (direction == 2) {
-               /*  Decrease TX power */
-               TxAGC[0] -=  pwrtrac_value;
-               TxAGC[1] -=  pwrtrac_value;
-       }
-
-       /*  rf-A cck tx power */
-       tmpval = TxAGC[RF_PATH_A] & 0xff;
-       rtl8188e_PHY_SetBBReg(Adapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval);
-       tmpval = TxAGC[RF_PATH_A] >> 8;
-       rtl8188e_PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval);
-
-       /*  rf-B cck tx power */
-       tmpval = TxAGC[RF_PATH_B] >> 24;
-       rtl8188e_PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval);
-       tmpval = TxAGC[RF_PATH_B] & 0x00ffffff;
-       rtl8188e_PHY_SetBBReg(Adapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval);
-}      /* PHY_RF6052SetCckTxPower */
-
-/*  */
-/*  powerbase0 for OFDM rates */
-/*  powerbase1 for HT MCS rates */
-/*  */
-static void getpowerbase88e(struct adapter *Adapter, u8 *pPowerLevelOFDM,
-                           u8 *pPowerLevelBW20, u8 *pPowerLevelBW40, u8 Channel, u32 *OfdmBase, u32 *MCSBase)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       u32 powerBase0, powerBase1;
-       u8 i;
-
-       for (i = 0; i < 2; i++) {
-               powerBase0 = pPowerLevelOFDM[i];
-
-               powerBase0 = (powerBase0 << 24) | (powerBase0 << 16) | (powerBase0 << 8) | powerBase0;
-               *(OfdmBase + i) = powerBase0;
-       }
-
-       /* Check HT20 to HT40 diff */
-       if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
-               powerBase1 = pPowerLevelBW20[0];
-       else
-               powerBase1 = pPowerLevelBW40[0];
-       powerBase1 = (powerBase1 << 24) | (powerBase1 << 16) | (powerBase1 << 8) | powerBase1;
-       *MCSBase = powerBase1;
-}
-
-static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel,
-                                   u8 index, u32 *powerBase0, u32 *powerBase1,
-                                   u32 *pOutWriteVal)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       u8      i, chnlGroup = 0, pwr_diff_limit[4], customer_pwr_limit;
-       s8      pwr_diff = 0;
-       u32     writeVal, customer_limit, rf;
-       u8      Regulatory = pHalData->EEPROMRegulatory;
-
-       /*  Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate */
-
-       for (rf = 0; rf < 2; rf++) {
-               switch (Regulatory) {
-               case 0: /*  Realtek better performance */
-                               /*  increase power diff defined by Realtek for large power */
-                       chnlGroup = 0;
-                       writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] +
-                               ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
-                       break;
-               case 1: /*  Realtek regulatory */
-                       /*  increase power diff defined by Realtek for regulatory */
-                       if (pHalData->pwrGroupCnt == 1)
-                               chnlGroup = 0;
-                       if (pHalData->pwrGroupCnt >= MAX_PG_GROUP) {
-                               if (Channel < 3)                        /*  Channel 1-2 */
-                                       chnlGroup = 0;
-                               else if (Channel < 6)           /*  Channel 3-5 */
-                                       chnlGroup = 1;
-                               else     if (Channel < 9)               /*  Channel 6-8 */
-                                       chnlGroup = 2;
-                               else if (Channel < 12)          /*  Channel 9-11 */
-                                       chnlGroup = 3;
-                               else if (Channel < 14)          /*  Channel 12-13 */
-                                       chnlGroup = 4;
-                               else if (Channel == 14)         /*  Channel 14 */
-                                       chnlGroup = 5;
-                       }
-                       writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] +
-                                       ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
-                       break;
-               case 2: /*  Better regulatory */
-                               /*  don't increase any power diff */
-                       writeVal = ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
-                       break;
-               case 3: /*  Customer defined power diff. */
-                               /*  increase power diff defined by customer. */
-                       chnlGroup = 0;
-
-                       if (index < 2)
-                               pwr_diff = pHalData->TxPwrLegacyHtDiff[rf][Channel - 1];
-                       else if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
-                               pwr_diff = pHalData->TxPwrHt20Diff[rf][Channel - 1];
-
-                       if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_40)
-                               customer_pwr_limit = pHalData->PwrGroupHT40[rf][Channel - 1];
-                       else
-                               customer_pwr_limit = pHalData->PwrGroupHT20[rf][Channel - 1];
-
-                       if (pwr_diff >= customer_pwr_limit)
-                               pwr_diff = 0;
-                       else
-                               pwr_diff = customer_pwr_limit - pwr_diff;
-
-                       for (i = 0; i < 4; i++) {
-                               pwr_diff_limit[i] = (u8)((pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] & (0x7f << (i * 8))) >> (i * 8));
-
-                               if (pwr_diff_limit[i] > pwr_diff)
-                                       pwr_diff_limit[i] = pwr_diff;
-                       }
-                       customer_limit = (pwr_diff_limit[3] << 24) | (pwr_diff_limit[2] << 16) |
-                                        (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]);
-                       writeVal = customer_limit + ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
-                       break;
-               default:
-                       chnlGroup = 0;
-                       writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] +
-                                       ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
-                       break;
-               }
-
-               *(pOutWriteVal + rf) = writeVal;
-       }
-}
-static void writeOFDMPowerReg88E(struct adapter *Adapter, u8 index, u32 *pValue)
-{
-       u16 regoffset_a[6] = {
-               rTxAGC_A_Rate18_06, rTxAGC_A_Rate54_24,
-               rTxAGC_A_Mcs03_Mcs00, rTxAGC_A_Mcs07_Mcs04,
-               rTxAGC_A_Mcs11_Mcs08, rTxAGC_A_Mcs15_Mcs12};
-       u16 regoffset_b[6] = {
-               rTxAGC_B_Rate18_06, rTxAGC_B_Rate54_24,
-               rTxAGC_B_Mcs03_Mcs00, rTxAGC_B_Mcs07_Mcs04,
-               rTxAGC_B_Mcs11_Mcs08, rTxAGC_B_Mcs15_Mcs12};
-       u8 i, rf, pwr_val[4];
-       u32 writeVal;
-       u16 regoffset;
-
-       for (rf = 0; rf < 2; rf++) {
-               writeVal = pValue[rf];
-               for (i = 0; i < 4; i++) {
-                       pwr_val[i] = (u8)((writeVal & (0x7f << (i * 8))) >> (i * 8));
-                       if (pwr_val[i]  > RF6052_MAX_TX_PWR)
-                               pwr_val[i]  = RF6052_MAX_TX_PWR;
-               }
-               writeVal = (pwr_val[3] << 24) | (pwr_val[2] << 16) | (pwr_val[1] << 8) | pwr_val[0];
-
-               if (rf == 0)
-                       regoffset = regoffset_a[index];
-               else
-                       regoffset = regoffset_b[index];
-
-               rtl8188e_PHY_SetBBReg(Adapter, regoffset, bMaskDWord, writeVal);
-
-               /*  201005115 Joseph: Set Tx Power diff for Tx power training mechanism. */
-               if (regoffset == rTxAGC_A_Mcs07_Mcs04 || regoffset == rTxAGC_B_Mcs07_Mcs04) {
-                       writeVal = pwr_val[3];
-                       if (regoffset == rTxAGC_A_Mcs15_Mcs12 || regoffset == rTxAGC_A_Mcs07_Mcs04)
-                               regoffset = 0xc90;
-                       if (regoffset == rTxAGC_B_Mcs15_Mcs12 || regoffset == rTxAGC_B_Mcs07_Mcs04)
-                               regoffset = 0xc98;
-                       for (i = 0; i < 3; i++) {
-                               if (i != 2)
-                                       writeVal = (writeVal > 8) ? (writeVal - 8) : 0;
-                               else
-                                       writeVal = (writeVal > 6) ? (writeVal - 6) : 0;
-                               rtw_write8(Adapter, (u32)(regoffset + i), (u8)writeVal);
-                       }
-               }
-       }
-}
-
-/*-----------------------------------------------------------------------------
- * Function:   PHY_RF6052SetOFDMTxPower
- *
- * Overview:   For legacy and HY OFDM, we must read EEPROM TX power index for
- *                     different channel and read original value in TX power register area from
- *                     0xe00. We increase offset and original value to be correct tx pwr.
- *
- * Input:       NONE
- *
- * Output:      NONE
- *
- * Return:      NONE
- *
- * Revised History:
- * When                        Who             Remark
- * 11/05/2008  MHC             Simulate 8192 series method.
- * 01/06/2009  MHC             1. Prevent Path B tx power overflow or underflow dure to
- *                                             A/B pwr difference or legacy/HT pwr diff.
- *                                             2. We concern with path B legacy/HT OFDM difference.
- * 01/22/2009  MHC             Support new EPRO format from SD3.
- *
- *---------------------------------------------------------------------------*/
-
-void
-rtl8188e_PHY_RF6052SetOFDMTxPower(
-               struct adapter *Adapter,
-               u8 *pPowerLevelOFDM,
-               u8 *pPowerLevelBW20,
-               u8 *pPowerLevelBW40,
-               u8 Channel)
-{
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       u32 writeVal[2], powerBase0[2], powerBase1[2], pwrtrac_value;
-       u8 direction;
-       u8 index = 0;
-
-       getpowerbase88e(Adapter, pPowerLevelOFDM, pPowerLevelBW20, pPowerLevelBW40, Channel, &powerBase0[0], &powerBase1[0]);
-
-       /*  2012/04/23 MH According to power tracking value, we need to revise OFDM tx power. */
-       /*  This is ued to fix unstable power tracking mode. */
-       ODM_TxPwrTrackAdjust88E(&pHalData->odmpriv, 0, &direction, &pwrtrac_value);
-
-       for (index = 0; index < 6; index++) {
-               get_rx_power_val_by_reg(Adapter, Channel, index,
-                                       &powerBase0[0], &powerBase1[0],
-                                       &writeVal[0]);
-
-               if (direction == 1) {
-                       writeVal[0] += pwrtrac_value;
-                       writeVal[1] += pwrtrac_value;
-               } else if (direction == 2) {
-                       writeVal[0] -= pwrtrac_value;
-                       writeVal[1] -= pwrtrac_value;
-               }
-               writeOFDMPowerReg88E(Adapter, index, &writeVal[0]);
-       }
-}
-
-int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
-{
-       struct bb_reg_def *pPhyReg;
-       struct hal_data_8188e *pHalData = &Adapter->haldata;
-       u32 u4RegValue = 0;
-       int err;
-
-       /* Initialize RF */
-
-       pPhyReg = &pHalData->PHYRegDef;
-
-       /*----Store original RFENV control type----*/
-       u4RegValue = rtl8188e_PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV);
-
-       /*----Set RF_ENV enable----*/
-       rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1);
-       udelay(1);/* PlatformStallExecution(1); */
-
-       /*----Set RF_ENV output high----*/
-       rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
-       udelay(1);/* PlatformStallExecution(1); */
-
-       /* Set bit number of Address and Data for RF register */
-       rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /*  Set 1 to 4 bits for 8255 */
-       udelay(1);/* PlatformStallExecution(1); */
-
-       rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0);    /*  Set 0 to 12  bits for 8255 */
-       udelay(1);/* PlatformStallExecution(1); */
-
-       /*----Initialize RF fom connfiguration file----*/
-       err = ODM_ReadAndConfig_RadioA_1T_8188E(&pHalData->odmpriv);
-
-       /*----Restore RFENV control type----*/;
-       rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
-
-       return err;
-}
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c
deleted file mode 100644 (file)
index d1ac296..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _RTL8188E_REDESC_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/rtl8188e_hal.h"
-
-static void process_rssi(struct adapter *padapter, struct recv_frame *prframe)
-{
-       struct rx_pkt_attrib *pattrib = &prframe->attrib;
-       struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data;
-
-       if (signal_stat->update_req) {
-               signal_stat->total_num = 0;
-               signal_stat->total_val = 0;
-               signal_stat->update_req = 0;
-       }
-
-       signal_stat->total_num++;
-       signal_stat->total_val  += pattrib->phy_info.SignalStrength;
-       signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num;
-} /*  Process_UI_RSSI_8192C */
-
-static void process_link_qual(struct adapter *padapter, struct recv_frame *prframe)
-{
-       struct rx_pkt_attrib *pattrib;
-       struct signal_stat *signal_stat;
-
-       if (!prframe || !padapter)
-               return;
-
-       pattrib = &prframe->attrib;
-       signal_stat = &padapter->recvpriv.signal_qual_data;
-
-       if (signal_stat->update_req) {
-               signal_stat->total_num = 0;
-               signal_stat->total_val = 0;
-               signal_stat->update_req = 0;
-       }
-
-       signal_stat->total_num++;
-       signal_stat->total_val  += pattrib->phy_info.SignalQuality;
-       signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num;
-}
-
-static void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe)
-{
-       struct recv_frame *precvframe = (struct recv_frame *)prframe;
-
-       /*  Check RSSI */
-       process_rssi(padapter, precvframe);
-       /*  Check EVM */
-       process_link_qual(padapter,  precvframe);
-}
-
-void update_recvframe_attrib_88e(struct recv_frame *precvframe, struct recv_stat *prxstat)
-{
-       struct rx_pkt_attrib *pattrib = &precvframe->attrib;
-       memset(pattrib, 0, sizeof(struct rx_pkt_attrib));
-
-       pattrib->crc_err = (le32_to_cpu(prxstat->rxdw0) >> 14) & 0x1;
-
-       pattrib->pkt_rpt_type = (le32_to_cpu(prxstat->rxdw3) >> 14) & 0x3;
-
-       if (pattrib->pkt_rpt_type == NORMAL_RX) {
-               pattrib->pkt_len = le32_to_cpu(prxstat->rxdw0) & 0x00003fff;
-               pattrib->icv_err = (le32_to_cpu(prxstat->rxdw0) >> 15) & 0x1;
-               pattrib->drvinfo_sz = ((le32_to_cpu(prxstat->rxdw0) >> 16) & 0xf) * 8;
-               pattrib->encrypt = (u8)((le32_to_cpu(prxstat->rxdw0) >> 20) & 0x7);
-               pattrib->qos = (le32_to_cpu(prxstat->rxdw0) >> 23) & 0x1;
-               pattrib->shift_sz = (le32_to_cpu(prxstat->rxdw0) >> 24) & 0x3;
-               pattrib->physt = (le32_to_cpu(prxstat->rxdw0) >> 26) & 0x1;
-               pattrib->bdecrypted = (le32_to_cpu(prxstat->rxdw0) & BIT(27)) ? 0 : 1;
-
-               pattrib->priority = (le32_to_cpu(prxstat->rxdw1) >> 8) & 0xf;
-               pattrib->amsdu = (le32_to_cpu(prxstat->rxdw1) >> 13) & 0x1;
-               pattrib->mdata = (le32_to_cpu(prxstat->rxdw1) >> 26) & 0x1;
-               pattrib->mfrag = (le32_to_cpu(prxstat->rxdw1) >> 27) & 0x1;
-
-               pattrib->seq_num = le32_to_cpu(prxstat->rxdw2) & 0x00000fff;
-               pattrib->frag_num = (le32_to_cpu(prxstat->rxdw2) >> 12) & 0xf;
-
-               pattrib->mcs_rate = le32_to_cpu(prxstat->rxdw3) & 0x3f;
-               pattrib->rxht = (le32_to_cpu(prxstat->rxdw3) >> 6) & 0x1;
-
-       } else if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX */
-               pattrib->pkt_len = TX_RPT1_PKT_LEN;
-       } else if (pattrib->pkt_rpt_type == TX_REPORT2) {
-               pattrib->pkt_len = le32_to_cpu(prxstat->rxdw0) & 0x3FF;
-
-               pattrib->MacIDValidEntry[0] = le32_to_cpu(prxstat->rxdw4);
-               pattrib->MacIDValidEntry[1] = le32_to_cpu(prxstat->rxdw5);
-
-       } else if (pattrib->pkt_rpt_type == HIS_REPORT) {
-               pattrib->pkt_len = le32_to_cpu(prxstat->rxdw0) & 0x00003fff;
-       }
-}
-
-/*
- * Notice:
- *     Before calling this function,
- *     precvframe->rx_data should be ready!
- */
-void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, struct phy_stat *pphy_status)
-{
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precvframe->rx_data;
-       struct adapter *padapter = precvframe->adapter;
-       struct rx_pkt_attrib *pattrib = &precvframe->attrib;
-       struct hal_data_8188e *pHalData = &padapter->haldata;
-       struct phy_info *pPHYInfo  = &pattrib->phy_info;
-       u8 *wlanhdr = precvframe->rx_data;
-       struct odm_per_pkt_info pkt_info;
-       u8 *sa = NULL;
-       struct sta_priv *pstapriv;
-       struct sta_info *psta;
-
-       pkt_info.bPacketMatchBSSID = ((!ieee80211_is_ctl(hdr->frame_control)) &&
-               !pattrib->icv_err && !pattrib->crc_err &&
-               !memcmp(get_hdr_bssid(wlanhdr),
-                get_bssid(&padapter->mlmepriv), ETH_ALEN));
-
-       pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID &&
-                                ether_addr_equal(ieee80211_get_DA(hdr),
-                                                 myid(&padapter->eeprompriv));
-
-       pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID &&
-                                ieee80211_is_beacon(hdr->frame_control);
-       if (pkt_info.bPacketBeacon) {
-               if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE))
-                       sa = padapter->mlmepriv.cur_network.network.MacAddress;
-               /* to do Ad-hoc */
-       } else {
-               sa = ieee80211_get_SA(hdr);
-       }
-
-       pstapriv = &padapter->stapriv;
-       pkt_info.StationID = 0xFF;
-       psta = rtw_get_stainfo(pstapriv, sa);
-       if (psta)
-               pkt_info.StationID = psta->mac_id;
-       pkt_info.Rate = pattrib->mcs_rate;
-
-       ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info), padapter);
-
-       precvframe->psta = NULL;
-       if (pkt_info.bPacketMatchBSSID &&
-           (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) {
-               if (psta) {
-                       precvframe->psta = psta;
-                       rtl8188e_process_phy_info(padapter, precvframe);
-               }
-       } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) {
-               if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) {
-                       if (psta)
-                               precvframe->psta = psta;
-               }
-               rtl8188e_process_phy_info(padapter, precvframe);
-       }
-}
diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c
deleted file mode 100644 (file)
index 3ffab49..0000000
+++ /dev/null
@@ -1,627 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _RTL8188E_XMIT_C_
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/wifi.h"
-#include "../include/osdep_intf.h"
-#include "../include/usb_ops.h"
-#include "../include/rtl8188e_hal.h"
-
-static void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc)
-{
-       u16     *usptr = (u16 *)ptxdesc;
-       u32 count = 16;         /*  (32 bytes / 2 bytes per XOR) => 16 times */
-       u32 index;
-       u16 checksum = 0;
-
-       /* Clear first */
-       ptxdesc->txdw7 &= cpu_to_le32(0xffff0000);
-
-       for (index = 0; index < count; index++)
-               checksum = checksum ^ le16_to_cpu(*(__le16 *)(usptr + index));
-       ptxdesc->txdw7 |= cpu_to_le32(0x0000ffff & checksum);
-}
-
-/*  Description: In normal chip, we should send some packet to Hw which will be used by Fw */
-/*                     in FW LPS mode. The function is to fill the Tx descriptor of this packets, then */
-/*                     Fw can tell Hw to send these packet derectly. */
-void rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u8  ispspoll, u8  is_btqosnull)
-{
-       struct tx_desc *ptxdesc;
-
-       /*  Clear all status */
-       ptxdesc = (struct tx_desc *)desc;
-       memset(desc, 0, TXDESC_SIZE);
-
-       /* offset 0 */
-       ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */
-
-       ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00ff0000); /* 32 bytes for TX Desc */
-
-       ptxdesc->txdw0 |= cpu_to_le32(BufferLen & 0x0000ffff); /*  Buffer size + command header */
-
-       /* offset 4 */
-       ptxdesc->txdw1 |= cpu_to_le32((QSLT_MGNT << QSEL_SHT) & 0x00001f00); /*  Fixed queue of Mgnt queue */
-
-       /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error vlaue by Hw. */
-       if (ispspoll) {
-               ptxdesc->txdw1 |= cpu_to_le32(NAVUSEHDR);
-       } else {
-               ptxdesc->txdw4 |= cpu_to_le32(BIT(7)); /*  Hw set sequence number */
-               ptxdesc->txdw3 |= cpu_to_le32((8 << 28)); /* set bit3 to 1. Suugested by TimChen. 2009.12.29. */
-       }
-
-       if (is_btqosnull)
-               ptxdesc->txdw2 |= cpu_to_le32(BIT(23)); /*  BT NULL */
-
-       /* offset 16 */
-       ptxdesc->txdw4 |= cpu_to_le32(BIT(8));/* driver uses rate */
-
-       /*  USB interface drop packet if the checksum of descriptor isn't correct. */
-       /*  Using this checksum can let hardware recovery from packet bulk out error (e.g. Cancel URC, Bulk out error.). */
-       rtl8188eu_cal_txdesc_chksum(ptxdesc);
-}
-
-static void fill_txdesc_sectype(struct pkt_attrib *pattrib, struct tx_desc *ptxdesc)
-{
-       if ((pattrib->encrypt > 0) && !pattrib->bswenc) {
-               switch (pattrib->encrypt) {
-               /* SEC_TYPE : 0:NO_ENC,1:WEP40/TKIP,2:WAPI,3:AES */
-               case _WEP40_:
-               case _WEP104_:
-                       ptxdesc->txdw1 |= cpu_to_le32((0x01 << SEC_TYPE_SHT) & 0x00c00000);
-                       ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT);
-                       break;
-               case _TKIP_:
-               case _TKIP_WTMIC_:
-                       ptxdesc->txdw1 |= cpu_to_le32((0x01 << SEC_TYPE_SHT) & 0x00c00000);
-                       ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT);
-                       break;
-               case _AES_:
-                       ptxdesc->txdw1 |= cpu_to_le32((0x03 << SEC_TYPE_SHT) & 0x00c00000);
-                       ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT);
-                       break;
-               case _NO_PRIVACY_:
-               default:
-                       break;
-               }
-       }
-}
-
-static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw)
-{
-       switch (pattrib->vcs_mode) {
-       case RTS_CTS:
-               *pdw |= cpu_to_le32(RTS_EN);
-               break;
-       case CTS_TO_SELF:
-               *pdw |= cpu_to_le32(CTS_2_SELF);
-               break;
-       case NONE_VCS:
-       default:
-               break;
-       }
-       if (pattrib->vcs_mode) {
-               *pdw |= cpu_to_le32(HW_RTS_EN);
-               /*  Set RTS BW */
-               if (pattrib->ht_en) {
-                       *pdw |= (pattrib->bwmode & HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0;
-
-                       if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER)
-                               *pdw |= cpu_to_le32((0x01 << 28) & 0x30000000);
-                       else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER)
-                               *pdw |= cpu_to_le32((0x02 << 28) & 0x30000000);
-                       else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE)
-                               *pdw |= 0;
-                       else
-                               *pdw |= cpu_to_le32((0x03 << 28) & 0x30000000);
-               }
-       }
-}
-
-static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw)
-{
-       if (pattrib->ht_en) {
-               *pdw |= (pattrib->bwmode & HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0;
-
-               if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER)
-                       *pdw |= cpu_to_le32((0x01 << DATA_SC_SHT) & 0x003f0000);
-               else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER)
-                       *pdw |= cpu_to_le32((0x02 << DATA_SC_SHT) & 0x003f0000);
-               else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE)
-                       *pdw |= 0;
-               else
-                       *pdw |= cpu_to_le32((0x03 << DATA_SC_SHT) & 0x003f0000);
-       }
-}
-
-static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz)
-{
-       uint    qsel;
-       u8 data_rate, pwr_status, offset;
-       struct adapter          *adapt = pxmitframe->padapter;
-       struct pkt_attrib       *pattrib = &pxmitframe->attrib;
-       struct hal_data_8188e *haldata = &adapt->haldata;
-       struct tx_desc  *ptxdesc = (struct tx_desc *)pmem;
-       struct mlme_ext_priv    *pmlmeext = &adapt->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-
-       memset(ptxdesc, 0, sizeof(struct tx_desc));
-
-       /* 4 offset 0 */
-       ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG);
-       ptxdesc->txdw0 |= cpu_to_le32(sz & 0x0000ffff);/* update TXPKTSIZE */
-
-       offset = TXDESC_SIZE + OFFSET_SZ;
-
-       ptxdesc->txdw0 |= cpu_to_le32(((offset) << OFFSET_SHT) & 0x00ff0000);/* 32 bytes for TX Desc */
-
-       if (is_multicast_ether_addr(pattrib->ra))
-               ptxdesc->txdw0 |= cpu_to_le32(BMC);
-
-       /*  pkt_offset, unit:8 bytes padding */
-       if (pxmitframe->pkt_offset > 0)
-               ptxdesc->txdw1 |= cpu_to_le32((pxmitframe->pkt_offset << 26) & 0x7c000000);
-
-       /* driver uses rate */
-       ptxdesc->txdw4 |= cpu_to_le32(USERATE);/* rate control always by driver */
-
-       if ((pxmitframe->frame_tag & 0x0f) == DATA_FRAMETAG) {
-               /* offset 4 */
-               ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3F);
-
-               qsel = (uint)(pattrib->qsel & 0x0000001f);
-               ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00);
-
-               ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000F0000);
-
-               fill_txdesc_sectype(pattrib, ptxdesc);
-
-               if (pattrib->ampdu_en) {
-                       ptxdesc->txdw2 |= cpu_to_le32(AGG_EN);/* AGG EN */
-                       ptxdesc->txdw6 = cpu_to_le32(0x6666f800);
-               } else {
-                       ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);/* AGG BK */
-               }
-
-               /* offset 8 */
-
-               /* offset 12 */
-               ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0FFF0000);
-
-               /* offset 16 , offset 20 */
-               if (pattrib->qos_en)
-                       ptxdesc->txdw4 |= cpu_to_le32(QOS);/* QoS */
-
-               /* offset 20 */
-               if (pxmitframe->agg_num > 1)
-                       ptxdesc->txdw5 |= cpu_to_le32((pxmitframe->agg_num << USB_TXAGG_NUM_SHT) & 0xFF000000);
-
-               if ((pattrib->ether_type != 0x888e) &&
-                   (pattrib->ether_type != 0x0806) &&
-                   (pattrib->ether_type != 0x88b4) &&
-                   (pattrib->dhcp_pkt != 1)) {
-                       /* Non EAP & ARP & DHCP type data packet */
-
-                       fill_txdesc_vcs(pattrib, &ptxdesc->txdw4);
-                       fill_txdesc_phy(pattrib, &ptxdesc->txdw4);
-
-                       ptxdesc->txdw4 |= cpu_to_le32(0x00000008);/* RTS Rate=24M */
-                       ptxdesc->txdw5 |= cpu_to_le32(0x0001ff00);/* DATA/RTS  Rate FB LMT */
-
-                       if (pattrib->ht_en) {
-                               if (ODM_RA_GetShortGI_8188E(&haldata->odmpriv, pattrib->mac_id))
-                                       ptxdesc->txdw5 |= cpu_to_le32(SGI);/* SGI */
-                       }
-                       data_rate = ODM_RA_GetDecisionRate_8188E(&haldata->odmpriv, pattrib->mac_id);
-                       ptxdesc->txdw5 |= cpu_to_le32(data_rate & 0x3F);
-                       pwr_status = ODM_RA_GetHwPwrStatus_8188E(&haldata->odmpriv, pattrib->mac_id);
-                       ptxdesc->txdw4 |= cpu_to_le32((pwr_status & 0x7) << PWR_STATUS_SHT);
-               } else {
-                       /*  EAP data packet and ARP packet and DHCP. */
-                       /*  Use the 1M data rate to send the EAP/ARP packet. */
-                       /*  This will maybe make the handshake smooth. */
-                       ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);/* AGG BK */
-                       if (pmlmeinfo->preamble_mode == PREAMBLE_SHORT)
-                               ptxdesc->txdw4 |= cpu_to_le32(BIT(24));/*  DATA_SHORT */
-                       ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate));
-               }
-       } else if ((pxmitframe->frame_tag & 0x0f) == MGNT_FRAMETAG) {
-               /* offset 4 */
-               ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3f);
-
-               qsel = (uint)(pattrib->qsel & 0x0000001f);
-               ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00);
-
-               ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000f0000);
-
-               /* offset 8 */
-               /* CCX-TXRPT ack for xmit mgmt frames. */
-               if (pxmitframe->ack_report)
-                       ptxdesc->txdw2 |= cpu_to_le32(BIT(19));
-
-               /* offset 12 */
-               ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0FFF0000);
-
-               /* offset 20 */
-               ptxdesc->txdw5 |= cpu_to_le32(RTY_LMT_EN);/* retry limit enable */
-               if (pattrib->retry_ctrl)
-                       ptxdesc->txdw5 |= cpu_to_le32(0x00180000);/* retry limit = 6 */
-               else
-                       ptxdesc->txdw5 |= cpu_to_le32(0x00300000);/* retry limit = 12 */
-
-               ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate));
-       } else if ((pxmitframe->frame_tag & 0x0f) != TXAGG_FRAMETAG) {
-               /* offset 4 */
-               ptxdesc->txdw1 |= cpu_to_le32((4) & 0x3f);/* CAM_ID(MAC_ID) */
-
-               ptxdesc->txdw1 |= cpu_to_le32((6 << RATE_ID_SHT) & 0x000f0000);/* raid */
-
-               /* offset 8 */
-
-               /* offset 12 */
-               ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0fff0000);
-
-               /* offset 20 */
-               ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate));
-       }
-
-       /*  2009.11.05. tynli_test. Suggested by SD4 Filen for FW LPS. */
-       /*  (1) The sequence number of each non-Qos frame / broadcast / multicast / */
-       /*  mgnt frame should be controlled by Hw because Fw will also send null data */
-       /*  which we cannot control when Fw LPS enable. */
-       /*  --> default enable non-Qos data sequense number. 2010.06.23. by tynli. */
-       /*  (2) Enable HW SEQ control for beacon packet, because we use Hw beacon. */
-       /*  (3) Use HW Qos SEQ to control the seq num of Ext port non-Qos packets. */
-       /*  2010.06.23. Added by tynli. */
-       if (!pattrib->qos_en) {
-               ptxdesc->txdw3 |= cpu_to_le32(EN_HWSEQ); /*  Hw set sequence number */
-               ptxdesc->txdw4 |= cpu_to_le32(HW_SSN);  /*  Hw set sequence number */
-       }
-
-       ODM_SetTxAntByTxInfo_88E(&haldata->odmpriv, pmem, pattrib->mac_id);
-
-       rtl8188eu_cal_txdesc_chksum(ptxdesc);
-       return 0;
-}
-
-/* for non-agg data frame or  management frame */
-static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe)
-{
-       s32 ret = _SUCCESS;
-       s32 inner_ret = _SUCCESS;
-       int t, sz, w_sz, pull = 0;
-       u8 *mem_addr;
-       u32 ff_hwaddr;
-       struct xmit_buf *pxmitbuf = pxmitframe->pxmitbuf;
-       struct pkt_attrib *pattrib = &pxmitframe->attrib;
-       struct xmit_priv *pxmitpriv = &adapt->xmitpriv;
-       struct security_priv *psecuritypriv = &adapt->securitypriv;
-       if ((pxmitframe->frame_tag == DATA_FRAMETAG) &&
-           (pxmitframe->attrib.ether_type != 0x0806) &&
-           (pxmitframe->attrib.ether_type != 0x888e) &&
-           (pxmitframe->attrib.ether_type != 0x88b4) &&
-           (pxmitframe->attrib.dhcp_pkt != 1))
-               rtw_issue_addbareq_cmd(adapt, pxmitframe);
-       mem_addr = pxmitframe->buf_addr;
-
-       for (t = 0; t < pattrib->nr_frags; t++) {
-               if (inner_ret != _SUCCESS && ret == _SUCCESS)
-                       ret = _FAIL;
-
-               if (t != (pattrib->nr_frags - 1)) {
-                       sz = pxmitpriv->frag_len;
-                       sz = sz - 4 - (psecuritypriv->sw_encrypt ? 0 : pattrib->icv_len);
-               } else {
-                       /* no frag */
-                       sz = pattrib->last_txcmdsz;
-               }
-
-               pull = update_txdesc(pxmitframe, mem_addr, sz);
-
-               if (pull) {
-                       mem_addr += PACKET_OFFSET_SZ; /* pull txdesc head */
-                       pxmitframe->buf_addr = mem_addr;
-                       w_sz = sz + TXDESC_SIZE;
-               } else {
-                       w_sz = sz + TXDESC_SIZE + PACKET_OFFSET_SZ;
-               }
-               ff_hwaddr = rtw_get_ff_hwaddr(pxmitframe);
-
-               inner_ret = rtw_write_port(adapt, ff_hwaddr, w_sz, (unsigned char *)pxmitbuf);
-
-               rtw_count_tx_stats(adapt, pxmitframe, sz);
-
-               mem_addr += w_sz;
-
-               mem_addr = PTR_ALIGN(mem_addr, 4);
-       }
-
-       rtw_free_xmitframe(pxmitpriv, pxmitframe);
-
-       if  (ret != _SUCCESS)
-               rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_UNKNOWN);
-
-       return ret;
-}
-
-static u32 xmitframe_need_length(struct xmit_frame *pxmitframe)
-{
-       struct pkt_attrib *pattrib = &pxmitframe->attrib;
-
-       u32 len = 0;
-
-       /*  no consider fragement */
-       len = pattrib->hdrlen + pattrib->iv_len +
-               SNAP_SIZE + sizeof(u16) +
-               pattrib->pktlen +
-               ((pattrib->bswenc) ? pattrib->icv_len : 0);
-
-       if (pattrib->encrypt == _TKIP_)
-               len += 8;
-
-       return len;
-}
-
-bool rtl8188eu_xmitframe_complete(struct adapter *adapt)
-{
-       struct xmit_priv *pxmitpriv = &adapt->xmitpriv;
-       struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt);
-       struct xmit_frame *pxmitframe = NULL;
-       struct xmit_frame *pfirstframe = NULL;
-       struct xmit_buf *pxmitbuf;
-
-       /*  aggregate variable */
-       struct hw_xmit *phwxmit;
-       struct sta_info *psta = NULL;
-       struct tx_servq *ptxservq = NULL;
-       struct list_head *xmitframe_plist = NULL, *xmitframe_phead = NULL;
-
-       u32 pbuf;       /*  next pkt address */
-       u32 pbuf_tail;  /*  last pkt tail */
-       u32 len;        /*  packet length, except TXDESC_SIZE and PKT_OFFSET */
-
-       u32 bulksize;
-       u8 desc_cnt;
-       u32 bulkptr;
-
-       /*  dump frame variable */
-       u32 ff_hwaddr;
-
-       if (pdvobjpriv->pusbdev->speed == USB_SPEED_HIGH)
-               bulksize = USB_HIGH_SPEED_BULK_SIZE;
-       else
-               bulksize = USB_FULL_SPEED_BULK_SIZE;
-
-       pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv);
-       if (!pxmitbuf)
-               return false;
-
-       pxmitframe = rtw_dequeue_xframe(pxmitpriv, pxmitpriv->hwxmits);
-       if (!pxmitframe) {
-               /*  no more xmit frame, release xmit buffer */
-               rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
-               return false;
-       }
-
-       pxmitframe->pxmitbuf = pxmitbuf;
-       pxmitframe->buf_addr = pxmitbuf->pbuf;
-       pxmitbuf->priv_data = pxmitframe;
-
-       pxmitframe->agg_num = 1; /*  alloc xmitframe should assign to 1. */
-       pxmitframe->pkt_offset = 1; /*  first frame of aggregation, reserve offset */
-
-       rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe);
-
-       /*  always return ndis_packet after rtw_xmitframe_coalesce */
-       rtw_xmit_complete(adapt, pxmitframe);
-
-       /* 3 2. aggregate same priority and same DA(AP or STA) frames */
-       pfirstframe = pxmitframe;
-       len = xmitframe_need_length(pfirstframe) + TXDESC_SIZE + (pfirstframe->pkt_offset * PACKET_OFFSET_SZ);
-       pbuf_tail = len;
-       pbuf = round_up(pbuf_tail, 8);
-
-       /*  check pkt amount in one bulk */
-       desc_cnt = 0;
-       bulkptr = bulksize;
-       if (pbuf < bulkptr) {
-               desc_cnt++;
-       } else {
-               desc_cnt = 0;
-               bulkptr = ((pbuf / bulksize) + 1) * bulksize; /*  round to next bulksize */
-       }
-
-       /*  dequeue same priority packet from station tx queue */
-       psta = pfirstframe->attrib.psta;
-       switch (pfirstframe->attrib.priority) {
-       case 1:
-       case 2:
-               ptxservq = &psta->sta_xmitpriv.bk_q;
-               phwxmit = pxmitpriv->hwxmits + 3;
-               break;
-       case 4:
-       case 5:
-               ptxservq = &psta->sta_xmitpriv.vi_q;
-               phwxmit = pxmitpriv->hwxmits + 1;
-               break;
-       case 6:
-       case 7:
-               ptxservq = &psta->sta_xmitpriv.vo_q;
-               phwxmit = pxmitpriv->hwxmits;
-               break;
-       case 0:
-       case 3:
-       default:
-               ptxservq = &psta->sta_xmitpriv.be_q;
-               phwxmit = pxmitpriv->hwxmits + 2;
-               break;
-       }
-       spin_lock_bh(&pxmitpriv->lock);
-
-       xmitframe_phead = &ptxservq->sta_pending;
-       xmitframe_plist = xmitframe_phead->next;
-
-       while (xmitframe_phead != xmitframe_plist) {
-               pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
-               xmitframe_plist = xmitframe_plist->next;
-
-               pxmitframe->agg_num = 0; /*  not first frame of aggregation */
-               pxmitframe->pkt_offset = 0; /*  not first frame of aggregation, no need to reserve offset */
-
-               len = xmitframe_need_length(pxmitframe) + TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);
-
-               if (pbuf + len > MAX_XMITBUF_SZ) {
-                       pxmitframe->agg_num = 1;
-                       pxmitframe->pkt_offset = 1;
-                       break;
-               }
-               list_del_init(&pxmitframe->list);
-               ptxservq->qcnt--;
-               phwxmit->accnt--;
-
-               pxmitframe->buf_addr = pxmitbuf->pbuf + pbuf;
-
-               rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe);
-               /*  always return ndis_packet after rtw_xmitframe_coalesce */
-               rtw_xmit_complete(adapt, pxmitframe);
-
-               /*  (len - TXDESC_SIZE) == pxmitframe->attrib.last_txcmdsz */
-               update_txdesc(pxmitframe, pxmitframe->buf_addr, pxmitframe->attrib.last_txcmdsz);
-
-               /*  don't need xmitframe any more */
-               rtw_free_xmitframe(pxmitpriv, pxmitframe);
-
-               /*  handle pointer and stop condition */
-               pbuf_tail = pbuf + len;
-               pbuf = round_up(pbuf_tail, 8);
-
-               pfirstframe->agg_num++;
-               if (MAX_TX_AGG_PACKET_NUMBER == pfirstframe->agg_num)
-                       break;
-
-               if (pbuf < bulkptr) {
-                       desc_cnt++;
-                       if (desc_cnt == USB_TXAGG_DESC_NUM)
-                               break;
-               } else {
-                       desc_cnt = 0;
-                       bulkptr = ((pbuf / bulksize) + 1) * bulksize;
-               }
-       } /* end while (aggregate same priority and same DA(AP or STA) frames) */
-
-       if (list_empty(&ptxservq->sta_pending))
-               list_del_init(&ptxservq->tx_pending);
-
-       spin_unlock_bh(&pxmitpriv->lock);
-       if ((pfirstframe->attrib.ether_type != 0x0806) &&
-           (pfirstframe->attrib.ether_type != 0x888e) &&
-           (pfirstframe->attrib.ether_type != 0x88b4) &&
-           (pfirstframe->attrib.dhcp_pkt != 1))
-               rtw_issue_addbareq_cmd(adapt, pfirstframe);
-       /* 3 3. update first frame txdesc */
-       if ((pbuf_tail % bulksize) == 0) {
-               /*  remove pkt_offset */
-               pbuf_tail -= PACKET_OFFSET_SZ;
-               pfirstframe->buf_addr += PACKET_OFFSET_SZ;
-               pfirstframe->pkt_offset--;
-       }
-
-       update_txdesc(pfirstframe, pfirstframe->buf_addr, pfirstframe->attrib.last_txcmdsz);
-
-       /* 3 4. write xmit buffer to USB FIFO */
-       ff_hwaddr = rtw_get_ff_hwaddr(pfirstframe);
-       rtw_write_port(adapt, ff_hwaddr, pbuf_tail, (u8 *)pxmitbuf);
-
-       /* 3 5. update statisitc */
-       pbuf_tail -= (pfirstframe->agg_num * TXDESC_SIZE);
-       pbuf_tail -= (pfirstframe->pkt_offset * PACKET_OFFSET_SZ);
-
-       rtw_count_tx_stats(adapt, pfirstframe, pbuf_tail);
-
-       rtw_free_xmitframe(pxmitpriv, pfirstframe);
-
-       return true;
-}
-
-static s32 xmitframe_direct(struct adapter *adapt, struct xmit_frame *pxmitframe)
-{
-       s32 res = _SUCCESS;
-
-       res = rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe);
-       if (res == _SUCCESS)
-               rtw_dump_xframe(adapt, pxmitframe);
-
-       return res;
-}
-
-/*
- * Return
- *     true    dump packet directly
- *     false   enqueue packet
- */
-static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe)
-{
-       s32 res;
-       struct xmit_buf *pxmitbuf = NULL;
-       struct xmit_priv *pxmitpriv = &adapt->xmitpriv;
-       struct pkt_attrib *pattrib = &pxmitframe->attrib;
-       struct mlme_priv *pmlmepriv = &adapt->mlmepriv;
-
-       spin_lock_bh(&pxmitpriv->lock);
-
-       if (rtw_txframes_sta_ac_pending(adapt, pattrib) > 0)
-               goto enqueue;
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING))
-               goto enqueue;
-
-       pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv);
-       if (!pxmitbuf)
-               goto enqueue;
-
-       spin_unlock_bh(&pxmitpriv->lock);
-
-       pxmitframe->pxmitbuf = pxmitbuf;
-       pxmitframe->buf_addr = pxmitbuf->pbuf;
-       pxmitbuf->priv_data = pxmitframe;
-
-       if (xmitframe_direct(adapt, pxmitframe) != _SUCCESS) {
-               rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
-               rtw_free_xmitframe(pxmitpriv, pxmitframe);
-       }
-
-       return true;
-
-enqueue:
-       res = rtw_xmit_classifier(adapt, pxmitframe);
-       spin_unlock_bh(&pxmitpriv->lock);
-
-       if (res != _SUCCESS) {
-               rtw_free_xmitframe(pxmitpriv, pxmitframe);
-
-               /*  Trick, make the statistics correct */
-               pxmitpriv->tx_pkts--;
-               pxmitpriv->tx_drop++;
-               return true;
-       }
-
-       return false;
-}
-
-s32 rtl8188eu_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe)
-{
-       return rtw_dump_xframe(adapt, pmgntframe);
-}
-
-/*
- * Return
- *     true    dump packet directly ok
- *     false   temporary can't transmit packets to hardware
- */
-s32 rtl8188eu_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
-{
-       return pre_xmitframe(adapt, pxmitframe);
-}
diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
deleted file mode 100644 (file)
index a1051ac..0000000
+++ /dev/null
@@ -1,1069 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _HCI_HAL_INIT_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/rtw_efuse.h"
-#include "../include/rtw_fw.h"
-#include "../include/rtl8188e_hal.h"
-#include "../include/rtw_iol.h"
-#include "../include/usb_ops.h"
-#include "../include/usb_osintf.h"
-#include "../include/HalPwrSeqCmd.h"
-
-static void one_out_pipe(struct adapter *adapter)
-{
-       struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
-
-       pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
-       pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
-       pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */
-       pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
-}
-
-static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)
-{
-       struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
-
-       /* 0:H, 1:L */
-
-       pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
-       pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
-
-       if (wifi_cfg) {
-               pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */
-               pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
-       } else {
-               pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
-               pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
-       }
-}
-
-static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
-{
-       struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
-
-       /* 0:H, 1:N, 2:L */
-
-       pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
-       pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
-       pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
-
-       pdvobjpriv->Queue2Pipe[3] = wifi_cfg ?
-               pdvobjpriv->RtOutPipe[1] : pdvobjpriv->RtOutPipe[2];/* BK */
-}
-
-int rtl8188eu_interface_configure(struct adapter *adapt)
-{
-       struct registry_priv *pregistrypriv = &adapt->registrypriv;
-       struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt);
-       struct hal_data_8188e *haldata = &adapt->haldata;
-       bool wifi_cfg = pregistrypriv->wifi_spec;
-
-       pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
-       pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
-       pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
-       pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
-
-       switch (pdvobjpriv->RtNumOutPipes) {
-       case 3:
-               haldata->out_ep_extra_queues = TX_SELE_LQ | TX_SELE_NQ;
-               three_out_pipe(adapt, wifi_cfg);
-               break;
-       case 2:
-               haldata->out_ep_extra_queues = TX_SELE_NQ;
-               two_out_pipe(adapt, wifi_cfg);
-               break;
-       case 1:
-               one_out_pipe(adapt);
-               break;
-       default:
-               return -ENXIO;
-       }
-
-       return 0;
-}
-
-u32 rtl8188eu_InitPowerOn(struct adapter *adapt)
-{
-       u16 value16;
-       int res;
-
-       /*  HW Power on sequence */
-       struct hal_data_8188e *haldata = &adapt->haldata;
-       if (haldata->bMacPwrCtrlOn)
-               return _SUCCESS;
-
-       if (!HalPwrSeqCmdParsing(adapt, PWR_ON_FLOW))
-               return _FAIL;
-
-       /*  Enable MAC DMA/WMAC/SCHEDULE/SEC block */
-       /*  Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */
-       rtw_write16(adapt, REG_CR, 0x00);  /* suggseted by zhouzhou, by page, 20111230 */
-
-               /*  Enable MAC DMA/WMAC/SCHEDULE/SEC block */
-       res = rtw_read16(adapt, REG_CR, &value16);
-       if (res)
-               return _FAIL;
-
-       value16 |= (HCI_TXDMA_EN | HCI_RXDMA_EN | TXDMA_EN | RXDMA_EN
-                               | PROTOCOL_EN | SCHEDULE_EN | ENSEC | CALTMR_EN);
-       /*  for SDIO - Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */
-
-       rtw_write16(adapt, REG_CR, value16);
-       haldata->bMacPwrCtrlOn = true;
-
-       return _SUCCESS;
-}
-
-/*  Shall USB interface init this? */
-static void _InitInterrupt(struct adapter *Adapter)
-{
-       u32 imr, imr_ex;
-       u8  usb_opt;
-       int res;
-
-       /* HISR write one to clear */
-       rtw_write32(Adapter, REG_HISR_88E, 0xFFFFFFFF);
-       /*  HIMR - */
-       imr = IMR_PSTIMEOUT_88E | IMR_TBDER_88E | IMR_CPWM_88E | IMR_CPWM2_88E;
-       rtw_write32(Adapter, REG_HIMR_88E, imr);
-
-       imr_ex = IMR_TXERR_88E | IMR_RXERR_88E | IMR_TXFOVW_88E | IMR_RXFOVW_88E;
-       rtw_write32(Adapter, REG_HIMRE_88E, imr_ex);
-
-       /*  REG_USB_SPECIAL_OPTION - BIT(4) */
-       /*  0; Use interrupt endpoint to upload interrupt pkt */
-       /*  1; Use bulk endpoint to upload interrupt pkt, */
-       res = rtw_read8(Adapter, REG_USB_SPECIAL_OPTION, &usb_opt);
-       if (res)
-               return;
-
-       if (adapter_to_dvobj(Adapter)->pusbdev->speed == USB_SPEED_HIGH)
-               usb_opt = usb_opt | (INT_BULK_SEL);
-       else
-               usb_opt = usb_opt & (~INT_BULK_SEL);
-
-       rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, usb_opt);
-}
-
-static void _InitQueueReservedPage(struct adapter *Adapter)
-{
-       struct hal_data_8188e *haldata = &Adapter->haldata;
-       struct registry_priv    *pregistrypriv = &Adapter->registrypriv;
-       u8 numLQ = 0;
-       u8 numNQ = 0;
-       u8 numPubQ;
-
-       if (pregistrypriv->wifi_spec) {
-               if (haldata->out_ep_extra_queues & TX_SELE_LQ)
-                       numLQ = 0x1C;
-
-               /*  NOTE: This step shall be proceed before writing REG_RQPN. */
-               if (haldata->out_ep_extra_queues & TX_SELE_NQ)
-                       numNQ = 0x1C;
-
-               rtw_write8(Adapter, REG_RQPN_NPQ, numNQ);
-
-               numPubQ = 0xA8 - NUM_HQ - numLQ - numNQ;
-
-               /*  TX DMA */
-               rtw_write32(Adapter, REG_RQPN, LD_RQPN | numPubQ << 16 | numLQ << 8 | NUM_HQ);
-       } else {
-               rtw_write16(Adapter, REG_RQPN_NPQ, 0x0000);/* Just follow MP Team,??? Georgia 03/28 */
-               rtw_write16(Adapter, REG_RQPN_NPQ, 0x0d);
-               rtw_write32(Adapter, REG_RQPN, 0x808E000d);/* reserve 7 page for LPS */
-       }
-}
-
-static void _InitTxBufferBoundary(struct adapter *Adapter, u8 txpktbuf_bndy)
-{
-       rtw_write8(Adapter, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy);
-       rtw_write8(Adapter, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy);
-       rtw_write8(Adapter, REG_TXPKTBUF_WMAC_LBK_BF_HD, txpktbuf_bndy);
-       rtw_write8(Adapter, REG_TRXFF_BNDY, txpktbuf_bndy);
-       rtw_write8(Adapter, REG_TDECTRL + 1, txpktbuf_bndy);
-}
-
-static void _InitPageBoundary(struct adapter *Adapter)
-{
-       /*  RX Page Boundary */
-       /*  */
-       u16 rxff_bndy = MAX_RX_DMA_BUFFER_SIZE_88E - 1;
-
-       rtw_write16(Adapter, (REG_TRXFF_BNDY + 2), rxff_bndy);
-}
-
-static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ,
-                                      u16 bkQ, u16 viQ, u16 voQ, u16 mgtQ,
-                                      u16 hiQ)
-{
-       u16 value16;
-       int res;
-
-       res = rtw_read16(Adapter, REG_TRXDMA_CTRL, &value16);
-       if (res)
-               return;
-
-       value16 &= 0x7;
-
-       value16 |= _TXDMA_BEQ_MAP(beQ)  | _TXDMA_BKQ_MAP(bkQ) |
-                  _TXDMA_VIQ_MAP(viQ)  | _TXDMA_VOQ_MAP(voQ) |
-                  _TXDMA_MGQ_MAP(mgtQ) | _TXDMA_HIQ_MAP(hiQ);
-
-       rtw_write16(Adapter, REG_TRXDMA_CTRL, value16);
-}
-
-static void _InitNormalChipTwoOutEpPriority(struct adapter *Adapter)
-{
-       struct registry_priv *pregistrypriv = &Adapter->registrypriv;
-       u16 bkQ, voQ;
-
-       if (!pregistrypriv->wifi_spec) {
-               bkQ     = QUEUE_NORMAL;
-               voQ     = QUEUE_HIGH;
-       } else {/* for WMM ,CONFIG_OUT_EP_WIFI_MODE */
-               bkQ     = QUEUE_HIGH;
-               voQ     = QUEUE_NORMAL;
-       }
-       _InitNormalChipRegPriority(Adapter, QUEUE_NORMAL, bkQ, QUEUE_HIGH,
-                                  voQ, QUEUE_HIGH, QUEUE_HIGH);
-}
-
-static void _InitNormalChipThreeOutEpPriority(struct adapter *Adapter)
-{
-       struct registry_priv *pregistrypriv = &Adapter->registrypriv;
-       u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ;
-
-       if (!pregistrypriv->wifi_spec) {/*  typical setting */
-               beQ     = QUEUE_LOW;
-               bkQ     = QUEUE_LOW;
-               viQ     = QUEUE_NORMAL;
-               voQ     = QUEUE_HIGH;
-               mgtQ    = QUEUE_HIGH;
-               hiQ     = QUEUE_HIGH;
-       } else {/*  for WMM */
-               beQ     = QUEUE_LOW;
-               bkQ     = QUEUE_NORMAL;
-               viQ     = QUEUE_NORMAL;
-               voQ     = QUEUE_HIGH;
-               mgtQ    = QUEUE_HIGH;
-               hiQ     = QUEUE_HIGH;
-       }
-       _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ);
-}
-
-static void _InitQueuePriority(struct adapter *Adapter)
-{
-       struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(Adapter);
-
-       switch (pdvobjpriv->RtNumOutPipes) {
-       case 1:
-               _InitNormalChipRegPriority(Adapter, QUEUE_HIGH, QUEUE_HIGH, QUEUE_HIGH,
-                                          QUEUE_HIGH, QUEUE_HIGH, QUEUE_HIGH);
-               break;
-       case 2:
-               _InitNormalChipTwoOutEpPriority(Adapter);
-               break;
-       case 3:
-               _InitNormalChipThreeOutEpPriority(Adapter);
-               break;
-       default:
-               break;
-       }
-}
-
-static void _InitNetworkType(struct adapter *Adapter)
-{
-       u32 value32;
-       int res;
-
-       res = rtw_read32(Adapter, REG_CR, &value32);
-       if (res)
-               return;
-
-       /*  TODO: use the other function to set network type */
-       value32 = (value32 & ~MASK_NETTYPE) | _NETTYPE(NT_LINK_AP);
-
-       rtw_write32(Adapter, REG_CR, value32);
-}
-
-static void _InitTransferPageSize(struct adapter *Adapter)
-{
-       /*  Tx page size is always 128. */
-
-       u8 value8;
-       value8 = _PSRX(PBP_128) | _PSTX(PBP_128);
-       rtw_write8(Adapter, REG_PBP, value8);
-}
-
-static void _InitDriverInfoSize(struct adapter *Adapter, u8 drvInfoSize)
-{
-       rtw_write8(Adapter, REG_RX_DRVINFO_SZ, drvInfoSize);
-}
-
-static void _InitWMACSetting(struct adapter *Adapter)
-{
-       u32 receive_config = RCR_AAP | RCR_APM | RCR_AM | RCR_AB |
-                            RCR_CBSSID_DATA | RCR_CBSSID_BCN |
-                            RCR_APP_ICV | RCR_AMF | RCR_HTC_LOC_CTRL |
-                            RCR_APP_MIC | RCR_APP_PHYSTS;
-
-       /*  some REG_RCR will be modified later by phy_ConfigMACWithHeaderFile() */
-       rtw_write32(Adapter, REG_RCR, receive_config);
-
-       /*  Accept all multicast address */
-       rtw_write32(Adapter, REG_MAR, 0xFFFFFFFF);
-       rtw_write32(Adapter, REG_MAR + 4, 0xFFFFFFFF);
-}
-
-static void _InitAdaptiveCtrl(struct adapter *Adapter)
-{
-       u16 value16;
-       u32 value32;
-       int res;
-
-       /*  Response Rate Set */
-       res = rtw_read32(Adapter, REG_RRSR, &value32);
-       if (res)
-               return;
-
-       value32 &= ~RATE_BITMAP_ALL;
-       value32 |= RATE_RRSR_CCK_ONLY_1M;
-       rtw_write32(Adapter, REG_RRSR, value32);
-
-       /*  CF-END Threshold */
-
-       /*  SIFS (used in NAV) */
-       value16 = _SPEC_SIFS_CCK(0x10) | _SPEC_SIFS_OFDM(0x10);
-       rtw_write16(Adapter, REG_SPEC_SIFS, value16);
-
-       /*  Retry Limit */
-       value16 = _LRL(0x30) | _SRL(0x30);
-       rtw_write16(Adapter, REG_RL, value16);
-}
-
-static void _InitEDCA(struct adapter *Adapter)
-{
-       /*  Set Spec SIFS (used in NAV) */
-       rtw_write16(Adapter, REG_SPEC_SIFS, 0x100a);
-       rtw_write16(Adapter, REG_MAC_SPEC_SIFS, 0x100a);
-
-       /*  Set SIFS for CCK */
-       rtw_write16(Adapter, REG_SIFS_CTX, 0x100a);
-
-       /*  Set SIFS for OFDM */
-       rtw_write16(Adapter, REG_SIFS_TRX, 0x100a);
-
-       /*  TXOP */
-       rtw_write32(Adapter, REG_EDCA_BE_PARAM, 0x005EA42B);
-       rtw_write32(Adapter, REG_EDCA_BK_PARAM, 0x0000A44F);
-       rtw_write32(Adapter, REG_EDCA_VI_PARAM, 0x005EA324);
-       rtw_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226);
-}
-
-static void _InitRetryFunction(struct adapter *Adapter)
-{
-       u8 value8;
-       int res;
-
-       res = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL, &value8);
-       if (res)
-               return;
-
-       value8 |= EN_AMPDU_RTY_NEW;
-       rtw_write8(Adapter, REG_FWHW_TXQ_CTRL, value8);
-
-       /*  Set ACK timeout */
-       rtw_write8(Adapter, REG_ACKTO, 0x40);
-}
-
-/*-----------------------------------------------------------------------------
- * Function:   usb_AggSettingTxUpdate()
- *
- * Overview:   Separate TX/RX parameters update independent for TP detection and
- *                     dynamic TX/RX aggreagtion parameters update.
- *
- * Input:                      struct adapter *
- *
- * Output/Return:      NONE
- *
- * Revised History:
- *     When            Who             Remark
- *     12/10/2010      MHC             Separate to smaller function.
- *
- *---------------------------------------------------------------------------*/
-static void usb_AggSettingTxUpdate(struct adapter *Adapter)
-{
-       u32 value32;
-       int res;
-
-       if (Adapter->registrypriv.wifi_spec)
-               return;
-
-       res = rtw_read32(Adapter, REG_TDECTRL, &value32);
-       if (res)
-               return;
-
-       value32 = value32 & ~(BLK_DESC_NUM_MASK << BLK_DESC_NUM_SHIFT);
-       value32 |= ((USB_TXAGG_DESC_NUM & BLK_DESC_NUM_MASK) << BLK_DESC_NUM_SHIFT);
-
-       rtw_write32(Adapter, REG_TDECTRL, value32);
-}
-
-/*-----------------------------------------------------------------------------
- * Function:   usb_AggSettingRxUpdate()
- *
- * Overview:   Separate TX/RX parameters update independent for TP detection and
- *                     dynamic TX/RX aggreagtion parameters update.
- *
- * Input:                      struct adapter *
- *
- * Output/Return:      NONE
- *
- * Revised History:
- *     When            Who             Remark
- *     12/10/2010      MHC             Separate to smaller function.
- *
- *---------------------------------------------------------------------------*/
-static void
-usb_AggSettingRxUpdate(
-               struct adapter *Adapter
-       )
-{
-       u8 valueDMA;
-       u8 valueUSB;
-       int res;
-
-       res = rtw_read8(Adapter, REG_TRXDMA_CTRL, &valueDMA);
-       if (res)
-               return;
-
-       res = rtw_read8(Adapter, REG_USB_SPECIAL_OPTION, &valueUSB);
-       if (res)
-               return;
-
-       valueDMA |= RXDMA_AGG_EN;
-       valueUSB &= ~USB_AGG_EN;
-
-       rtw_write8(Adapter, REG_TRXDMA_CTRL, valueDMA);
-       rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, valueUSB);
-
-       rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, USB_RXAGG_PAGE_COUNT);
-       rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH + 1, USB_RXAGG_PAGE_TIMEOUT);
-}
-
-static void InitUsbAggregationSetting(struct adapter *Adapter)
-{
-       /*  Tx aggregation setting */
-       usb_AggSettingTxUpdate(Adapter);
-
-       /*  Rx aggregation setting */
-       usb_AggSettingRxUpdate(Adapter);
-}
-
-/* FIXME: add error handling in callers */
-static int _InitBeaconParameters(struct adapter *Adapter)
-{
-       struct hal_data_8188e *haldata = &Adapter->haldata;
-       int res;
-
-       rtw_write16(Adapter, REG_BCN_CTRL, 0x1010);
-
-       /*  TODO: Remove these magic number */
-       rtw_write16(Adapter, REG_TBTT_PROHIBIT, 0x6404);/*  ms */
-       rtw_write8(Adapter, REG_DRVERLYINT, DRIVER_EARLY_INT_TIME);/*  5ms */
-       rtw_write8(Adapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME); /*  2ms */
-
-       /*  Suggested by designer timchen. Change beacon AIFS to the largest number */
-       /*  beacause test chip does not contension before sending beacon. by tynli. 2009.11.03 */
-       rtw_write16(Adapter, REG_BCNTCFG, 0x660F);
-
-       res = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL + 2, &haldata->RegFwHwTxQCtrl);
-       if (res)
-               return res;
-
-       res = rtw_read8(Adapter, REG_TBTT_PROHIBIT + 2, &haldata->RegReg542);
-       if (res)
-               return res;
-
-       res = rtw_read8(Adapter, REG_CR + 1, &haldata->RegCR_1);
-       if (res)
-               return res;
-
-       return 0;
-}
-
-static void _BeaconFunctionEnable(struct adapter *Adapter)
-{
-       rtw_write8(Adapter, REG_BCN_CTRL, (BIT(4) | BIT(3) | BIT(1)));
-
-       rtw_write8(Adapter, REG_RD_CTRL + 1, 0x6F);
-}
-
-/*  Set CCK and OFDM Block "ON" */
-static void _BBTurnOnBlock(struct adapter *Adapter)
-{
-       rtl8188e_PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bCCKEn, 0x1);
-       rtl8188e_PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bOFDMEn, 0x1);
-}
-
-static void _InitAntenna_Selection(struct adapter *Adapter)
-{
-       struct hal_data_8188e *haldata = &Adapter->haldata;
-       int res;
-       u32 reg;
-
-       if (haldata->AntDivCfg == 0)
-               return;
-
-       res = rtw_read32(Adapter, REG_LEDCFG0, &reg);
-       if (res)
-               return;
-
-       rtw_write32(Adapter, REG_LEDCFG0, reg | BIT(23));
-       rtl8188e_PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, BIT(13), 0x01);
-
-       if (rtl8188e_PHY_QueryBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300) == Antenna_A)
-               haldata->CurAntenna = Antenna_A;
-       else
-               haldata->CurAntenna = Antenna_B;
-}
-
-static void hw_var_set_macaddr(struct adapter *Adapter, u8 *val)
-{
-       u8 idx = 0;
-       u32 reg_macid;
-
-       reg_macid = REG_MACID;
-
-       for (idx = 0; idx < 6; idx++)
-               rtw_write8(Adapter, (reg_macid + idx), val[idx]);
-}
-
-u32 rtl8188eu_hal_init(struct adapter *Adapter)
-{
-       u8 value8 = 0;
-       u16  value16;
-       u32 status = _SUCCESS;
-       int res;
-       struct hal_data_8188e *haldata = &Adapter->haldata;
-       struct pwrctrl_priv             *pwrctrlpriv = &Adapter->pwrctrlpriv;
-       struct registry_priv    *pregistrypriv = &Adapter->registrypriv;
-       u32 reg;
-
-       if (Adapter->pwrctrlpriv.bkeepfwalive) {
-               if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) {
-                       PHY_IQCalibrate_8188E(Adapter, true);
-               } else {
-                       PHY_IQCalibrate_8188E(Adapter, false);
-                       haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true;
-               }
-
-               ODM_TXPowerTrackingCheck(&haldata->odmpriv);
-               PHY_LCCalibrate_8188E(Adapter);
-
-               goto exit;
-       }
-
-       status = rtl8188eu_InitPowerOn(Adapter);
-       if (status == _FAIL)
-               goto exit;
-
-       /*  Save target channel */
-       haldata->CurrentChannel = 6;/* default set to 6 */
-
-       /*  2010/08/09 MH We need to check if we need to turnon or off RF after detecting */
-       /*  HW GPIO pin. Before PHY_RFConfig8192C. */
-       /*  2010/08/26 MH If Efuse does not support sective suspend then disable the function. */
-
-       _InitQueueReservedPage(Adapter);
-       _InitQueuePriority(Adapter);
-       _InitPageBoundary(Adapter);
-       _InitTransferPageSize(Adapter);
-
-       _InitTxBufferBoundary(Adapter, 0);
-
-       status = rtl8188e_firmware_download(Adapter);
-
-       if (status != _SUCCESS) {
-               Adapter->bFWReady = false;
-               haldata->fw_ractrl = false;
-               return status;
-       } else {
-               Adapter->bFWReady = true;
-               haldata->fw_ractrl = false;
-       }
-       /* Initialize firmware vars */
-       Adapter->pwrctrlpriv.bFwCurrentInPSMode = false;
-       haldata->LastHMEBoxNum = 0;
-
-       if (PHY_MACConfig8188E(Adapter))
-               return _FAIL;
-
-       /*  */
-       /* d. Initialize BB related configurations. */
-       /*  */
-       if (PHY_BBConfig8188E(Adapter))
-               return _FAIL;
-
-       if (phy_RF6052_Config_ParaFile(Adapter))
-               return _FAIL;
-
-       status = rtl8188e_iol_efuse_patch(Adapter);
-       if (status == _FAIL)
-               goto exit;
-
-       _InitTxBufferBoundary(Adapter, TX_PAGE_BOUNDARY_88E);
-
-       status =  InitLLTTable(Adapter, TX_PAGE_BOUNDARY_88E);
-       if (status == _FAIL)
-               goto exit;
-
-       /*  Get Rx PHY status in order to report RSSI and others. */
-       _InitDriverInfoSize(Adapter, DRVINFO_SZ);
-
-       _InitInterrupt(Adapter);
-       hw_var_set_macaddr(Adapter, Adapter->eeprompriv.mac_addr);
-       _InitNetworkType(Adapter);/* set msr */
-       _InitWMACSetting(Adapter);
-       _InitAdaptiveCtrl(Adapter);
-       _InitEDCA(Adapter);
-       _InitRetryFunction(Adapter);
-       InitUsbAggregationSetting(Adapter);
-       _InitBeaconParameters(Adapter);
-
-       /*  */
-       /*  Init CR MACTXEN, MACRXEN after setting RxFF boundary REG_TRXFF_BNDY to patch */
-       /*  Hw bug which Hw initials RxFF boundary size to a value which is larger than the real Rx buffer size in 88E. */
-       /*  */
-       /*  Enable MACTXEN/MACRXEN block */
-       res = rtw_read16(Adapter, REG_CR, &value16);
-       if (res)
-               return _FAIL;
-
-       value16 |= (MACTXEN | MACRXEN);
-       rtw_write8(Adapter, REG_CR, value16);
-
-       /* Enable TX Report */
-       /* Enable Tx Report Timer */
-       res = rtw_read8(Adapter, REG_TX_RPT_CTRL, &value8);
-       if (res)
-               return _FAIL;
-
-       rtw_write8(Adapter,  REG_TX_RPT_CTRL, (value8 | BIT(1) | BIT(0)));
-       /* Set MAX RPT MACID */
-       rtw_write8(Adapter,  REG_TX_RPT_CTRL + 1, 2);/* FOR sta mode ,0: bc/mc ,1:AP */
-       /* Tx RPT Timer. Unit: 32us */
-       rtw_write16(Adapter, REG_TX_RPT_TIME, 0xCdf0);
-
-       rtw_write8(Adapter, REG_EARLY_MODE_CONTROL, 0);
-
-       rtw_write16(Adapter, REG_PKT_VO_VI_LIFE_TIME, 0x0400);  /*  unit: 256us. 256ms */
-       rtw_write16(Adapter, REG_PKT_BE_BK_LIFE_TIME, 0x0400);  /*  unit: 256us. 256ms */
-
-       /* Keep RfRegChnlVal for later use. */
-       haldata->RfRegChnlVal = rtl8188e_PHY_QueryRFReg(Adapter, RF_CHNLBW, bRFRegOffsetMask);
-
-       _BBTurnOnBlock(Adapter);
-
-       invalidate_cam_all(Adapter);
-
-       /*  2010/12/17 MH We need to set TX power according to EFUSE content at first. */
-       PHY_SetTxPowerLevel8188E(Adapter, haldata->CurrentChannel);
-
-/*  Move by Neo for USB SS to below setp */
-/* _RfPowerSave(Adapter); */
-
-       _InitAntenna_Selection(Adapter);
-
-       /*  */
-       /*  Disable BAR, suggested by Scott */
-       /*  2010.04.09 add by hpfan */
-       /*  */
-       rtw_write32(Adapter, REG_BAR_MODE_CTRL, 0x0201ffff);
-
-       /*  HW SEQ CTRL */
-       /* set 0x0 to 0xFF by tynli. Default enable HW SEQ NUM. */
-       rtw_write8(Adapter, REG_HWSEQ_CTRL, 0xFF);
-
-       if (pregistrypriv->wifi_spec)
-               rtw_write16(Adapter, REG_FAST_EDCA_CTRL, 0);
-
-       /* Nav limit , suggest by scott */
-       rtw_write8(Adapter, 0x652, 0x0);
-
-       rtl8188e_InitHalDm(Adapter);
-
-       /*  2010/08/11 MH Merge from 8192SE for Minicard init. We need to confirm current radio status */
-       /*  and then decide to enable RF or not.!!!??? For Selective suspend mode. We may not */
-       /*  call initstruct adapter. May cause some problem?? */
-       /*  Fix the bug that Hw/Sw radio off before S3/S4, the RF off action will not be executed */
-       /*  in MgntActSet_RF_State() after wake up, because the value of haldata->eRFPowerState */
-       /*  is the same as eRfOff, we should change it to eRfOn after we config RF parameters. */
-       /*  Added by tynli. 2010.03.30. */
-       pwrctrlpriv->rf_pwrstate = rf_on;
-
-       /*  enable Tx report. */
-       rtw_write8(Adapter,  REG_FWHW_TXQ_CTRL + 1, 0x0F);
-
-       /*  Suggested by SD1 pisa. Added by tynli. 2011.10.21. */
-       rtw_write8(Adapter, REG_EARLY_MODE_CONTROL + 3, 0x01);/* Pretx_en, for WEP/TKIP SEC */
-
-       /* tynli_test_tx_report. */
-       rtw_write16(Adapter, REG_TX_RPT_TIME, 0x3DF0);
-
-       /* enable tx DMA to drop the redundate data of packet */
-       res = rtw_read16(Adapter, REG_TXDMA_OFFSET_CHK, &value16);
-       if (res)
-               return _FAIL;
-
-       rtw_write16(Adapter, REG_TXDMA_OFFSET_CHK, (value16 | DROP_DATA_EN));
-
-       /*  2010/08/26 MH Merge from 8192CE. */
-       if (pwrctrlpriv->rf_pwrstate == rf_on) {
-               if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) {
-                       PHY_IQCalibrate_8188E(Adapter, true);
-               } else {
-                       PHY_IQCalibrate_8188E(Adapter, false);
-                       haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true;
-               }
-
-               ODM_TXPowerTrackingCheck(&haldata->odmpriv);
-
-               PHY_LCCalibrate_8188E(Adapter);
-       }
-
-/*     _InitPABias(Adapter); */
-       rtw_write8(Adapter, REG_USB_HRPWM, 0);
-
-       /* ack for xmit mgmt frames. */
-       res = rtw_read32(Adapter, REG_FWHW_TXQ_CTRL, &reg);
-       if (res)
-               return _FAIL;
-
-       rtw_write32(Adapter, REG_FWHW_TXQ_CTRL, reg | BIT(12));
-
-exit:
-       return status;
-}
-
-static void CardDisableRTL8188EU(struct adapter *Adapter)
-{
-       u8 val8;
-       struct hal_data_8188e *haldata = &Adapter->haldata;
-       int res;
-
-       /* Stop Tx Report Timer. 0x4EC[Bit1]=b'0 */
-       res = rtw_read8(Adapter, REG_TX_RPT_CTRL, &val8);
-       if (res)
-               return;
-
-       rtw_write8(Adapter, REG_TX_RPT_CTRL, val8 & (~BIT(1)));
-
-       /*  stop rx */
-       rtw_write8(Adapter, REG_CR, 0x0);
-
-       /*  Run LPS WL RFOFF flow */
-       HalPwrSeqCmdParsing(Adapter, LPS_ENTER_FLOW);
-
-       /*  2. 0x1F[7:0] = 0            turn off RF */
-
-       res = rtw_read8(Adapter, REG_MCUFWDL, &val8);
-       if (res)
-               return;
-
-       if ((val8 & RAM_DL_SEL) && Adapter->bFWReady) { /* 8051 RAM code */
-               /*  Reset MCU 0x2[10]=0. */
-               res = rtw_read8(Adapter, REG_SYS_FUNC_EN + 1, &val8);
-               if (res)
-                       return;
-
-               val8 &= ~BIT(2);        /*  0x2[10], FEN_CPUEN */
-               rtw_write8(Adapter, REG_SYS_FUNC_EN + 1, val8);
-       }
-
-       /*  reset MCU ready status */
-       rtw_write8(Adapter, REG_MCUFWDL, 0);
-
-       /* YJ,add,111212 */
-       /* Disable 32k */
-       res = rtw_read8(Adapter, REG_32K_CTRL, &val8);
-       if (res)
-               return;
-
-       rtw_write8(Adapter, REG_32K_CTRL, val8 & (~BIT(0)));
-
-       /*  Card disable power action flow */
-       HalPwrSeqCmdParsing(Adapter, DISABLE_FLOW);
-
-       /*  Reset MCU IO Wrapper */
-       res = rtw_read8(Adapter, REG_RSV_CTRL + 1, &val8);
-       if (res)
-               return;
-
-       rtw_write8(Adapter, REG_RSV_CTRL + 1, (val8 & (~BIT(3))));
-
-       res = rtw_read8(Adapter, REG_RSV_CTRL + 1, &val8);
-       if (res)
-               return;
-
-       rtw_write8(Adapter, REG_RSV_CTRL + 1, val8 | BIT(3));
-
-       /* YJ,test add, 111207. For Power Consumption. */
-       res = rtw_read8(Adapter, GPIO_IN, &val8);
-       if (res)
-               return;
-
-       rtw_write8(Adapter, GPIO_OUT, val8);
-       rtw_write8(Adapter, GPIO_IO_SEL, 0xFF);/* Reg0x46 */
-
-       res = rtw_read8(Adapter, REG_GPIO_IO_SEL, &val8);
-       if (res)
-               return;
-
-       rtw_write8(Adapter, REG_GPIO_IO_SEL, (val8 << 4));
-       res = rtw_read8(Adapter, REG_GPIO_IO_SEL + 1, &val8);
-       if (res)
-               return;
-
-       rtw_write8(Adapter, REG_GPIO_IO_SEL + 1, val8 | 0x0F);/* Reg0x43 */
-       rtw_write32(Adapter, REG_BB_PAD_CTRL, 0x00080808);/* set LNA ,TRSW,EX_PA Pin to output mode */
-       haldata->bMacPwrCtrlOn = false;
-       Adapter->bFWReady = false;
-}
-
-u32 rtl8188eu_hal_deinit(struct adapter *Adapter)
-{
-       rtw_write32(Adapter, REG_HIMR_88E, IMR_DISABLED_88E);
-       rtw_write32(Adapter, REG_HIMRE_88E, IMR_DISABLED_88E);
-
-       if (!Adapter->pwrctrlpriv.bkeepfwalive) {
-               if (Adapter->hw_init_completed) {
-                       CardDisableRTL8188EU(Adapter);
-               }
-       }
-       return _SUCCESS;
- }
-
-int rtl8188eu_inirp_init(struct adapter *Adapter)
-{
-       u8 i;
-       struct recv_buf *precvbuf;
-       struct recv_priv *precvpriv = &Adapter->recvpriv;
-       int ret;
-
-       /* issue Rx irp to receive data */
-       precvbuf = (struct recv_buf *)precvpriv->precv_buf;
-       for (i = 0; i < NR_RECVBUFF; i++) {
-               ret = rtw_read_port(Adapter, precvbuf);
-               if (ret)
-                       return ret;
-
-               precvbuf++;
-               precvpriv->free_recv_buf_queue_cnt--;
-       }
-
-       return 0;
-}
-
-/*  */
-/*  */
-/*     EEPROM/EFUSE Content Parsing */
-/*  */
-/*  */
-
-static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail)
-{
-       struct eeprom_priv *eeprom = &adapt->eeprompriv;
-
-       if (AutoLoadFail) {
-               eth_random_addr(eeprom->mac_addr);
-       } else {
-               /* Read Permanent MAC address */
-               memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN);
-       }
-}
-
-int ReadAdapterInfo8188EU(struct adapter *Adapter)
-{
-       struct eeprom_priv *eeprom = &Adapter->eeprompriv;
-       struct led_priv *ledpriv = &Adapter->ledpriv;
-       u8 *efuse_buf;
-       u8 eeValue;
-       int res;
-
-       /* check system boot selection */
-       res = rtw_read8(Adapter, REG_9346CR, &eeValue);
-       if (res)
-               return res;
-
-       eeprom->bautoload_fail_flag     = !(eeValue & EEPROM_EN);
-
-       efuse_buf = kmalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
-       if (!efuse_buf)
-               return -ENOMEM;
-       memset(efuse_buf, 0xFF, EFUSE_MAP_LEN_88E);
-
-       if (!(eeValue & BOOT_FROM_EEPROM) && !eeprom->bautoload_fail_flag) {
-               rtl8188e_EfusePowerSwitch(Adapter, true);
-               rtl8188e_ReadEFuse(Adapter, EFUSE_MAP_LEN_88E, efuse_buf);
-               rtl8188e_EfusePowerSwitch(Adapter, false);
-       }
-
-       /* parse the eeprom/efuse content */
-       Hal_EfuseParseIDCode88E(Adapter, efuse_buf);
-       Hal_EfuseParseMACAddr_8188EU(Adapter, efuse_buf, eeprom->bautoload_fail_flag);
-
-       Hal_ReadPowerSavingMode88E(Adapter, efuse_buf, eeprom->bautoload_fail_flag);
-       Hal_ReadTxPowerInfo88E(Adapter, efuse_buf, eeprom->bautoload_fail_flag);
-       rtl8188e_EfuseParseChnlPlan(Adapter, efuse_buf, eeprom->bautoload_fail_flag);
-       Hal_EfuseParseXtal_8188E(Adapter, efuse_buf, eeprom->bautoload_fail_flag);
-       Hal_ReadAntennaDiversity88E(Adapter, efuse_buf, eeprom->bautoload_fail_flag);
-       Hal_ReadThermalMeter_88E(Adapter, efuse_buf, eeprom->bautoload_fail_flag);
-
-       ledpriv->bRegUseLed = true;
-       kfree(efuse_buf);
-       return 0;
-}
-
-void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level)
-{
-       u8 init_rate = 0;
-       u8 networkType, raid;
-       u32 mask, rate_bitmap;
-       u8 shortGIrate = false;
-       int     supportRateNum = 0;
-       struct sta_info *psta;
-       struct hal_data_8188e *haldata = &adapt->haldata;
-       struct mlme_ext_priv    *pmlmeext = &adapt->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_bssid_ex    *cur_network = &pmlmeinfo->network;
-
-       if (mac_id >= NUM_STA) /* CAM_SIZE */
-               return;
-       psta = pmlmeinfo->FW_sta_info[mac_id].psta;
-       if (!psta)
-               return;
-       switch (mac_id) {
-       case 0:/*  for infra mode */
-               supportRateNum = rtw_get_rateset_len(cur_network->SupportedRates);
-               networkType = judge_network_type(adapt, cur_network->SupportedRates, supportRateNum) & 0xf;
-               raid = networktype_to_raid(networkType);
-               mask = update_supported_rate(cur_network->SupportedRates, supportRateNum);
-               mask |= (pmlmeinfo->HT_enable) ? update_MSC_rate(&pmlmeinfo->HT_caps) : 0;
-               if (support_short_GI(adapt, &pmlmeinfo->HT_caps))
-                       shortGIrate = true;
-               break;
-       case 1:/* for broadcast/multicast */
-               supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates);
-               if (pmlmeext->cur_wireless_mode & WIRELESS_11B)
-                       networkType = WIRELESS_11B;
-               else
-                       networkType = WIRELESS_11G;
-               raid = networktype_to_raid(networkType);
-               mask = update_basic_rate(cur_network->SupportedRates, supportRateNum);
-               break;
-       default: /* for each sta in IBSS */
-               supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates);
-               networkType = judge_network_type(adapt, pmlmeinfo->FW_sta_info[mac_id].SupportedRates, supportRateNum) & 0xf;
-               raid = networktype_to_raid(networkType);
-               mask = update_supported_rate(cur_network->SupportedRates, supportRateNum);
-
-               /* todo: support HT in IBSS */
-               break;
-       }
-
-       rate_bitmap = 0x0fffffff;
-       rate_bitmap = ODM_Get_Rate_Bitmap(&haldata->odmpriv, mac_id, mask, rssi_level);
-
-       mask &= rate_bitmap;
-
-       init_rate = get_highest_rate_idx(mask) & 0x3f;
-
-       if (haldata->fw_ractrl) {
-               mask |= ((raid << 28) & 0xf0000000);
-               psta->ra_mask = mask;
-               mask |= ((raid << 28) & 0xf0000000);
-
-               /* to do ,for 8188E-SMIC */
-               rtl8188e_set_raid_cmd(adapt, mask);
-       } else {
-               ODM_RA_UpdateRateInfo_8188E(&haldata->odmpriv,
-                               mac_id,
-                               raid,
-                               mask,
-                               shortGIrate
-                               );
-       }
-       /* set ra_id */
-       psta->raid = raid;
-       psta->init_rate = init_rate;
-}
-
-void SetBeaconRelatedRegisters8188EUsb(struct adapter *adapt)
-{
-       u32 value32;
-       struct mlme_ext_priv    *pmlmeext = &adapt->mlmeextpriv;
-       struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       u32 bcn_ctrl_reg                        = REG_BCN_CTRL;
-       int res;
-       u8 reg;
-       /* reset TSF, enable update TSF, correcting TSF On Beacon */
-
-       /* BCN interval */
-       rtw_write16(adapt, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval);
-       rtw_write8(adapt, REG_ATIMWND, 0x02);/*  2ms */
-
-       _InitBeaconParameters(adapt);
-
-       rtw_write8(adapt, REG_SLOT, 0x09);
-
-       res = rtw_read32(adapt, REG_TCR, &value32);
-       if (res)
-               return;
-
-       value32 &= ~TSFRST;
-       rtw_write32(adapt,  REG_TCR, value32);
-
-       value32 |= TSFRST;
-       rtw_write32(adapt, REG_TCR, value32);
-
-       /*  NOTE: Fix test chip's bug (about contention windows's randomness) */
-       rtw_write8(adapt,  REG_RXTSF_OFFSET_CCK, 0x50);
-       rtw_write8(adapt, REG_RXTSF_OFFSET_OFDM, 0x50);
-
-       _BeaconFunctionEnable(adapt);
-
-       rtw_resume_tx_beacon(adapt);
-
-       res = rtw_read8(adapt, bcn_ctrl_reg, &reg);
-       if (res)
-               return;
-
-       rtw_write8(adapt, bcn_ctrl_reg, reg | BIT(1));
-}
-
-void rtl8188eu_init_default_value(struct adapter *adapt)
-{
-       struct hal_data_8188e *haldata = &adapt->haldata;
-       struct pwrctrl_priv *pwrctrlpriv;
-       u8 i;
-
-       pwrctrlpriv = &adapt->pwrctrlpriv;
-
-       /* init default value */
-       haldata->fw_ractrl = false;
-       if (!pwrctrlpriv->bkeepfwalive)
-               haldata->LastHMEBoxNum = 0;
-
-       /* init dm default value */
-       haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = false;
-       haldata->odmpriv.RFCalibrateInfo.TM_Trigger = 0;/* for IQK */
-       haldata->pwrGroupCnt = 0;
-       haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP_index = 0;
-       for (i = 0; i < HP_THERMAL_NUM; i++)
-               haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP[i] = 0;
-}
diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c
deleted file mode 100644 (file)
index 9611b19..0000000
+++ /dev/null
@@ -1,476 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/osdep_intf.h"
-#include "../include/usb_ops.h"
-#include "../include/rtl8188e_hal.h"
-
-#define VENDOR_CMD_MAX_DATA_LEN        254
-
-#define RTW_USB_CONTROL_MSG_TIMEOUT    500/* ms */
-
-static int usb_read(struct adapter *adapt, u16 value, void *data, u8 size)
-{
-       struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt);
-       struct usb_device *udev = dvobjpriv->pusbdev;
-       int status;
-       u8 io_buf[4];
-
-       if (adapt->bSurpriseRemoved)
-               return -EPERM;
-
-       status = usb_control_msg_recv(udev, 0, REALTEK_USB_VENQT_CMD_REQ,
-                                     REALTEK_USB_VENQT_READ, value,
-                                     REALTEK_USB_VENQT_CMD_IDX, io_buf,
-                                     size, RTW_USB_CONTROL_MSG_TIMEOUT,
-                                     GFP_KERNEL);
-
-       if (status == -ESHUTDOWN ||
-           status == -ENODEV ||
-           status == -ENOENT) {
-               /*
-                * device or controller has been disabled due to
-                * some problem that could not be worked around,
-                * device or bus doesn’t exist, endpoint does not
-                * exist or is not enabled.
-                */
-               adapt->bSurpriseRemoved = true;
-               return status;
-       }
-
-       if (status < 0) {
-               if (rtw_inc_and_chk_continual_urb_error(dvobjpriv))
-                       adapt->bSurpriseRemoved = true;
-
-               return status;
-       }
-
-       rtw_reset_continual_urb_error(dvobjpriv);
-       memcpy(data, io_buf, size);
-
-       return status;
-}
-
-static int usb_write(struct adapter *adapt, u16 value, void *data, u8 size)
-{
-       struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt);
-       struct usb_device *udev = dvobjpriv->pusbdev;
-       int status;
-       u8 io_buf[VENDOR_CMD_MAX_DATA_LEN];
-
-       if (adapt->bSurpriseRemoved)
-               return -EPERM;
-
-       memcpy(io_buf, data, size);
-       status = usb_control_msg_send(udev, 0, REALTEK_USB_VENQT_CMD_REQ,
-                                     REALTEK_USB_VENQT_WRITE, value,
-                                     REALTEK_USB_VENQT_CMD_IDX, io_buf,
-                                     size, RTW_USB_CONTROL_MSG_TIMEOUT,
-                                     GFP_KERNEL);
-
-       if (status == -ESHUTDOWN ||
-           status == -ENODEV ||
-           status == -ENOENT) {
-               /*
-                * device or controller has been disabled due to
-                * some problem that could not be worked around,
-                * device or bus doesn’t exist, endpoint does not
-                * exist or is not enabled.
-                */
-               adapt->bSurpriseRemoved = true;
-               return status;
-       }
-
-       if (status < 0) {
-               if (rtw_inc_and_chk_continual_urb_error(dvobjpriv))
-                       adapt->bSurpriseRemoved = true;
-
-               return status;
-       }
-
-       rtw_reset_continual_urb_error(dvobjpriv);
-
-       return status;
-}
-
-int __must_check rtw_read8(struct adapter *adapter, u32 addr, u8 *data)
-{
-       u16 value = addr & 0xffff;
-
-       return usb_read(adapter, value, data, 1);
-}
-
-int __must_check rtw_read16(struct adapter *adapter, u32 addr, u16 *data)
-{
-       u16 value = addr & 0xffff;
-       __le16 le_data;
-       int res;
-
-       res = usb_read(adapter, value, &le_data, 2);
-       if (res)
-               return res;
-
-       *data = le16_to_cpu(le_data);
-
-       return 0;
-}
-
-int __must_check rtw_read32(struct adapter *adapter, u32 addr, u32 *data)
-{
-       u16 value = addr & 0xffff;
-       __le32 le_data;
-       int res;
-
-       res = usb_read(adapter, value, &le_data, 4);
-       if (res)
-               return res;
-
-       *data = le32_to_cpu(le_data);
-
-       return 0;
-}
-
-int rtw_write8(struct adapter *adapter, u32 addr, u8 val)
-{
-       u16 value = addr & 0xffff;
-       int ret;
-
-       ret = usb_write(adapter, value, &val, 1);
-
-       return RTW_STATUS_CODE(ret);
-}
-
-int rtw_write16(struct adapter *adapter, u32 addr, u16 val)
-{
-       u16 value = addr & 0xffff;
-       __le16 data = cpu_to_le16(val);
-       int ret;
-
-       ret = usb_write(adapter, value, &data, 2);
-
-       return RTW_STATUS_CODE(ret);
-}
-
-int rtw_write32(struct adapter *adapter, u32 addr, u32 val)
-{
-       u16 value = addr & 0xffff;
-       __le32 data = cpu_to_le32(val);
-       int ret;
-
-       ret = usb_write(adapter, value, &data, 4);
-
-       return RTW_STATUS_CODE(ret);
-}
-
-int rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *data)
-{
-       u16 value = addr & 0xffff;
-
-       if (length > VENDOR_CMD_MAX_DATA_LEN)
-               return -EINVAL;
-
-       return usb_write(adapter, value, data, length);
-}
-
-static void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf)
-{
-       struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf;
-
-       if (txrpt_ccx->int_ccx) {
-               if (txrpt_ccx->pkt_ok)
-                       rtw_ack_tx_done(&adapter->xmitpriv,
-                                       RTW_SCTX_DONE_SUCCESS);
-               else
-                       rtw_ack_tx_done(&adapter->xmitpriv,
-                                       RTW_SCTX_DONE_CCX_PKT_FAIL);
-       }
-}
-
-static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb)
-{
-       u8      *pbuf;
-       u8      shift_sz = 0;
-       u16     pkt_cnt;
-       u32     pkt_offset, skb_len, alloc_sz;
-       s32     transfer_len;
-       struct recv_stat        *prxstat;
-       struct phy_stat *pphy_status = NULL;
-       struct sk_buff *pkt_copy = NULL;
-       struct recv_frame       *precvframe = NULL;
-       struct rx_pkt_attrib    *pattrib = NULL;
-       struct hal_data_8188e *haldata = &adapt->haldata;
-       struct recv_priv        *precvpriv = &adapt->recvpriv;
-       struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue;
-
-       transfer_len = (s32)pskb->len;
-       pbuf = pskb->data;
-
-       prxstat = (struct recv_stat *)pbuf;
-       pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff;
-
-       do {
-               prxstat = (struct recv_stat *)pbuf;
-
-               precvframe = rtw_alloc_recvframe(pfree_recv_queue);
-               if (!precvframe)
-                       goto _exit_recvbuf2recvframe;
-
-               INIT_LIST_HEAD(&precvframe->list);
-               precvframe->precvbuf = NULL;    /* can't access the precvbuf for new arch. */
-               precvframe->len = 0;
-
-               update_recvframe_attrib_88e(precvframe, prxstat);
-
-               pattrib = &precvframe->attrib;
-
-               if ((pattrib->crc_err) || (pattrib->icv_err)) {
-                       rtw_free_recvframe(precvframe, pfree_recv_queue);
-                       goto _exit_recvbuf2recvframe;
-               }
-
-               if ((pattrib->physt) && (pattrib->pkt_rpt_type == NORMAL_RX))
-                       pphy_status = (struct phy_stat *)(pbuf + RXDESC_OFFSET);
-
-               pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len;
-
-               if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) {
-                       rtw_free_recvframe(precvframe, pfree_recv_queue);
-                       goto _exit_recvbuf2recvframe;
-               }
-
-               /*      Modified by Albert 20101213 */
-               /*      For 8 bytes IP header alignment. */
-               if (pattrib->qos)       /*      Qos data, wireless lan header length is 26 */
-                       shift_sz = 6;
-               else
-                       shift_sz = 0;
-
-               skb_len = pattrib->pkt_len;
-
-               /*  for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet. */
-               /*  modify alloc_sz for recvive crc error packet by thomas 2011-06-02 */
-               if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) {
-                       if (skb_len <= 1650)
-                               alloc_sz = 1664;
-                       else
-                               alloc_sz = skb_len + 14;
-               } else {
-                       alloc_sz = skb_len;
-                       /*      6 is for IP header 8 bytes alignment in QoS packet case. */
-                       /*      8 is for skb->data 4 bytes alignment. */
-                       alloc_sz += 14;
-               }
-
-               pkt_copy = netdev_alloc_skb(adapt->pnetdev, alloc_sz);
-               if (pkt_copy) {
-                       precvframe->pkt = pkt_copy;
-                       precvframe->rx_head = pkt_copy->data;
-                       precvframe->rx_end = pkt_copy->data + alloc_sz;
-                       skb_reserve(pkt_copy, 8 - ((size_t)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */
-                       skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */
-                       memcpy(pkt_copy->data, (pbuf + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len);
-                       precvframe->rx_tail = pkt_copy->data;
-                       precvframe->rx_data = pkt_copy->data;
-               } else {
-                       if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) {
-                               rtw_free_recvframe(precvframe, pfree_recv_queue);
-                               goto _exit_recvbuf2recvframe;
-                       }
-                       precvframe->pkt = skb_clone(pskb, GFP_ATOMIC);
-                       if (precvframe->pkt) {
-                               precvframe->rx_tail = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE;
-                               precvframe->rx_head = precvframe->rx_tail;
-                               precvframe->rx_data = precvframe->rx_tail;
-                               precvframe->rx_end =  pbuf + pattrib->drvinfo_sz + RXDESC_SIZE + alloc_sz;
-                       } else {
-                               rtw_free_recvframe(precvframe, pfree_recv_queue);
-                               goto _exit_recvbuf2recvframe;
-                       }
-               }
-
-               recvframe_put(precvframe, skb_len);
-
-               pkt_offset = (u16)round_up(pkt_offset, 128);
-
-               if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */
-                       if (pattrib->physt)
-                               update_recvframe_phyinfo_88e(precvframe, (struct phy_stat *)pphy_status);
-                       rtw_recv_entry(precvframe);
-               } else {
-                       /* enqueue recvframe to txrtp queue */
-                       if (pattrib->pkt_rpt_type == TX_REPORT1) {
-                               /* CCX-TXRPT ack for xmit mgmt frames. */
-                               handle_txrpt_ccx_88e(adapt, precvframe->rx_data);
-                       } else if (pattrib->pkt_rpt_type == TX_REPORT2) {
-                               ODM_RA_TxRPT2Handle_8188E(
-                                                       &haldata->odmpriv,
-                                                       precvframe->rx_data,
-                                                       pattrib->pkt_len,
-                                                       pattrib->MacIDValidEntry[0],
-                                                       pattrib->MacIDValidEntry[1]
-                                                       );
-                       }
-                       rtw_free_recvframe(precvframe, pfree_recv_queue);
-               }
-               pkt_cnt--;
-               transfer_len -= pkt_offset;
-               pbuf += pkt_offset;
-               precvframe = NULL;
-               pkt_copy = NULL;
-
-               if (transfer_len > 0 && pkt_cnt == 0)
-                       pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff;
-
-       } while ((transfer_len > 0) && (pkt_cnt > 0));
-
-_exit_recvbuf2recvframe:
-
-       return _SUCCESS;
-}
-
-void rtl8188eu_recv_tasklet(unsigned long priv)
-{
-       struct sk_buff *pskb;
-       struct adapter *adapt = (struct adapter *)priv;
-       struct recv_priv *precvpriv = &adapt->recvpriv;
-
-       while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) {
-               if ((adapt->bDriverStopped) || (adapt->bSurpriseRemoved)) {
-                       dev_kfree_skb_any(pskb);
-                       break;
-               }
-               recvbuf2recvframe(adapt, pskb);
-               skb_reset_tail_pointer(pskb);
-               pskb->len = 0;
-               skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb);
-       }
-}
-
-static void usb_read_port_complete(struct urb *purb)
-{
-       struct recv_buf *precvbuf = (struct recv_buf *)purb->context;
-       struct adapter  *adapt = (struct adapter *)precvbuf->adapter;
-       struct recv_priv *precvpriv = &adapt->recvpriv;
-
-       precvpriv->rx_pending_cnt--;
-
-       if (adapt->bSurpriseRemoved || adapt->bDriverStopped || adapt->bReadPortCancel) {
-               precvbuf->reuse = true;
-               return;
-       }
-
-       if (purb->status == 0) { /* SUCCESS */
-               if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) {
-                       precvbuf->reuse = true;
-                       rtw_read_port(adapt, precvbuf);
-               } else {
-                       rtw_reset_continual_urb_error(adapter_to_dvobj(adapt));
-
-                       skb_put(precvbuf->pskb, purb->actual_length);
-                       skb_queue_tail(&precvpriv->rx_skb_queue, precvbuf->pskb);
-
-                       if (skb_queue_len(&precvpriv->rx_skb_queue) <= 1)
-                               tasklet_schedule(&precvpriv->recv_tasklet);
-
-                       precvbuf->pskb = NULL;
-                       precvbuf->reuse = false;
-                       rtw_read_port(adapt, precvbuf);
-               }
-       } else {
-               skb_put(precvbuf->pskb, purb->actual_length);
-               precvbuf->pskb = NULL;
-
-               if (rtw_inc_and_chk_continual_urb_error(adapter_to_dvobj(adapt)))
-                       adapt->bSurpriseRemoved = true;
-
-               switch (purb->status) {
-               case -EINVAL:
-               case -EPIPE:
-               case -ENODEV:
-               case -ESHUTDOWN:
-               case -ENOENT:
-                       adapt->bDriverStopped = true;
-                       break;
-               case -EPROTO:
-               case -EOVERFLOW:
-                       precvbuf->reuse = true;
-                       rtw_read_port(adapt, precvbuf);
-                       break;
-               case -EINPROGRESS:
-                       break;
-               default:
-                       break;
-               }
-       }
-}
-
-int rtw_read_port(struct adapter *adapter, struct recv_buf *precvbuf)
-{
-       struct urb *purb = NULL;
-       struct dvobj_priv       *pdvobj = adapter_to_dvobj(adapter);
-       struct recv_priv        *precvpriv = &adapter->recvpriv;
-       struct usb_device       *pusbd = pdvobj->pusbdev;
-       int err;
-       unsigned int pipe;
-       size_t tmpaddr = 0;
-       size_t alignment = 0;
-
-       if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
-               return -EPERM;
-
-       if (!precvbuf)
-               return -ENOMEM;
-
-       if (!precvbuf->reuse || !precvbuf->pskb) {
-               precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue);
-               if (precvbuf->pskb)
-                       precvbuf->reuse = true;
-       }
-
-       /* re-assign for linux based on skb */
-       if (!precvbuf->reuse || !precvbuf->pskb) {
-               precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
-               if (!precvbuf->pskb)
-                       return -ENOMEM;
-
-               tmpaddr = (size_t)precvbuf->pskb->data;
-               alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1);
-               skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment));
-       } else { /* reuse skb */
-               precvbuf->reuse = false;
-       }
-
-       precvpriv->rx_pending_cnt++;
-
-       purb = precvbuf->purb;
-
-       /* translate DMA FIFO addr to pipehandle */
-       pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe);
-
-       usb_fill_bulk_urb(purb, pusbd, pipe,
-                         precvbuf->pskb->data,
-                         MAX_RECVBUF_SZ,
-                         usb_read_port_complete,
-                         precvbuf);/* context is precvbuf */
-
-       err = usb_submit_urb(purb, GFP_ATOMIC);
-       if ((err) && (err != (-EPERM)))
-               return err;
-
-       return 0;
-}
-
-void rtl8188eu_xmit_tasklet(unsigned long priv)
-{
-       struct adapter *adapt = (struct adapter *)priv;
-
-       if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY))
-               return;
-
-       do {
-               if (adapt->bDriverStopped || adapt->bSurpriseRemoved || adapt->bWritePortCancel)
-                       break;
-       } while (rtl8188eu_xmitframe_complete(adapt));
-}
diff --git a/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h
deleted file mode 100644 (file)
index 4a0b782..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __INC_HAL8188EPHYCFG_H__
-#define __INC_HAL8188EPHYCFG_H__
-
-#define MAX_AGGR_NUM                   0x07
-
-enum rf_radio_path {
-       RF_PATH_A = 0,                  /* Radio Path A */
-       RF_PATH_B = 1,                  /* Radio Path B */
-};
-
-#define MAX_PG_GROUP 13
-
-#define        RF_PATH_MAX                     3
-#define                MAX_TX_COUNT            4 /* path numbers */
-
-#define CHANNEL_MAX_NUMBER             14      /*  14 is the max chnl number */
-#define MAX_CHNL_GROUP_24G             6       /*  ch1~2, ch3~5, ch6~8,
-                                                *ch9~11, ch12~13, CH 14
-                                                * total three groups */
-
-struct bb_reg_def {
-       u32 rfintfs;            /*  set software control: */
-                               /*      0x870~0x877[8 bytes] */
-       u32 rfintfi;            /*  readback data: */
-                               /*      0x8e0~0x8e7[8 bytes] */
-       u32 rfintfo;            /*  output data: */
-                               /*      0x860~0x86f [16 bytes] */
-       u32 rfintfe;            /*  output enable: */
-                               /*      0x860~0x86f [16 bytes] */
-       u32 rf3wireOffset;      /*  LSSI data: */
-                               /*      0x840~0x84f [16 bytes] */
-       u32 rfLSSI_Select;      /*  BB Band Select: */
-                               /*      0x878~0x87f [8 bytes] */
-       u32 rfTxGainStage;      /*  Tx gain stage: */
-                               /*      0x80c~0x80f [4 bytes] */
-       u32 rfHSSIPara1;        /*  wire parameter control1 : */
-                               /*      0x820~0x823,0x828~0x82b,
-                                *      0x830~0x833, 0x838~0x83b [16 bytes] */
-       u32 rfHSSIPara2;        /*  wire parameter control2 : */
-                               /*      0x824~0x827,0x82c~0x82f, 0x834~0x837,
-                                *      0x83c~0x83f [16 bytes] */
-       u32 rfSwitchControl;    /* Tx Rx antenna control : */
-                               /*      0x858~0x85f [16 bytes] */
-       u32 rfAGCControl1;      /* AGC parameter control1 : */
-                               /*      0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63,
-                                * 0xc68~0xc6b [16 bytes] */
-       u32 rfAGCControl2;      /* AGC parameter control2 : */
-                               /*      0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67,
-                                *      0xc6c~0xc6f [16 bytes] */
-       u32 rfRxIQImbalance;    /* OFDM Rx IQ imbalance matrix : */
-                               /*      0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27,
-                                *      0xc2c~0xc2f [16 bytes] */
-       u32 rfRxAFE;            /* Rx IQ DC ofset and Rx digital filter,
-                                * Rx DC notch filter : */
-                               /*      0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23,
-                                *      0xc28~0xc2b [16 bytes] */
-       u32 rfTxIQImbalance;    /* OFDM Tx IQ imbalance matrix */
-                               /*      0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93,
-                                *       0xc98~0xc9b [16 bytes] */
-       u32 rfTxAFE;            /* Tx IQ DC Offset and Tx DFIR type */
-                               /*      0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97,
-                                *      0xc9c~0xc9f [16 bytes] */
-       u32 rfLSSIReadBack;     /* LSSI RF readback data SI mode */
-                               /*      0x8a0~0x8af [16 bytes] */
-       u32 rfLSSIReadBackPi;   /* LSSI RF readback data PI mode 0x8b8-8bc for
-                                * Path A and B */
-};
-
-/*  BB and RF register read/write */
-u32 rtl8188e_PHY_QueryBBReg(struct adapter *adapter, u32 regaddr, u32 mask);
-void rtl8188e_PHY_SetBBReg(struct adapter *Adapter, u32 RegAddr,
-                          u32 mask, u32 data);
-u32 rtl8188e_PHY_QueryRFReg(struct adapter *adapter, u32 regaddr, u32 mask);
-void rtl8188e_PHY_SetRFReg(struct adapter *adapter, u32 regaddr, u32 mask, u32 data);
-
-/*  Initialization related function */
-/* MAC/BB/RF HAL config */
-int PHY_MACConfig8188E(struct adapter *adapter);
-int PHY_BBConfig8188E(struct adapter *adapter);
-
-/*  BB TX Power R/W */
-void PHY_SetTxPowerLevel8188E(struct adapter *adapter, u8 channel);
-
-/*  Switch bandwidth for 8192S */
-void PHY_SetBWMode8188E(struct adapter *adapter,
-                       enum ht_channel_width chnlwidth, unsigned char offset);
-
-/*  channel switch related funciton */
-void PHY_SwChnl8188E(struct adapter *adapter, u8 channel);
-
-void storePwrIndexDiffRateOffset(struct adapter *adapter, u32 regaddr,
-                                u32 mask, u32 data);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/Hal8188EPhyReg.h b/drivers/staging/r8188eu/include/Hal8188EPhyReg.h
deleted file mode 100644 (file)
index da2329b..0000000
+++ /dev/null
@@ -1,1072 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __INC_HAL8188EPHYREG_H__
-#define __INC_HAL8188EPHYREG_H__
-/*--------------------------Define Parameters-------------------------------*/
-/*  */
-/*  BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF */
-/*  1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */
-/*  2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00 */
-/*  3. RF register 0x00-2E */
-/*  4. Bit Mask for BB/RF register */
-/*  5. Other definition for BB/RF R/W */
-/*  */
-
-/*  */
-/*  1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */
-/*  1. Page1(0x100) */
-/*  */
-#define        rPMAC_Reset             0x100
-#define        rPMAC_TxStart           0x104
-#define        rPMAC_TxLegacySIG       0x108
-#define        rPMAC_TxHTSIG1          0x10c
-#define        rPMAC_TxHTSIG2          0x110
-#define        rPMAC_PHYDebug          0x114
-#define        rPMAC_TxPacketNum       0x118
-#define        rPMAC_TxIdle            0x11c
-#define        rPMAC_TxMACHeader0      0x120
-#define        rPMAC_TxMACHeader1      0x124
-#define        rPMAC_TxMACHeader2      0x128
-#define        rPMAC_TxMACHeader3      0x12c
-#define        rPMAC_TxMACHeader4      0x130
-#define        rPMAC_TxMACHeader5      0x134
-#define        rPMAC_TxDataType        0x138
-#define        rPMAC_TxRandomSeed      0x13c
-#define        rPMAC_CCKPLCPPreamble   0x140
-#define        rPMAC_CCKPLCPHeader     0x144
-#define        rPMAC_CCKCRC16          0x148
-#define        rPMAC_OFDMRxCRC32OK     0x170
-#define        rPMAC_OFDMRxCRC32Er     0x174
-#define        rPMAC_OFDMRxParityEr    0x178
-#define        rPMAC_OFDMRxCRC8Er      0x17c
-#define        rPMAC_CCKCRxRC16Er      0x180
-#define        rPMAC_CCKCRxRC32Er      0x184
-#define        rPMAC_CCKCRxRC32OK      0x188
-#define        rPMAC_TxStatus          0x18c
-
-/*  2. Page2(0x200) */
-/*  The following two definition are only used for USB interface. */
-#define        RF_BB_CMD_ADDR          0x02c0  /*  RF/BB r/w cmd address. */
-#define        RF_BB_CMD_DATA          0x02c4  /*  RF/BB r/w cmd data. */
-
-/*  3. Page8(0x800) */
-#define        rFPGA0_RFMOD            0x800   /* RF mode & CCK TxSC RF BW Setting */
-
-#define        rFPGA0_TxInfo           0x804   /*  Status report?? */
-#define        rFPGA0_PSDFunction      0x808
-
-#define        rFPGA0_TxGainStage      0x80c   /*  Set TX PWR init gain? */
-
-#define        rFPGA0_RFTiming1        0x810   /*  Useless now */
-#define        rFPGA0_RFTiming2        0x814
-
-#define        rFPGA0_XA_HSSIParameter1        0x820   /*  RF 3 wire register */
-#define        rFPGA0_XA_HSSIParameter2        0x824
-#define        rFPGA0_XB_HSSIParameter1        0x828
-#define        rFPGA0_XB_HSSIParameter2        0x82c
-
-#define        rFPGA0_XA_LSSIParameter         0x840
-#define        rFPGA0_XB_LSSIParameter         0x844
-
-#define        rFPGA0_RFWakeUpParameter        0x850   /*  Useless now */
-#define        rFPGA0_RFSleepUpParameter       0x854
-
-#define        rFPGA0_XAB_SwitchControl        0x858   /*  RF Channel switch */
-#define        rFPGA0_XCD_SwitchControl        0x85c
-
-#define        rFPGA0_XA_RFInterfaceOE         0x860   /*  RF Channel switch */
-#define        rFPGA0_XB_RFInterfaceOE         0x864
-
-#define        rFPGA0_XAB_RFInterfaceSW        0x870   /*  RF Iface Software Control */
-#define        rFPGA0_XCD_RFInterfaceSW        0x874
-
-#define        rFPGA0_XAB_RFParameter          0x878   /*  RF Parameter */
-#define        rFPGA0_XCD_RFParameter          0x87c
-
-/* Crystal cap setting RF-R/W protection for parameter4?? */
-#define        rFPGA0_AnalogParameter1         0x880
-#define        rFPGA0_AnalogParameter2         0x884
-#define        rFPGA0_AnalogParameter3         0x888
-/*  enable ad/da clock1 for dual-phy */
-#define        rFPGA0_AdDaClockEn              0x888
-#define        rFPGA0_AnalogParameter4         0x88c
-
-#define        rFPGA0_XA_LSSIReadBack          0x8a0   /*  Transceiver LSSI Readback */
-#define        rFPGA0_XB_LSSIReadBack          0x8a4
-#define        rFPGA0_XC_LSSIReadBack          0x8a8
-#define        rFPGA0_XD_LSSIReadBack          0x8ac
-
-#define        rFPGA0_PSDReport                0x8b4   /*  Useless now */
-/*  Transceiver A HSPI Readback */
-#define        TransceiverA_HSPI_Readback      0x8b8
-/*  Transceiver B HSPI Readback */
-#define        TransceiverB_HSPI_Readback      0x8bc
-/*  Useless now RF Interface Readback Value */
-#define        rFPGA0_XAB_RFInterfaceRB        0x8e0
-#define        rFPGA0_XCD_RFInterfaceRB        0x8e4   /*  Useless now */
-
-/*  4. Page9(0x900) */
-/* RF mode & OFDM TxSC RF BW Setting?? */
-#define        rFPGA1_RFMOD                    0x900
-
-#define        rFPGA1_TxBlock                  0x904   /*  Useless now */
-#define        rFPGA1_DebugSelect              0x908   /*  Useless now */
-#define        rFPGA1_TxInfo                   0x90c   /*  Useless now Status report */
-
-/*  5. PageA(0xA00) */
-/*  Set Control channel to upper or lower - required only for 40MHz */
-#define        rCCK0_System                    0xa00
-
-/*  Disable init gain now Select RX path by RSSI */
-#define        rCCK0_AFESetting                0xa04
-/*  Disable init gain now Init gain */
-#define        rCCK0_CCA                       0xa08
-
-/* AGC default value, saturation level Antenna Diversity, RX AGC, LNA Threshold,
- * RX LNA Threshold useless now. Not the same as 90 series */
-#define        rCCK0_RxAGC1                    0xa0c
-#define        rCCK0_RxAGC2                    0xa10   /* AGC & DAGC */
-
-#define        rCCK0_RxHP                      0xa14
-
-/* Timing recovery & Channel estimation threshold */
-#define        rCCK0_DSPParameter1             0xa18
-#define        rCCK0_DSPParameter2             0xa1c   /* SQ threshold */
-
-#define        rCCK0_TxFilter1                 0xa20
-#define        rCCK0_TxFilter2                 0xa24
-#define        rCCK0_DebugPort                 0xa28   /* debug port and Tx filter3 */
-#define        rCCK0_FalseAlarmReport          0xa2c   /* 0xa2d useless now */
-#define        rCCK0_TRSSIReport               0xa50
-#define        rCCK0_RxReport                  0xa54  /* 0xa57 */
-#define        rCCK0_FACounterLower            0xa5c  /* 0xa5b */
-#define        rCCK0_FACounterUpper            0xa58  /* 0xa5c */
-
-/*  */
-/*  PageB(0xB00) */
-/*  */
-#define        rPdp_AntA                       0xb00
-#define        rPdp_AntA_4                     0xb04
-#define        rConfig_Pmpd_AntA               0xb28
-#define        rConfig_AntA                    0xb68
-#define        rConfig_AntB                    0xb6c
-#define        rPdp_AntB                       0xb70
-#define        rPdp_AntB_4                     0xb74
-#define        rConfig_Pmpd_AntB               0xb98
-#define        rAPK                            0xbd8
-
-/*  */
-/*  6. PageC(0xC00) */
-/*  */
-#define        rOFDM0_LSTF                     0xc00
-
-#define        rOFDM0_TRxPathEnable            0xc04
-#define        rOFDM0_TRMuxPar                 0xc08
-#define        rOFDM0_TRSWIsolation            0xc0c
-
-/* RxIQ DC offset, Rx digital filter, DC notch filter */
-#define        rOFDM0_XARxAFE                  0xc10
-#define        rOFDM0_XARxIQImbalance          0xc14  /* RxIQ imbalance matrix */
-#define        rOFDM0_XBRxAFE                  0xc18
-#define        rOFDM0_XBRxIQImbalance          0xc1c
-#define        rOFDM0_XCRxAFE                  0xc20
-#define        rOFDM0_XCRxIQImbalance          0xc24
-#define        rOFDM0_XDRxAFE                  0xc28
-#define        rOFDM0_XDRxIQImbalance          0xc2c
-
-#define        rOFDM0_RxDetector1              0xc30  /*PD,BW & SBD DM tune init gain*/
-#define        rOFDM0_RxDetector2              0xc34  /* SBD & Fame Sync. */
-#define        rOFDM0_RxDetector3              0xc38  /* Frame Sync. */
-#define        rOFDM0_RxDetector4              0xc3c  /* PD, SBD, Frame Sync & Short-GI */
-
-#define        rOFDM0_RxDSP                    0xc40  /* Rx Sync Path */
-#define        rOFDM0_CFOandDAGC               0xc44  /* CFO & DAGC */
-#define        rOFDM0_CCADropThreshold         0xc48 /* CCA Drop threshold */
-#define        rOFDM0_ECCAThreshold            0xc4c /*  energy CCA */
-
-#define        rOFDM0_XAAGCCore1               0xc50   /*  DIG */
-#define        rOFDM0_XAAGCCore2               0xc54
-#define        rOFDM0_XBAGCCore1               0xc58
-#define        rOFDM0_XBAGCCore2               0xc5c
-#define        rOFDM0_XCAGCCore1               0xc60
-#define        rOFDM0_XCAGCCore2               0xc64
-#define        rOFDM0_XDAGCCore1               0xc68
-#define        rOFDM0_XDAGCCore2               0xc6c
-
-#define        rOFDM0_AGCParameter1            0xc70
-#define        rOFDM0_AGCParameter2            0xc74
-#define        rOFDM0_AGCRSSITable             0xc78
-#define        rOFDM0_HTSTFAGC                 0xc7c
-
-#define        rOFDM0_XATxIQImbalance          0xc80   /*  TX PWR TRACK and DIG */
-#define        rOFDM0_XATxAFE                  0xc84
-#define        rOFDM0_XBTxIQImbalance          0xc88
-#define        rOFDM0_XBTxAFE                  0xc8c
-#define        rOFDM0_XCTxIQImbalance          0xc90
-#define        rOFDM0_XCTxAFE                  0xc94
-#define        rOFDM0_XDTxIQImbalance          0xc98
-#define        rOFDM0_XDTxAFE                  0xc9c
-
-#define        rOFDM0_RxIQExtAnta              0xca0
-#define        rOFDM0_TxCoeff1                 0xca4
-#define        rOFDM0_TxCoeff2                 0xca8
-#define        rOFDM0_TxCoeff3                 0xcac
-#define        rOFDM0_TxCoeff4                 0xcb0
-#define        rOFDM0_TxCoeff5                 0xcb4
-#define        rOFDM0_TxCoeff6                 0xcb8
-#define        rOFDM0_RxHPParameter            0xce0
-#define        rOFDM0_TxPseudoNoiseWgt         0xce4
-#define        rOFDM0_FrameSync                0xcf0
-#define        rOFDM0_DFSReport                0xcf4
-
-/*  */
-/*  7. PageD(0xD00) */
-/*  */
-#define        rOFDM1_LSTF                     0xd00
-#define        rOFDM1_TRxPathEnable            0xd04
-
-#define        rOFDM1_CFO                      0xd08   /*  No setting now */
-#define        rOFDM1_CSI1                     0xd10
-#define        rOFDM1_SBD                      0xd14
-#define        rOFDM1_CSI2                     0xd18
-#define        rOFDM1_CFOTracking              0xd2c
-#define        rOFDM1_TRxMesaure1              0xd34
-#define        rOFDM1_IntfDet                  0xd3c
-#define        rOFDM1_PseudoNoiseStateAB       0xd50
-#define        rOFDM1_PseudoNoiseStateCD       0xd54
-#define        rOFDM1_RxPseudoNoiseWgt         0xd58
-
-#define        rOFDM_PHYCounter1               0xda0  /* cca, parity fail */
-#define        rOFDM_PHYCounter2               0xda4  /* rate illegal, crc8 fail */
-#define        rOFDM_PHYCounter3               0xda8  /* MCS not support */
-
-#define        rOFDM_ShortCFOAB                0xdac   /*  No setting now */
-#define        rOFDM_ShortCFOCD                0xdb0
-#define        rOFDM_LongCFOAB                 0xdb4
-#define        rOFDM_LongCFOCD                 0xdb8
-#define        rOFDM_TailCFOAB                 0xdbc
-#define        rOFDM_TailCFOCD                 0xdc0
-#define        rOFDM_PWMeasure1                0xdc4
-#define        rOFDM_PWMeasure2                0xdc8
-#define        rOFDM_BWReport                  0xdcc
-#define        rOFDM_AGCReport                 0xdd0
-#define        rOFDM_RxSNR                     0xdd4
-#define        rOFDM_RxEVMCSI                  0xdd8
-#define        rOFDM_SIGReport                 0xddc
-
-/*  */
-/*  8. PageE(0xE00) */
-/*  */
-#define        rTxAGC_A_Rate18_06              0xe00
-#define        rTxAGC_A_Rate54_24              0xe04
-#define        rTxAGC_A_CCK1_Mcs32             0xe08
-#define        rTxAGC_A_Mcs03_Mcs00            0xe10
-#define        rTxAGC_A_Mcs07_Mcs04            0xe14
-#define        rTxAGC_A_Mcs11_Mcs08            0xe18
-#define        rTxAGC_A_Mcs15_Mcs12            0xe1c
-
-#define        rTxAGC_B_Rate18_06              0x830
-#define        rTxAGC_B_Rate54_24              0x834
-#define        rTxAGC_B_CCK1_55_Mcs32          0x838
-#define        rTxAGC_B_Mcs03_Mcs00            0x83c
-#define        rTxAGC_B_Mcs07_Mcs04            0x848
-#define        rTxAGC_B_Mcs11_Mcs08            0x84c
-#define        rTxAGC_B_Mcs15_Mcs12            0x868
-#define        rTxAGC_B_CCK11_A_CCK2_11        0x86c
-
-#define        rFPGA0_IQK                      0xe28
-#define        rTx_IQK_Tone_A                  0xe30
-#define        rRx_IQK_Tone_A                  0xe34
-#define        rTx_IQK_PI_A                    0xe38
-#define        rRx_IQK_PI_A                    0xe3c
-
-#define        rTx_IQK                         0xe40
-#define        rRx_IQK                         0xe44
-#define        rIQK_AGC_Pts                    0xe48
-#define        rIQK_AGC_Rsp                    0xe4c
-#define        rTx_IQK_Tone_B                  0xe50
-#define        rRx_IQK_Tone_B                  0xe54
-#define        rTx_IQK_PI_B                    0xe58
-#define        rRx_IQK_PI_B                    0xe5c
-#define        rIQK_AGC_Cont                   0xe60
-
-#define        rBlue_Tooth                     0xe6c
-#define        rRx_Wait_CCA                    0xe70
-#define        rTx_CCK_RFON                    0xe74
-#define        rTx_CCK_BBON                    0xe78
-#define        rTx_OFDM_RFON                   0xe7c
-#define        rTx_OFDM_BBON                   0xe80
-#define        rTx_To_Rx                       0xe84
-#define        rTx_To_Tx                       0xe88
-#define        rRx_CCK                         0xe8c
-
-#define        rTx_Power_Before_IQK_A          0xe94
-#define        rTx_Power_After_IQK_A           0xe9c
-
-#define        rRx_Power_Before_IQK_A          0xea0
-#define        rRx_Power_Before_IQK_A_2        0xea4
-#define        rRx_Power_After_IQK_A           0xea8
-#define        rRx_Power_After_IQK_A_2         0xeac
-
-#define        rTx_Power_Before_IQK_B          0xeb4
-#define        rTx_Power_After_IQK_B           0xebc
-
-#define        rRx_Power_Before_IQK_B          0xec0
-#define        rRx_Power_Before_IQK_B_2        0xec4
-#define        rRx_Power_After_IQK_B           0xec8
-#define        rRx_Power_After_IQK_B_2         0xecc
-
-#define        rRx_OFDM                        0xed0
-#define        rRx_Wait_RIFS                   0xed4
-#define        rRx_TO_Rx                       0xed8
-#define        rStandby                        0xedc
-#define        rSleep                          0xee0
-#define        rPMPD_ANAEN                     0xeec
-
-/*  */
-/*  7. RF Register 0x00-0x2E (RF 8256) */
-/*     RF-0222D 0x00-3F */
-/*  */
-/* Zebra1 */
-#define        rZebra1_HSSIEnable              0x0     /*  Useless now */
-#define        rZebra1_TRxEnable1              0x1
-#define        rZebra1_TRxEnable2              0x2
-#define        rZebra1_AGC                     0x4
-#define        rZebra1_ChargePump              0x5
-#define        rZebra1_Channel                 0x7     /*  RF channel switch */
-
-/* endif */
-#define        rZebra1_TxGain                  0x8     /*  Useless now */
-#define        rZebra1_TxLPF                   0x9
-#define        rZebra1_RxLPF                   0xb
-#define        rZebra1_RxHPFCorner             0xc
-
-/* Zebra4 */
-#define        rGlobalCtrl             0       /*  Useless now */
-#define        rRTL8256_TxLPF          19
-#define        rRTL8256_RxLPF          11
-
-/* RTL8258 */
-#define        rRTL8258_TxLPF          0x11    /*  Useless now */
-#define        rRTL8258_RxLPF          0x13
-#define        rRTL8258_RSSILPF        0xa
-
-/*  */
-/*  RL6052 Register definition */
-/*  */
-#define        RF_AC                   0x00    /*  */
-
-#define        RF_IQADJ_G1             0x01    /*  */
-#define        RF_IQADJ_G2             0x02    /*  */
-
-#define        RF_POW_TRSW             0x05    /*  */
-
-#define        RF_GAIN_RX              0x06    /*  */
-#define        RF_GAIN_TX              0x07    /*  */
-
-#define        RF_TXM_IDAC             0x08    /*  */
-#define        RF_IPA_G                0x09    /*  */
-#define        RF_TXBIAS_G             0x0A
-#define        RF_TXPA_AG              0x0B
-#define        RF_IPA_A                0x0C    /*  */
-#define        RF_TXBIAS_A             0x0D
-#define        RF_BS_PA_APSET_G9_G11   0x0E
-#define        RF_BS_IQGEN             0x0F    /*  */
-
-#define        RF_MODE1                0x10    /*  */
-#define        RF_MODE2                0x11    /*  */
-
-#define        RF_RX_AGC_HP            0x12    /*  */
-#define        RF_TX_AGC               0x13    /*  */
-#define        RF_BIAS                 0x14    /*  */
-#define        RF_IPA                  0x15    /*  */
-#define        RF_TXBIAS               0x16
-#define        RF_POW_ABILITY          0x17    /*  */
-#define        RF_CHNLBW               0x18    /*  RF channel and BW switch */
-#define        RF_TOP                  0x19    /*  */
-
-#define        RF_RX_G1                0x1A    /*  */
-#define        RF_RX_G2                0x1B    /*  */
-
-#define        RF_RX_BB2               0x1C    /*  */
-#define        RF_RX_BB1               0x1D    /*  */
-
-#define        RF_RCK1                 0x1E    /*  */
-#define        RF_RCK2                 0x1F    /*  */
-
-#define        RF_TX_G1                0x20    /*  */
-#define        RF_TX_G2                0x21    /*  */
-#define        RF_TX_G3                0x22    /*  */
-
-#define        RF_TX_BB1               0x23    /*  */
-
-#define        RF_T_METER_92D          0x42    /*  */
-#define        RF_T_METER_88E          0x42    /*  */
-#define        RF_T_METER              0x24    /*  */
-
-#define        RF_SYN_G1               0x25    /*  RF TX Power control */
-#define        RF_SYN_G2               0x26    /*  RF TX Power control */
-#define        RF_SYN_G3               0x27    /*  RF TX Power control */
-#define        RF_SYN_G4               0x28    /*  RF TX Power control */
-#define        RF_SYN_G5               0x29    /*  RF TX Power control */
-#define        RF_SYN_G6               0x2A    /*  RF TX Power control */
-#define        RF_SYN_G7               0x2B    /*  RF TX Power control */
-#define        RF_SYN_G8               0x2C    /*  RF TX Power control */
-
-#define        RF_RCK_OS               0x30    /*  RF TX PA control */
-#define        RF_TXPA_G1              0x31    /*  RF TX PA control */
-#define        RF_TXPA_G2              0x32    /*  RF TX PA control */
-#define        RF_TXPA_G3              0x33    /*  RF TX PA control */
-#define        RF_TX_BIAS_A            0x35
-#define        RF_TX_BIAS_D            0x36
-#define        RF_LOBF_9               0x38
-#define        RF_RXRF_A3              0x3C    /*  */
-#define        RF_TRSW                 0x3F
-
-#define        RF_TXRF_A2              0x41
-#define        RF_TXPA_G4              0x46
-#define        RF_TXPA_A4              0x4B
-#define        RF_0x52                 0x52
-#define        RF_WE_LUT               0xEF
-
-/*  */
-/* Bit Mask */
-/*  */
-/*  1. Page1(0x100) */
-#define        bBBResetB               0x100   /*  Useless now? */
-#define        bGlobalResetB           0x200
-#define        bOFDMTxStart            0x4
-#define        bCCKTxStart             0x8
-#define        bCRC32Debug             0x100
-#define        bPMACLoopback           0x10
-#define        bTxLSIG                 0xffffff
-#define        bOFDMTxRate             0xf
-#define        bOFDMTxReserved         0x10
-#define        bOFDMTxLength           0x1ffe0
-#define        bOFDMTxParity           0x20000
-#define        bTxHTSIG1               0xffffff
-#define        bTxHTMCSRate            0x7f
-#define        bTxHTBW                 0x80
-#define        bTxHTLength             0xffff00
-#define        bTxHTSIG2               0xffffff
-#define        bTxHTSmoothing          0x1
-#define        bTxHTSounding           0x2
-#define        bTxHTReserved           0x4
-#define        bTxHTAggreation         0x8
-#define        bTxHTSTBC               0x30
-#define        bTxHTAdvanceCoding      0x40
-#define        bTxHTShortGI            0x80
-#define        bTxHTNumberHT_LTF       0x300
-#define        bTxHTCRC8               0x3fc00
-#define        bCounterReset           0x10000
-#define        bNumOfOFDMTx            0xffff
-#define        bNumOfCCKTx             0xffff0000
-#define        bTxIdleInterval         0xffff
-#define        bOFDMService            0xffff0000
-#define        bTxMACHeader            0xffffffff
-#define        bTxDataInit             0xff
-#define        bTxHTMode               0x100
-#define        bTxDataType             0x30000
-#define        bTxRandomSeed           0xffffffff
-#define        bCCKTxPreamble          0x1
-#define        bCCKTxSFD               0xffff0000
-#define        bCCKTxSIG               0xff
-#define        bCCKTxService           0xff00
-#define        bCCKLengthExt           0x8000
-#define        bCCKTxLength            0xffff0000
-#define        bCCKTxCRC16             0xffff
-#define        bCCKTxStatus            0x1
-#define        bOFDMTxStatus           0x2
-
-#define        IS_BB_REG_OFFSET_92S(_Offset)                   \
-       ((_Offset >= 0x800) && (_Offset <= 0xfff))
-
-/*  2. Page8(0x800) */
-#define        bRFMOD                  0x1     /*  Reg 0x800 rFPGA0_RFMOD */
-#define        bJapanMode              0x2
-#define        bCCKTxSC                0x30
-#define        bCCKEn                  0x1000000
-#define        bOFDMEn                 0x2000000
-
-#define        bOFDMRxADCPhase         0x10000 /*  Useless now */
-#define        bOFDMTxDACPhase         0x40000
-#define        bXATxAGC                0x3f
-
-#define        bAntennaSelect          0x0300
-
-#define        bXBTxAGC                0xf00   /*  Reg 80c rFPGA0_TxGainStage */
-#define        bXCTxAGC                0xf000
-#define        bXDTxAGC                0xf0000
-
-#define        bPAStart                0xf0000000      /*  Useless now */
-#define        bTRStart                0x00f00000
-#define        bRFStart                0x0000f000
-#define        bBBStart                0x000000f0
-#define        bBBCCKStart             0x0000000f
-#define        bPAEnd                  0xf          /* Reg0x814 */
-#define        bTREnd                  0x0f000000
-#define        bRFEnd                  0x000f0000
-#define        bCCAMask                0x000000f0   /* T2R */
-#define        bR2RCCAMask             0x00000f00
-#define        bHSSI_R2TDelay          0xf8000000
-#define        bHSSI_T2RDelay          0xf80000
-#define        bContTxHSSI             0x400     /* change gain at continue Tx */
-#define        bIGFromCCK              0x200
-#define        bAGCAddress             0x3f
-#define        bRxHPTx                 0x7000
-#define        bRxHPT2R                0x38000
-#define        bRxHPCCKIni             0xc0000
-#define        bAGCTxCode              0xc00000
-#define        bAGCRxCode              0x300000
-
-/* Reg 0x820~84f rFPGA0_XA_HSSIParameter1 */
-#define        b3WireDataLength        0x800
-#define        b3WireAddressLength     0x400
-
-#define        b3WireRFPowerDown       0x1     /*  Useless now */
-#define        b5GPAPEPolarity         0x40000000
-#define        b2GPAPEPolarity         0x80000000
-#define        bRFSW_TxDefaultAnt      0x3
-#define        bRFSW_TxOptionAnt       0x30
-#define        bRFSW_RxDefaultAnt      0x300
-#define        bRFSW_RxOptionAnt       0x3000
-#define        bRFSI_3WireData         0x1
-#define        bRFSI_3WireClock        0x2
-#define        bRFSI_3WireLoad         0x4
-#define        bRFSI_3WireRW           0x8
-#define        bRFSI_3Wire             0xf
-
-#define        bRFSI_RFENV             0x10    /* Reg 0x870 rFPGA0_XAB_RFInterfaceSW */
-
-#define        bRFSI_TRSW              0x20    /*  Useless now */
-#define        bRFSI_TRSWB             0x40
-#define        bRFSI_ANTSW             0x100
-#define        bRFSI_ANTSWB            0x200
-#define        bRFSI_PAPE              0x400
-#define        bRFSI_PAPE5G            0x800
-#define        bBandSelect             0x1
-#define        bHTSIG2_GI              0x80
-#define        bHTSIG2_Smoothing       0x01
-#define        bHTSIG2_Sounding        0x02
-#define        bHTSIG2_Aggreaton       0x08
-#define        bHTSIG2_STBC            0x30
-#define        bHTSIG2_AdvCoding       0x40
-#define        bHTSIG2_NumOfHTLTF      0x300
-#define        bHTSIG2_CRC8            0x3fc
-#define        bHTSIG1_MCS             0x7f
-#define        bHTSIG1_BandWidth       0x80
-#define        bHTSIG1_HTLength        0xffff
-#define        bLSIG_Rate              0xf
-#define        bLSIG_Reserved          0x10
-#define        bLSIG_Length            0x1fffe
-#define        bLSIG_Parity            0x20
-#define        bCCKRxPhase             0x4
-
-#define        bLSSIReadAddress        0x7f800000   /*  T65 RF */
-
-#define        bLSSIReadEdge           0x80000000   /* LSSI "Read" edge signal */
-
-#define        bLSSIReadBackData       0xfffff         /*  T65 RF */
-
-#define        bLSSIReadOKFlag         0x1000  /*  Useless now */
-#define        bCCKSampleRate          0x8       /* 0: 44MHz, 1:88MHz */
-#define        bRegulator0Standby      0x1
-#define        bRegulatorPLLStandby    0x2
-#define        bRegulator1Standby      0x4
-#define        bPLLPowerUp             0x8
-#define        bDPLLPowerUp            0x10
-#define        bDA10PowerUp            0x20
-#define        bAD7PowerUp             0x200
-#define        bDA6PowerUp             0x2000
-#define        bXtalPowerUp            0x4000
-#define        b40MDClkPowerUP         0x8000
-#define        bDA6DebugMode           0x20000
-#define        bDA6Swing               0x380000
-
-/*  Reg 0x880 rFPGA0_AnalogParameter1 20/40 CCK support switch 40/80 BB MHZ */
-#define        bADClkPhase             0x4000000
-
-#define        b80MClkDelay            0x18000000      /*  Useless */
-#define        bAFEWatchDogEnable      0x20000000
-
-/*  Reg 0x884 rFPGA0_AnalogParameter2 Crystal cap */
-#define        bXtalCap01              0xc0000000
-#define        bXtalCap23              0x3
-#define        bXtalCap92x             0x0f000000
-#define        bXtalCap                0x0f000000
-
-#define        bIntDifClkEnable        0x400   /*  Useless */
-#define        bExtSigClkEnable        0x800
-#define        bBandgapMbiasPowerUp    0x10000
-#define        bAD11SHGain             0xc0000
-#define        bAD11InputRange         0x700000
-#define        bAD11OPCurrent          0x3800000
-#define        bIPathLoopback          0x4000000
-#define        bQPathLoopback          0x8000000
-#define        bAFELoopback            0x10000000
-#define        bDA10Swing              0x7e0
-#define        bDA10Reverse            0x800
-#define        bDAClkSource            0x1000
-#define        bAD7InputRange          0x6000
-#define        bAD7Gain                0x38000
-#define        bAD7OutputCMMode        0x40000
-#define        bAD7InputCMMode         0x380000
-#define        bAD7Current             0xc00000
-#define        bRegulatorAdjust        0x7000000
-#define        bAD11PowerUpAtTx        0x1
-#define        bDA10PSAtTx             0x10
-#define        bAD11PowerUpAtRx        0x100
-#define        bDA10PSAtRx             0x1000
-#define        bCCKRxAGCFormat         0x200
-#define        bPSDFFTSamplepPoint     0xc000
-#define        bPSDAverageNum          0x3000
-#define        bIQPathControl          0xc00
-#define        bPSDFreq                0x3ff
-#define        bPSDAntennaPath         0x30
-#define        bPSDIQSwitch            0x40
-#define        bPSDRxTrigger           0x400000
-#define        bPSDTxTrigger           0x80000000
-#define        bPSDSineToneScale       0x7f000000
-#define        bPSDReport              0xffff
-
-/*  3. Page9(0x900) */
-#define        bOFDMTxSC               0x30000000      /*  Useless */
-#define        bCCKTxOn                0x1
-#define        bOFDMTxOn               0x2
-#define        bDebugPage              0xfff  /* reset debug page and HWord, LWord */
-#define        bDebugItem              0xff   /* reset debug page and LWord */
-#define        bAntL                   0x10
-#define        bAntNonHT               0x100
-#define        bAntHT1                 0x1000
-#define        bAntHT2                 0x10000
-#define        bAntHT1S1               0x100000
-#define        bAntNonHTS1             0x1000000
-
-/*  4. PageA(0xA00) */
-#define        bCCKBBMode              0x3     /*  Useless */
-#define        bCCKTxPowerSaving       0x80
-#define        bCCKRxPowerSaving       0x40
-
-#define        bCCKSideBand            0x10    /*  Reg 0xa00 rCCK0_System 20/40 */
-
-#define        bCCKScramble            0x8     /*  Useless */
-#define        bCCKAntDiversity        0x8000
-#define        bCCKCarrierRecovery     0x4000
-#define        bCCKTxRate              0x3000
-#define        bCCKDCCancel            0x0800
-#define        bCCKISICancel           0x0400
-#define        bCCKMatchFilter         0x0200
-#define        bCCKEqualizer           0x0100
-#define        bCCKPreambleDetect      0x800000
-#define        bCCKFastFalseCCA        0x400000
-#define        bCCKChEstStart          0x300000
-#define        bCCKCCACount            0x080000
-#define        bCCKcs_lim              0x070000
-#define        bCCKBistMode            0x80000000
-#define        bCCKCCAMask             0x40000000
-#define        bCCKTxDACPhase          0x4
-#define        bCCKRxADCPhase          0x20000000   /* r_rx_clk */
-#define        bCCKr_cp_mode0          0x0100
-#define        bCCKTxDCOffset          0xf0
-#define        bCCKRxDCOffset          0xf
-#define        bCCKCCAMode             0xc000
-#define        bCCKFalseCS_lim         0x3f00
-#define        bCCKCS_ratio            0xc00000
-#define        bCCKCorgBit_sel         0x300000
-#define        bCCKPD_lim              0x0f0000
-#define        bCCKNewCCA              0x80000000
-#define        bCCKRxHPofIG            0x8000
-#define        bCCKRxIG                0x7f00
-#define        bCCKLNAPolarity         0x800000
-#define        bCCKRx1stGain           0x7f0000
-#define        bCCKRFExtend            0x20000000 /* CCK Rx Iinital gain polarity */
-#define        bCCKRxAGCSatLevel       0x1f000000
-#define        bCCKRxAGCSatCount       0xe0
-#define        bCCKRxRFSettle          0x1f       /* AGCsamp_dly */
-#define        bCCKFixedRxAGC          0x8000
-#define        bCCKAntennaPolarity     0x2000
-#define        bCCKTxFilterType        0x0c00
-#define        bCCKRxAGCReportType     0x0300
-#define        bCCKRxDAGCEn            0x80000000
-#define        bCCKRxDAGCPeriod        0x20000000
-#define        bCCKRxDAGCSatLevel      0x1f000000
-#define        bCCKTimingRecovery      0x800000
-#define        bCCKTxC0                0x3f0000
-#define        bCCKTxC1                0x3f000000
-#define        bCCKTxC2                0x3f
-#define        bCCKTxC3                0x3f00
-#define        bCCKTxC4                0x3f0000
-#define        bCCKTxC5                0x3f000000
-#define        bCCKTxC6                0x3f
-#define        bCCKTxC7                0x3f00
-#define        bCCKDebugPort           0xff0000
-#define        bCCKDACDebug            0x0f000000
-#define        bCCKFalseAlarmEnable    0x8000
-#define        bCCKFalseAlarmRead      0x4000
-#define        bCCKTRSSI               0x7f
-#define        bCCKRxAGCReport         0xfe
-#define        bCCKRxReport_AntSel     0x80000000
-#define        bCCKRxReport_MFOff      0x40000000
-#define        bCCKRxRxReport_SQLoss   0x20000000
-#define        bCCKRxReport_Pktloss    0x10000000
-#define        bCCKRxReport_Lockedbit  0x08000000
-#define        bCCKRxReport_RateError  0x04000000
-#define        bCCKRxReport_RxRate     0x03000000
-#define        bCCKRxFACounterLower    0xff
-#define        bCCKRxFACounterUpper    0xff000000
-#define        bCCKRxHPAGCStart        0xe000
-#define        bCCKRxHPAGCFinal        0x1c00
-#define        bCCKRxFalseAlarmEnable  0x8000
-#define        bCCKFACounterFreeze     0x4000
-#define        bCCKTxPathSel           0x10000000
-#define        bCCKDefaultRxPath       0xc000000
-#define        bCCKOptionRxPath        0x3000000
-
-/*  5. PageC(0xC00) */
-#define        bNumOfSTF               0x3     /*  Useless */
-#define        bShift_L                0xc0
-#define        bGI_TH                  0xc
-#define        bRxPathA                0x1
-#define        bRxPathB                0x2
-#define        bRxPathC                0x4
-#define        bRxPathD                0x8
-#define        bTxPathA                0x1
-#define        bTxPathB                0x2
-#define        bTxPathC                0x4
-#define        bTxPathD                0x8
-#define        bTRSSIFreq              0x200
-#define        bADCBackoff             0x3000
-#define        bDFIRBackoff            0xc000
-#define        bTRSSILatchPhase        0x10000
-#define        bRxIDCOffset            0xff
-#define        bRxQDCOffset            0xff00
-#define        bRxDFIRMode             0x1800000
-#define        bRxDCNFType             0xe000000
-#define        bRXIQImb_A              0x3ff
-#define        bRXIQImb_B              0xfc00
-#define        bRXIQImb_C              0x3f0000
-#define        bRXIQImb_D              0xffc00000
-#define        bDC_dc_Notch            0x60000
-#define        bRxNBINotch             0x1f000000
-#define        bPD_TH                  0xf
-#define        bPD_TH_Opt2             0xc000
-#define        bPWED_TH                0x700
-#define        bIfMF_Win_L             0x800
-#define        bPD_Option              0x1000
-#define        bMF_Win_L               0xe000
-#define        bBW_Search_L            0x30000
-#define        bwin_enh_L              0xc0000
-#define        bBW_TH                  0x700000
-#define        bED_TH2                 0x3800000
-#define        bBW_option              0x4000000
-#define        bRatio_TH               0x18000000
-#define        bWindow_L               0xe0000000
-#define        bSBD_Option             0x1
-#define        bFrame_TH               0x1c
-#define        bFS_Option              0x60
-#define        bDC_Slope_check         0x80
-#define        bFGuard_Counter_DC_L    0xe00
-#define        bFrame_Weight_Short     0x7000
-#define        bSub_Tune               0xe00000
-#define        bFrame_DC_Length        0xe000000
-#define        bSBD_start_offset       0x30000000
-#define        bFrame_TH_2             0x7
-#define        bFrame_GI2_TH           0x38
-#define        bGI2_Sync_en            0x40
-#define        bSarch_Short_Early      0x300
-#define        bSarch_Short_Late       0xc00
-#define        bSarch_GI2_Late         0x70000
-#define        bCFOAntSum              0x1
-#define        bCFOAcc                 0x2
-#define        bCFOStartOffset         0xc
-#define        bCFOLookBack            0x70
-#define        bCFOSumWeight           0x80
-#define        bDAGCEnable             0x10000
-#define        bTXIQImb_A              0x3ff
-#define        bTXIQImb_B              0xfc00
-#define        bTXIQImb_C              0x3f0000
-#define        bTXIQImb_D              0xffc00000
-#define        bTxIDCOffset            0xff
-#define        bTxQDCOffset            0xff00
-#define        bTxDFIRMode             0x10000
-#define        bTxPesudoNoiseOn        0x4000000
-#define        bTxPesudoNoise_A        0xff
-#define        bTxPesudoNoise_B        0xff00
-#define        bTxPesudoNoise_C        0xff0000
-#define        bTxPesudoNoise_D        0xff000000
-#define        bCCADropOption          0x20000
-#define        bCCADropThres           0xfff00000
-#define        bEDCCA_H                0xf
-#define        bEDCCA_L                0xf0
-#define        bLambda_ED              0x300
-#define        bRxInitialGain          0x7f
-#define        bRxAntDivEn             0x80
-#define        bRxAGCAddressForLNA     0x7f00
-#define        bRxHighPowerFlow        0x8000
-#define        bRxAGCFreezeThres       0xc0000
-#define        bRxFreezeStep_AGC1      0x300000
-#define        bRxFreezeStep_AGC2      0xc00000
-#define        bRxFreezeStep_AGC3      0x3000000
-#define        bRxFreezeStep_AGC0      0xc000000
-#define        bRxRssi_Cmp_En          0x10000000
-#define        bRxQuickAGCEn           0x20000000
-#define        bRxAGCFreezeThresMode   0x40000000
-#define        bRxOverFlowCheckType    0x80000000
-#define        bRxAGCShift             0x7f
-#define        bTRSW_Tri_Only          0x80
-#define        bPowerThres             0x300
-#define        bRxAGCEn                0x1
-#define        bRxAGCTogetherEn        0x2
-#define        bRxAGCMin               0x4
-#define        bRxHP_Ini               0x7
-#define        bRxHP_TRLNA             0x70
-#define        bRxHP_RSSI              0x700
-#define        bRxHP_BBP1              0x7000
-#define        bRxHP_BBP2              0x70000
-#define        bRxHP_BBP3              0x700000
-#define        bRSSI_H                 0x7f0000     /* threshold for high power */
-#define        bRSSI_Gen               0x7f000000   /* threshold for ant diversity */
-#define        bRxSettle_TRSW          0x7
-#define        bRxSettle_LNA           0x38
-#define        bRxSettle_RSSI          0x1c0
-#define        bRxSettle_BBP           0xe00
-#define        bRxSettle_RxHP          0x7000
-#define        bRxSettle_AntSW_RSSI    0x38000
-#define        bRxSettle_AntSW         0xc0000
-#define        bRxProcessTime_DAGC     0x300000
-#define        bRxSettle_HSSI          0x400000
-#define        bRxProcessTime_BBPPW    0x800000
-#define        bRxAntennaPowerShift    0x3000000
-#define        bRSSITableSelect        0xc000000
-#define        bRxHP_Final             0x7000000
-#define        bRxHTSettle_BBP         0x7
-#define        bRxHTSettle_HSSI        0x8
-#define        bRxHTSettle_RxHP        0x70
-#define        bRxHTSettle_BBPPW       0x80
-#define        bRxHTSettle_Idle        0x300
-#define        bRxHTSettle_Reserved    0x1c00
-#define        bRxHTRxHPEn             0x8000
-#define        bRxHTAGCFreezeThres     0x30000
-#define        bRxHTAGCTogetherEn      0x40000
-#define        bRxHTAGCMin             0x80000
-#define        bRxHTAGCEn              0x100000
-#define        bRxHTDAGCEn             0x200000
-#define        bRxHTRxHP_BBP           0x1c00000
-#define        bRxHTRxHP_Final         0xe0000000
-#define        bRxPWRatioTH            0x3
-#define        bRxPWRatioEn            0x4
-#define        bRxMFHold               0x3800
-#define        bRxPD_Delay_TH1         0x38
-#define        bRxPD_Delay_TH2         0x1c0
-#define        bRxPD_DC_COUNT_MAX      0x600
-#define        bRxPD_Delay_TH          0x8000
-#define        bRxProcess_Delay        0xf0000
-#define        bRxSearchrange_GI2_Early        0x700000
-#define        bRxFrame_Guard_Counter_L        0x3800000
-#define        bRxSGI_Guard_L          0xc000000
-#define        bRxSGI_Search_L         0x30000000
-#define        bRxSGI_TH               0xc0000000
-#define        bDFSCnt0                0xff
-#define        bDFSCnt1                0xff00
-#define        bDFSFlag                0xf0000
-#define        bMFWeightSum            0x300000
-#define        bMinIdxTH               0x7f000000
-#define        bDAFormat               0x40000
-#define        bTxChEmuEnable          0x01000000
-#define        bTRSWIsolation_A        0x7f
-#define        bTRSWIsolation_B        0x7f00
-#define        bTRSWIsolation_C        0x7f0000
-#define        bTRSWIsolation_D        0x7f000000
-#define        bExtLNAGain             0x7c00
-
-/*  6. PageE(0xE00) */
-#define        bSTBCEn                 0x4     /*  Useless */
-#define        bAntennaMapping         0x10
-#define        bNss                    0x20
-#define        bCFOAntSumD             0x200
-#define        bPHYCounterReset        0x8000000
-#define        bCFOReportGet           0x4000000
-#define        bOFDMContinueTx         0x10000000
-#define        bOFDMSingleCarrier      0x20000000
-#define        bOFDMSingleTone         0x40000000
-#define        bHTDetect               0x100
-#define        bCFOEn                  0x10000
-#define        bCFOValue               0xfff00000
-#define        bSigTone_Re             0x3f
-#define        bSigTone_Im             0x7f00
-#define        bCounter_CCA            0xffff
-#define        bCounter_ParityFail     0xffff0000
-#define        bCounter_RateIllegal    0xffff
-#define        bCounter_CRC8Fail       0xffff0000
-#define        bCounter_MCSNoSupport   0xffff
-#define        bCounter_FastSync       0xffff
-#define        bShortCFO               0xfff
-#define        bShortCFOTLength        12   /* total */
-#define        bShortCFOFLength        11   /* fraction */
-#define        bLongCFO                0x7ff
-#define        bLongCFOTLength         11
-#define        bLongCFOFLength         11
-#define        bTailCFO                0x1fff
-#define        bTailCFOTLength         13
-#define        bTailCFOFLength         12
-#define        bmax_en_pwdB            0xffff
-#define        bCC_power_dB            0xffff0000
-#define        bnoise_pwdB             0xffff
-#define        bPowerMeasTLength       10
-#define        bPowerMeasFLength       3
-#define        bRx_HT_BW               0x1
-#define        bRxSC                   0x6
-#define        bRx_HT                  0x8
-#define        bNB_intf_det_on         0x1
-#define        bIntf_win_len_cfg       0x30
-#define        bNB_Intf_TH_cfg         0x1c0
-#define        bRFGain                 0x3f
-#define        bTableSel               0x40
-#define        bTRSW                   0x80
-#define        bRxSNR_A                0xff
-#define        bRxSNR_B                0xff00
-#define        bRxSNR_C                0xff0000
-#define        bRxSNR_D                0xff000000
-#define        bSNREVMTLength          8
-#define        bSNREVMFLength          1
-#define        bCSI1st                 0xff
-#define        bCSI2nd                 0xff00
-#define        bRxEVM1st               0xff0000
-#define        bRxEVM2nd               0xff000000
-#define        bSIGEVM                 0xff
-#define        bPWDB                   0xff00
-#define        bSGIEN                  0x10000
-
-#define        bSFactorQAM1            0xf     /*  Useless */
-#define        bSFactorQAM2            0xf0
-#define        bSFactorQAM3            0xf00
-#define        bSFactorQAM4            0xf000
-#define        bSFactorQAM5            0xf0000
-#define        bSFactorQAM6            0xf0000
-#define        bSFactorQAM7            0xf00000
-#define        bSFactorQAM8            0xf000000
-#define        bSFactorQAM9            0xf0000000
-#define        bCSIScheme              0x100000
-
-#define        bNoiseLvlTopSet         0x3     /*  Useless */
-#define        bChSmooth               0x4
-#define        bChSmoothCfg1           0x38
-#define        bChSmoothCfg2           0x1c0
-#define        bChSmoothCfg3           0xe00
-#define        bChSmoothCfg4           0x7000
-#define        bMRCMode                0x800000
-#define        bTHEVMCfg               0x7000000
-
-#define        bLoopFitType            0x1     /*  Useless */
-#define        bUpdCFO                 0x40
-#define        bUpdCFOOffData          0x80
-#define        bAdvUpdCFO              0x100
-#define        bAdvTimeCtrl            0x800
-#define        bUpdClko                0x1000
-#define        bFC                     0x6000
-#define        bTrackingMode           0x8000
-#define        bPhCmpEnable            0x10000
-#define        bUpdClkoLTF             0x20000
-#define        bComChCFO               0x40000
-#define        bCSIEstiMode            0x80000
-#define        bAdvUpdEqz              0x100000
-#define        bUChCfg                 0x7000000
-#define        bUpdEqz                 0x8000000
-
-/* Rx Pseduo noise */
-#define        bRxPesudoNoiseOn        0x20000000      /*  Useless */
-#define        bRxPesudoNoise_A        0xff
-#define        bRxPesudoNoise_B        0xff00
-#define        bRxPesudoNoise_C        0xff0000
-#define        bRxPesudoNoise_D        0xff000000
-#define        bPesudoNoiseState_A     0xffff
-#define        bPesudoNoiseState_B     0xffff0000
-#define        bPesudoNoiseState_C     0xffff
-#define        bPesudoNoiseState_D     0xffff0000
-
-/* 7. RF Register */
-/* Zebra1 */
-#define        bZebra1_HSSIEnable      0x8             /*  Useless */
-#define        bZebra1_TRxControl      0xc00
-#define        bZebra1_TRxGainSetting  0x07f
-#define        bZebra1_RxCorner        0xc00
-#define        bZebra1_TxChargePump    0x38
-#define        bZebra1_RxChargePump    0x7
-#define        bZebra1_ChannelNum      0xf80
-#define        bZebra1_TxLPFBW         0x400
-#define        bZebra1_RxLPFBW         0x600
-
-/* Zebra4 */
-#define        bRTL8256RegModeCtrl1    0x100   /*  Useless */
-#define        bRTL8256RegModeCtrl0    0x40
-#define        bRTL8256_TxLPFBW        0x18
-#define        bRTL8256_RxLPFBW        0x600
-
-/* RTL8258 */
-#define        bRTL8258_TxLPFBW        0xc     /*  Useless */
-#define        bRTL8258_RxLPFBW        0xc00
-#define        bRTL8258_RSSILPFBW      0xc0
-
-/*  */
-/*  Other Definition */
-/*  */
-
-/* byte endable for sb_write */
-#define        bByte0                  0x1     /*  Useless */
-#define        bByte1                  0x2
-#define        bByte2                  0x4
-#define        bByte3                  0x8
-#define        bWord0                  0x3
-#define        bWord1                  0xc
-#define        bDWord                  0xf
-
-/* for PutRegsetting & GetRegSetting BitMask */
-#define        bMaskByte0              0xff    /*  Reg 0xc50 rOFDM0_XAAGCCore~0xC6f */
-#define        bMaskByte1              0xff00
-#define        bMaskByte2              0xff0000
-#define        bMaskByte3              0xff000000
-#define        bMaskHWord              0xffff0000
-#define        bMaskLWord              0x0000ffff
-#define        bMaskDWord              0xffffffff
-#define        bMask12Bits             0xfff
-#define        bMaskH4Bits             0xf0000000
-#define        bMaskOFDM_D             0xffc00000
-#define        bMaskCCK                0x3f3f3f3f
-
-/* for PutRFRegsetting & GetRFRegSetting BitMask */
-#define        bRFRegOffsetMask        0xfffff
-
-#define        bEnable                 0x1     /*  Useless */
-#define        bDisable                0x0
-
-#define        LeftAntenna             0x0     /*  Useless */
-#define        RightAntenna            0x1
-
-#define        tCheckTxStatus          500   /* 500ms Useless */
-#define        tUpdateRxCounter        100   /* 100ms */
-
-#define        rateCCK                 0       /*  Useless */
-#define        rateOFDM                1
-#define        rateHT                  2
-
-/* define Register-End */
-#define        bPMAC_End               0x1ff   /*  Useless */
-#define        bFPGAPHY0_End           0x8ff
-#define        bFPGAPHY1_End           0x9ff
-#define        bCCKPHY0_End            0xaff
-#define        bOFDMPHY0_End           0xcff
-#define        bOFDMPHY1_End           0xdff
-
-#define        bPMACControl            0x0     /*  Useless */
-#define        bWMACControl            0x1
-#define        bWNICControl            0x2
-
-#define        PathA                   0x0     /*  Useless */
-#define        PathB                   0x1
-#define        PathC                   0x2
-#define        PathD                   0x3
-
-/*--------------------------Define Parameters-------------------------------*/
-
-#endif
diff --git a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h
deleted file mode 100644 (file)
index c571ad9..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright (c) 2011 Realtek Semiconductor Corp. */
-
-#ifndef __INC_RA_H
-#define __INC_RA_H
-/* Module Name: RateAdaptive.h
- * Abstract: Prototype of RA and related data structure.
- */
-
-#include <linux/bitfield.h>
-
-/*  Rate adaptive define */
-#define        PERENTRY        23
-#define        RETRYSIZE       5
-#define        RATESIZE        28
-#define        TX_RPT2_ITEM_SIZE       8
-
-/*  TX report 2 format in Rx desc */
-#define GET_TX_RPT2_DESC_PKT_LEN_88E(__rxstatusdesc)           \
-       le32_get_bits(*(__le32 *)__rxstatusdesc, GENMASK(8, 0))
-#define GET_TX_RPT2_DESC_MACID_VALID_1_88E(__rxstatusdesc)     \
-       le32_to_cpu((*(__le32 *)(__rxstatusdesc + 16))
-#define GET_TX_RPT2_DESC_MACID_VALID_2_88E(__rxstatusdesc)     \
-       le32_to_cpu((*(__le32 *)(__rxstatusdesc + 20))
-/*  End rate adaptive define */
-
-int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm);
-
-int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 MacID);
-
-u8 ODM_RA_GetShortGI_8188E(struct odm_dm_struct *dm_odm, u8 MacID);
-
-u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 MacID);
-
-u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 MacID);
-void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 MacID,
-                                u8 RateID, u32 RateMask,
-                                u8 SGIEnable);
-
-void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid,
-                         u8 rssi);
-
-void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm,
-                              u8 *txrpt_buf, u16 txrpt_len,
-                              u32 validentry0, u32 validentry1);
-
-void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h b/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h
deleted file mode 100644 (file)
index 0a290bc..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __INC_BB_8188E_HW_IMG_H
-#define __INC_BB_8188E_HW_IMG_H
-
-/* static bool CheckCondition(const u32 Condition, const u32 Hex); */
-
-/******************************************************************************
-*                           AGC_TAB_1T.TXT
-******************************************************************************/
-
-int ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *odm);
-
-/******************************************************************************
-*                           PHY_REG_1T.TXT
-******************************************************************************/
-
-int ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *odm);
-
-/******************************************************************************
-*                           PHY_REG_PG.TXT
-******************************************************************************/
-
-void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h b/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h
deleted file mode 100644 (file)
index b3d67c1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __INC_MAC_8188E_HW_IMG_H
-#define __INC_MAC_8188E_HW_IMG_H
-
-/******************************************************************************
-*                           MAC_REG.TXT
-******************************************************************************/
-int ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *pDM_Odm);
-
-#endif /*  end of HWIMG_SUPPORT */
diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h b/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h
deleted file mode 100644 (file)
index 880fead..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __INC_RF_8188E_HW_IMG_H
-#define __INC_RF_8188E_HW_IMG_H
-
-/******************************************************************************
- *                           RadioA_1T.TXT
- ******************************************************************************/
-
-int ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *odm);
-
-#endif /*  end of HWIMG_SUPPORT */
diff --git a/drivers/staging/r8188eu/include/HalPhyRf_8188e.h b/drivers/staging/r8188eu/include/HalPhyRf_8188e.h
deleted file mode 100644 (file)
index b75a5d8..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __HAL_PHY_RF_8188E_H__
-#define __HAL_PHY_RF_8188E_H__
-
-/*--------------------------Define Parameters-------------------------------*/
-#define        IQK_DELAY_TIME_88E              10              /* ms */
-#define        index_mapping_NUM_88E   15
-#define AVG_THERMAL_NUM_88E    4
-
-void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *pDM_Odm,
-                            u8 Type,   /* 0 = OFDM, 1 = CCK */
-                            u8 *pDirection,/* 1 = +(incr) 2 = -(decr) */
-                            u32 *pOutWriteVal); /* Tx tracking CCK/OFDM BB
-                                                    * swing index adjust */
-
-void odm_TXPowerTrackingCallback_ThermalMeter_8188E(struct adapter *Adapter);
-
-/* 1 7.        IQK */
-
-void PHY_IQCalibrate_8188E(struct adapter *Adapter, bool ReCovery);
-
-/*  LC calibrate */
-void PHY_LCCalibrate_8188E(struct adapter *pAdapter);
-
-/*  AP calibrate */
-void PHY_DigitalPredistortion_8188E(struct adapter *pAdapter);
-
-void _PHY_SaveADDARegisters(struct adapter *pAdapter, u32 *ADDAReg,
-                           u32 *ADDABackup, u32 RegisterNum);
-
-void _PHY_MACSettingCalibration(struct adapter *pAdapter, u32 *MACReg,
-                               u32 *MACBackup);
-
-#endif /*  #ifndef __HAL_PHY_RF_8188E_H__ */
diff --git a/drivers/staging/r8188eu/include/HalPwrSeqCmd.h b/drivers/staging/r8188eu/include/HalPwrSeqCmd.h
deleted file mode 100644 (file)
index 0886300..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __HALPWRSEQCMD_H__
-#define __HALPWRSEQCMD_H__
-
-#include "drv_types.h"
-
-enum r8188eu_pwr_seq {
-       PWR_ON_FLOW,
-       DISABLE_FLOW,
-       LPS_ENTER_FLOW,
-};
-
-/*     Prototype of protected function. */
-u8 HalPwrSeqCmdParsing(struct adapter *padapter, enum r8188eu_pwr_seq seq);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/HalVerDef.h b/drivers/staging/r8188eu/include/HalVerDef.h
deleted file mode 100644 (file)
index 7a530c7..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-#ifndef __HAL_VERSION_DEF_H__
-#define __HAL_VERSION_DEF_H__
-
-enum HAL_CHIP_TYPE {
-       TEST_CHIP       =       0,
-       NORMAL_CHIP     =       1,
-};
-
-enum HAL_CUT_VERSION {
-       A_CUT_VERSION   =       0,
-       B_CUT_VERSION   =       1,
-       C_CUT_VERSION   =       2,
-       D_CUT_VERSION   =       3,
-       E_CUT_VERSION   =       4,
-};
-
-enum HAL_VENDOR {
-       CHIP_VENDOR_TSMC        =       0,
-       CHIP_VENDOR_UMC         =       1,
-};
-
-struct HAL_VERSION {
-       enum HAL_CHIP_TYPE      ChipType;
-       enum HAL_CUT_VERSION    CUTVersion;
-       enum HAL_VENDOR         VendorType;
-};
-
-/*  Get element */
-#define GET_CVID_CHIP_TYPE(version)    (((version).ChipType))
-#define GET_CVID_MANUFACTUER(version)  (((version).VendorType))
-
-/* HAL_CHIP_TYPE_E */
-#define IS_NORMAL_CHIP(version)                                \
-       (GET_CVID_CHIP_TYPE(version) == NORMAL_CHIP)
-
-/* HAL_VENDOR_E */
-#define IS_CHIP_VENDOR_TSMC(version)                   \
-       (GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_TSMC)
-
-#endif
diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h
deleted file mode 100644 (file)
index 159990f..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-/*-----------------------------------------------------------------------------
-
-       For type defines and data structure defines
-
-------------------------------------------------------------------------------*/
-
-#ifndef __DRV_TYPES_H__
-#define __DRV_TYPES_H__
-
-#include "osdep_service.h"
-#include "wlan_bssdef.h"
-#include "rtw_ht.h"
-#include "rtw_cmd.h"
-#include "rtw_xmit.h"
-#include "rtw_recv.h"
-#include "hal_intf.h"
-#include "hal_com.h"
-#include "rtw_security.h"
-#include "rtw_pwrctrl.h"
-#include "rtw_io.h"
-#include "rtw_eeprom.h"
-#include "sta_info.h"
-#include "rtw_mlme.h"
-#include "rtw_rf.h"
-#include "rtw_event.h"
-#include "rtw_led.h"
-#include "rtw_mlme_ext.h"
-#include "rtw_p2p.h"
-#include "rtw_ap.h"
-#include "rtw_br_ext.h"
-#include "rtl8188e_hal.h"
-#include "rtw_fw.h"
-
-#define FW_RTL8188EU   "rtlwifi/rtl8188eufw.bin"
-
-struct registry_priv {
-       u8      rfintfs;
-       u8      lbkmode;
-       u8      hci;
-       struct ndis_802_11_ssid ssid;
-       u8      network_mode;   /* infra, ad-hoc, auto */
-       u8      channel;/* ad-hoc support requirement */
-       u8      wireless_mode;/* A, B, G, auto */
-       u8      scan_mode;/* active, passive */
-       u8      radio_enable;
-       u8      preamble;/* long, short, auto */
-       u8      vrtl_carrier_sense;/* Enable, Disable, Auto */
-       u8      vcs_type;/* RTS/CTS, CTS-to-self */
-       u16     rts_thresh;
-       u16     frag_thresh;
-       u8      adhoc_tx_pwr;
-       u8      soft_ap;
-       u8      power_mgnt;
-       u8      ips_mode;
-       u8      smart_ps;
-       u8      long_retry_lmt;
-       u8      short_retry_lmt;
-       u16     busy_thresh;
-       u8      ack_policy;
-       u8      software_encrypt;
-       u8      software_decrypt;
-       u8      acm_method;
-         /* UAPSD */
-       u8      wmm_enable;
-       u8      uapsd_enable;
-       u8      uapsd_max_sp;
-       u8      uapsd_acbk_en;
-       u8      uapsd_acbe_en;
-       u8      uapsd_acvi_en;
-       u8      uapsd_acvo_en;
-
-       u8      led_enable;
-
-       struct wlan_bssid_ex    dev_network;
-
-       u8      ht_enable;
-       u8      cbw40_enable;
-       u8      ampdu_enable;/* for tx */
-       u8      rx_stbc;
-       u8      ampdu_amsdu;/* A-MPDU Supports A-MSDU is permitted */
-       u8      lowrate_two_xmit;
-
-       u8      low_power;
-
-       u8      wifi_spec;/*  !turbo_mode */
-
-       u8      channel_plan;
-       bool    bAcceptAddbaReq;
-
-       u8      antdiv_cfg;
-       u8      antdiv_type;
-
-       u8      usbss_enable;/* 0:disable,1:enable */
-       u8      hwpdn_mode;/* 0:disable,1:enable,2:decide by EFUSE config */
-       u8      hwpwrp_detect;/* 0:disable,1:enable */
-
-       u8      hw_wps_pbc;/* 0:disable,1:enable */
-
-       u8      max_roaming_times; /*  the max number driver will try */
-
-       u8      fw_iol; /* enable iol without other concern */
-
-       u8      enable80211d;
-
-       u8      ifname[16];
-       u8      if2name[16];
-
-       u8      notch_filter;
-};
-
-#define MAX_CONTINUAL_URB_ERR          4
-
-struct dvobj_priv {
-       struct adapter *if1;
-
-       /* For 92D, DMDP have 2 interface. */
-       u8      InterfaceNumber;
-       u8      NumInterfaces;
-
-       /* In /Out Pipe information */
-       int     RtInPipe;
-       int     RtOutPipe[3];
-       u8      Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */
-
-       struct rt_firmware firmware;
-
-/*-------- below is for USB INTERFACE --------*/
-
-       u8      RtNumOutPipes;
-
-       struct usb_interface *pusbintf;
-       struct usb_device *pusbdev;
-
-       atomic_t continual_urb_error;
-};
-
-static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
-{
-       /* todo: get interface type from dvobj and the return
-        * the dev accordingly */
-       return &dvobj->pusbintf->dev;
-};
-
-struct adapter {
-       int     pid[3];/* process id from UI, 0:wps, 1:hostapd, 2:dhcpcd */
-
-       struct dvobj_priv *dvobj;
-       struct  mlme_priv mlmepriv;
-       struct  mlme_ext_priv mlmeextpriv;
-       struct  cmd_priv        cmdpriv;
-       struct  evt_priv        evtpriv;
-       struct  xmit_priv       xmitpriv;
-       struct  recv_priv       recvpriv;
-       struct  sta_priv        stapriv;
-       struct  security_priv   securitypriv;
-       struct  registry_priv   registrypriv;
-       struct  pwrctrl_priv    pwrctrlpriv;
-       struct  eeprom_priv eeprompriv;
-       struct  led_priv        ledpriv;
-       struct wifidirect_info  wdinfo;
-
-       struct hal_data_8188e haldata;
-
-       s32     bDriverStopped;
-       s32     bSurpriseRemoved;
-
-       u8      hw_init_completed;
-       s8      signal_strength;
-
-       void *cmdThread;
-       struct  net_device *pnetdev;
-
-       /*  used by rtw_rereg_nd_name related function */
-       struct rereg_nd_name_data {
-               struct  net_device *old_pnetdev;
-               char old_ifname[IFNAMSIZ];
-               u8 old_ips_mode;
-               u8 old_bRegUseLed;
-       } rereg_nd_name_priv;
-
-       int bup;
-       struct net_device_stats stats;
-       struct iw_statistics iwstats;
-
-       int net_closed;
-       u8 bFWReady;
-       u8 bReadPortCancel;
-       u8 bWritePortCancel;
-       u8 bRxRSSIDisplay;
-       /* The driver will show up the desired channel number
-        * when this flag is 1. */
-       u8 bNotifyChannelChange;
-       /* The driver will show the current P2P status when the
-        * upper application reads it. */
-       u8 bShowGetP2PState;
-       struct adapter *pbuddy_adapter;
-
-       struct mutex *hw_init_mutex;
-
-       spinlock_t br_ext_lock;
-       struct nat25_network_db_entry   *nethash[NAT25_HASH_SIZE];
-       int                             pppoe_connection_in_progress;
-       unsigned char                   pppoe_addr[ETH_ALEN];
-       unsigned char                   scdb_mac[ETH_ALEN];
-       unsigned char                   scdb_ip[4];
-       struct nat25_network_db_entry   *scdb_entry;
-       unsigned char                   br_mac[ETH_ALEN];
-       unsigned char                   br_ip[4];
-       struct br_ext_info              ethBrExtInfo;
-};
-
-#define adapter_to_dvobj(adapter) (adapter->dvobj)
-
-void rtw_handle_dualmac(struct adapter *adapter, bool init);
-
-static inline u8 *myid(struct eeprom_priv *peepriv)
-{
-       return peepriv->mac_addr;
-}
-
-#endif /* __DRV_TYPES_H__ */
diff --git a/drivers/staging/r8188eu/include/hal_com.h b/drivers/staging/r8188eu/include/hal_com.h
deleted file mode 100644 (file)
index cd3f845..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __HAL_COMMON_H__
-#define __HAL_COMMON_H__
-
-/*  */
-/*        Rate Definition */
-/*  */
-/* CCK */
-#define        RATR_1M                                 0x00000001
-#define        RATR_2M                                 0x00000002
-#define        RATR_55M                                0x00000004
-#define        RATR_11M                                0x00000008
-/* OFDM */
-#define        RATR_6M                                 0x00000010
-#define        RATR_9M                                 0x00000020
-#define        RATR_12M                                0x00000040
-#define        RATR_18M                                0x00000080
-#define        RATR_24M                                0x00000100
-#define        RATR_36M                                0x00000200
-#define        RATR_48M                                0x00000400
-#define        RATR_54M                                0x00000800
-/* MCS 1 Spatial Stream */
-#define        RATR_MCS0                               0x00001000
-#define        RATR_MCS1                               0x00002000
-#define        RATR_MCS2                               0x00004000
-#define        RATR_MCS3                               0x00008000
-#define        RATR_MCS4                               0x00010000
-#define        RATR_MCS5                               0x00020000
-#define        RATR_MCS6                               0x00040000
-#define        RATR_MCS7                               0x00080000
-/* MCS 2 Spatial Stream */
-#define        RATR_MCS8                               0x00100000
-#define        RATR_MCS9                               0x00200000
-#define        RATR_MCS10                              0x00400000
-#define        RATR_MCS11                              0x00800000
-#define        RATR_MCS12                              0x01000000
-#define        RATR_MCS13                              0x02000000
-#define        RATR_MCS14                              0x04000000
-#define        RATR_MCS15                              0x08000000
-
-/* CCK */
-#define RATE_1M                                        BIT(0)
-#define RATE_2M                                        BIT(1)
-#define RATE_5_5M                              BIT(2)
-#define RATE_11M                               BIT(3)
-/* OFDM */
-#define RATE_6M                                        BIT(4)
-#define RATE_9M                                        BIT(5)
-#define RATE_12M                               BIT(6)
-#define RATE_18M                               BIT(7)
-#define RATE_24M                               BIT(8)
-#define RATE_36M                               BIT(9)
-#define RATE_48M                               BIT(10)
-#define RATE_54M                               BIT(11)
-/* MCS 1 Spatial Stream */
-#define RATE_MCS0                              BIT(12)
-#define RATE_MCS1                              BIT(13)
-#define RATE_MCS2                              BIT(14)
-#define RATE_MCS3                              BIT(15)
-#define RATE_MCS4                              BIT(16)
-#define RATE_MCS5                              BIT(17)
-#define RATE_MCS6                              BIT(18)
-#define RATE_MCS7                              BIT(19)
-/* MCS 2 Spatial Stream */
-#define RATE_MCS8                              BIT(20)
-#define RATE_MCS9                              BIT(21)
-#define RATE_MCS10                             BIT(22)
-#define RATE_MCS11                             BIT(23)
-#define RATE_MCS12                             BIT(24)
-#define RATE_MCS13                             BIT(25)
-#define RATE_MCS14                             BIT(26)
-#define RATE_MCS15                             BIT(27)
-
-/*  ALL CCK Rate */
-#define        RATE_ALL_CCK            (RATR_1M | RATR_2M | RATR_55M | RATR_11M)
-#define        RATE_ALL_OFDM_AG        (RATR_6M | RATR_9M | RATR_12M | RATR_18M | \
-                                RATR_24M | RATR_36M | RATR_48M | RATR_54M)
-#define        RATE_ALL_OFDM_1SS       (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 |    \
-                                RATR_MCS3 | RATR_MCS4 | RATR_MCS5|RATR_MCS6 | \
-                                RATR_MCS7)
-#define        RATE_ALL_OFDM_2SS       (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | \
-                                RATR_MCS11 | RATR_MCS12 | RATR_MCS13 | \
-                                RATR_MCS14 | RATR_MCS15)
-
-/*------------------------------ Tx Desc definition Macro --------------------*/
-/* pragma mark -- Tx Desc related definition. -- */
-/*     Rate */
-/*  CCK Rates, TxHT = 0 */
-#define DESC_RATE1M                            0x00
-#define DESC_RATE2M                            0x01
-#define DESC_RATE5_5M                          0x02
-#define DESC_RATE11M                           0x03
-
-/*  OFDM Rates, TxHT = 0 */
-#define DESC_RATE6M                            0x04
-#define DESC_RATE9M                            0x05
-#define DESC_RATE12M                           0x06
-#define DESC_RATE18M                           0x07
-#define DESC_RATE24M                           0x08
-#define DESC_RATE36M                           0x09
-#define DESC_RATE48M                           0x0a
-#define DESC_RATE54M                           0x0b
-
-/*  MCS Rates, TxHT = 1 */
-#define DESC_RATEMCS0                          0x0c
-#define DESC_RATEMCS1                          0x0d
-#define DESC_RATEMCS2                          0x0e
-#define DESC_RATEMCS3                          0x0f
-#define DESC_RATEMCS4                          0x10
-#define DESC_RATEMCS5                          0x11
-#define DESC_RATEMCS6                          0x12
-#define DESC_RATEMCS7                          0x13
-#define DESC_RATEMCS8                          0x14
-#define DESC_RATEMCS9                          0x15
-#define DESC_RATEMCS10                         0x16
-#define DESC_RATEMCS11                         0x17
-#define DESC_RATEMCS12                         0x18
-#define DESC_RATEMCS13                         0x19
-#define DESC_RATEMCS14                         0x1a
-#define DESC_RATEMCS15                         0x1b
-#define DESC_RATEMCS15_SG                      0x1c
-#define DESC_RATEMCS32                         0x20
-
-/*  1 Byte long (in unit of TU) */
-#define REG_P2P_CTWIN                          0x0572
-#define REG_NOA_DESC_SEL                       0x05CF
-#define REG_NOA_DESC_DURATION                  0x05E0
-#define REG_NOA_DESC_INTERVAL                  0x05E4
-#define REG_NOA_DESC_START                     0x05E8
-#define REG_NOA_DESC_COUNT                     0x05EC
-
-/* return the final channel plan decision */
-u8 hal_com_get_channel_plan(struct adapter *padapter,
-                           u8 hw_channel_plan,
-                           u8 sw_channel_plan,
-                           u8 def_channel_plan,
-                           bool AutoLoadFail
-);
-
-u8 MRateToHwRate(u8 rate);
-
-void HalSetBrateCfg(struct adapter *Adapter, u8 *mBratesOS, u16 *pBrateCfg);
-
-#endif /* __HAL_COMMON_H__ */
diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h
deleted file mode 100644 (file)
index 296aa5b..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#ifndef __HAL_INTF_H__
-#define __HAL_INTF_H__
-
-#include "osdep_service.h"
-#include "drv_types.h"
-#include "Hal8188EPhyCfg.h"
-
-typedef s32 (*c2h_id_filter)(u8 id);
-
-int rtl8188eu_interface_configure(struct adapter *adapt);
-int ReadAdapterInfo8188EU(struct adapter *Adapter);
-void rtl8188eu_init_default_value(struct adapter *adapt);
-void rtl8188e_SetHalODMVar(struct adapter *Adapter, void *pValue1, bool bSet);
-u32 rtl8188eu_InitPowerOn(struct adapter *adapt);
-void rtl8188e_EfusePowerSwitch(struct adapter *pAdapter, u8 PwrState);
-void rtl8188e_ReadEFuse(struct adapter *Adapter, u16 _size_byte, u8 *pbuf);
-
-void hal_notch_filter_8188e(struct adapter *adapter, bool enable);
-
-void SetBeaconRelatedRegisters8188EUsb(struct adapter *adapt);
-void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level);
-
-int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter,
-                               struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt);
-
-int rtl8188eu_inirp_init(struct adapter *Adapter);
-
-uint rtw_hal_init(struct adapter *padapter);
-uint rtw_hal_deinit(struct adapter *padapter);
-void rtw_hal_stop(struct adapter *padapter);
-
-u32 rtl8188eu_hal_init(struct adapter *Adapter);
-u32 rtl8188eu_hal_deinit(struct adapter *Adapter);
-
-void rtw_hal_update_ra_mask(struct adapter *padapter, u32 mac_id, u8 level);
-void   rtw_hal_clone_data(struct adapter *dst_adapt,
-                          struct adapter *src_adapt);
-
-u8 rtw_do_join(struct adapter *padapter);
-
-#endif /* __HAL_INTF_H__ */
diff --git a/drivers/staging/r8188eu/include/ieee80211.h b/drivers/staging/r8188eu/include/ieee80211.h
deleted file mode 100644 (file)
index e7a4f8a..0000000
+++ /dev/null
@@ -1,817 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __IEEE80211_H
-#define __IEEE80211_H
-
-#include "osdep_service.h"
-#include "drv_types.h"
-#include "wifi.h"
-#include <linux/wireless.h>
-
-#define MGMT_QUEUE_NUM 5
-
-#define ETH_TYPE_LEN           2
-#define PAYLOAD_TYPE_LEN       1
-
-#define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28)
-
-/* STA flags */
-#define WLAN_STA_AUTH BIT(0)
-#define WLAN_STA_ASSOC BIT(1)
-#define WLAN_STA_PS BIT(2)
-#define WLAN_STA_TIM BIT(3)
-#define WLAN_STA_PERM BIT(4)
-#define WLAN_STA_AUTHORIZED BIT(5)
-#define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
-#define WLAN_STA_SHORT_PREAMBLE BIT(7)
-#define WLAN_STA_PREAUTH BIT(8)
-#define WLAN_STA_WME BIT(9)
-#define WLAN_STA_MFP BIT(10)
-#define WLAN_STA_HT BIT(11)
-#define WLAN_STA_WPS BIT(12)
-#define WLAN_STA_MAYBE_WPS BIT(13)
-#define WLAN_STA_NONERP BIT(31)
-
-#define IEEE_CMD_SET_WPA_PARAM                 1
-#define IEEE_CMD_SET_WPA_IE                            2
-#define IEEE_CMD_SET_ENCRYPTION                        3
-#define IEEE_CMD_MLME                                          4
-
-#define IEEE_PARAM_WPA_ENABLED                         1
-#define IEEE_PARAM_TKIP_COUNTERMEASURES                2
-#define IEEE_PARAM_DROP_UNENCRYPTED                    3
-#define IEEE_PARAM_PRIVACY_INVOKED                     4
-#define IEEE_PARAM_AUTH_ALGS                                   5
-#define IEEE_PARAM_IEEE_802_1X                         6
-#define IEEE_PARAM_WPAX_SELECT                         7
-
-#define AUTH_ALG_OPEN_SYSTEM                   0x1
-#define AUTH_ALG_SHARED_KEY                    0x2
-#define AUTH_ALG_LEAP                          0x00000004
-
-#define IEEE_MLME_STA_DEAUTH                           1
-#define IEEE_MLME_STA_DISASSOC                 2
-
-#define IEEE_CRYPT_ERR_UNKNOWN_ALG                     2
-#define IEEE_CRYPT_ERR_UNKNOWN_ADDR                    3
-#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED               4
-#define IEEE_CRYPT_ERR_KEY_SET_FAILED                  5
-#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED               6
-#define IEEE_CRYPT_ERR_CARD_CONF_FAILED                7
-
-#define        IEEE_CRYPT_ALG_NAME_LEN                 16
-
-#define WPA_CIPHER_NONE                BIT(0)
-#define WPA_CIPHER_WEP40       BIT(1)
-#define WPA_CIPHER_WEP104 BIT(2)
-#define WPA_CIPHER_TKIP                BIT(3)
-#define WPA_CIPHER_CCMP                BIT(4)
-
-
-#define WPA_SELECTOR_LEN 4
-extern u8 RTW_WPA_OUI_TYPE[];
-extern u16 RTW_WPA_VERSION;
-extern u8 WPA_AUTH_KEY_MGMT_NONE[];
-extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
-extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
-extern u8 WPA_CIPHER_SUITE_NONE[];
-extern u8 WPA_CIPHER_SUITE_WEP40[];
-extern u8 WPA_CIPHER_SUITE_TKIP[];
-extern u8 WPA_CIPHER_SUITE_WRAP[];
-extern u8 WPA_CIPHER_SUITE_CCMP[];
-extern u8 WPA_CIPHER_SUITE_WEP104[];
-
-#define RSN_HEADER_LEN 4
-#define RSN_SELECTOR_LEN 4
-
-extern u16 RSN_VERSION_BSD;
-extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[];
-extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
-extern u8 RSN_CIPHER_SUITE_NONE[];
-extern u8 RSN_CIPHER_SUITE_WEP40[];
-extern u8 RSN_CIPHER_SUITE_TKIP[];
-extern u8 RSN_CIPHER_SUITE_WRAP[];
-extern u8 RSN_CIPHER_SUITE_CCMP[];
-extern u8 RSN_CIPHER_SUITE_WEP104[];
-
-enum ratr_table_mode {
-       RATR_INX_WIRELESS_NGB = 0,      /*  BGN 40 Mhz 2SS 1SS */
-       RATR_INX_WIRELESS_NG = 1,       /*  GN or N */
-       RATR_INX_WIRELESS_NB = 2,       /*  BGN 20 Mhz 2SS 1SS  or BN */
-       RATR_INX_WIRELESS_N = 3,
-       RATR_INX_WIRELESS_GB = 4,
-       RATR_INX_WIRELESS_G = 5,
-       RATR_INX_WIRELESS_B = 6,
-       RATR_INX_WIRELESS_MC = 7,
-       RATR_INX_WIRELESS_AC_N = 8,
-};
-
-enum NETWORK_TYPE {
-       WIRELESS_INVALID = 0,
-       /* Sub-Element */
-       WIRELESS_11B = BIT(0), /* tx:cck only, rx:cck only, hw: cck */
-       WIRELESS_11G = BIT(1), /* tx:ofdm only, rx:ofdm & cck, hw:cck & ofdm*/
-       WIRELESS_11_24N = BIT(3), /* tx:MCS only, rx:MCS & cck, hw:MCS & cck */
-
-       /* Combination */
-       /*  tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */
-       WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G),
-       /*  tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */
-       WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N),
-       /*  tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
-       WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N),
-};
-
-struct ieee_param {
-       u32 cmd;
-       u8 sta_addr[ETH_ALEN];
-       union {
-               struct {
-                       u8 name;
-                       u32 value;
-               } wpa_param;
-               struct {
-                       u32 len;
-                       u8 reserved[32];
-                       u8 data[];
-               } wpa_ie;
-               struct {
-                       int command;
-                       int reason_code;
-               } mlme;
-               struct {
-                       u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
-                       u8 set_tx;
-                       u32 err;
-                       u8 idx;
-                       u8 seq[8]; /* sequence counter (set: RX, get: TX) */
-                       u16 key_len;
-                       u8 key[];
-               } crypt;
-               struct {
-                       u16 aid;
-                       u16 capability;
-                       int flags;
-                       u8 tx_supp_rates[16];
-                       struct ieee80211_ht_cap ht_cap;
-               } add_sta;
-               struct {
-                       u8      reserved[2];/* for set max_num_sta */
-                       u8      buf[];
-               } bcn_ie;
-       } u;
-};
-
-#define IEEE80211_DATA_LEN             2304
-/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
-   6.2.1.1.2.
-
-   The figure in section 7.1.2 suggests a body size of up to 2312
-   bytes is allowed, which is a bit confusing, I suspect this
-   represents the 2304 bytes of real data, plus a possible 8 bytes of
-   WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
-
-#define IEEE80211_HLEN                 30
-#define IEEE80211_FRAME_LEN            (IEEE80211_DATA_LEN + IEEE80211_HLEN)
-
-/* this is stolen from ipw2200 driver */
-#define IEEE_IBSS_MAC_HASH_SIZE 31
-
-#define IEEE80211_3ADDR_LEN 24
-#define IEEE80211_4ADDR_LEN 30
-#define IEEE80211_FCS_LEN    4
-
-#define MIN_FRAG_THRESHOLD     256U
-#define        MAX_FRAG_THRESHOLD     2346U
-
-/* Frame control field constants */
-#define RTW_IEEE80211_FCTL_VERS                0x0003
-#define RTW_IEEE80211_FCTL_FTYPE       0x000c
-#define RTW_IEEE80211_FCTL_STYPE       0x00f0
-#define RTW_IEEE80211_FCTL_TODS                0x0100
-#define RTW_IEEE80211_FCTL_FROMDS      0x0200
-#define RTW_IEEE80211_FCTL_MOREFRAGS   0x0400
-#define RTW_IEEE80211_FCTL_RETRY       0x0800
-#define RTW_IEEE80211_FCTL_PM          0x1000
-#define RTW_IEEE80211_FCTL_MOREDATA    0x2000
-#define RTW_IEEE80211_FCTL_PROTECTED   0x4000
-#define RTW_IEEE80211_FCTL_ORDER       0x8000
-#define RTW_IEEE80211_FCTL_CTL_EXT     0x0f00
-
-#define RTW_IEEE80211_FTYPE_MGMT       0x0000
-#define RTW_IEEE80211_FTYPE_CTL                0x0004
-#define RTW_IEEE80211_FTYPE_DATA       0x0008
-#define RTW_IEEE80211_FTYPE_EXT                0x000c
-
-/* management */
-#define RTW_IEEE80211_STYPE_ASSOC_REQ  0x0000
-#define RTW_IEEE80211_STYPE_ASSOC_RESP 0x0010
-#define RTW_IEEE80211_STYPE_REASSOC_REQ        0x0020
-#define RTW_IEEE80211_STYPE_REASSOC_RESP       0x0030
-#define RTW_IEEE80211_STYPE_PROBE_REQ  0x0040
-#define RTW_IEEE80211_STYPE_PROBE_RESP 0x0050
-#define RTW_IEEE80211_STYPE_BEACON     0x0080
-#define RTW_IEEE80211_STYPE_ATIM       0x0090
-#define RTW_IEEE80211_STYPE_DISASSOC   0x00A0
-#define RTW_IEEE80211_STYPE_AUTH       0x00B0
-#define RTW_IEEE80211_STYPE_DEAUTH     0x00C0
-#define RTW_IEEE80211_STYPE_ACTION     0x00D0
-
-/* control */
-#define RTW_IEEE80211_STYPE_CTL_EXT    0x0060
-#define RTW_IEEE80211_STYPE_BACK_REQ   0x0080
-#define RTW_IEEE80211_STYPE_BACK       0x0090
-#define RTW_IEEE80211_STYPE_PSPOLL     0x00A0
-#define RTW_IEEE80211_STYPE_RTS                0x00B0
-#define RTW_IEEE80211_STYPE_CTS                0x00C0
-#define RTW_IEEE80211_STYPE_ACK                0x00D0
-#define RTW_IEEE80211_STYPE_CFEND      0x00E0
-#define RTW_IEEE80211_STYPE_CFENDACK   0x00F0
-
-/* data */
-#define RTW_IEEE80211_STYPE_DATA       0x0000
-#define RTW_IEEE80211_STYPE_DATA_CFACK 0x0010
-#define RTW_IEEE80211_STYPE_DATA_CFPOLL        0x0020
-#define RTW_IEEE80211_STYPE_DATA_CFACKPOLL     0x0030
-#define RTW_IEEE80211_STYPE_NULLFUNC   0x0040
-#define RTW_IEEE80211_STYPE_CFACK      0x0050
-#define RTW_IEEE80211_STYPE_CFPOLL     0x0060
-#define RTW_IEEE80211_STYPE_CFACKPOLL  0x0070
-#define RTW_IEEE80211_STYPE_QOS_DATA   0x0080
-#define RTW_IEEE80211_STYPE_QOS_DATA_CFACK     0x0090
-#define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL    0x00A0
-#define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
-#define RTW_IEEE80211_STYPE_QOS_NULLFUNC       0x00C0
-#define RTW_IEEE80211_STYPE_QOS_CFACK          0x00D0
-#define RTW_IEEE80211_STYPE_QOS_CFPOLL         0x00E0
-#define RTW_IEEE80211_STYPE_QOS_CFACKPOLL      0x00F0
-
-/* sequence control field */
-#define RTW_IEEE80211_SCTL_FRAG        0x000F
-#define RTW_IEEE80211_SCTL_SEQ 0xFFF0
-
-#define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0)
-#define RTW_ERP_INFO_USE_PROTECTION BIT(1)
-#define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
-
-/* QoS, QOS */
-#define NORMAL_ACK                     0
-#define NO_ACK                         1
-#define NON_EXPLICIT_ACK               2
-#define BLOCK_ACK                      3
-
-#ifndef ETH_P_PAE
-#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
-#endif /* ETH_P_PAE */
-
-#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
-
-#define ETH_P_ECONET   0x0018
-
-#ifndef ETH_P_80211_RAW
-#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
-#endif
-
-/* IEEE 802.11 defines */
-
-#define P80211_OUI_LEN 3
-
-struct ieee80211_snap_hdr {
-       u8    dsap;   /* always 0xAA */
-       u8    ssap;   /* always 0xAA */
-       u8    ctrl;   /* always 0x03 */
-       u8    oui[P80211_OUI_LEN];    /* organizational universal id */
-} __packed;
-
-#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
-
-#define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE)
-#define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE)
-
-#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
-
-#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
-#define WLAN_GET_SEQ_SEQ(seq)  ((seq) & RTW_IEEE80211_SCTL_SEQ)
-
-/* Authentication algorithms */
-#define WLAN_AUTH_OPEN 0
-#define WLAN_AUTH_SHARED_KEY 1
-
-#define WLAN_AUTH_CHALLENGE_LEN 128
-
-#define WLAN_CAPABILITY_BSS (1<<0)
-#define WLAN_CAPABILITY_IBSS (1<<1)
-#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
-#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
-#define WLAN_CAPABILITY_PRIVACY (1<<4)
-#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
-#define WLAN_CAPABILITY_PBCC (1<<6)
-#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
-#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
-
-/* Status codes */
-#define WLAN_STATUS_SUCCESS 0
-#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
-#define WLAN_STATUS_CAPS_UNSUPPORTED 10
-#define WLAN_STATUS_REASSOC_NO_ASSOC 11
-#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
-#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
-#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
-#define WLAN_STATUS_CHALLENGE_FAIL 15
-#define WLAN_STATUS_AUTH_TIMEOUT 16
-#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
-#define WLAN_STATUS_ASSOC_DENIED_RATES 18
-/* 802.11b */
-#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
-#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
-#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
-
-/* Reason codes */
-#define WLAN_REASON_UNSPECIFIED 1
-#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
-#define WLAN_REASON_DEAUTH_LEAVING 3
-#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
-#define WLAN_REASON_DISASSOC_AP_BUSY 5
-#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
-#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
-#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
-#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
-#define WLAN_REASON_JOIN_WRONG_CHANNEL       65534
-#define WLAN_REASON_EXPIRATION_CHK 65535
-
-/* Information Element IDs */
-#define WLAN_EID_SSID 0
-#define WLAN_EID_SUPP_RATES 1
-#define WLAN_EID_FH_PARAMS 2
-#define WLAN_EID_DS_PARAMS 3
-#define WLAN_EID_CF_PARAMS 4
-#define WLAN_EID_TIM 5
-#define WLAN_EID_IBSS_PARAMS 6
-#define WLAN_EID_CHALLENGE 16
-/* EIDs defined by IEEE 802.11h - START */
-#define WLAN_EID_PWR_CONSTRAINT 32
-#define WLAN_EID_PWR_CAPABILITY 33
-#define WLAN_EID_TPC_REQUEST 34
-#define WLAN_EID_TPC_REPORT 35
-#define WLAN_EID_SUPPORTED_CHANNELS 36
-#define WLAN_EID_CHANNEL_SWITCH 37
-#define WLAN_EID_MEASURE_REQUEST 38
-#define WLAN_EID_MEASURE_REPORT 39
-#define WLAN_EID_QUITE 40
-#define WLAN_EID_IBSS_DFS 41
-/* EIDs defined by IEEE 802.11h - END */
-#define WLAN_EID_ERP_INFO 42
-#define WLAN_EID_HT_CAP 45
-#define WLAN_EID_RSN 48
-#define WLAN_EID_EXT_SUPP_RATES 50
-#define WLAN_EID_MOBILITY_DOMAIN 54
-#define WLAN_EID_FAST_BSS_TRANSITION 55
-#define WLAN_EID_TIMEOUT_INTERVAL 56
-#define WLAN_EID_RIC_DATA 57
-#define WLAN_EID_HT_OPERATION 61
-#define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62
-#define WLAN_EID_20_40_BSS_COEXISTENCE 72
-#define WLAN_EID_20_40_BSS_INTOLERANT 73
-#define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
-#define WLAN_EID_MMIE 76
-#define WLAN_EID_VENDOR_SPECIFIC 221
-#define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC)
-
-#define IEEE80211_MGMT_HDR_LEN 24
-#define IEEE80211_DATA_HDR3_LEN 24
-#define IEEE80211_DATA_HDR4_LEN 30
-
-#define IEEE80211_STATMASK_SIGNAL (1<<0)
-#define IEEE80211_STATMASK_RSSI (1<<1)
-#define IEEE80211_STATMASK_NOISE (1<<2)
-#define IEEE80211_STATMASK_RATE (1<<3)
-#define IEEE80211_STATMASK_WEMASK 0x7
-
-#define IEEE80211_CCK_MODULATION    (1<<0)
-#define IEEE80211_OFDM_MODULATION   (1<<1)
-
-#define IEEE80211_24GHZ_BAND     (1<<0)
-#define IEEE80211_52GHZ_BAND     (1<<1)
-
-#define IEEE80211_CCK_RATE_LEN                 4
-#define IEEE80211_NUM_OFDM_RATESLEN    8
-
-#define IEEE80211_CCK_RATE_1MB                 0x02
-#define IEEE80211_CCK_RATE_2MB                 0x04
-#define IEEE80211_CCK_RATE_5MB                 0x0B
-#define IEEE80211_CCK_RATE_11MB                        0x16
-#define IEEE80211_OFDM_RATE_LEN                        8
-#define IEEE80211_OFDM_RATE_6MB                        0x0C
-#define IEEE80211_OFDM_RATE_9MB                        0x12
-#define IEEE80211_OFDM_RATE_12MB               0x18
-#define IEEE80211_OFDM_RATE_18MB               0x24
-#define IEEE80211_OFDM_RATE_24MB               0x30
-#define IEEE80211_OFDM_RATE_36MB               0x48
-#define IEEE80211_OFDM_RATE_48MB               0x60
-#define IEEE80211_OFDM_RATE_54MB               0x6C
-#define IEEE80211_BASIC_RATE_MASK              0x80
-
-#define IEEE80211_CCK_RATE_1MB_MASK            (1<<0)
-#define IEEE80211_CCK_RATE_2MB_MASK            (1<<1)
-#define IEEE80211_CCK_RATE_5MB_MASK            (1<<2)
-#define IEEE80211_CCK_RATE_11MB_MASK           (1<<3)
-#define IEEE80211_OFDM_RATE_6MB_MASK           (1<<4)
-#define IEEE80211_OFDM_RATE_9MB_MASK           (1<<5)
-#define IEEE80211_OFDM_RATE_12MB_MASK          (1<<6)
-#define IEEE80211_OFDM_RATE_18MB_MASK          (1<<7)
-#define IEEE80211_OFDM_RATE_24MB_MASK          (1<<8)
-#define IEEE80211_OFDM_RATE_36MB_MASK          (1<<9)
-#define IEEE80211_OFDM_RATE_48MB_MASK          (1<<10)
-#define IEEE80211_OFDM_RATE_54MB_MASK          (1<<11)
-
-#define IEEE80211_CCK_RATES_MASK               0x0000000F
-#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
-       IEEE80211_CCK_RATE_2MB_MASK)
-#define IEEE80211_CCK_DEFAULT_RATES_MASK                               \
-       (IEEE80211_CCK_BASIC_RATES_MASK |                               \
-       IEEE80211_CCK_RATE_5MB_MASK |                                   \
-       IEEE80211_CCK_RATE_11MB_MASK)
-
-#define IEEE80211_OFDM_RATES_MASK              0x00000FF0
-#define IEEE80211_OFDM_BASIC_RATES_MASK        (IEEE80211_OFDM_RATE_6MB_MASK | \
-       IEEE80211_OFDM_RATE_12MB_MASK |                                 \
-       IEEE80211_OFDM_RATE_24MB_MASK)
-#define IEEE80211_OFDM_DEFAULT_RATES_MASK                              \
-       (IEEE80211_OFDM_BASIC_RATES_MASK |                              \
-       IEEE80211_OFDM_RATE_9MB_MASK  |                                 \
-       IEEE80211_OFDM_RATE_18MB_MASK |                                 \
-       IEEE80211_OFDM_RATE_36MB_MASK |                                 \
-       IEEE80211_OFDM_RATE_48MB_MASK |                                 \
-       IEEE80211_OFDM_RATE_54MB_MASK)
-#define IEEE80211_DEFAULT_RATES_MASK                                   \
-       (IEEE80211_OFDM_DEFAULT_RATES_MASK |                            \
-        IEEE80211_CCK_DEFAULT_RATES_MASK)
-
-#define IEEE80211_NUM_OFDM_RATES       8
-#define IEEE80211_NUM_CCK_RATES                4
-#define IEEE80211_OFDM_SHIFT_MASK_A    4
-
-/* IEEE 802.11 requires that STA supports concurrent reception of at least
- * three fragmented frames. This define can be increased to support more
- * concurrent frames, but it should be noted that each entry can consume about
- * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
-#define IEEE80211_FRAG_CACHE_LEN 4
-
-#define SEC_KEY_1      (1<<0)
-#define SEC_KEY_2      (1<<1)
-#define SEC_KEY_3      (1<<2)
-#define SEC_KEY_4      (1<<3)
-#define SEC_ACTIVE_KEY  (1<<4)
-#define SEC_AUTH_MODE   (1<<5)
-#define SEC_UNICAST_GROUP (1<<6)
-#define SEC_LEVEL      (1<<7)
-#define SEC_ENABLED     (1<<8)
-
-#define SEC_LEVEL_0      0 /* None */
-#define SEC_LEVEL_1      1 /* WEP 40 and 104 bit */
-#define SEC_LEVEL_2      2 /* Level 1 + TKIP */
-#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
-#define SEC_LEVEL_3      4 /* Level 2 + CCMP */
-
-#define WEP_KEYS 4
-#define WEP_KEY_LEN 13
-
-/*
-
- 802.11 data frame from AP
-
-      ,-------------------------------------------------------------------.
-Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
-      |------|------|---------|---------|---------|------|---------|------|
-Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
-      |      | tion | (BSSID) |         |       | ence |  data   |      |
-      `-------------------------------------------------------------------'
-
-Total: 28-2340 bytes
-
-*/
-
-#define BEACON_PROBE_SSID_ID_POSITION 12
-
-/* Management Frame Information Element Types */
-#define MFIE_TYPE_SSID         0
-#define MFIE_TYPE_RATES                1
-#define MFIE_TYPE_FH_SET       2
-#define MFIE_TYPE_DS_SET       3
-#define MFIE_TYPE_CF_SET       4
-#define MFIE_TYPE_TIM          5
-#define MFIE_TYPE_IBSS_SET     6
-#define MFIE_TYPE_CHALLENGE    16
-#define MFIE_TYPE_ERP          42
-#define MFIE_TYPE_RSN          48
-#define MFIE_TYPE_RATES_EX     50
-#define MFIE_TYPE_GENERIC      221
-
-/*
- * These are the data types that can make up management packets
- *
-       u16 auth_algorithm;
-       u16 auth_sequence;
-       u16 beacon_interval;
-       u16 capability;
-       u8 current_ap[ETH_ALEN];
-       u16 listen_interval;
-       struct {
-               u16 association_id:14, reserved:2;
-       } __packed;
-       u32 time_stamp[2];
-       u16 reason;
-       u16 status;
-*/
-
-#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
-#define IEEE80211_DEFAULT_BASIC_RATE 10
-
-/* SWEEP TABLE ENTRIES NUMBER*/
-#define MAX_SWEEP_TAB_ENTRIES            42
-#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET  7
-/* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
- * only use 8, and then use extended rates for the remaining supported
- * rates.  Other APs, however, stick all of their supported rates on the
- * main rates information element... */
-#define MAX_RATES_LENGTH               ((u8)12)
-#define MAX_RATES_EX_LENGTH            ((u8)16)
-#define MAX_NETWORK_COUNT              128
-#define MAX_CHANNEL_NUMBER             161
-#define IEEE80211_SOFTMAC_SCAN_TIME    400
-/* HZ / 2) */
-#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
-
-#define CRC_LENGTH              4U
-
-#define MAX_WPA_IE_LEN (256)
-#define MAX_WPS_IE_LEN (512)
-#define MAX_P2P_IE_LEN (256)
-#define MAX_WFD_IE_LEN (128)
-
-#define NETWORK_EMPTY_ESSID (1<<0)
-#define NETWORK_HAS_OFDM    (1<<1)
-#define NETWORK_HAS_CCK     (1<<2)
-
-#define IEEE80211_DTIM_MBCAST 4
-#define IEEE80211_DTIM_UCAST 2
-#define IEEE80211_DTIM_VALID 1
-#define IEEE80211_DTIM_INVALID 0
-
-#define IEEE80211_PS_DISABLED 0
-#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
-#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
-#define IW_ESSID_MAX_SIZE 32
-/*
-join_res:
--1: authentication fail
--2: association fail
-> 0: TID
-*/
-
-#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
-#define DEFAULT_FTS 2346
-
-static inline int is_multicast_mac_addr(const u8 *addr)
-{
-       return ((addr[0] != 0xff) && (0x01 & addr[0]));
-}
-
-static inline int is_broadcast_mac_addr(const u8 *addr)
-{
-       return (addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
-              (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff);
-}
-
-#define CFG_IEEE80211_RESERVE_FCS (1<<0)
-#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
-
-#define MAXTID 16
-
-/* Action category code */
-enum rtw_ieee80211_category {
-       RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
-};
-
-/* SPECTRUM_MGMT action code */
-enum rtw_ieee80211_spectrum_mgmt_actioncode {
-       RTW_WLAN_ACTION_SPCT_MSR_REQ = 0,
-       RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1,
-       RTW_WLAN_ACTION_SPCT_TPC_REQ = 2,
-       RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3,
-       RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4,
-       RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
-};
-
-enum _PUBLIC_ACTION {
-       ACT_PUBLIC_BSSCOEXIST = 0, /*  20/40 BSS Coexistence */
-       ACT_PUBLIC_DSE_ENABLE = 1,
-       ACT_PUBLIC_DSE_DEENABLE = 2,
-       ACT_PUBLIC_DSE_REG_LOCATION = 3,
-       ACT_PUBLIC_EXT_CHL_SWITCH = 4,
-       ACT_PUBLIC_DSE_MSR_REQ = 5,
-       ACT_PUBLIC_DSE_MSR_RPRT = 6,
-       ACT_PUBLIC_MP = 7, /*  Measurement Pilot */
-       ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
-       ACT_PUBLIC_VENDOR = 9, /*  for WIFI_DIRECT */
-       ACT_PUBLIC_GAS_INITIAL_REQ = 10,
-       ACT_PUBLIC_GAS_INITIAL_RSP = 11,
-       ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
-       ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
-       ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
-       ACT_PUBLIC_LOCATION_TRACK = 15,
-       ACT_PUBLIC_MAX
-};
-
-#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
-                               * 00:50:F2 */
-#define WME_OUI_TYPE 2
-#define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
-#define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
-#define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
-#define WME_VERSION 1
-
-#define WME_ACTION_CODE_SETUP_REQUEST 0
-#define WME_ACTION_CODE_SETUP_RESPONSE 1
-#define WME_ACTION_CODE_TEARDOWN 2
-
-#define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
-#define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
-#define WME_SETUP_RESPONSE_STATUS_REFUSED 3
-
-#define WME_TSPEC_DIRECTION_UPLINK 0
-#define WME_TSPEC_DIRECTION_DOWNLINK 1
-#define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
-
-#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
-
-#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
-
-/**
- * enum rtw_ieee80211_channel_flags - channel flags
- *
- * Channel flags set by the regulatory control code.
- *
- * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled.
- * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
- *      on this channel.
- * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
- * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
- * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
- *      is not permitted.
- * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
- *      is not permitted.
- */
-enum rtw_ieee80211_channel_flags {
-       RTW_IEEE80211_CHAN_DISABLED      = 1<<0,
-       RTW_IEEE80211_CHAN_PASSIVE_SCAN     = 1<<1,
-       RTW_IEEE80211_CHAN_NO_IBSS        = 1<<2,
-       RTW_IEEE80211_CHAN_RADAR            = 1<<3,
-       RTW_IEEE80211_CHAN_NO_HT40PLUS      = 1<<4,
-       RTW_IEEE80211_CHAN_NO_HT40MINUS     = 1<<5,
-};
-
-#define RTW_IEEE80211_CHAN_NO_HT40 \
-         (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS)
-
-/* Represent channel details, subset of ieee80211_channel */
-struct rtw_ieee80211_channel {
-       u16 hw_value;
-       u32 flags;
-};
-
-#define CHAN_FMT \
-       "hw_value:%u, " \
-       "flags:0x%08x" \
-
-#define CHAN_ARG(channel) \
-       (channel)->hw_value \
-       , (channel)->flags \
-
-/* Parsed Information Elements */
-struct rtw_ieee802_11_elems {
-       u8 *ssid;
-       u8 ssid_len;
-       u8 *supp_rates;
-       u8 supp_rates_len;
-       u8 *fh_params;
-       u8 fh_params_len;
-       u8 *ds_params;
-       u8 ds_params_len;
-       u8 *cf_params;
-       u8 cf_params_len;
-       u8 *tim;
-       u8 tim_len;
-       u8 *ibss_params;
-       u8 ibss_params_len;
-       u8 *challenge;
-       u8 challenge_len;
-       u8 *erp_info;
-       u8 erp_info_len;
-       u8 *ext_supp_rates;
-       u8 ext_supp_rates_len;
-       u8 *wpa_ie;
-       u8 wpa_ie_len;
-       u8 *rsn_ie;
-       u8 rsn_ie_len;
-       u8 *wme;
-       u8 wme_len;
-       u8 *wme_tspec;
-       u8 wme_tspec_len;
-       u8 *wps_ie;
-       u8 wps_ie_len;
-       u8 *power_cap;
-       u8 power_cap_len;
-       u8 *supp_channels;
-       u8 supp_channels_len;
-       u8 *mdie;
-       u8 mdie_len;
-       u8 *ftie;
-       u8 ftie_len;
-       u8 *timeout_int;
-       u8 timeout_int_len;
-       u8 *ht_capabilities;
-       u8 ht_capabilities_len;
-       u8 *ht_operation;
-       u8 ht_operation_len;
-       u8 *vendor_ht_cap;
-       u8 vendor_ht_cap_len;
-};
-
-enum parse_res {
-       ParseOK = 0,
-       ParseUnknown = 1,
-       ParseFailed = -1
-};
-
-enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len,
-                                         struct rtw_ieee802_11_elems *elems,
-                                         int show_errors);
-
-u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len,
-                    unsigned char *source, unsigned int *frlen);
-u8 *rtw_set_ie(u8 *pbuf, int index, uint len, u8 *source, uint *frlen);
-u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit);
-
-void rtw_set_supported_rate(u8 *SupportedRates, uint mode);
-
-unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit);
-unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
-int rtw_get_wpa_cipher_suite(u8 *s);
-int rtw_get_wpa2_cipher_suite(u8 *s);
-int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len);
-int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
-                    int *pairwise_cipher, int *is_8021x);
-int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
-                     int *pairwise_cipher, int *is_8021x);
-
-int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
-                  u8 *wpa_ie, u16 *wpa_len);
-
-u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen);
-u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
-u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
-                    u8 *buf_attr, u32 *len_attr);
-u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
-                            u8 *buf_content, uint *len_content);
-
-/**
- * for_each_ie - iterate over continuous IEs
- * @ie:
- * @buf:
- * @buf_len:
- */
-#define for_each_ie(ie, buf, buf_len) \
-       for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len;        \
-               ie = (void *)(((u8 *)ie) + *(((u8 *)ie)+1) + 2))
-
-u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen);
-u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id,
-                    u8 *buf_attr, u32 *len_attr);
-u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id,
-                            u8 *buf_content, uint *len_content);
-u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len,
-                            u8 *pdata_attr);
-void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex,
-                                      u8 attr_id);
-uint   rtw_get_rateset_len(u8  *rateset);
-
-struct registry_priv;
-int rtw_generate_ie(struct registry_priv *pregistrypriv);
-
-int rtw_get_bit_value_from_ieee_value(u8 val);
-
-bool   rtw_is_cckrates_included(u8 *rate);
-
-bool   rtw_is_cckratesonly_included(u8 *rate);
-
-int rtw_check_network_type(unsigned char *rate, int ratelen, int channel);
-
-void rtw_get_bcn_info(struct wlan_network *pnetwork);
-
-void rtw_macaddr_cfg(u8 *mac_addr);
-
-u16 rtw_mcs_rate(u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsigned char *MCS_rate);
-
-#endif /* IEEE80211_H */
diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h
deleted file mode 100644 (file)
index 8cea166..0000000
+++ /dev/null
@@ -1,416 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef        __HALDMOUTSRC_H__
-#define __HALDMOUTSRC_H__
-
-struct rtw_dig {
-       u8              PreIGValue;
-       u8              CurIGValue;
-       u8              BackupIGValue;
-
-       u8              rx_gain_range_max;
-       u8              rx_gain_range_min;
-
-       u8              CurCCK_CCAThres;
-
-       u8              LargeFAHit;
-       u8              ForbiddenIGI;
-       u32             Recover_cnt;
-
-       u8              DIG_Dynamic_MIN_0;
-       bool            bMediaConnect_0;
-
-       u32             AntDiv_RSSI_max;
-       u32             RSSI_max;
-};
-
-struct rtl_ps {
-       u8              pre_rf_state;
-       u8              cur_rf_state;
-       u8              initialize;
-       u32             reg_874;
-       u32             reg_c70;
-       u32             reg_85c;
-       u32             reg_a74;
-
-};
-
-struct false_alarm_stats {
-       u32     Cnt_Parity_Fail;
-       u32     Cnt_Rate_Illegal;
-       u32     Cnt_Crc8_fail;
-       u32     Cnt_Mcs_fail;
-       u32     Cnt_Ofdm_fail;
-       u32     Cnt_Cck_fail;
-       u32     Cnt_all;
-       u32     Cnt_Fast_Fsync;
-       u32     Cnt_SB_Search_fail;
-       u32     Cnt_OFDM_CCA;
-       u32     Cnt_CCK_CCA;
-       u32     Cnt_CCA_all;
-       u32     Cnt_BW_USC;     /* Gary */
-       u32     Cnt_BW_LSC;     /* Gary */
-};
-
-#define ODM_ASSOCIATE_ENTRY_NUM        32 /*  Max size of AsocEntry[]. */
-
-struct sw_ant_switch {
-       u8      CurAntenna;
-       u8      SWAS_NoLink_State; /* Before link Antenna Switch check */
-       u8      RxIdleAnt;
-};
-
-struct edca_turbo {
-       bool bCurrentTurboEDCA;
-       bool bIsCurRDLState;
-       u32     prv_traffic_idx; /*  edca turbo */
-};
-
-struct odm_rate_adapt {
-       u8      HighRSSIThresh; /*  if RSSI > HighRSSIThresh    => RATRState is DM_RATR_STA_HIGH */
-       u8      LowRSSIThresh;  /*  if RSSI <= LowRSSIThresh    => RATRState is DM_RATR_STA_LOW */
-       u8      RATRState;      /*  Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_STA_LOW */
-       u32     LastRATR;       /*  RATR Register Content */
-};
-
-#define IQK_MAC_REG_NUM                4
-#define IQK_ADDA_REG_NUM       16
-#define IQK_BB_REG_NUM         9
-#define HP_THERMAL_NUM         8
-
-#define AVG_THERMAL_NUM                8
-
-struct odm_phy_dbg_info {
-       /* ODM Write,debug info */
-       s8      RxSNRdB[MAX_PATH_NUM_92CS];
-       u64     NumQryPhyStatus;
-       /* Others */
-       s32     RxEVM[MAX_PATH_NUM_92CS];
-};
-
-struct odm_per_pkt_info {
-       s8      Rate;
-       u8      StationID;
-       bool    bPacketMatchBSSID;
-       bool    bPacketToSelf;
-       bool    bPacketBeacon;
-};
-
-/*  2011/10/20 MH Define Common info enum for all team. */
-
-enum odm_common_info_def {
-       /*  Fixed value: */
-
-       /* HOOK BEFORE REG INIT----------- */
-       ODM_CMNINFO_MP_TEST_CHIP,
-       /* HOOK BEFORE REG INIT-----------  */
-
-/* CALL BY VALUE------------- */
-       ODM_CMNINFO_RF_ANTENNA_TYPE,            /*  u8 */
-/* CALL BY VALUE-------------*/
-};
-
-enum odm_ability_def {
-       /*  BB ODM section BIT 0-15 */
-       ODM_BB_RSSI_MONITOR             = BIT(4),
-       ODM_BB_ANT_DIV                  = BIT(6),
-       ODM_BB_PWR_TRA                  = BIT(8),
-};
-
-#define ODM_ITRF_USB   0x2
-#define ODM_CE         0x04
-
-/*  ODM_CMNINFO_WM_MODE */
-enum odm_wireless_mode {
-       ODM_WM_UNKNOW   = 0x0,
-       ODM_WM_B        = BIT(0),
-       ODM_WM_G        = BIT(1),
-       ODM_WM_N24G     = BIT(3),
-       ODM_WM_AUTO     = BIT(5),
-};
-
-struct odm_ra_info {
-       u8 RateID;
-       u32 RateMask;
-       u32 RAUseRate;
-       u8 RateSGI;
-       u8 RssiStaRA;
-       u8 PreRssiStaRA;
-       u8 SGIEnable;
-       u8 DecisionRate;
-       u8 PreRate;
-       u8 HighestRate;
-       u8 LowestRate;
-       u32 NscUp;
-       u32 NscDown;
-       u16 RTY[5];
-       u32 TOTAL;
-       u16 DROP;
-       u8 Active;
-       u16 RptTime;
-       u8 RAWaitingCounter;
-       u8 RAPendingCounter;
-       u8 PTActive;    /*  on or off */
-       u8 PTTryState;  /*  0 trying state, 1 for decision state */
-       u8 PTStage;     /*  0~6 */
-       u8 PTStopCount; /* Stop PT counter */
-       u8 PTPreRate;   /*  if rate change do PT */
-       u8 PTPreRssi;   /*  if RSSI change 5% do PT */
-       u8 PTModeSS;    /*  decide whitch rate should do PT */
-       u8 RAstage;     /*  StageRA, decide how many times RA will be done
-                        * between PT */
-       u8 PTSmoothFactor;
-};
-
-struct odm_rf_cal {
-       /* for tx power tracking */
-       u32     RegA24; /*  for TempCCK */
-       s32     RegE94;
-       s32     RegE9C;
-       s32     RegEB4;
-       s32     RegEBC;
-
-       u8      TxPowerTrackControl; /* for mp mode, turn off txpwrtracking
-                                     * as default */
-       u8      TM_Trigger;
-       u8      InternalPA5G[2];        /* pathA / pathB */
-
-       u8      ThermalMeter[2];    /* ThermalMeter, index 0 for RFIC0,
-                                    * and 1 for RFIC1 */
-       u8      ThermalValue;
-       u8      ThermalValue_LCK;
-       u8      ThermalValue_IQK;
-       u8      ThermalValue_DPK;
-       u8      ThermalValue_AVG[AVG_THERMAL_NUM];
-       u8      ThermalValue_AVG_index;
-       u8      ThermalValue_RxGain;
-       u8      ThermalValue_Crystal;
-       u8      ThermalValue_DPKstore;
-       u8      ThermalValue_DPKtrack;
-       bool    TxPowerTrackingInProgress;
-       bool    bDPKenable;
-
-       bool    bReloadtxpowerindex;
-       u8      bRfPiEnable;
-
-       u8      CCK_index;
-       u8      OFDM_index;
-       bool bDoneTxpower;
-
-       u8      ThermalValue_HP[HP_THERMAL_NUM];
-       u8      ThermalValue_HP_index;
-
-       u8      Delta_IQK;
-       u8      Delta_LCK;
-
-       /* for IQK */
-       u32     RegC04;
-       u32     Reg874;
-       u32     RegC08;
-       u32     RegB68;
-       u32     RegB6C;
-       u32     Reg870;
-       u32     Reg860;
-       u32     Reg864;
-
-       bool    bIQKInitialized;
-       bool    bAntennaDetected;
-       u32     ADDA_backup[IQK_ADDA_REG_NUM];
-       u32     IQK_MAC_backup[IQK_MAC_REG_NUM];
-       u32     IQK_BB_backup_recover[9];
-       u32     IQK_BB_backup[IQK_BB_REG_NUM];
-
-       /* for APK */
-       u32     APKoutput[2][2]; /* path A/B; output1_1a/output1_2a */
-       u8      bAPKdone;
-       u8      bAPKThermalMeterIgnore;
-       u8      bDPdone;
-       u8      bDPPathAOK;
-       u8      bDPPathBOK;
-};
-
-/*  ODM Dynamic common info value definition */
-
-struct fast_ant_train {
-       u8      antsel_rx_keep_0;
-       u8      antsel_rx_keep_1;
-       u8      antsel_rx_keep_2;
-       u8      antsel_a[ODM_ASSOCIATE_ENTRY_NUM];
-       u8      antsel_b[ODM_ASSOCIATE_ENTRY_NUM];
-       u8      antsel_c[ODM_ASSOCIATE_ENTRY_NUM];
-       u32     MainAnt_Sum[ODM_ASSOCIATE_ENTRY_NUM];
-       u32     AuxAnt_Sum[ODM_ASSOCIATE_ENTRY_NUM];
-       u32     MainAnt_Cnt[ODM_ASSOCIATE_ENTRY_NUM];
-       u32     AuxAnt_Cnt[ODM_ASSOCIATE_ENTRY_NUM];
-       u8      RxIdleAnt;
-       bool    bBecomeLinked;
-};
-
-enum ant_div_type {
-       NO_ANTDIV                       = 0xFF,
-       CG_TRX_HW_ANTDIV                = 0x01,
-       CGCS_RX_HW_ANTDIV               = 0x02,
-       FIXED_HW_ANTDIV                 = 0x03,
-       CG_TRX_SMART_ANTDIV             = 0x04,
-};
-
-/* Copy from SD4 defined structure. We use to support PHY DM integration. */
-struct odm_dm_struct {
-       struct adapter *Adapter;        /*  For CE/NIC team */
-
-/*  ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */
-       bool    bCckHighPower;
-       u8      RFPathRxEnable;         /*  ODM_CMNINFO_RFPATH_ENABLE */
-       u8      ControlChannel;
-/*  ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */
-
-/* 1  COMMON INFORMATION */
-       /*  Init Value */
-/* HOOK BEFORE REG INIT----------- */
-       /*  ODM Support Ability DIG/RATR/TX_PWR_TRACK/ �K�K = 1/2/3/�K */
-       u32     SupportAbility;
-
-       u32     BK_SupportAbility;
-       u8      AntDivType;
-/* HOOK BEFORE REG INIT----------- */
-
-       /*  Dynamic Value */
-/*  POINTER REFERENCE----------- */
-       /*  Wireless mode B/G/A/N = BIT(0)/BIT(1)/BIT(2)/BIT(3) */
-       u8      *pWirelessMode; /* ODM_WIRELESS_MODE_E */
-       /*  Secondary channel offset don't_care/below/above = 0/1/2 */
-       u8      *pSecChOffset;
-       /*  BW info 20M/40M/80M = 0/1/2 */
-       enum ht_channel_width *pBandWidth;
-       /*  Central channel location Ch1/Ch2/.... */
-       u8      *pChannel;      /* central channel number */
-
-       /*  Common info for Status */
-       bool    *pbScanInProcess;
-       bool    *pbPowerSaving;
-/*  POINTER REFERENCE----------- */
-       /*  */
-/* CALL BY VALUE------------- */
-       bool    bLinked;
-       u8      RSSI_Min;
-       bool    bIsMPChip;
-       bool    bOneEntryOnly;
-/* CALL BY VALUE------------- */
-
-       /* 2 Define STA info. */
-       /*  _ODM_STA_INFO */
-       /*  For MP, we need to reduce one array pointer for default port.?? */
-       struct sta_info *pODM_StaInfo[ODM_ASSOCIATE_ENTRY_NUM];
-
-       u16     CurrminRptTime;
-       struct odm_ra_info RAInfo[ODM_ASSOCIATE_ENTRY_NUM]; /* Use MacID as
-                       * array index. STA MacID=0,
-                       * VWiFi Client MacID={1, ODM_ASSOCIATE_ENTRY_NUM-1} */
-
-       /*  Latest packet phy info (ODM write) */
-       struct odm_phy_dbg_info PhyDbgInfo;
-
-       /* ODM Structure */
-       struct fast_ant_train DM_FatTable;
-       struct rtw_dig  DM_DigTable;
-       struct rtl_ps   DM_PSTable;
-       struct false_alarm_stats FalseAlmCnt;
-       struct sw_ant_switch DM_SWAT_Table;
-
-       struct edca_turbo DM_EDCA_Table;
-
-       /* PSD */
-       bool    bDMInitialGainEnable;
-
-       struct odm_rate_adapt RateAdaptive;
-
-       struct odm_rf_cal RFCalibrateInfo;
-
-       /*  TX power tracking */
-       u8      BbSwingIdxOfdm;
-       u8      BbSwingIdxOfdmCurrent;
-       u8      BbSwingIdxOfdmBase;
-       bool    BbSwingFlagOfdm;
-       u8      BbSwingIdxCck;
-       u8      BbSwingIdxCckCurrent;
-       u8      BbSwingIdxCckBase;
-       bool    BbSwingFlagCck;
-};
-
-enum odm_bb_config_type {
-    CONFIG_BB_PHY_REG,
-    CONFIG_BB_AGC_TAB,
-    CONFIG_BB_AGC_TAB_2G,
-    CONFIG_BB_PHY_REG_PG,
-};
-
-#define                DM_DIG_MAX_NIC                  0x4e
-#define                DM_DIG_MIN_NIC                  0x1e /* 0x22/0x1c */
-
-#define                DM_DIG_MAX_AP                   0x32
-
-/* vivi 92c&92d has different definition, 20110504 */
-/* this is for 92c */
-#define                DM_DIG_FA_TH0                   0x200/* 0x20 */
-#define                DM_DIG_FA_TH1                   0x300/* 0x100 */
-#define                DM_DIG_FA_TH2                   0x400/* 0x200 */
-
-/* 3=========================================================== */
-/* 3 Rate Adaptive */
-/* 3=========================================================== */
-#define                DM_RATR_STA_INIT                0
-#define                DM_RATR_STA_HIGH                1
-#define                DM_RATR_STA_MIDDLE              2
-#define                DM_RATR_STA_LOW                 3
-
-/* 3=========================================================== */
-/* 3 BB Power Save */
-/* 3=========================================================== */
-
-enum dm_rf {
-       RF_Save = 0,
-       RF_Normal = 1,
-       RF_MAX = 2,
-};
-
-/* 3=========================================================== */
-/* 3 Antenna Diversity */
-/* 3=========================================================== */
-enum dm_swas {
-       Antenna_A = 1,
-       Antenna_B = 2,
-       Antenna_MAX = 3,
-};
-
-/*  Extern Global Variables. */
-#define        OFDM_TABLE_SIZE_92D     43
-#define        CCK_TABLE_SIZE          33
-
-extern u32 OFDMSwingTable[OFDM_TABLE_SIZE_92D];
-extern u8 cck_swing_table[CCK_TABLE_SIZE][8];
-
-/*  check Sta pointer valid or not */
-#define IS_STA_VALID(pSta)             (pSta)
-
-void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI);
-void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres);
-
-void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal);
-
-void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm);
-
-bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI,
-                     bool bForceUpdate, u8 *pRATRState);
-
-u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid,
-                       u32 ra_mask, u8 rssi_level);
-
-void ODM_DMInit(struct odm_dm_struct *pDM_Odm);
-
-void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm);
-
-void ODM_CmnInfoInit(struct odm_dm_struct *pDM_Odm,
-                    enum odm_common_info_def CmnInfo, u32 Value);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/odm_HWConfig.h b/drivers/staging/r8188eu/include/odm_HWConfig.h
deleted file mode 100644 (file)
index 3f71857..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef        __HALHWOUTSRC_H__
-#define __HALHWOUTSRC_H__
-
-/*  CCK Rates, TxHT = 0 */
-#define DESC92C_RATE1M                         0x00
-#define DESC92C_RATE11M                                0x03
-
-/*  MCS Rates, TxHT = 1 */
-#define DESC92C_RATEMCS8                       0x14
-#define DESC92C_RATEMCS15                      0x1b
-
-/*  structure and define */
-
-struct phy_rx_agc_info {
-       #ifdef __LITTLE_ENDIAN
-               u8      gain:7, trsw:1;
-       #else
-               u8      trsw:1, gain:7;
-       #endif
-};
-
-struct phy_status_rpt {
-       struct phy_rx_agc_info path_agc[3];
-       u8      ch_corr[2];
-       u8      cck_sig_qual_ofdm_pwdb_all;
-       u8      cck_agc_rpt_ofdm_cfosho_a;
-       u8      cck_rpt_b_ofdm_cfosho_b;
-       u8      rsvd_1;/* ch_corr_msb; */
-       u8      noise_power_db_msb;
-       u8      path_cfotail[2];
-       u8      pcts_mask[2];
-       s8      stream_rxevm[2];
-       u8      path_rxsnr[3];
-       u8      noise_power_db_lsb;
-       u8      rsvd_2[3];
-       u8      stream_csi[2];
-       u8      stream_target_csi[2];
-       s8      sig_evm;
-       u8      rsvd_3;
-
-#ifdef __LITTLE_ENDIAN
-       u8      antsel_rx_keep_2:1;     /* ex_intf_flg:1; */
-       u8      sgi_en:1;
-       u8      rxsc:2;
-       u8      idle_long:1;
-       u8      r_ant_train_en:1;
-       u8      ant_sel_b:1;
-       u8      ant_sel:1;
-#else  /*  _BIG_ENDIAN_ */
-       u8      ant_sel:1;
-       u8      ant_sel_b:1;
-       u8      r_ant_train_en:1;
-       u8      idle_long:1;
-       u8      rxsc:2;
-       u8      sgi_en:1;
-       u8      antsel_rx_keep_2:1;     /* ex_intf_flg:1; */
-#endif
-};
-
-void ODM_PhyStatusQuery(struct odm_dm_struct *pDM_Odm,
-                       struct phy_info *pPhyInfo,
-                       u8 *pPhyStatus,
-                       struct odm_per_pkt_info *pPktinfo,
-                       struct adapter *adapt);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/odm_RTL8188E.h b/drivers/staging/r8188eu/include/odm_RTL8188E.h
deleted file mode 100644 (file)
index 4f16af2..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef        __ODM_RTL8188E_H__
-#define __ODM_RTL8188E_H__
-
-#define        MAIN_ANT        0
-#define        AUX_ANT 1
-#define        MAIN_ANT_CG_TRX 1
-#define        AUX_ANT_CG_TRX  0
-#define        MAIN_ANT_CGCS_RX        0
-#define        AUX_ANT_CGCS_RX 1
-
-#define SET_TX_DESC_ANTSEL_A_88E(__ptxdesc, __value)                   \
-       le32p_replace_bits((__le32 *)(__ptxdesc + 8), __value, BIT(24))
-#define SET_TX_DESC_ANTSEL_B_88E(__ptxdesc, __value)                   \
-       le32p_replace_bits((__le32 *)(__ptxdesc + 8), __value, BIT(25))
-#define SET_TX_DESC_ANTSEL_C_88E(__ptxdesc, __value)                   \
-       le32p_replace_bits((__le32 *)(__ptxdesc + 28), __value, BIT(29))
-
-void ODM_AntennaDiversityInit_88E(struct odm_dm_struct *pDM_Odm);
-
-void ODM_AntennaDiversity_88E(struct odm_dm_struct *pDM_Odm);
-
-void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *pDM_Odm, u8 *pDesc,
-                             u8 macId);
-
-void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *pDM_Odm, u8 Ant);
-
-void ODM_AntselStatistics_88E(struct odm_dm_struct *pDM_Odm, u8        antsel_tr_mux,
-                             u32 MacId, u8 RxPWDBAll);
-
-void odm_FastAntTraining(struct odm_dm_struct *pDM_Odm);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/odm_RegDefine11N.h b/drivers/staging/r8188eu/include/odm_RegDefine11N.h
deleted file mode 100644 (file)
index 82a602b..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef        __ODM_REGDEFINE11N_H__
-#define __ODM_REGDEFINE11N_H__
-
-/* 2 BB REG LIST */
-/* PAGE 8 */
-#define        ODM_REG_TX_ANT_CTRL_11N                 0x80C
-#define        ODM_REG_RX_DEFUALT_A_11N                0x858
-#define        ODM_REG_ANTSEL_CTRL_11N                 0x860
-#define        ODM_REG_RX_ANT_CTRL_11N                 0x864
-#define        ODM_REG_PIN_CTRL_11N                    0x870
-#define        ODM_REG_SC_CNT_11N                      0x8C4
-/* PAGE 9 */
-#define        ODM_REG_ANT_MAPPING1_11N                0x914
-/* PAGE A */
-#define        ODM_REG_CCK_ANTDIV_PARA1_11N            0xA00
-#define        ODM_REG_CCK_CCA_11N                     0xA0A
-#define        ODM_REG_CCK_ANTDIV_PARA2_11N            0xA0C
-#define        ODM_REG_CCK_FA_RST_11N                  0xA2C
-#define        ODM_REG_CCK_FA_MSB_11N                  0xA58
-#define        ODM_REG_CCK_FA_LSB_11N                  0xA5C
-#define        ODM_REG_CCK_CCA_CNT_11N                 0xA60
-#define        ODM_REG_BB_PWR_SAV4_11N                 0xA74
-/* PAGE B */
-#define        ODM_REG_LNA_SWITCH_11N                  0xB2C
-/* PAGE C */
-#define        ODM_REG_OFDM_FA_HOLDC_11N               0xC00
-#define        ODM_REG_OFDM_FA_RSTC_11N                0xC0C
-#define        ODM_REG_IGI_A_11N                       0xC50
-#define        ODM_REG_ANTDIV_PARA1_11N                0xCA4
-#define        ODM_REG_OFDM_FA_TYPE1_11N               0xCF0
-/* PAGE D */
-#define        ODM_REG_OFDM_FA_RSTD_11N                0xD00
-#define        ODM_REG_OFDM_FA_TYPE2_11N               0xDA0
-#define        ODM_REG_OFDM_FA_TYPE3_11N               0xDA4
-#define        ODM_REG_OFDM_FA_TYPE4_11N               0xDA8
-
-/* 2 MAC REG LIST */
-#define        ODM_REG_ANTSEL_PIN_11N                  0x4C
-#define        ODM_REG_RESP_TX_11N                     0x6D8
-
-/* DIG Related */
-#define        ODM_BIT_IGI_11N                         0x0000007F
-
-#endif
diff --git a/drivers/staging/r8188eu/include/osdep_intf.h b/drivers/staging/r8188eu/include/osdep_intf.h
deleted file mode 100644 (file)
index 457fb38..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __OSDEP_INTF_H_
-#define __OSDEP_INTF_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-
-int netdev_open(struct net_device *pnetdev);
-int netdev_close(struct net_device *pnetdev);
-
-u8 rtw_init_drv_sw(struct adapter *padapter);
-void rtw_free_drv_sw(struct adapter *padapter);
-void rtw_reset_drv_sw(struct adapter *padapter);
-
-int rtw_start_drv_threads(struct adapter *padapter);
-void rtw_stop_drv_threads (struct adapter *padapter);
-void rtw_cancel_all_timer(struct adapter *padapter);
-
-int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname);
-struct net_device *rtw_init_netdev(struct adapter *padapter);
-u16 rtw_recv_select_queue(struct sk_buff *skb);
-
-void rtw_ips_dev_unload(struct adapter *padapter);
-
-int rtw_ips_pwr_up(struct adapter *padapter);
-void rtw_ips_pwr_down(struct adapter *padapter);
-
-#endif /* _OSDEP_INTF_H_ */
diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
deleted file mode 100644 (file)
index f8ed04f..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __OSDEP_SERVICE_H_
-#define __OSDEP_SERVICE_H_
-
-#include <linux/sched/signal.h>
-
-#define _FAIL          0
-#define _SUCCESS       1
-#define RTW_RX_HANDLED 2
-
-#include <linux/spinlock.h>
-#include <linux/compiler.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/kref.h>
-#include <linux/netdevice.h>
-#include <linux/skbuff.h>
-#include <linux/circ_buf.h>
-#include <linux/uaccess.h>
-#include <asm/byteorder.h>
-#include <asm/atomic.h>
-#include <linux/io.h>
-#include <linux/semaphore.h>
-#include <linux/sem.h>
-#include <linux/sched.h>
-#include <linux/etherdevice.h>
-#include <linux/wireless.h>
-#include <net/iw_handler.h>
-#include <linux/if_arp.h>
-#include <linux/rtnetlink.h>
-#include <linux/delay.h>
-#include <linux/proc_fs.h>     /*  Necessary because we use the proc fs */
-#include <linux/interrupt.h>   /*  for struct tasklet_struct */
-#include <linux/ip.h>
-#include <linux/kthread.h>
-#include <linux/vmalloc.h>
-
-#include <linux/usb.h>
-#include <linux/usb/ch9.h>
-
-struct __queue {
-       struct  list_head       queue;
-       spinlock_t lock;
-};
-
-static inline struct list_head *get_list_head(struct __queue *queue)
-{
-       return (&(queue->queue));
-}
-
-static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
-{
-       mod_timer(ptimer, jiffies + msecs_to_jiffies(delay_time));
-}
-
-static inline int rtw_netif_queue_stopped(struct net_device *pnetdev)
-{
-       return  netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) &&
-               netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 1)) &&
-               netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 2)) &&
-               netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3));
-}
-
-int RTW_STATUS_CODE(int error_code);
-
-void *rtw_malloc2d(int h, int w, int size);
-
-#define rtw_init_queue(q)                                      \
-       do {                                                    \
-               INIT_LIST_HEAD(&((q)->queue));                  \
-               spin_lock_init(&((q)->lock));                   \
-       } while (0)
-
-static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer)
-{
-       return del_timer_sync(ptimer);
-}
-
-static inline void flush_signals_thread(void)
-{
-       if (signal_pending (current))
-               flush_signals(current);
-}
-
-struct rtw_netdev_priv_indicator {
-       void *priv;
-       u32 sizeof_priv;
-};
-struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv,
-                                                   void *old_priv);
-struct net_device *rtw_alloc_etherdev(int sizeof_priv);
-
-#define rtw_netdev_priv(netdev)                                        \
-       (((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv)
-void rtw_free_netdev(struct net_device *netdev);
-
-#define NDEV_FMT "%s"
-#define NDEV_ARG(ndev) ndev->name
-#define ADPT_FMT "%s"
-#define ADPT_ARG(adapter) adapter->pnetdev->name
-#define FUNC_NDEV_FMT "%s(%s)"
-#define FUNC_NDEV_ARG(ndev) __func__, ndev->name
-#define FUNC_ADPT_FMT "%s(%s)"
-#define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name
-
-#define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1)
-
-/* Macros for handling unaligned memory accesses */
-
-#define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
-#define RTW_PUT_BE16(a, val)                   \
-       do {                                    \
-               (a)[0] = ((u16) (val)) >> 8;    \
-               (a)[1] = ((u16) (val)) & 0xff;  \
-       } while (0)
-
-#define RTW_PUT_LE16(a, val)                   \
-       do {                                    \
-               (a)[1] = ((u16) (val)) >> 8;    \
-               (a)[0] = ((u16) (val)) & 0xff;  \
-       } while (0)
-
-#define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
-                        ((u32) (a)[2]))
-
-#define RTW_PUT_BE32(a, val)                                   \
-       do {                                                    \
-               (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff);   \
-               (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff);   \
-               (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff);    \
-               (a)[3] = (u8) (((u32) (val)) & 0xff);           \
-       } while (0)
-
-void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len);
-
-struct rtw_cbuf {
-       u32 write;
-       u32 read;
-       u32 size;
-       void *bufs[];
-};
-
-bool rtw_cbuf_empty(struct rtw_cbuf *cbuf);
-void *rtw_cbuf_pop(struct rtw_cbuf *cbuf);
-struct rtw_cbuf *rtw_cbuf_alloc(u32 size);
-int wifirate2_ratetbl_inx(unsigned char rate);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/rtl8188e_cmd.h b/drivers/staging/r8188eu/include/rtl8188e_cmd.h
deleted file mode 100644 (file)
index c785cf8..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTL8188E_CMD_H__
-#define __RTL8188E_CMD_H__
-
-enum RTL8188E_H2C_CMD_ID {
-       /* Class Common */
-       H2C_COM_RSVD_PAGE               = 0x00,
-       H2C_COM_MEDIA_STATUS_RPT        = 0x01,
-       H2C_COM_SCAN                    = 0x02,
-       H2C_COM_KEEP_ALIVE              = 0x03,
-       H2C_COM_DISCNT_DECISION         = 0x04,
-       H2C_COM_INIT_OFFLOAD            = 0x06,
-       H2C_COM_REMOTE_WAKE_CTL         = 0x07,
-       H2C_COM_AP_OFFLOAD              = 0x08,
-       H2C_COM_BCN_RSVD_PAGE           = 0x09,
-       H2C_COM_PROB_RSP_RSVD_PAGE      = 0x0A,
-
-       /* Class PS */
-       H2C_PS_PWR_MODE                 = 0x20,
-       H2C_PS_TUNE_PARA                = 0x21,
-       H2C_PS_TUNE_PARA_2              = 0x22,
-       H2C_PS_LPS_PARA                 = 0x23,
-       H2C_PS_P2P_OFFLOAD              = 0x24,
-
-       /* Class DM */
-       H2C_DM_MACID_CFG                = 0x40,
-       H2C_DM_TXBF                     = 0x41,
-};
-
-struct cmd_msg_parm {
-       u8 eid; /* element id */
-       u8 sz; /*  sz */
-       u8 buf[6];
-};
-
-struct setpwrmode_parm {
-       u8 Mode;/* 0:Active,1:LPS,2:WMMPS */
-       u8 SmartPS_RLBM;/* LPS= 0:PS_Poll,1:PS_Poll,2:NullData,WMM= 0:PS_Poll,1:NullData */
-       u8 AwakeInterval;       /*  unit: beacon interval */
-       u8 bAllQueueUAPSD;
-       u8 PwrState;/* AllON(0x0c),RFON(0x04),RFOFF(0x00) */
-};
-
-struct H2C_SS_RFOFF_PARAM {
-       u8 ROFOn; /*  1: on, 0:off */
-       u16 gpio_period; /*  unit: 1024 us */
-} __packed;
-
-struct joinbssrpt_parm {
-       u8 OpMode;      /*  RT_MEDIA_STATUS */
-};
-
-struct rsvdpage_loc {
-       u8 LocProbeRsp;
-       u8 LocPsPoll;
-       u8 LocNullData;
-       u8 LocQosNull;
-       u8 LocBTQosNull;
-};
-
-struct P2P_PS_Offload_t {
-       u8 Offload_En:1;
-       u8 role:1; /*  1: Owner, 0: Client */
-       u8 CTWindow_En:1;
-       u8 NoA0_En:1;
-       u8 NoA1_En:1;
-       u8 AllStaSleep:1; /*  Only valid in Owner */
-       u8 discovery:1;
-       u8 rsvd:1;
-};
-
-struct P2P_PS_CTWPeriod_t {
-       u8 CTWPeriod;   /* TU */
-};
-
-/*  host message to firmware cmd */
-void rtl8188e_set_FwPwrMode_cmd(struct adapter *padapter, u8 Mode);
-void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *padapter, u8 mstatus);
-u8 rtl8188e_set_raid_cmd(struct adapter *padapter, u32 mask);
-void rtl8188e_Add_RateATid(struct adapter *padapter, u32 bitmap, u8 arg,
-                          u8 rssi_level);
-
-void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state);
-
-void CheckFwRsvdPageContent(struct adapter *adapt);
-void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, u16 mstatus_rpt);
-
-#endif/* __RTL8188E_CMD_H__ */
diff --git a/drivers/staging/r8188eu/include/rtl8188e_dm.h b/drivers/staging/r8188eu/include/rtl8188e_dm.h
deleted file mode 100644 (file)
index d62cdfc..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTL8188E_DM_H__
-#define __RTL8188E_DM_H__
-
-enum{
-       UP_LINK,
-       DOWN_LINK,
-};
-
-struct dm_priv {
-       u32     InitODMFlag;
-
-       /* Lower Signal threshold for Rate Adaptive */
-       int     EntryMinUndecoratedSmoothedPWDB;
-       int     MinUndecoratedPWDBForDM;
-};
-
-void rtl8188e_init_dm_priv(struct adapter *adapt);
-void rtl8188e_InitHalDm(struct adapter *adapt);
-void rtl8188e_HalDmWatchDog(struct adapter *adapt);
-
-void AntDivCompare8188E(struct adapter *adapt, struct wlan_bssid_ex *dst,
-                       struct wlan_bssid_ex *src);
-u8 AntDivBeforeLink8188E(struct adapter *adapt);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h
deleted file mode 100644 (file)
index feeb37c..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTL8188E_HAL_H__
-#define __RTL8188E_HAL_H__
-
-/* include HAL Related header after HAL Related compiling flags */
-#include "rtl8188e_spec.h"
-#include "Hal8188EPhyReg.h"
-#include "Hal8188EPhyCfg.h"
-#include "rtl8188e_rf.h"
-#include "rtl8188e_dm.h"
-#include "rtl8188e_recv.h"
-#include "rtl8188e_xmit.h"
-#include "rtl8188e_cmd.h"
-#include "rtw_efuse.h"
-#include "odm.h"
-#include "odm_HWConfig.h"
-#include "odm_RegDefine11N.h"
-#include "HalPhyRf_8188e.h"
-#include "Hal8188ERateAdaptive.h"
-#include "HalHWImg8188E_MAC.h"
-#include "HalHWImg8188E_RF.h"
-#include "HalHWImg8188E_BB.h"
-#include "odm_RTL8188E.h"
-
-#define DRVINFO_SZ     4 /*  unit is 8bytes */
-#define PageNum_128(_Len)      (u32)(((_Len)>>7) + ((_Len) & 0x7F ? 1 : 0))
-
-#define DRIVER_EARLY_INT_TIME          0x05
-#define BCN_DMA_ATIME_INT_TIME         0x02
-
-#define MAX_RX_DMA_BUFFER_SIZE_88E                             \
-      0x2400 /* 9k for 88E nornal chip , MaxRxBuff=10k-max(TxReportSize(64*8),
-             * WOLPattern(16*24)) */
-
-#define TX_SELE_LQ                     BIT(1)          /*  Low Queue */
-#define TX_SELE_NQ                     BIT(2)          /*  Normal Queue */
-
-/*  Note: We will divide number of page equally for each queue other
- *  than public queue! */
-/*  22k = 22528 bytes = 176 pages (@page =  128 bytes) */
-/*  must reserved about 7 pages for LPS =>  176-7 = 169 (0xA9) */
-/*  2*BCN / 1*ps-poll / 1*null-data /1*prob_rsp /1*QOS null-data /1*BT QOS
- *  null-data */
-
-#define TX_TOTAL_PAGE_NUMBER_88E               0xA9/*   169 (21632=> 21k) */
-
-#define TX_PAGE_BOUNDARY_88E (TX_TOTAL_PAGE_NUMBER_88E + 1)
-
-#include "HalVerDef.h"
-#include "hal_com.h"
-
-/*     Channel Plan */
-enum ChannelPlan {
-       CHPL_FCC        = 0,
-       CHPL_IC         = 1,
-       CHPL_ETSI       = 2,
-       CHPL_SPA        = 3,
-       CHPL_FRANCE     = 4,
-       CHPL_MKK        = 5,
-       CHPL_MKK1       = 6,
-       CHPL_ISRAEL     = 7,
-       CHPL_TELEC      = 8,
-       CHPL_GLOBAL     = 9,
-       CHPL_WORLD      = 10,
-};
-
-struct txpowerinfo24g {
-       u8 IndexCCK_Base[RF_PATH_MAX][MAX_CHNL_GROUP_24G];
-       u8 IndexBW40_Base[RF_PATH_MAX][MAX_CHNL_GROUP_24G];
-       /* If only one tx, only BW20 and OFDM are used. */
-       s8 CCK_Diff[RF_PATH_MAX][MAX_TX_COUNT];
-       s8 OFDM_Diff[RF_PATH_MAX][MAX_TX_COUNT];
-       s8 BW20_Diff[RF_PATH_MAX][MAX_TX_COUNT];
-       s8 BW40_Diff[RF_PATH_MAX][MAX_TX_COUNT];
-};
-
-#define EFUSE_REAL_CONTENT_LEN         512
-#define AVAILABLE_EFUSE_ADDR(addr)     (addr < EFUSE_REAL_CONTENT_LEN)
-
-#define                EFUSE_REAL_CONTENT_LEN_88E      256
-#define                EFUSE_MAP_LEN_88E               512
-#define                EFUSE_MAX_SECTION_88E           64
-/*  To prevent out of boundary programming case, leave 1byte and program
- *  full section */
-/*  9bytes + 1byt + 5bytes and pre 1byte. */
-/*  For worst case: */
-/*  | 2byte|----8bytes----|1byte|--7bytes--| 92D */
-/*  PG data exclude header, dummy 7 bytes from CP test and reserved 1byte. */
-#define                EFUSE_OOB_PROTECT_BYTES_88E     18
-
-#define EFUSE_PROTECT_BYTES_BANK       16
-
-#define USB_RXAGG_PAGE_COUNT   48
-#define USB_RXAGG_PAGE_TIMEOUT 0x4
-
-struct hal_data_8188e {
-       struct HAL_VERSION      VersionID;
-       /* current WIFI_PHY values */
-       enum ht_channel_width CurrentChannelBW;
-       u8      CurrentChannel;
-       u8      nCur40MhzPrimeSC;/*  Control channel sub-carrier */
-
-       u8      EEPROMRegulatory;
-       u8      EEPROMThermalMeter;
-
-       u8      Index24G_CCK_Base[CHANNEL_MAX_NUMBER];
-       u8      Index24G_BW40_Base[CHANNEL_MAX_NUMBER];
-       /* If only one tx, only BW20 and OFDM are used. */
-       s8      OFDM_24G_Diff[MAX_TX_COUNT];
-       s8      BW20_24G_Diff[MAX_TX_COUNT];
-
-       /*  HT 20<->40 Pwr diff */
-       u8      TxPwrHt20Diff[RF_PATH_MAX][CHANNEL_MAX_NUMBER];
-       /*  For HT<->legacy pwr diff */
-       u8      TxPwrLegacyHtDiff[RF_PATH_MAX][CHANNEL_MAX_NUMBER];
-       /*  For power group */
-       u8      PwrGroupHT20[RF_PATH_MAX][CHANNEL_MAX_NUMBER];
-       u8      PwrGroupHT40[RF_PATH_MAX][CHANNEL_MAX_NUMBER];
-
-       /*  Read/write are allow for following hardware information variables */
-       u8      pwrGroupCnt;
-       u32     MCSTxPowerLevelOriginalOffset[MAX_PG_GROUP][16];
-
-       u8      CrystalCap;
-
-       u32     AcParam_BE; /* Original parameter for BE, use for EDCA turbo. */
-
-       struct bb_reg_def PHYRegDef;
-
-       u32     RfRegChnlVal;
-
-       /* for host message to fw */
-       u8      LastHMEBoxNum;
-
-       u8      fw_ractrl;
-       u8      RegFwHwTxQCtrl;
-       u8      RegReg542;
-       u8      RegCR_1;
-
-       struct dm_priv  dmpriv;
-       struct odm_dm_struct odmpriv;
-
-       u8      CurAntenna;
-       u8      AntDivCfg;
-       u8      TRxAntDivType;
-
-       u8      out_ep_extra_queues;
-
-       struct P2P_PS_Offload_t p2p_ps_offload;
-
-       /*  Auto FSM to Turn On, include clock, isolation, power control
-        *  for MAC only */
-       u8      bMacPwrCtrlOn;
-};
-
-s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy);
-
-/*  EFuse */
-void Hal_EfuseParseIDCode88E(struct adapter *padapter, u8 *hwinfo);
-void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *hwinfo,
-                           bool AutoLoadFail);
-
-void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo,
-                                bool AutoLoadFail);
-void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent,
-                                bool AutoLoadFail);
-void Hal_ReadThermalMeter_88E(struct adapter *padapter, u8 *PROMContent,
-                             bool AutoloadFail);
-void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo,
-                             bool AutoLoadFail);
-void Hal_ReadPowerSavingMode88E(struct adapter *pAdapter, u8 *hwinfo,
-                               bool AutoLoadFail);
-
-void rtl8188e_read_chip_version(struct adapter *padapter);
-
-s32 rtl8188e_iol_efuse_patch(struct adapter *padapter);
-void rtw_cancel_all_timer(struct adapter *padapter);
-
-#endif /* __RTL8188E_HAL_H__ */
diff --git a/drivers/staging/r8188eu/include/rtl8188e_recv.h b/drivers/staging/r8188eu/include/rtl8188e_recv.h
deleted file mode 100644 (file)
index dc4f358..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTL8188E_RECV_H__
-#define __RTL8188E_RECV_H__
-
-#define TX_RPT1_PKT_LEN 8
-
-#define NR_PREALLOC_RECV_SKB (8)
-
-#define NR_RECVBUFF (4)
-
-#define MAX_RECVBUF_SZ (15360) /*  15k < 16k */
-
-struct phy_stat {
-       unsigned int phydw0;
-       unsigned int phydw1;
-       unsigned int phydw2;
-       unsigned int phydw3;
-       unsigned int phydw4;
-       unsigned int phydw5;
-       unsigned int phydw6;
-       unsigned int phydw7;
-};
-
-/*  Rx smooth factor */
-#define        Rx_Smooth_Factor (20)
-
-enum rx_packet_type {
-       NORMAL_RX,/* Normal rx packet */
-       TX_REPORT1,/* CCX */
-       TX_REPORT2,/* TX RPT */
-       HIS_REPORT,/*  USB HISR RPT */
-};
-
-void rtl8188eu_recv_tasklet(unsigned long priv);
-void update_recvframe_phyinfo_88e(struct recv_frame *fra, struct phy_stat *phy);
-void update_recvframe_attrib_88e(struct recv_frame *fra, struct recv_stat *stat);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/rtl8188e_rf.h b/drivers/staging/r8188eu/include/rtl8188e_rf.h
deleted file mode 100644 (file)
index 63ac0ac..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTL8188E_RF_H__
-#define __RTL8188E_RF_H__
-
-#define                RF6052_MAX_TX_PWR               0x3F
-#define                RF6052_MAX_REG                  0x3F
-#define                RF6052_MAX_PATH                 2
-
-int phy_RF6052_Config_ParaFile(struct adapter *Adapter);
-void rtl8188e_PHY_RF6052SetBandwidth(struct adapter *Adapter,
-                                    enum ht_channel_width Bandwidth);
-void   rtl8188e_PHY_RF6052SetCckTxPower(struct adapter *Adapter, u8 *level);
-void   rtl8188e_PHY_RF6052SetOFDMTxPower(struct adapter *Adapter, u8 *ofdm,
-                                         u8 *pwrbw20, u8 *pwrbw40, u8 channel);
-
-#endif/* __RTL8188E_RF_H__ */
diff --git a/drivers/staging/r8188eu/include/rtl8188e_spec.h b/drivers/staging/r8188eu/include/rtl8188e_spec.h
deleted file mode 100644 (file)
index 25b3141..0000000
+++ /dev/null
@@ -1,1142 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTL8188E_SPEC_H__
-#define __RTL8188E_SPEC_H__
-
-/*        8192C Register offset definition */
-
-#define                HAL_PS_TIMER_INT_DELAY  50      /*   50 microseconds */
-#define                HAL_92C_NAV_UPPER_UNIT  128     /*  micro-second */
-
-/*  8188E PKT_BUFF_ACCESS_CTRL value */
-#define TXPKT_BUF_SELECT               0x69
-#define RXPKT_BUF_SELECT               0xA5
-#define DISABLE_TRXPKT_BUF_ACCESS      0x0
-
-/*     0x0000h ~ 0x00FFh       System Configuration */
-#define REG_SYS_ISO_CTRL               0x0000
-#define REG_SYS_FUNC_EN                        0x0002
-#define REG_APS_FSMCO                  0x0004
-#define REG_SYS_CLKR                   0x0008
-#define REG_9346CR                     0x000A
-#define REG_EE_VPD                     0x000C
-#define REG_AFE_MISC                   0x0010
-#define REG_SPS0_CTRL                  0x0011
-#define REG_SPS_OCP_CFG                        0x0018
-#define REG_RSV_CTRL                   0x001C
-#define REG_RF_CTRL                    0x001F
-#define REG_LDOA15_CTRL                        0x0020
-#define REG_LDOV12D_CTRL               0x0021
-#define REG_LDOHCI12_CTRL              0x0022
-#define REG_LPLDO_CTRL                 0x0023
-#define REG_AFE_XTAL_CTRL              0x0024
-#define REG_AFE_PLL_CTRL               0x0028
-#define REG_APE_PLL_CTRL_EXT           0x002c
-#define REG_EFUSE_CTRL                 0x0030
-#define REG_EFUSE_TEST                 0x0034
-#define REG_GPIO_MUXCFG                        0x0040
-#define REG_GPIO_IO_SEL                        0x0042
-#define REG_MAC_PINMUX_CFG             0x0043
-#define REG_GPIO_PIN_CTRL              0x0044
-#define REG_GPIO_INTM                  0x0048
-#define REG_LEDCFG0                    0x004C
-#define REG_LEDCFG1                    0x004D
-#define REG_LEDCFG2                    0x004E
-#define REG_LEDCFG3                    0x004F
-#define REG_FSIMR                      0x0050
-#define REG_FSISR                      0x0054
-#define REG_HSIMR                      0x0058
-#define REG_HSISR                      0x005c
-#define REG_GPIO_PIN_CTRL_2            0x0060 /*  RTL8723 WIFI/BT/GPS
-                                * Multi-Function GPIO Pin Control. */
-#define REG_GPIO_IO_SEL_2              0x0062 /*  RTL8723 WIFI/BT/GPS
-                                * Multi-Function GPIO Select. */
-#define REG_BB_PAD_CTRL                        0x0064
-#define REG_MULTI_FUNC_CTRL            0x0068 /*  RTL8723 WIFI/BT/GPS
-                                * Multi-Function control source. */
-#define REG_GPIO_OUTPUT                        0x006c
-#define REG_AFE_XTAL_CTRL_EXT          0x0078 /* RTL8188E */
-#define REG_XCK_OUT_CTRL               0x007c /* RTL8188E */
-#define REG_MCUFWDL                    0x0080
-#define REG_WOL_EVENT                  0x0081 /* RTL8188E */
-#define REG_MCUTSTCFG                  0x0084
-#define REG_HMEBOX_E0                  0x0088
-#define REG_HMEBOX_E1                  0x008A
-#define REG_HMEBOX_E2                  0x008C
-#define REG_HMEBOX_E3                  0x008E
-#define REG_HMEBOX_EXT_0               0x01F0
-#define REG_HMEBOX_EXT_1               0x01F4
-#define REG_HMEBOX_EXT_2               0x01F8
-#define REG_HMEBOX_EXT_3               0x01FC
-#define REG_HIMR_88E                   0x00B0
-#define REG_HISR_88E                   0x00B4
-#define REG_HIMRE_88E                  0x00B8
-#define REG_HISRE_88E                  0x00BC
-#define REG_EFUSE_ACCESS               0x00CF  /*  Efuse access protection
-                                                * for RTL8723 */
-#define REG_BIST_SCAN                  0x00D0
-#define REG_BIST_RPT                   0x00D4
-#define REG_BIST_ROM_RPT               0x00D8
-#define REG_USB_SIE_INTF               0x00E0
-#define REG_PCIE_MIO_INTF              0x00E4
-#define REG_PCIE_MIO_INTD              0x00E8
-#define REG_HPON_FSM                   0x00EC
-#define REG_SYS_CFG                    0x00F0
-#define REG_GPIO_OUTSTS                        0x00F4  /*  For RTL8723 only. */
-#define REG_TYPE_ID                    0x00FC
-
-#define REG_MAC_PHY_CTRL_NORMAL                0x00f8
-
-/*     0x0100h ~ 0x01FFh       MACTOP General Configuration */
-#define REG_CR                         0x0100
-#define REG_PBP                                0x0104
-#define REG_PKT_BUFF_ACCESS_CTRL       0x0106
-#define REG_TRXDMA_CTRL                        0x010C
-#define REG_TRXFF_BNDY                 0x0114
-#define REG_TRXFF_STATUS               0x0118
-#define REG_RXFF_PTR                   0x011C
-/* define REG_HIMR                     0x0120 */
-/* define REG_HISR                     0x0124 */
-#define REG_HIMRE                      0x0128
-#define REG_HISRE                      0x012C
-#define REG_CPWM                       0x012F
-#define REG_FWIMR                      0x0130
-#define REG_FTIMR                      0x0138
-#define REG_FWISR                      0x0134
-#define REG_PKTBUF_DBG_CTRL            0x0140
-#define REG_PKTBUF_DBG_ADDR            (REG_PKTBUF_DBG_CTRL)
-#define REG_RXPKTBUF_DBG               (REG_PKTBUF_DBG_CTRL+2)
-#define REG_TXPKTBUF_DBG               (REG_PKTBUF_DBG_CTRL+3)
-#define REG_RXPKTBUF_CTRL              (REG_PKTBUF_DBG_CTRL+2)
-#define REG_PKTBUF_DBG_DATA_L          0x0144
-#define REG_PKTBUF_DBG_DATA_H          0x0148
-
-#define REG_TC0_CTRL                   0x0150
-#define REG_TC1_CTRL                   0x0154
-#define REG_TC2_CTRL                   0x0158
-#define REG_TC3_CTRL                   0x015C
-#define REG_TC4_CTRL                   0x0160
-#define REG_TCUNIT_BASE                        0x0164
-#define REG_MBIST_START                        0x0174
-#define REG_MBIST_DONE                 0x0178
-#define REG_MBIST_FAIL                 0x017C
-#define REG_32K_CTRL                   0x0194 /* RTL8188E */
-#define REG_C2HEVT_MSG_NORMAL          0x01A0
-#define REG_C2HEVT_CLEAR               0x01AF
-#define REG_MCUTST_1                   0x01c0
-#define REG_FMETHR                     0x01C8
-#define REG_HMETFR                     0x01CC
-#define REG_HMEBOX_0                   0x01D0
-#define REG_HMEBOX_1                   0x01D4
-#define REG_HMEBOX_2                   0x01D8
-#define REG_HMEBOX_3                   0x01DC
-
-#define REG_LLT_INIT                   0x01E0
-
-/*     0x0200h ~ 0x027Fh       TXDMA Configuration */
-#define REG_RQPN                       0x0200
-#define REG_FIFOPAGE                   0x0204
-#define REG_TDECTRL                    0x0208
-#define REG_TXDMA_OFFSET_CHK           0x020C
-#define REG_TXDMA_STATUS               0x0210
-#define REG_RQPN_NPQ                   0x0214
-
-/*     0x0280h ~ 0x02FFh       RXDMA Configuration */
-#define                REG_RXDMA_AGG_PG_TH     0x0280
-#define        REG_RXPKT_NUM                   0x0284
-#define                REG_RXDMA_STATUS        0x0288
-
-/*     0x0300h ~ 0x03FFh       PCIe */
-#define        REG_PCIE_CTRL_REG               0x0300
-#define        REG_INT_MIG                     0x0304  /*  Interrupt Migration */
-#define        REG_BCNQ_DESA                   0x0308  /*  TX Beacon Descr Address */
-#define        REG_HQ_DESA                     0x0310  /*  TX High Queue Descr Addr */
-#define        REG_MGQ_DESA                    0x0318  /*  TX Manage Queue Descr Addr*/
-#define        REG_VOQ_DESA                    0x0320  /*  TX VO Queue Descr Addr */
-#define        REG_VIQ_DESA                    0x0328  /*  TX VI Queue Descr Addr */
-#define        REG_BEQ_DESA                    0x0330  /*  TX BE Queue Descr Addr */
-#define        REG_BKQ_DESA                    0x0338  /*  TX BK Queue Descr Addr */
-#define        REG_RX_DESA                     0x0340  /*  RX Queue Descr Addr */
-#define        REG_MDIO                        0x0354  /*  MDIO for Access PCIE PHY */
-#define        REG_DBG_SEL                     0x0360  /*  Debug Selection Register */
-#define        REG_PCIE_HRPWM                  0x0361  /* PCIe RPWM */
-#define        REG_PCIE_HCPWM                  0x0363  /* PCIe CPWM */
-#define        REG_WATCH_DOG                   0x0368
-
-/*  RTL8723 series ------------------------------ */
-#define        REG_PCIE_HISR                   0x03A0
-
-/*  spec version 11 */
-/*     0x0400h ~ 0x047Fh       Protocol Configuration */
-#define REG_VOQ_INFORMATION            0x0400
-#define REG_VIQ_INFORMATION            0x0404
-#define REG_BEQ_INFORMATION            0x0408
-#define REG_BKQ_INFORMATION            0x040C
-#define REG_MGQ_INFORMATION            0x0410
-#define REG_HGQ_INFORMATION            0x0414
-#define REG_BCNQ_INFORMATION           0x0418
-#define REG_TXPKT_EMPTY                        0x041A
-
-#define REG_CPU_MGQ_INFORMATION                0x041C
-#define REG_FWHW_TXQ_CTRL              0x0420
-#define REG_HWSEQ_CTRL                 0x0423
-#define REG_TXPKTBUF_BCNQ_BDNY         0x0424
-#define REG_TXPKTBUF_MGQ_BDNY          0x0425
-#define REG_LIFETIME_EN                        0x0426
-#define REG_MULTI_BCNQ_OFFSET          0x0427
-#define REG_SPEC_SIFS                  0x0428
-#define REG_RL                         0x042A
-#define REG_DARFRC                     0x0430
-#define REG_RARFRC                     0x0438
-#define REG_RRSR                       0x0440
-#define REG_ARFR0                      0x0444
-#define REG_ARFR1                      0x0448
-#define REG_ARFR2                      0x044C
-#define REG_ARFR3                      0x0450
-#define REG_AGGLEN_LMT                 0x0458
-#define REG_AMPDU_MIN_SPACE            0x045C
-#define REG_TXPKTBUF_WMAC_LBK_BF_HD    0x045D
-#define REG_FAST_EDCA_CTRL             0x0460
-#define REG_RD_RESP_PKT_TH             0x0463
-#define REG_INIRTS_RATE_SEL            0x0480
-/* define REG_INIDATA_RATE_SEL         0x0484 */
-#define REG_POWER_STATUS               0x04A4
-#define REG_POWER_STAGE1               0x04B4
-#define REG_POWER_STAGE2               0x04B8
-#define REG_PKT_VO_VI_LIFE_TIME                0x04C0
-#define REG_PKT_BE_BK_LIFE_TIME                0x04C2
-#define REG_STBC_SETTING               0x04C4
-#define REG_PROT_MODE_CTRL             0x04C8
-#define REG_MAX_AGGR_NUM               0x04CA
-#define REG_RTS_MAX_AGGR_NUM           0x04CB
-#define REG_BAR_MODE_CTRL              0x04CC
-#define REG_RA_TRY_RATE_AGG_LMT                0x04CF
-#define REG_EARLY_MODE_CONTROL         0x4D0
-#define REG_NQOS_SEQ                   0x04DC
-#define REG_QOS_SEQ                    0x04DE
-#define REG_NEED_CPU_HANDLE            0x04E0
-#define REG_PKT_LOSE_RPT               0x04E1
-#define REG_PTCL_ERR_STATUS            0x04E2
-#define REG_TX_RPT_CTRL                        0x04EC
-#define REG_TX_RPT_TIME                        0x04F0  /*  2 byte */
-#define REG_DUMMY                      0x04FC
-
-/*     0x0500h ~ 0x05FFh       EDCA Configuration */
-#define REG_EDCA_VO_PARAM              0x0500
-#define REG_EDCA_VI_PARAM              0x0504
-#define REG_EDCA_BE_PARAM              0x0508
-#define REG_EDCA_BK_PARAM              0x050C
-#define REG_BCNTCFG                    0x0510
-#define REG_PIFS                       0x0512
-#define REG_RDG_PIFS                   0x0513
-#define REG_SIFS_CTX                   0x0514
-#define REG_SIFS_TRX                   0x0516
-#define REG_TSFTR_SYN_OFFSET           0x0518
-#define REG_AGGR_BREAK_TIME            0x051A
-#define REG_SLOT                       0x051B
-#define REG_TX_PTCL_CTRL               0x0520
-#define REG_TXPAUSE                    0x0522
-#define REG_DIS_TXREQ_CLR              0x0523
-#define REG_RD_CTRL                    0x0524
-/*  Format for offset 540h-542h: */
-/*     [3:0]:   TBTT prohibit setup in unit of 32us. The time for HW getting
- *              beacon content before TBTT. */
-/*     [7:4]:   Reserved. */
-/*     [19:8]:  TBTT prohibit hold in unit of 32us. The time for HW holding
- *              to send the beacon packet. */
-/*     [23:20]: Reserved */
-/*  Description: */
-/*                   | */
-/*      |<--Setup--|--Hold------------>| */
-/*     --------------|---------------------- */
-/*                 | */
-/*                TBTT */
-/*  Note: We cannot update beacon content to HW or send any AC packets during
- *       the time between Setup and Hold. */
-#define REG_TBTT_PROHIBIT              0x0540
-#define REG_RD_NAV_NXT                 0x0544
-#define REG_NAV_PROT_LEN               0x0546
-#define REG_BCN_CTRL                   0x0550
-#define REG_BCN_CTRL_1                 0x0551
-#define REG_MBID_NUM                   0x0552
-#define REG_DUAL_TSF_RST               0x0553
-#define REG_BCN_INTERVAL               0x0554
-#define REG_DRVERLYINT                 0x0558
-#define REG_BCNDMATIM                  0x0559
-#define REG_ATIMWND                    0x055A
-#define REG_BCN_MAX_ERR                        0x055D
-#define REG_RXTSF_OFFSET_CCK           0x055E
-#define REG_RXTSF_OFFSET_OFDM          0x055F
-#define REG_TSFTR                      0x0560
-#define REG_TSFTR1                     0x0568
-#define REG_ATIMWND_1                  0x0570
-#define REG_PSTIMER                    0x0580
-#define REG_TIMER0                     0x0584
-#define REG_TIMER1                     0x0588
-#define REG_ACMHWCTRL                  0x05C0
-
-/* define REG_FW_TSF_SYNC_CNT          0x04A0 */
-#define REG_FW_RESET_TSF_CNT_1         0x05FC
-#define REG_FW_RESET_TSF_CNT_0         0x05FD
-#define REG_FW_BCN_DIS_CNT             0x05FE
-
-/*     0x0600h ~ 0x07FFh       WMAC Configuration */
-#define REG_APSD_CTRL                  0x0600
-#define REG_BWOPMODE                   0x0603
-#define REG_TCR                                0x0604
-#define REG_RCR                                0x0608
-#define REG_RX_PKT_LIMIT               0x060C
-#define REG_RX_DLK_TIME                        0x060D
-#define REG_RX_DRVINFO_SZ              0x060F
-
-#define REG_MACID                      0x0610
-#define REG_BSSID                      0x0618
-#define REG_MAR                                0x0620
-#define REG_MBIDCAMCFG                 0x0628
-
-#define REG_USTIME_EDCA                        0x0638
-#define REG_MAC_SPEC_SIFS              0x063A
-
-/*  20100719 Joseph: Hardware register definition change. (HW datasheet v54) */
-/*  [15:8]SIFS_R2T_OFDM, [7:0]SIFS_R2T_CCK */
-#define REG_R2T_SIFS                   0x063C
-/*  [15:8]SIFS_T2T_OFDM, [7:0]SIFS_T2T_CCK */
-#define REG_T2T_SIFS                   0x063E
-#define REG_ACKTO                      0x0640
-#define REG_CTS2TO                     0x0641
-#define REG_EIFS                       0x0642
-
-/* RXERR_RPT */
-#define RXERR_TYPE_OFDM_PPDU           0
-#define RXERR_TYPE_OFDM_false_ALARM    1
-#define RXERR_TYPE_OFDM_MPDU_OK                2
-#define RXERR_TYPE_OFDM_MPDU_FAIL      3
-#define RXERR_TYPE_CCK_PPDU            4
-#define RXERR_TYPE_CCK_false_ALARM     5
-#define RXERR_TYPE_CCK_MPDU_OK         6
-#define RXERR_TYPE_CCK_MPDU_FAIL       7
-#define RXERR_TYPE_HT_PPDU             8
-#define RXERR_TYPE_HT_false_ALARM      9
-#define RXERR_TYPE_HT_MPDU_TOTAL       10
-#define RXERR_TYPE_HT_MPDU_OK          11
-#define RXERR_TYPE_HT_MPDU_FAIL                12
-#define RXERR_TYPE_RX_FULL_DROP                15
-
-#define RXERR_COUNTER_MASK             0xFFFFF
-#define RXERR_RPT_RST                  BIT(27)
-#define _RXERR_RPT_SEL(type)           ((type) << 28)
-
-/*  Note: */
-/*     The NAV upper value is very important to WiFi 11n 5.2.3 NAV test.
- *     The default value is always too small, but the WiFi TestPlan test
- *     by 25,000 microseconds of NAV through sending CTS in the air.
- *     We must update this value greater than 25,000 microseconds to pass
- *     the item. The offset of NAV_UPPER in 8192C Spec is incorrect, and
- *     the offset should be 0x0652. */
-#define REG_NAV_UPPER                  0x0652  /*  unit of 128 */
-
-/* WMA, BA, CCX */
-/* define REG_NAV_CTRL                 0x0650 */
-#define REG_BACAMCMD                   0x0654
-#define REG_BACAMCONTENT               0x0658
-#define REG_LBDLY                      0x0660
-#define REG_FWDLY                      0x0661
-#define REG_RXERR_RPT                  0x0664
-#define REG_WMAC_TRXPTCL_CTL           0x0668
-
-/*  Security */
-#define REG_CAMCMD                     0x0670
-#define REG_CAMWRITE                   0x0674
-#define REG_CAMREAD                    0x0678
-#define REG_CAMDBG                     0x067C
-#define REG_SECCFG                     0x0680
-
-/*  Power */
-#define REG_WOW_CTRL                   0x0690
-#define REG_PS_RX_INFO                 0x0692
-#define REG_UAPSD_TID                  0x0693
-#define REG_WKFMCAM_CMD                        0x0698
-#define REG_WKFMCAM_NUM_88E            0x698
-#define REG_RXFLTMAP0                  0x06A0
-#define REG_RXFLTMAP1                  0x06A2
-#define REG_RXFLTMAP2                  0x06A4
-#define REG_BCN_PSR_RPT                        0x06A8
-#define REG_BT_COEX_TABLE              0x06C0
-
-/*  Hardware Port 2 */
-#define REG_MACID1                     0x0700
-#define REG_BSSID1                     0x0708
-
-/*     0xFE00h ~ 0xFE55h       USB Configuration */
-#define REG_USB_INFO                   0xFE17
-#define REG_USB_SPECIAL_OPTION         0xFE55
-#define REG_USB_DMA_AGG_TO             0xFE5B
-#define REG_USB_AGG_TO                 0xFE5C
-#define REG_USB_AGG_TH                 0xFE5D
-
-/*  For normal chip */
-#define REG_NORMAL_SIE_VID             0xFE60          /*  0xFE60~0xFE61 */
-#define REG_NORMAL_SIE_PID             0xFE62          /*  0xFE62~0xFE63 */
-#define REG_NORMAL_SIE_OPTIONAL                0xFE64
-#define REG_NORMAL_SIE_EP              0xFE65          /*  0xFE65~0xFE67 */
-#define REG_NORMAL_SIE_PHY             0xFE68          /*  0xFE68~0xFE6B */
-#define REG_NORMAL_SIE_OPTIONAL2       0xFE6C
-#define REG_NORMAL_SIE_GPS_EP          0xFE6D  /*  0xFE6D, for RTL8723 only. */
-#define REG_NORMAL_SIE_MAC_ADDR                0xFE70          /*  0xFE70~0xFE75 */
-#define REG_NORMAL_SIE_STRING          0xFE80          /*  0xFE80~0xFEDF */
-
-/*  TODO: use these definition when using REG_xxx naming rule. */
-/*  NOTE: DO NOT Remove these definition. Use later. */
-
-#define        EFUSE_CTRL                      REG_EFUSE_CTRL  /*  E-Fuse Control. */
-#define        EFUSE_TEST                      REG_EFUSE_TEST  /*  E-Fuse Test. */
-#define        MSR                             (REG_CR + 2)    /*  Media Status reg */
-#define        ISR                             REG_HISR_88E
-/*  Timing Sync Function Timer Register. */
-#define        TSFR                            REG_TSFTR
-
-#define                PBP                     REG_PBP
-
-/*  Redifine MACID register, to compatible prior ICs. */
-/*  MAC ID Register, Offset 0x0050-0x0053 */
-#define        IDR0                            REG_MACID
-/*  MAC ID Register, Offset 0x0054-0x0055 */
-#define        IDR4                            (REG_MACID + 4)
-
-/*  9. Security Control Registers      (Offset: ) */
-/* IN 8190 Data Sheet is called CAMcmd */
-#define        RWCAM                           REG_CAMCMD
-/*  Software write CAM input content */
-#define        WCAMI                           REG_CAMWRITE
-/*  Software read/write CAM config */
-#define        RCAMO                           REG_CAMREAD
-#define        CAMDBG                          REG_CAMDBG
-/* Security Configuration Register */
-#define        SECR                            REG_SECCFG
-
-/*  Unused register */
-#define        UnusedRegister                  0x1BF
-#define        DCAM                            UnusedRegister
-#define        PSR                             UnusedRegister
-#define        BBAddr                          UnusedRegister
-#define        PhyDataR                        UnusedRegister
-
-/*  Min Spacing related settings. */
-#define        MAX_MSS_DENSITY_2T              0x13
-#define        MAX_MSS_DENSITY_1T              0x0A
-
-/*        8192C GPIO MUX Configuration Register (offset 0x40, 4 byte) */
-#define        GPIOSEL_GPIO                    0
-#define        GPIOSEL_ENBT                    BIT(5)
-
-/*        8192C GPIO PIN Control Register (offset 0x44, 4 byte) */
-/*  GPIO pins input value */
-#define        GPIO_IN                         REG_GPIO_PIN_CTRL
-/*  GPIO pins output value */
-#define        GPIO_OUT                        (REG_GPIO_PIN_CTRL+1)
-/*  GPIO pins output enable when a bit is set to "1"; otherwise,
- *  input is configured. */
-#define        GPIO_IO_SEL                     (REG_GPIO_PIN_CTRL+2)
-#define        GPIO_MOD                        (REG_GPIO_PIN_CTRL+3)
-
-/* 8723/8188E Host System Interrupt Mask Register (offset 0x58, 32 byte) */
-#define        HSIMR_GPIO12_0_INT_EN           BIT(0)
-#define        HSIMR_SPS_OCP_INT_EN            BIT(5)
-#define        HSIMR_RON_INT_EN                BIT(6)
-#define        HSIMR_PDN_INT_EN                BIT(7)
-#define        HSIMR_GPIO9_INT_EN              BIT(25)
-
-/* 8723/8188E Host System Interrupt Status Register (offset 0x5C, 32 byte) */
-#define        HSISR_GPIO12_0_INT              BIT(0)
-#define        HSISR_SPS_OCP_INT               BIT(5)
-#define        HSISR_RON_INT_EN                BIT(6)
-#define        HSISR_PDNINT                    BIT(7)
-#define        HSISR_GPIO9_INT                 BIT(25)
-
-/*   8192C (MSR) Media Status Register (Offset 0x4C, 8 bits) */
-/*
-Network Type
-00: No link
-01: Link in ad hoc network
-10: Link in infrastructure network
-11: AP mode
-Default: 00b.
-*/
-#define        MSR_NOLINK                      0x00
-#define        MSR_ADHOC                       0x01
-#define        MSR_INFRA                       0x02
-#define        MSR_AP                          0x03
-
-/*  88E Driver Initialization Offload REG_FDHM0(Offset 0x88, 8 bits) */
-/* IOL config for REG_FDHM0(Reg0x88) */
-#define CMD_INIT_LLT                   BIT(0)
-#define CMD_READ_EFUSE_MAP             BIT(1)
-#define CMD_EFUSE_PATCH                        BIT(2)
-#define CMD_IOCONFIG                   BIT(3)
-#define CMD_INIT_LLT_ERR               BIT(4)
-#define CMD_READ_EFUSE_MAP_ERR         BIT(5)
-#define CMD_EFUSE_PATCH_ERR            BIT(6)
-#define CMD_IOCONFIG_ERR               BIT(7)
-
-/*  6. Adaptive Control Registers  (Offset: 0x0160 - 0x01CF) */
-/*  8192C Response Rate Set Register   (offset 0x181, 24bits) */
-#define        RRSR_1M                         BIT(0)
-#define        RRSR_2M                         BIT(1)
-#define        RRSR_5_5M                       BIT(2)
-#define        RRSR_11M                        BIT(3)
-#define        RRSR_6M                         BIT(4)
-#define        RRSR_9M                         BIT(5)
-#define        RRSR_12M                        BIT(6)
-#define        RRSR_18M                        BIT(7)
-#define        RRSR_24M                        BIT(8)
-#define        RRSR_36M                        BIT(9)
-#define        RRSR_48M                        BIT(10)
-#define        RRSR_54M                        BIT(11)
-#define        RRSR_MCS0                       BIT(12)
-#define        RRSR_MCS1                       BIT(13)
-#define        RRSR_MCS2                       BIT(14)
-#define        RRSR_MCS3                       BIT(15)
-#define        RRSR_MCS4                       BIT(16)
-#define        RRSR_MCS5                       BIT(17)
-#define        RRSR_MCS6                       BIT(18)
-#define        RRSR_MCS7                       BIT(19)
-
-/*  8192C Response Rate Set Register   (offset 0x1BF, 8bits) */
-/*  WOL bit information */
-#define        HAL92C_WOL_PTK_UPDATE_EVENT     BIT(0)
-#define        HAL92C_WOL_GTK_UPDATE_EVENT     BIT(1)
-
-/*        8192C BW_OPMODE bits         (Offset 0x203, 8bit) */
-#define        BW_OPMODE_20MHZ                 BIT(2)
-
-#define        CAM_WRITE                       BIT(16)
-#define        CAM_POLLINIG                    BIT(31)
-
-#define        SCR_UseDK                       0x01
-#define        SCR_TxSecEnable                 0x02
-#define        SCR_RxSecEnable                 0x04
-
-/*  10. Power Save Control Registers    (Offset: 0x0260 - 0x02DF) */
-#define        WOW_PMEN                        BIT(0) /*  Power management Enable. */
-#define        WOW_WOMEN                       BIT(1) /*  WoW function on or off. */
-#define        WOW_MAGIC                       BIT(2) /*  Magic packet */
-#define        WOW_UWF                         BIT(3) /*  Unicast Wakeup frame. */
-
-/*  12. Host Interrupt Status Registers         (Offset: 0x0300 - 0x030F) */
-/*        8188 IMR/ISR bits */
-#define        IMR_DISABLED_88E                0x0
-/*  IMR DW0(0x0060-0063) Bit 0-31 */
-#define        IMR_TXCCK_88E                   BIT(30) /*  TXRPT interrupt when CCX bit of the packet is set */
-#define        IMR_PSTIMEOUT_88E               BIT(29) /*  Power Save Time Out Interrupt */
-#define        IMR_GTINT4_88E                  BIT(28) /*  When GTIMER4 expires, this bit is set to 1 */
-#define        IMR_GTINT3_88E                  BIT(27) /*  When GTIMER3 expires, this bit is set to 1 */
-#define        IMR_TBDER_88E                   BIT(26) /*  Transmit Beacon0 Error */
-#define        IMR_TBDOK_88E                   BIT(25) /*  Transmit Beacon0 OK */
-#define        IMR_TSF_BIT32_TOGGLE_88E        BIT(24) /*  TSF Timer BIT32 toggle indication interrupt */
-#define        IMR_BCNDMAINT0_88E              BIT(20) /*  Beacon DMA Interrupt 0 */
-#define        IMR_BCNDERR0_88E                BIT(16) /*  Beacon Queue DMA Error 0 */
-#define        IMR_HSISR_IND_ON_INT_88E        BIT(15) /*  HSISR Indicator (HSIMR & HSISR is true, this bit is set to 1) */
-#define        IMR_BCNDMAINT_E_88E             BIT(14) /*  Beacon DMA Interrupt Extension for Win7 */
-#define        IMR_ATIMEND_88E                 BIT(12) /*  CTWidnow End or ATIM Window End */
-#define        IMR_HISR1_IND_INT_88E           BIT(11) /*  HISR1 Indicator (HISR1 & HIMR1 is true, this bit is set to 1) */
-#define        IMR_C2HCMD_88E                  BIT(10) /*  CPU to Host Command INT Status, Write 1 clear */
-#define        IMR_CPWM2_88E                   BIT(9)  /*  CPU power Mode exchange INT Status, Write 1 clear */
-#define        IMR_CPWM_88E                    BIT(8)  /*  CPU power Mode exchange INT Status, Write 1 clear */
-#define        IMR_HIGHDOK_88E                 BIT(7)  /*  High Queue DMA OK */
-#define        IMR_MGNTDOK_88E                 BIT(6)  /*  Management Queue DMA OK */
-#define        IMR_BKDOK_88E                   BIT(5)  /*  AC_BK DMA OK */
-#define        IMR_BEDOK_88E                   BIT(4)  /*  AC_BE DMA OK */
-#define        IMR_VIDOK_88E                   BIT(3)  /*  AC_VI DMA OK */
-#define        IMR_VODOK_88E                   BIT(2)  /*  AC_VO DMA OK */
-#define        IMR_RDU_88E                     BIT(1)  /*  Rx Descriptor Unavailable */
-#define        IMR_ROK_88E                     BIT(0)  /*  Receive DMA OK */
-
-/*  IMR DW1(0x00B4-00B7) Bit 0-31 */
-#define        IMR_BCNDMAINT7_88E              BIT(27) /*  Beacon DMA Interrupt 7 */
-#define        IMR_BCNDMAINT6_88E              BIT(26) /*  Beacon DMA Interrupt 6 */
-#define        IMR_BCNDMAINT5_88E              BIT(25) /*  Beacon DMA Interrupt 5 */
-#define        IMR_BCNDMAINT4_88E              BIT(24) /*  Beacon DMA Interrupt 4 */
-#define        IMR_BCNDMAINT3_88E              BIT(23) /*  Beacon DMA Interrupt 3 */
-#define        IMR_BCNDMAINT2_88E              BIT(22) /*  Beacon DMA Interrupt 2 */
-#define        IMR_BCNDMAINT1_88E              BIT(21) /*  Beacon DMA Interrupt 1 */
-#define        IMR_BCNDERR7_88E                BIT(20) /*  Beacon DMA Error Int 7 */
-#define        IMR_BCNDERR6_88E                BIT(19) /*  Beacon DMA Error Int 6 */
-#define        IMR_BCNDERR5_88E                BIT(18) /*  Beacon DMA Error Int 5 */
-#define        IMR_BCNDERR4_88E                BIT(17) /*  Beacon DMA Error Int 4 */
-#define        IMR_BCNDERR3_88E                BIT(16) /*  Beacon DMA Error Int 3 */
-#define        IMR_BCNDERR2_88E                BIT(15) /*  Beacon DMA Error Int 2 */
-#define        IMR_BCNDERR1_88E                BIT(14) /*  Beacon DMA Error Int 1 */
-#define        IMR_ATIMEND_E_88E               BIT(13) /*  ATIM Window End Ext for Win7 */
-#define        IMR_TXERR_88E                   BIT(11) /*  Tx Err Flag Int Status, write 1 clear. */
-#define        IMR_RXERR_88E                   BIT(10) /*  Rx Err Flag INT Status, Write 1 clear */
-#define        IMR_TXFOVW_88E                  BIT(9)  /*  Transmit FIFO Overflow */
-#define        IMR_RXFOVW_88E                  BIT(8)  /*  Receive FIFO Overflow */
-
-#define        HAL_NIC_UNPLUG_ISR              0xFFFFFFFF      /*  The value when the NIC is unplugged for PCI. */
-
-/*  8192C EFUSE */
-#define                HWSET_MAX_SIZE                  256
-#define                HWSET_MAX_SIZE_88E              512
-
-/*===================================================================
-=====================================================================
-Here the register defines are for 92C. When the define is as same with 92C,
-we will use the 92C's define for the consistency
-So the following defines for 92C is not entire!!!!!!
-=====================================================================
-=====================================================================*/
-/*
-Based on Datasheet V33---090401
-Register Summary
-Current IOREG MAP
-0x0000h ~ 0x00FFh   System Configuration (256 Bytes)
-0x0100h ~ 0x01FFh   MACTOP General Configuration (256 Bytes)
-0x0200h ~ 0x027Fh   TXDMA Configuration (128 Bytes)
-0x0280h ~ 0x02FFh   RXDMA Configuration (128 Bytes)
-0x0300h ~ 0x03FFh   PCIE EMAC Reserved Region (256 Bytes)
-0x0400h ~ 0x04FFh   Protocol Configuration (256 Bytes)
-0x0500h ~ 0x05FFh   EDCA Configuration (256 Bytes)
-0x0600h ~ 0x07FFh   WMAC Configuration (512 Bytes)
-0x2000h ~ 0x3FFFh   8051 FW Download Region (8196 Bytes)
-*/
-/*              8192C (TXPAUSE) transmission pause (Offset 0x522, 8 bits) */
-/*  Note: */
-/*     The bits of stopping AC(VO/VI/BE/BK) queue in datasheet
- *     RTL8192S/RTL8192C are wrong, */
-/*     the correct arragement is VO - Bit0, VI - Bit1, BE - Bit2,
- *     and BK - Bit3. */
-/*     8723 and 88E may be not correct either in the earlier version. */
-#define                StopBecon                       BIT(6)
-#define                StopHigh                        BIT(5)
-#define                StopMgt                         BIT(4)
-#define                StopBK                          BIT(3)
-#define                StopBE                          BIT(2)
-#define                StopVI                          BIT(1)
-#define                StopVO                          BIT(0)
-
-/*        8192C (RCR) Receive Configuration Register(Offset 0x608, 32 bits) */
-#define        RCR_APPFCS              BIT(31) /* WMAC append FCS after payload */
-#define        RCR_APP_MIC             BIT(30)
-#define        RCR_APP_PHYSTS          BIT(28)
-#define        RCR_APP_ICV             BIT(29)
-#define        RCR_APP_PHYST_RXFF      BIT(28)
-#define        RCR_APP_BA_SSN          BIT(27) /* Accept BA SSN */
-#define        RCR_ENMBID              BIT(24) /* Enable Multiple BssId. */
-#define        RCR_LSIGEN              BIT(23)
-#define        RCR_MFBEN               BIT(22)
-#define        RCR_HTC_LOC_CTRL        BIT(14)   /* MFC<--HTC=1 MFC-->HTC=0 */
-#define        RCR_AMF                 BIT(13) /* Accept management type frame */
-#define        RCR_ACF                 BIT(12) /* Accept control type frame */
-#define        RCR_ADF                 BIT(11) /* Accept data type frame */
-#define        RCR_AICV                BIT(9)  /* Accept ICV error packet */
-#define        RCR_ACRC32              BIT(8)  /* Accept CRC32 error packet */
-#define        RCR_CBSSID_BCN          BIT(7)  /* Accept BSSID match packet
-                                        * (Rx beacon, probe rsp) */
-#define        RCR_CBSSID_DATA         BIT(6)  /* Accept BSSID match (Data)*/
-#define        RCR_CBSSID              RCR_CBSSID_DATA /* Accept BSSID match */
-#define        RCR_APWRMGT             BIT(5)  /* Accept power management pkt*/
-#define        RCR_ADD3                BIT(4)  /* Accept address 3 match pkt */
-#define        RCR_AB                  BIT(3)  /* Accept broadcast packet */
-#define        RCR_AM                  BIT(2)  /* Accept multicast packet */
-#define        RCR_APM                 BIT(1)  /* Accept physical match pkt */
-#define        RCR_AAP                 BIT(0)  /* Accept all unicast packet */
-#define        RCR_MXDMA_OFFSET        8
-#define        RCR_FIFO_OFFSET         13
-
-/*     0xFE00h ~ 0xFE55h       USB Configuration */
-#define REG_USB_INFO                   0xFE17
-#define REG_USB_SPECIAL_OPTION         0xFE55
-#define REG_USB_DMA_AGG_TO             0xFE5B
-#define REG_USB_AGG_TO                 0xFE5C
-#define REG_USB_AGG_TH                 0xFE5D
-
-#define REG_USB_HRPWM                  0xFE58
-#define REG_USB_HCPWM                  0xFE57
-/*        8192C Register Bit and Content definition */
-/*     0x0000h ~ 0x00FFh       System Configuration */
-
-/* 2 SYS_ISO_CTRL */
-#define ISO_MD2PP                      BIT(0)
-#define ISO_UA2USB                     BIT(1)
-#define ISO_UD2CORE                    BIT(2)
-#define ISO_PA2PCIE                    BIT(3)
-#define ISO_PD2CORE                    BIT(4)
-#define ISO_IP2MAC                     BIT(5)
-#define ISO_DIOP                       BIT(6)
-#define ISO_DIOE                       BIT(7)
-#define ISO_EB2CORE                    BIT(8)
-#define ISO_DIOR                       BIT(9)
-#define PWC_EV12V                      BIT(15)
-
-/* 2 SYS_FUNC_EN */
-#define FEN_BBRSTB                     BIT(0)
-#define FEN_BB_GLB_RSTn                        BIT(1)
-#define FEN_USBA                       BIT(2)
-#define FEN_UPLL                       BIT(3)
-#define FEN_USBD                       BIT(4)
-#define FEN_DIO_PCIE                   BIT(5)
-#define FEN_PCIEA                      BIT(6)
-#define FEN_PPLL                       BIT(7)
-#define FEN_PCIED                      BIT(8)
-#define FEN_DIOE                       BIT(9)
-#define FEN_CPUEN                      BIT(10)
-#define FEN_DCORE                      BIT(11)
-#define FEN_ELDR                       BIT(12)
-#define FEN_DIO_RF                     BIT(13)
-#define FEN_HWPDN                      BIT(14)
-#define FEN_MREGEN                     BIT(15)
-
-/* 2 APS_FSMCO */
-#define PFM_LDALL                      BIT(0)
-#define PFM_ALDN                       BIT(1)
-#define PFM_LDKP                       BIT(2)
-#define PFM_WOWL                       BIT(3)
-#define EnPDN                          BIT(4)
-#define PDN_PL                         BIT(5)
-#define APFM_ONMAC                     BIT(8)
-#define APFM_OFF                       BIT(9)
-#define APFM_RSM                       BIT(10)
-#define AFSM_HSUS                      BIT(11)
-#define AFSM_PCIE                      BIT(12)
-#define APDM_MAC                       BIT(13)
-#define APDM_HOST                      BIT(14)
-#define APDM_HPDN                      BIT(15)
-#define RDY_MACON                      BIT(16)
-#define SUS_HOST                       BIT(17)
-#define ROP_ALD                                BIT(20)
-#define ROP_PWR                                BIT(21)
-#define ROP_SPS                                BIT(22)
-#define SOP_MRST                       BIT(25)
-#define SOP_FUSE                       BIT(26)
-#define SOP_ABG                                BIT(27)
-#define SOP_AMB                                BIT(28)
-#define SOP_RCK                                BIT(29)
-#define SOP_A8M                                BIT(30)
-#define XOP_BTCK                       BIT(31)
-
-/* 2 SYS_CLKR */
-#define ANAD16V_EN                     BIT(0)
-#define ANA8M                          BIT(1)
-#define MACSLP                         BIT(4)
-#define LOADER_CLK_EN                  BIT(5)
-
-/* 2 9346CR */
-
-#define                BOOT_FROM_EEPROM        BIT(4)
-#define                EEPROM_EN               BIT(5)
-
-/* 2 SPS0_CTRL */
-
-/* 2 SPS_OCP_CFG */
-
-/* 2 RF_CTRL */
-#define RF_EN                          BIT(0)
-#define RF_RSTB                                BIT(1)
-#define RF_SDMRSTB                     BIT(2)
-
-/* 2 LDOV12D_CTRL */
-#define LDV12_EN                       BIT(0)
-#define LDV12_SDBY                     BIT(1)
-#define LPLDO_HSM                      BIT(2)
-#define LPLDO_LSM_DIS                  BIT(3)
-#define _LDV12_VADJ(x)                 (((x) & 0xF) << 4)
-
-/* 2EFUSE_CTRL */
-#define ALD_EN                         BIT(18)
-#define EF_PD                          BIT(19)
-#define EF_FLAG                                BIT(31)
-
-/* 2 EFUSE_TEST (For RTL8723 partially) */
-#define EF_TRPT                                BIT(7)
-/*  00: Wifi Efuse, 01: BT Efuse0, 10: BT Efuse1, 11: BT Efuse2 */
-#define EF_CELL_SEL                    (BIT(8)|BIT(9))
-#define LDOE25_EN                      BIT(31)
-#define EFUSE_SEL(x)                   (((x) & 0x3) << 8)
-#define EFUSE_SEL_MASK                 0x300
-#define EFUSE_WIFI_SEL_0               0x0
-#define EFUSE_BT_SEL_0                 0x1
-#define EFUSE_BT_SEL_1                 0x2
-#define EFUSE_BT_SEL_2                 0x3
-
-#define EFUSE_ACCESS_ON                        0x69    /*  For RTL8723 only. */
-#define EFUSE_ACCESS_OFF               0x00    /*  For RTL8723 only. */
-
-/* 2 8051FWDL */
-/* 2 MCUFWDL */
-#define MCUFWDL_EN                     BIT(0)
-#define MCUFWDL_RDY                    BIT(1)
-#define FWDL_CHKSUM_RPT                        BIT(2)
-#define MACINI_RDY                     BIT(3)
-#define BBINI_RDY                      BIT(4)
-#define RFINI_RDY                      BIT(5)
-#define WINTINI_RDY                    BIT(6)
-#define RAM_DL_SEL                     BIT(7) /*  1:RAM, 0:ROM */
-#define ROM_DLEN                       BIT(19)
-#define CPRST                          BIT(23)
-
-/* 2 REG_SYS_CFG */
-#define XCLK_VLD                       BIT(0)
-#define ACLK_VLD                       BIT(1)
-#define UCLK_VLD                       BIT(2)
-#define PCLK_VLD                       BIT(3)
-#define PCIRSTB                                BIT(4)
-#define V15_VLD                                BIT(5)
-#define SW_OFFLOAD_EN                  BIT(7)
-#define SIC_IDLE                       BIT(8)
-#define BD_MAC2                                BIT(9)
-#define BD_MAC1                                BIT(10)
-#define IC_MACPHY_MODE                 BIT(11)
-#define CHIP_VER                       (BIT(12)|BIT(13)|BIT(14)|BIT(15))
-#define BT_FUNC                                BIT(16)
-#define VENDOR_ID                      BIT(19)
-#define PAD_HWPD_IDN                   BIT(22)
-#define TRP_VAUX_EN                    BIT(23) /*  RTL ID */
-#define TRP_BT_EN                      BIT(24)
-#define BD_PKG_SEL                     BIT(25)
-#define BD_HCI_SEL                     BIT(26)
-#define TYPE_ID                                BIT(27)
-
-#define CHIP_VER_RTL_MASK              0xF000  /* Bit 12 ~ 15 */
-#define CHIP_VER_RTL_SHIFT             12
-
-/* 2REG_GPIO_OUTSTS (For RTL8723 only) */
-#define        EFS_HCI_SEL                     (BIT(0)|BIT(1))
-#define        PAD_HCI_SEL                     (BIT(2)|BIT(3))
-#define        HCI_SEL                         (BIT(4)|BIT(5))
-#define        PKG_SEL_HCI                     BIT(6)
-#define        FEN_GPS                         BIT(7)
-#define        FEN_BT                          BIT(8)
-#define        FEN_WL                          BIT(9)
-#define        FEN_PCI                         BIT(10)
-#define        FEN_USB                         BIT(11)
-#define        BTRF_HWPDN_N                    BIT(12)
-#define        WLRF_HWPDN_N                    BIT(13)
-#define        PDN_BT_N                        BIT(14)
-#define        PDN_GPS_N                       BIT(15)
-#define        BT_CTL_HWPDN                    BIT(16)
-#define        GPS_CTL_HWPDN                   BIT(17)
-#define        PPHY_SUSB                       BIT(20)
-#define        UPHY_SUSB                       BIT(21)
-#define        PCI_SUSEN                       BIT(22)
-#define        USB_SUSEN                       BIT(23)
-#define        RF_RL_ID                        (BIT(31)|BIT(30)|BIT(29)|BIT(28))
-
-/* 2SYS_CFG */
-#define RTL_ID                         BIT(23) /*  TestChip ID, 1:Test(RLE); 0:MP(RL) */
-
-/*     0x0100h ~ 0x01FFh       MACTOP General Configuration */
-
-/* 2 Function Enable Registers */
-/* 2 CR */
-
-#define HCI_TXDMA_EN                   BIT(0)
-#define HCI_RXDMA_EN                   BIT(1)
-#define TXDMA_EN                       BIT(2)
-#define RXDMA_EN                       BIT(3)
-#define PROTOCOL_EN                    BIT(4)
-#define SCHEDULE_EN                    BIT(5)
-#define MACTXEN                                BIT(6)
-#define MACRXEN                                BIT(7)
-#define ENSWBCN                                BIT(8)
-#define ENSEC                          BIT(9)
-#define CALTMR_EN                      BIT(10) /*  32k CAL TMR enable */
-
-/*  Network type */
-#define _NETTYPE(x)                    (((x) & 0x3) << 16)
-#define MASK_NETTYPE                   0x30000
-#define NT_NO_LINK                     0x0
-#define NT_LINK_AD_HOC                 0x1
-#define NT_LINK_AP                     0x2
-#define NT_AS_AP                       0x3
-
-/* 2 PBP - Page Size Register */
-#define GET_RX_PAGE_SIZE(value)                ((value) & 0xF)
-#define GET_TX_PAGE_SIZE(value)                (((value) & 0xF0) >> 4)
-#define _PSRX_MASK                     0xF
-#define _PSTX_MASK                     0xF0
-#define _PSRX(x)                       (x)
-#define _PSTX(x)                       ((x) << 4)
-
-#define PBP_128                                0x1
-
-/* 2 TX/RXDMA */
-#define RXDMA_ARBBW_EN                 BIT(0)
-#define RXSHFT_EN                      BIT(1)
-#define RXDMA_AGG_EN                   BIT(2)
-#define QS_VO_QUEUE                    BIT(8)
-#define QS_VI_QUEUE                    BIT(9)
-#define QS_BE_QUEUE                    BIT(10)
-#define QS_BK_QUEUE                    BIT(11)
-#define QS_MANAGER_QUEUE               BIT(12)
-#define QS_HIGH_QUEUE                  BIT(13)
-
-#define HQSEL_VOQ                      BIT(0)
-#define HQSEL_VIQ                      BIT(1)
-#define HQSEL_BEQ                      BIT(2)
-#define HQSEL_BKQ                      BIT(3)
-#define HQSEL_MGTQ                     BIT(4)
-#define HQSEL_HIQ                      BIT(5)
-
-/*  For normal driver, 0x10C */
-#define _TXDMA_HIQ_MAP(x)              (((x) & 0x3) << 14)
-#define _TXDMA_MGQ_MAP(x)              (((x) & 0x3) << 12)
-#define _TXDMA_BKQ_MAP(x)              (((x) & 0x3) << 10)
-#define _TXDMA_BEQ_MAP(x)              (((x) & 0x3) << 8)
-#define _TXDMA_VIQ_MAP(x)              (((x) & 0x3) << 6)
-#define _TXDMA_VOQ_MAP(x)              (((x) & 0x3) << 4)
-
-#define QUEUE_LOW                      1
-#define QUEUE_NORMAL                   2
-#define QUEUE_HIGH                     3
-
-/* 2 TRXFF_BNDY */
-
-/* 2 LLT_INIT */
-#define _LLT_NO_ACTIVE                 0x0
-#define _LLT_WRITE_ACCESS              0x1
-#define _LLT_READ_ACCESS               0x2
-
-#define _LLT_INIT_DATA(x)              ((x) & 0xFF)
-#define _LLT_INIT_ADDR(x)              (((x) & 0xFF) << 8)
-#define _LLT_OP(x)                     (((x) & 0x3) << 30)
-#define _LLT_OP_VALUE(x)               (((x) >> 30) & 0x3)
-
-/*     0x0200h ~ 0x027Fh       TXDMA Configuration */
-
-#define NUM_HQ 0x29
-
-#define LD_RQPN                                BIT(31)
-
-/* 2TDECTRL */
-#define BCN_VALID                      BIT(16)
-#define BCN_HEAD(x)                    (((x) & 0xFF) << 8)
-#define        BCN_HEAD_MASK                   0xFF00
-
-/* 2 TDECTL */
-#define BLK_DESC_NUM_SHIFT             4
-#define BLK_DESC_NUM_MASK              0xF
-
-/* 2 TXDMA_OFFSET_CHK */
-#define DROP_DATA_EN                   BIT(9)
-
-/*     0x0280h ~ 0x028Bh       RX DMA Configuration */
-
-/*     REG_RXDMA_CONTROL, 0x0286h */
-
-/* 2 REG_RXPKT_NUM, 0x0284 */
-#define                RXPKT_RELEASE_POLL      BIT(16)
-#define        RXDMA_IDLE                      BIT(17)
-#define        RW_RELEASE_EN                   BIT(18)
-
-/*     0x0400h ~ 0x047Fh       Protocol Configuration */
-/* 2 FWHW_TXQ_CTRL */
-#define EN_AMPDU_RTY_NEW               BIT(7)
-
-/* 2 SPEC SIFS */
-#define _SPEC_SIFS_CCK(x)              ((x) & 0xFF)
-#define _SPEC_SIFS_OFDM(x)             (((x) & 0xFF) << 8)
-
-/* 2 RL */
-#define        RETRY_LIMIT_SHORT_SHIFT         8
-#define        RETRY_LIMIT_LONG_SHIFT          0
-
-/*     0x0500h ~ 0x05FFh       EDCA Configuration */
-
-/* 2 EDCA setting */
-#define AC_PARAM_TXOP_LIMIT_OFFSET     16
-#define AC_PARAM_ECW_MAX_OFFSET                12
-#define AC_PARAM_ECW_MIN_OFFSET                8
-#define AC_PARAM_AIFS_OFFSET           0
-
-#define _LRL(x)                        ((x) & 0x3F)
-#define _SRL(x)                        (((x) & 0x3F) << 8)
-
-/* 2 BCN_CTRL */
-#define EN_MBSSID              BIT(1)
-#define EN_TXBCN_RPT           BIT(2)
-#define EN_BCN_FUNCTION                BIT(3)
-#define DIS_TSF_UPDATE         BIT(3)
-
-/*  The same function but different bit field. */
-#define DIS_TSF_UDT0_NORMAL_CHIP       BIT(4)
-#define DIS_TSF_UDT0_TEST_CHIP BIT(5)
-#define STOP_BCNQ              BIT(6)
-
-/* 2 ACMHWCTRL */
-#define ACMHW_BEQEN            BIT(1)
-#define ACMHW_VIQEN            BIT(2)
-#define ACMHW_VOQEN            BIT(3)
-
-/*     0x0600h ~ 0x07FFh       WMAC Configuration */
-/* 2APSD_CTRL */
-#define APSDOFF                        BIT(6)
-#define APSDOFF_STATUS         BIT(7)
-
-#define RATE_BITMAP_ALL                0xFFFFF
-
-/*  Only use CCK 1M rate for ACK */
-#define RATE_RRSR_CCK_ONLY_1M  0xFFFF1
-
-/* 2 TCR */
-#define TSFRST                 BIT(0)
-#define DIS_GCLK               BIT(1)
-#define PAD_SEL                        BIT(2)
-#define PWR_ST                 BIT(6)
-#define PWRBIT_OW_EN           BIT(7)
-#define ACRC                   BIT(8)
-#define CFENDFORM              BIT(9)
-#define ICV                    BIT(10)
-
-/* 2 RCR */
-#define AAP                    BIT(0)
-#define APM                    BIT(1)
-#define AM                     BIT(2)
-#define AB                     BIT(3)
-#define ADD3                   BIT(4)
-#define APWRMGT                        BIT(5)
-#define CBSSID                 BIT(6)
-#define CBSSID_DATA            BIT(6)
-#define CBSSID_BCN             BIT(7)
-#define ACRC32                 BIT(8)
-#define AICV                   BIT(9)
-#define ADF                    BIT(11)
-#define ACF                    BIT(12)
-#define AMF                    BIT(13)
-#define HTC_LOC_CTRL           BIT(14)
-#define UC_DATA_EN             BIT(16)
-#define BM_DATA_EN             BIT(17)
-#define MFBEN                  BIT(22)
-#define LSIGEN                 BIT(23)
-#define EnMBID                 BIT(24)
-#define APP_BASSN              BIT(27)
-#define APP_PHYSTS             BIT(28)
-#define APP_ICV                        BIT(29)
-#define APP_MIC                        BIT(30)
-#define APP_FCS                        BIT(31)
-
-/* 2 SECCFG */
-#define        SCR_TxUseDK             BIT(0)  /* Force Tx Use Default Key */
-#define        SCR_RxUseDK             BIT(1)  /* Force Rx Use Default Key */
-#define        SCR_TxEncEnable         BIT(2)  /* Enable Tx Encryption */
-#define        SCR_RxDecEnable         BIT(3)  /* Enable Rx Decryption */
-#define        SCR_SKByA2              BIT(4)  /* Search kEY BY A2 */
-#define        SCR_NoSKMC              BIT(5)  /* No Key Search Multicast */
-#define SCR_TXBCUSEDK          BIT(6)  /* Force Tx Bcast pkt Use Default Key */
-#define SCR_RXBCUSEDK          BIT(7)  /* Force Rx Bcast pkt Use Default Key */
-
-/*     0xFE00h ~ 0xFE55h       USB Configuration */
-
-/* 2 USB Information (0xFE17) */
-#define USB_IS_HIGH_SPEED                      0
-#define USB_IS_FULL_SPEED                      1
-#define USB_SPEED_MASK                         BIT(5)
-
-#define USB_NORMAL_SIE_EP_MASK                 0xF
-#define USB_NORMAL_SIE_EP_SHIFT                        4
-
-/* 2 Special Option */
-#define USB_AGG_EN                             BIT(3)
-
-/*  0; Use interrupt endpoint to upload interrupt pkt */
-/*  1; Use bulk endpoint to upload interrupt pkt, */
-#define INT_BULK_SEL                           BIT(4)
-
-/* 2REG_C2HEVT_CLEAR */
-/*  Set by driver and notify FW that the driver has read
- *  the C2H command message */
-#define        C2H_EVT_HOST_CLOSE      0x00
-/*  Set by FW indicating that FW had set the C2H command
- *  message and it's not yet read by driver. */
-#define C2H_EVT_FW_CLOSE       0xFF
-
-/* 2REG_MULTI_FUNC_CTRL(For RTL8723 Only) */
-/*  Enable GPIO[9] as WiFi HW PDn source */
-#define        WL_HWPDN_EN                             BIT(0)
-/*  WiFi HW PDn polarity control */
-#define        WL_HWPDN_SL                             BIT(1)
-/*  WiFi function enable */
-#define        WL_FUNC_EN                              BIT(2)
-/*  Enable GPIO[9] as WiFi RF HW PDn source */
-#define        WL_HWROF_EN                             BIT(3)
-/*  Enable GPIO[11] as BT HW PDn source */
-#define        BT_HWPDN_EN                             BIT(16)
-/*  BT HW PDn polarity control */
-#define        BT_HWPDN_SL                             BIT(17)
-/*  BT function enable */
-#define        BT_FUNC_EN                              BIT(18)
-/*  Enable GPIO[11] as BT/GPS RF HW PDn source */
-#define        BT_HWROF_EN                             BIT(19)
-/*  Enable GPIO[10] as GPS HW PDn source */
-#define        GPS_HWPDN_EN                            BIT(20)
-/*  GPS HW PDn polarity control */
-#define        GPS_HWPDN_SL                            BIT(21)
-/*  GPS function enable */
-#define        GPS_FUNC_EN                             BIT(22)
-
-/* 3 REG_LIFECTRL_CTRL */
-#define        HAL92C_EN_PKT_LIFE_TIME_BK              BIT(3)
-#define        HAL92C_EN_PKT_LIFE_TIME_BE              BIT(2)
-#define        HAL92C_EN_PKT_LIFE_TIME_VI              BIT(1)
-#define        HAL92C_EN_PKT_LIFE_TIME_VO              BIT(0)
-
-#define        HAL92C_MSDU_LIFE_TIME_UNIT              128     /*  in us */
-
-/*  General definitions */
-#define LAST_ENTRY_OF_TX_PKT_BUFFER            176 /*  22k 22528 bytes */
-
-#define POLLING_LLT_THRESHOLD                  20
-#define POLLING_READY_TIMEOUT_COUNT            1000
-/*  GPIO BIT */
-#define        HAL_8192C_HW_GPIO_WPS_BIT               BIT(2)
-
-/*     8192C EEPROM/EFUSE share register definition. */
-
-/*     EEPROM/Efuse PG Offset for 88EE/88EU/88ES */
-#define        EEPROM_TX_PWR_INX_88E                   0x10
-
-#define        EEPROM_ChannelPlan_88E                  0xB8
-#define        EEPROM_XTAL_88E                         0xB9
-#define        EEPROM_THERMAL_METER_88E                0xBA
-#define        EEPROM_IQK_LCK_88E                      0xBB
-
-#define        EEPROM_RF_BOARD_OPTION_88E              0xC1
-#define        EEPROM_RF_FEATURE_OPTION_88E            0xC2
-#define        EEPROM_RF_ANTENNA_OPT_88E               0xC9
-
-/* RTL88EU */
-#define        EEPROM_MAC_ADDR_88EU                    0xD7
-#define EEPROM_USB_OPTIONAL_FUNCTION0          0xD4
-
-/*  RTL88ES */
-#define        EEPROM_MAC_ADDR_88ES                    0x11A
-
-#define EEPROM_Default_CrystalCap_88E          0x20
-#define        EEPROM_Default_ThermalMeter_88E         0x18
-
-/* New EFUSE default value */
-#define                EEPROM_DEFAULT_24G_INDEX        0x2D
-#define                EEPROM_DEFAULT_24G_HT20_DIFF    0X02
-#define                EEPROM_DEFAULT_24G_OFDM_DIFF    0X04
-
-#define                EEPROM_DEFAULT_DIFF             0XFE
-#define        EEPROM_DEFAULT_BOARD_OPTION             0x00
-
-#define EEPROM_CHANNEL_PLAN_FCC                        0x0
-#define EEPROM_CHANNEL_PLAN_IC                 0x1
-#define EEPROM_CHANNEL_PLAN_ETSI               0x2
-#define EEPROM_CHANNEL_PLAN_SPA                        0x3
-#define EEPROM_CHANNEL_PLAN_FRANCE             0x4
-#define EEPROM_CHANNEL_PLAN_MKK                        0x5
-#define EEPROM_CHANNEL_PLAN_MKK1               0x6
-#define EEPROM_CHANNEL_PLAN_ISRAEL             0x7
-#define EEPROM_CHANNEL_PLAN_TELEC              0x8
-#define EEPROM_CHANNEL_PLAN_GLOBAL_DOMA                0x9
-#define EEPROM_CHANNEL_PLAN_WORLD_WIDE_13      0xA
-#define EEPROM_CHANNEL_PLAN_NCC                        0xB
-#define EEPROM_USB_OPTIONAL1                   0xE
-#define EEPROM_CHANNEL_PLAN_BY_HW_MASK         0x80
-
-#define        RTL_EEPROM_ID                   0x8129
-
-#endif /* __RTL8188E_SPEC_H__ */
diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h
deleted file mode 100644 (file)
index a023dd7..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTL8188E_XMIT_H__
-#define __RTL8188E_XMIT_H__
-
-#define                MAX_TX_AGG_PACKET_NUMBER        0xFF
-#define QSLT_MGNT                                              0x12
-
-/* For 88e early mode */
-#define SET_EARLYMODE_PKTNUM(__paddr, __value)                 \
-       le32p_replace_bits((__le32 *)__paddr, __value, GENMASK(2, 0))
-#define SET_EARLYMODE_LEN0(__pAddr, __Value)                   \
-       le32p_replace_bits((__le32 *)__paddr, __value, GENMASK(15, 4))
-#define SET_EARLYMODE_LEN1(__paddr, __value)                   \
-       le32p_replace_bits((__le32 *)__paddr, __value, GENMASK(27, 16))
-#define SET_EARLYMODE_LEN2_1(__pdr, __vValue)                  \
-       le32p_replace_bits((__le32 *)__paddr, __value, GENMASK(31, 28))
-#define SET_EARLYMODE_LEN2_2(__paddr, __value)                 \
-       le32p_replace_bits((__le32 *)(__paddr + 4), __value, GENMASK(7, 0))
-#define SET_EARLYMODE_LEN3(__pAddr, __Value)                   \
-       le32p_replace_bits((__le32 *)(__paddr + 4), __value, GENMASK(19, 8))
-#define SET_EARLYMODE_LEN4(__paAddr, __vValue)                 \
-       le32p_replace_bits((__le32 *)(__paddr + 4), __value, GENMASK(31, 20))
-
-/* defined for TX DESC Operation */
-
-#define MAX_TID (15)
-
-/* OFFSET 0 */
-#define OFFSET_SZ      0
-#define OFFSET_SHT     16
-#define BMC            BIT(24)
-#define LSG            BIT(26)
-#define FSG            BIT(27)
-#define OWN            BIT(31)
-
-/* OFFSET 4 */
-#define PKT_OFFSET_SZ          0
-#define QSEL_SHT               8
-#define RATE_ID_SHT            16
-#define NAVUSEHDR              BIT(20)
-#define SEC_TYPE_SHT           22
-#define PKT_OFFSET_SHT         26
-
-/* OFFSET 8 */
-#define AGG_EN                 BIT(12)
-#define AGG_BK                 BIT(16)
-#define AMPDU_DENSITY_SHT      20
-#define ANTSEL_A               BIT(24)
-#define ANTSEL_B               BIT(25)
-#define TX_ANT_CCK_SHT         26
-#define TX_ANTL_SHT            28
-#define TX_ANT_HT_SHT          30
-
-/* OFFSET 12 */
-#define SEQ_SHT                        16
-#define EN_HWSEQ               BIT(31)
-
-/* OFFSET 16 */
-#define QOS                    BIT(6)
-#define        HW_SSN                  BIT(7)
-#define USERATE                        BIT(8)
-#define DISDATAFB              BIT(10)
-#define CTS_2_SELF             BIT(11)
-#define        RTS_EN                  BIT(12)
-#define        HW_RTS_EN               BIT(13)
-#define DATA_SHORT             BIT(24)
-#define PWR_STATUS_SHT         15
-#define DATA_SC_SHT            20
-#define DATA_BW                        BIT(25)
-
-/* OFFSET 20 */
-#define        RTY_LMT_EN              BIT(17)
-
-/* OFFSET 20 */
-#define SGI                    BIT(6)
-#define USB_TXAGG_NUM_SHT      24
-
-#define USB_TXAGG_DESC_NUM     0x6
-
-#define txdesc_set_ccx_sw_88e(txdesc, value) \
-       do { \
-               ((struct txdesc_88e *)(txdesc))->sw1 = (((value)>>8) & 0x0f); \
-               ((struct txdesc_88e *)(txdesc))->sw0 = ((value) & 0xff); \
-       } while (0)
-
-struct txrpt_ccx_88e {
-       /* offset 0 */
-       u8 tag1:1;
-       u8 pkt_num:3;
-       u8 txdma_underflow:1;
-       u8 int_bt:1;
-       u8 int_tri:1;
-       u8 int_ccx:1;
-
-       /* offset 1 */
-       u8 mac_id:6;
-       u8 pkt_ok:1;
-       u8 bmc:1;
-
-       /* offset 2 */
-       u8 retry_cnt:6;
-       u8 lifetime_over:1;
-       u8 retry_over:1;
-
-       /* offset 3 */
-       u8 ccx_qtime0;
-       u8 ccx_qtime1;
-
-       /* offset 5 */
-       u8 final_data_rate;
-
-       /* offset 6 */
-       u8 sw1:4;
-       u8 qsel:4;
-
-       /* offset 7 */
-       u8 sw0;
-};
-
-void rtl8188e_fill_fake_txdesc(struct adapter *padapter, u8 *pDesc,
-                              u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull);
-s32 rtl8188eu_hal_xmit(struct adapter *padapter, struct xmit_frame *frame);
-s32 rtl8188eu_mgnt_xmit(struct adapter *padapter, struct xmit_frame *frame);
-s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter);
-void rtl8188eu_xmit_tasklet(unsigned long priv);
-bool rtl8188eu_xmitframe_complete(struct adapter *padapter);
-
-#endif /* __RTL8188E_XMIT_H__ */
diff --git a/drivers/staging/r8188eu/include/rtw_ap.h b/drivers/staging/r8188eu/include/rtw_ap.h
deleted file mode 100644 (file)
index 89b02c9..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#ifndef __RTW_AP_H_
-#define __RTW_AP_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-
-/* external function */
-void rtw_indicate_sta_assoc_event(struct adapter *padapter,
-                                 struct sta_info *psta);
-void init_mlme_ap_info(struct adapter *padapter);
-void free_mlme_ap_info(struct adapter *padapter);
-void update_beacon(struct adapter *padapter, u8 ie_id,
-                  u8 *oui, u8 tx);
-void add_RATid(struct adapter *padapter, struct sta_info *psta,
-              u8 rssi_level);
-void expire_timeout_chk(struct adapter *padapter);
-void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta);
-void rtw_ap_restore_network(struct adapter *padapter);
-
-void associated_clients_update(struct adapter *padapter, u8 updated);
-void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta);
-u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta);
-void sta_info_update(struct adapter *padapter, struct sta_info *psta);
-u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta,
-              bool active, u16 reason);
-void rtw_sta_flush(struct adapter *padapter);
-void start_ap_mode(struct adapter *padapter);
-void stop_ap_mode(struct adapter *padapter);
-void update_bmc_sta(struct adapter *padapter);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/rtw_br_ext.h b/drivers/staging/r8188eu/include/rtw_br_ext.h
deleted file mode 100644 (file)
index 56772af..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef _RTW_BR_EXT_H_
-#define _RTW_BR_EXT_H_
-
-#define GET_MY_HWADDR(padapter)                ((padapter)->eeprompriv.mac_addr)
-
-#define NAT25_HASH_BITS                4
-#define NAT25_HASH_SIZE                (1 << NAT25_HASH_BITS)
-#define NAT25_AGEING_TIME      300
-
-#define MAX_NETWORK_ADDR_LEN   17
-
-struct nat25_network_db_entry {
-       struct nat25_network_db_entry   *next_hash;
-       struct nat25_network_db_entry   **pprev_hash;
-       atomic_t        use_count;
-       unsigned char   macAddr[6];
-       unsigned long   ageing_timer;
-       unsigned char   networkAddr[MAX_NETWORK_ADDR_LEN];
-};
-
-enum NAT25_METHOD {
-       NAT25_MIN,
-       NAT25_CHECK,
-       NAT25_INSERT,
-       NAT25_PARSE,
-       NAT25_MAX
-};
-
-struct br_ext_info {
-       unsigned int    nat25_disable;
-       unsigned int    macclone_enable;
-       unsigned int    dhcp_bcst_disable;
-       int     addPPPoETag;            /* 1: Add PPPoE relay-SID, 0: disable */
-       unsigned char   nat25_dmzMac[ETH_ALEN];
-       unsigned int    nat25sc_disable;
-};
-
-void nat25_db_cleanup(struct adapter *priv);
-
-#endif /*  _RTW_BR_EXT_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_cmd.h b/drivers/staging/r8188eu/include/rtw_cmd.h
deleted file mode 100644 (file)
index e8eecd5..0000000
+++ /dev/null
@@ -1,925 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_CMD_H_
-#define __RTW_CMD_H_
-
-#include "wlan_bssdef.h"
-#include "rtw_rf.h"
-
-#include "osdep_service.h"
-#include "ieee80211.h" /*  <ieee80211/ieee80211.h> */
-
-#define MAX_CMDSZ      1024
-#define MAX_RSPSZ      512
-#define MAX_EVTSZ      1024
-
-#define CMDBUFF_ALIGN_SZ 512
-
-struct cmd_obj {
-       struct adapter *padapter;
-       u16     cmdcode;
-       u8      res;
-       u8      *parmbuf;
-       u32     cmdsz;
-       u8      *rsp;
-       u32     rspsz;
-       struct list_head list;
-};
-
-struct cmd_priv {
-       struct completion enqueue_cmd;
-       struct completion start_cmd_thread;
-       struct completion stop_cmd_thread;
-       struct __queue cmd_queue;
-       u8      *cmd_buf;       /* shall be non-paged, and 4 bytes aligned */
-       u8      *cmd_allocated_buf;
-       u8      *rsp_buf;       /* shall be non-paged, and 4 bytes aligned */
-       u8      *rsp_allocated_buf;
-       u32     cmd_done_cnt;
-       u32     rsp_cnt;
-       u8 cmdthd_running;
-       struct adapter *padapter;
-};
-
-struct evt_priv {
-       struct work_struct c2h_wk;
-       bool c2h_wk_alive;
-       struct rtw_cbuf *c2h_queue;
-       #define C2H_QUEUE_MAX_LEN 10
-       atomic_t event_seq;
-       u8      *evt_buf;       /* shall be non-paged, and 4 bytes aligned */
-};
-
-#define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
-do {\
-       INIT_LIST_HEAD(&pcmd->list);\
-       pcmd->cmdcode = code;\
-       pcmd->parmbuf = (u8 *)(pparm);\
-       pcmd->cmdsz = sizeof(*pparm);\
-       pcmd->rsp = NULL;\
-       pcmd->rspsz = 0;\
-} while (0)
-
-struct c2h_evt_hdr {
-       u8 id:4;
-       u8 plen:4;
-       u8 seq;
-       u8 payload[];
-};
-
-#define c2h_evt_exist(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen)
-
-u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
-struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv);
-void rtw_free_cmd_obj(struct cmd_obj *pcmd);
-
-int rtw_cmd_thread(void *context);
-
-int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv);
-void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv);
-
-int rtw_init_evt_priv(struct evt_priv *pevtpriv);
-void rtw_free_evt_priv(struct evt_priv *pevtpriv);
-void rtw_evt_notify_isr(struct evt_priv *pevtpriv);
-u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType);
-
-enum rtw_drvextra_cmd_id {
-       NONE_WK_CID,
-       DYNAMIC_CHK_WK_CID,
-       DM_CTRL_WK_CID,
-       PBC_POLLING_WK_CID,
-       POWER_SAVING_CTRL_WK_CID,/* IPS,AUTOSuspend */
-       LPS_CTRL_WK_CID,
-       ANT_SELECT_WK_CID,
-       P2P_PS_WK_CID,
-       P2P_PROTO_WK_CID,
-       CHECK_HIQ_WK_CID,/* for softap mode, check hi queue if empty */
-       INTEl_WIDI_WK_CID,
-       C2H_WK_CID,
-       RTP_TIMER_CFG_WK_CID,
-       MAX_WK_CID
-};
-
-enum LPS_CTRL_TYPE {
-       LPS_CTRL_SCAN = 0,
-       LPS_CTRL_JOINBSS = 1,
-       LPS_CTRL_CONNECT = 2,
-       LPS_CTRL_DISCONNECT = 3,
-       LPS_CTRL_SPECIAL_PACKET = 4,
-       LPS_CTRL_LEAVE = 5,
-};
-
-enum RFINTFS {
-       SWSI,
-       HWSI,
-       HWPI,
-};
-
-/*
-Caller Mode: Infra, Ad-HoC
-
-Notes: To join a known BSS.
-
-Command-Event Mode
-
-*/
-
-/*
-Caller Mode: Infra, Ad-Hoc
-
-Notes: To join the specified bss
-
-Command Event Mode
-
-*/
-struct joinbss_parm {
-       struct wlan_bssid_ex network;
-};
-
-/*
-Caller Mode: Infra, Ad-HoC(C)
-
-Notes: To disconnect the current associated BSS
-
-Command Mode
-
-*/
-struct disconnect_parm {
-       u32 deauth_timeout_ms;
-};
-
-/*
-Caller Mode: AP, Ad-HoC(M)
-
-Notes: To create a BSS
-
-Command Mode
-*/
-struct createbss_parm {
-       struct wlan_bssid_ex network;
-};
-
-struct setopmode_parm {
-       u8      mode;
-       u8      rsvd[3];
-};
-
-/*
-Caller Mode: AP, Ad-HoC, Infra
-
-Notes: To ask RTL8711 performing site-survey
-
-Command-Event Mode
-
-*/
-
-#define RTW_SSID_SCAN_AMOUNT 9 /*  for WEXT_CSCAN_AMOUNT 9 */
-#define RTW_CHANNEL_SCAN_AMOUNT (14+37)
-struct sitesurvey_parm {
-       int scan_mode;  /* active: 1, passive: 0 */
-       u8 ssid_num;
-       u8 ch_num;
-       struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
-       struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
-};
-
-/*
-Caller Mode: Any
-
-Notes: To set the auth type of RTL8711. open/shared/802.1x
-
-Command Mode
-
-*/
-struct setauth_parm {
-       u8 mode;  /* 0: legacy open, 1: legacy shared 2: 802.1x */
-       u8 _1x;   /* 0: PSK, 1: TLS */
-       u8 rsvd[2];
-};
-
-/*
-Caller Mode: Infra
-
-a. algorithm: wep40, wep104, tkip & aes
-b. keytype: grp key/unicast key
-c. key contents
-
-when shared key ==> keyid is the camid
-when 802.1x ==> keyid [0:1] ==> grp key
-when 802.1x ==> keyid > 2 ==> unicast key
-
-*/
-struct setkey_parm {
-       u8      algorithm;      /* could be none, wep40, TKIP, CCMP, wep104 */
-       u8      keyid;
-       u8      grpkey;         /* 1: this is the grpkey for 802.1x.
-                                * 0: this is the unicast key for 802.1x */
-       u8      set_tx;         /* 1: main tx key for wep. 0: other key. */
-       u8      key[16];        /* this could be 40 or 104 */
-};
-
-/*
-When in AP or Ad-Hoc mode, this is used to
-allocate an sw/hw entry for a newly associated sta.
-
-Command
-
-when shared key ==> algorithm/keyid
-
-*/
-struct set_stakey_parm {
-       u8      addr[ETH_ALEN];
-       u8      algorithm;
-       u8      id;/* currently for erasing cam entry if
-                   * algorithm == _NO_PRIVACY_ */
-       u8      key[16];
-};
-
-struct set_stakey_rsp {
-       u8      addr[ETH_ALEN];
-       u8      keyid;
-       u8      rsvd;
-};
-
-/*
-Caller Ad-Hoc/AP
-
-Command -Rsp(AID == CAMID) mode
-
-This is to force fw to add an sta_data entry per driver's request.
-
-FW will write an cam entry associated with it.
-
-*/
-struct set_assocsta_parm {
-       u8      addr[ETH_ALEN];
-};
-
-struct set_assocsta_rsp {
-       u8      cam_id;
-       u8      rsvd[3];
-};
-
-/*
-       Caller Ad-Hoc/AP
-
-       Command mode
-
-       This is to force fw to del an sta_data entry per driver's request
-
-       FW will invalidate the cam entry associated with it.
-
-*/
-struct del_assocsta_parm {
-       u8      addr[ETH_ALEN];
-};
-
-/*
-Caller Mode: AP/Ad-HoC(M)
-
-Notes: To notify fw that given staid has changed its power state
-
-Command Mode
-
-*/
-struct setstapwrstate_parm {
-       u8      staid;
-       u8      status;
-       u8      hwaddr[6];
-};
-
-/*
-Caller Mode: Any
-
-Notes: To setup the basic rate of RTL8711
-
-Command Mode
-
-*/
-struct setbasicrate_parm {
-       u8      basicrates[NumRates];
-};
-
-/*
-Caller Mode: Any
-
-Notes: To read the current basic rate
-
-Command-Rsp Mode
-
-*/
-struct getbasicrate_parm {
-       u32 rsvd;
-};
-
-struct getbasicrate_rsp {
-       u8 basicrates[NumRates];
-};
-
-/*
-Caller Mode: Any
-
-Notes: To setup the data rate of RTL8711
-
-Command Mode
-
-*/
-struct setdatarate_parm {
-       u8      mac_id;
-       u8      datarates[NumRates];
-};
-
-/*
-Caller Mode: Any
-
-Notes: To read the current data rate
-
-Command-Rsp Mode
-
-*/
-struct getdatarate_parm {
-       u32 rsvd;
-
-};
-struct getdatarate_rsp {
-       u8 datarates[NumRates];
-};
-
-/*
-Caller Mode: Any
-AP: AP can use the info for the contents of beacon frame
-Infra: STA can use the info when sitesurveying
-Ad-HoC(M): Like AP
-Ad-HoC(C): Like STA
-
-Notes: To set the phy capability of the NIC
-
-Command Mode
-
-*/
-
-struct setphyinfo_parm {
-       struct regulatory_class class_sets[NUM_REGULATORYS];
-       u8      status;
-};
-
-struct getphyinfo_parm {
-       u32 rsvd;
-};
-
-struct getphyinfo_rsp {
-       struct regulatory_class class_sets[NUM_REGULATORYS];
-       u8      status;
-};
-
-/*
-Caller Mode: Any
-
-Notes: To set the channel/modem/band
-This command will be used when channel/modem/band is changed.
-
-Command Mode
-
-*/
-struct setphy_parm {
-       u8      rfchannel;
-       u8      modem;
-};
-
-/*
-Caller Mode: Any
-
-Notes: To get the current setting of channel/modem/band
-
-Command-Rsp Mode
-
-*/
-struct getphy_parm {
-       u32 rsvd;
-
-};
-struct getphy_rsp {
-       u8      rfchannel;
-       u8      modem;
-};
-
-struct readBB_parm {
-       u8      offset;
-};
-struct readBB_rsp {
-       u8      value;
-};
-
-struct readTSSI_parm {
-       u8      offset;
-};
-struct readTSSI_rsp {
-       u8      value;
-};
-
-struct writeBB_parm {
-       u8      offset;
-       u8      value;
-};
-
-struct readRF_parm {
-       u8      offset;
-};
-struct readRF_rsp {
-       u32     value;
-};
-
-struct writeRF_parm {
-       u32     offset;
-       u32     value;
-};
-
-struct getrfintfs_parm {
-       u8      rfintfs;
-};
-
-struct Tx_Beacon_param {
-       struct wlan_bssid_ex network;
-};
-
-/*
-       Notes: This command is used for H2C/C2H loopback testing
-
-       mac[0] == 0
-       ==> CMD mode, return H2C_SUCCESS.
-       The following condition must be true under CMD mode
-               mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
-               s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
-               s2 == (b1 << 8 | b0);
-
-       mac[0] == 1
-       ==> CMD_RSP mode, return H2C_SUCCESS_RSP
-
-       The rsp layout shall be:
-       rsp:                    parm:
-               mac[0]  =   mac[5];
-               mac[1]  =   mac[4];
-               mac[2]  =   mac[3];
-               mac[3]  =   mac[2];
-               mac[4]  =   mac[1];
-               mac[5]  =   mac[0];
-               s0              =   s1;
-               s1              =   swap16(s0);
-               w0              =       swap32(w1);
-               b0              =       b1
-               s2              =       s0 + s1
-               b1              =       b0
-               w1              =       w0
-
-       mac[0] ==       2
-       ==> CMD_EVENT mode, return      H2C_SUCCESS
-       The event layout shall be:
-       event:                  parm:
-               mac[0]  =   mac[5];
-               mac[1]  =   mac[4];
-               mac[2]  =   event's seq no, starting from 1 to parm's marc[3]
-               mac[3]  =   mac[2];
-               mac[4]  =   mac[1];
-               mac[5]  =   mac[0];
-               s0              =   swap16(s0) - event.mac[2];
-               s1              =   s1 + event.mac[2];
-               w0              =       swap32(w0);
-               b0              =       b1
-               s2              =       s0 + event.mac[2]
-               b1              =       b0
-               w1              =       swap32(w1) - event.mac[2];
-
-               parm->mac[3] is the total event counts that host requested.
-       event will be the same with the cmd's param.
-*/
-
-/*  CMD param Format for driver extra cmd handler */
-struct drvextra_cmd_parm {
-       int ec_id; /* extra cmd id */
-       int type_size; /*  Can use this field as the type id or command size */
-       unsigned char *pbuf;
-};
-
-/*------------------- Below are used for RF/BB tuning ---------------------*/
-
-struct setantenna_parm {
-       u8      tx_antset;
-       u8      rx_antset;
-       u8      tx_antenna;
-       u8      rx_antenna;
-};
-
-struct enrateadaptive_parm {
-       u32     en;
-};
-
-struct settxagctbl_parm {
-       u32     txagc[MAX_RATES_LENGTH];
-};
-
-struct gettxagctbl_parm {
-       u32 rsvd;
-};
-struct gettxagctbl_rsp {
-       u32     txagc[MAX_RATES_LENGTH];
-};
-
-struct setagcctrl_parm {
-       u32     agcctrl;                /*  0: pure hw, 1: fw */
-};
-
-struct setssup_parm    {
-       u32     ss_ForceUp[MAX_RATES_LENGTH];
-};
-
-struct getssup_parm    {
-       u32 rsvd;
-};
-
-struct getssup_rsp     {
-       u8      ss_ForceUp[MAX_RATES_LENGTH];
-};
-
-struct setssdlevel_parm        {
-       u8      ss_DLevel[MAX_RATES_LENGTH];
-};
-
-struct getssdlevel_parm        {
-       u32 rsvd;
-};
-
-struct getssdlevel_rsp {
-       u8      ss_DLevel[MAX_RATES_LENGTH];
-};
-
-struct setssulevel_parm        {
-       u8      ss_ULevel[MAX_RATES_LENGTH];
-};
-
-struct getssulevel_parm        {
-       u32 rsvd;
-};
-
-struct getssulevel_rsp {
-       u8      ss_ULevel[MAX_RATES_LENGTH];
-};
-
-struct setcountjudge_parm {
-       u8      count_judge[MAX_RATES_LENGTH];
-};
-
-struct getcountjudge_parm {
-       u32 rsvd;
-};
-
-struct getcountjudge_rsp {
-       u8      count_judge[MAX_RATES_LENGTH];
-};
-
-struct setratable_parm {
-       u8 ss_ForceUp[NumRates];
-       u8 ss_ULevel[NumRates];
-       u8 ss_DLevel[NumRates];
-       u8 count_judge[NumRates];
-};
-
-struct getratable_parm {
-       uint rsvd;
-};
-
-struct getratable_rsp {
-       u8 ss_ForceUp[NumRates];
-       u8 ss_ULevel[NumRates];
-       u8 ss_DLevel[NumRates];
-       u8 count_judge[NumRates];
-};
-
-/* to get TX,RX retry count */
-
-struct gettxretrycnt_parm {
-       unsigned int rsvd;
-};
-
-struct gettxretrycnt_rsp {
-       unsigned long tx_retrycnt;
-};
-
-struct getrxretrycnt_parm {
-       unsigned int rsvd;
-};
-
-struct getrxretrycnt_rsp {
-       unsigned long rx_retrycnt;
-};
-
-/* to get BCNOK,BCNERR count */
-struct getbcnokcnt_parm {
-       unsigned int rsvd;
-};
-
-struct getbcnokcnt_rsp {
-       unsigned long  bcnokcnt;
-};
-
-struct getbcnerrcnt_parm {
-       unsigned int rsvd;
-};
-
-struct getbcnerrcnt_rsp {
-       unsigned long bcnerrcnt;
-};
-
-/*  to get current TX power level */
-struct getcurtxpwrlevel_parm {
-       unsigned int rsvd;
-};
-struct getcurtxpwrlevel_rspi {
-       unsigned short tx_power;
-};
-
-struct setprobereqextraie_parm {
-       unsigned char e_id;
-       unsigned char ie_len;
-       unsigned char ie[];
-};
-
-struct setassocreqextraie_parm {
-       unsigned char e_id;
-       unsigned char ie_len;
-       unsigned char ie[];
-};
-
-struct setproberspextraie_parm {
-       unsigned char e_id;
-       unsigned char ie_len;
-       unsigned char ie[];
-};
-
-struct setassocrspextraie_parm {
-       unsigned char e_id;
-       unsigned char ie_len;
-       unsigned char ie[];
-};
-
-struct addBaReq_parm {
-       unsigned int tid;
-       u8      addr[ETH_ALEN];
-};
-
-/*H2C Handler index: 46 */
-struct set_ch_parm {
-       u8 ch;
-       u8 bw;
-       u8 ch_offset;
-};
-
-/*H2C Handler index: 59 */
-struct SetChannelPlan_param {
-       u8 channel_plan;
-};
-
-/*H2C Handler index: 60 */
-struct LedBlink_param {
-       struct LED_871x *pLed;
-};
-
-/*H2C Handler index: 61 */
-struct SetChannelSwitch_param {
-       u8 new_ch_no;
-};
-
-/*H2C Handler index: 62 */
-struct TDLSoption_param {
-       u8 addr[ETH_ALEN];
-       u8 option;
-};
-
-#define GEN_CMD_CODE(cmd)      cmd ## _CMD_
-
-/*
-
-Result:
-0x00: success
-0x01: success, and check Response.
-0x02: cmd ignored due to duplicated sequcne number
-0x03: cmd dropped due to invalid cmd code
-0x04: reserved.
-
-*/
-
-#define H2C_RSP_OFFSET         512
-
-#define H2C_SUCCESS            0x00
-#define H2C_SUCCESS_RSP                0x01
-#define H2C_DUPLICATED         0x02
-#define H2C_DROPPED            0x03
-#define H2C_PARAMETERS_ERROR   0x04
-#define H2C_REJECTED           0x05
-#define H2C_CMD_OVERFLOW       0x06
-#define H2C_RESERVED           0x07
-
-u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num);
-u8 rtw_createbss_cmd(struct adapter *padapter);
-u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key);
-u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue);
-u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork);
-u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue);
-u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra networktype);
-int rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset);
-u8 rtw_setrfintfs_cmd(struct adapter *padapter, u8 mode);
-
-u8 rtw_gettssi_cmd(struct adapter *padapter, u8 offset, u8 *pval);
-u8 rtw_setfwdig_cmd(struct adapter *padapter, u8 type);
-u8 rtw_setfwra_cmd(struct adapter *padapter, u8 type);
-
-u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr);
-
-u8 rtw_dynamic_chk_wk_cmd(struct adapter *adapter);
-
-u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue);
-u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 minRptTime);
-
-u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue);
-u8 rtw_ps_cmd(struct adapter *padapter);
-
-void rtw_chk_hi_queue_cmd(struct adapter *padapter);
-
-u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan);
-
-u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt);
-
-u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf);
-
-void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
-void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
-void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
-void rtw_createbss_cmd_callback(struct adapter *adapt, struct cmd_obj *pcmd);
-void rtw_getbbrfreg_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd);
-
-void rtw_setstaKey_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd);
-void rtw_setassocsta_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cm);
-void rtw_getrttbl_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd);
-
-struct _cmd_callback {
-       u32     cmd_code;
-       void (*callback)(struct adapter  *padapter, struct cmd_obj *cmd);
-};
-
-enum rtw_h2c_cmd {
-       GEN_CMD_CODE(_Read_MACREG),     /*0*/
-       GEN_CMD_CODE(_Write_MACREG),
-       GEN_CMD_CODE(_Read_BBREG),
-       GEN_CMD_CODE(_Write_BBREG),
-       GEN_CMD_CODE(_Read_RFREG),
-       GEN_CMD_CODE(_Write_RFREG), /*5*/
-       GEN_CMD_CODE(_Read_EEPROM),
-       GEN_CMD_CODE(_Write_EEPROM),
-       GEN_CMD_CODE(_Read_EFUSE),
-       GEN_CMD_CODE(_Write_EFUSE),
-
-       GEN_CMD_CODE(_Read_CAM),        /*10*/
-       GEN_CMD_CODE(_Write_CAM),
-       GEN_CMD_CODE(_setBCNITV),
-       GEN_CMD_CODE(_setMBIDCFG),
-       GEN_CMD_CODE(_JoinBss),   /*14*/
-       GEN_CMD_CODE(_DisConnect), /*15*/
-       GEN_CMD_CODE(_CreateBss),
-       GEN_CMD_CODE(_SetOpMode),
-       GEN_CMD_CODE(_SiteSurvey),  /*18*/
-       GEN_CMD_CODE(_SetAuth),
-
-       GEN_CMD_CODE(_SetKey),  /*20*/
-       GEN_CMD_CODE(_SetStaKey),
-       GEN_CMD_CODE(_SetAssocSta),
-       GEN_CMD_CODE(_DelAssocSta),
-       GEN_CMD_CODE(_SetStaPwrState),
-       GEN_CMD_CODE(_SetBasicRate), /*25*/
-       GEN_CMD_CODE(_GetBasicRate),
-       GEN_CMD_CODE(_SetDataRate),
-       GEN_CMD_CODE(_GetDataRate),
-       GEN_CMD_CODE(_SetPhyInfo),
-
-       GEN_CMD_CODE(_GetPhyInfo),      /*30*/
-       GEN_CMD_CODE(_SetPhy),
-       GEN_CMD_CODE(_GetPhy),
-       GEN_CMD_CODE(_readRssi),
-       GEN_CMD_CODE(_readGain),
-       GEN_CMD_CODE(_SetAtim), /*35*/
-       GEN_CMD_CODE(_SetPwrMode),
-       GEN_CMD_CODE(_JoinbssRpt),
-       GEN_CMD_CODE(_SetRaTable),
-       GEN_CMD_CODE(_GetRaTable),
-
-       GEN_CMD_CODE(_GetCCXReport), /*40*/
-       GEN_CMD_CODE(_GetDTMReport),
-       GEN_CMD_CODE(_GetTXRateStatistics),
-       GEN_CMD_CODE(_SetUsbSuspend),
-       GEN_CMD_CODE(_SetH2cLbk),
-       GEN_CMD_CODE(_AddBAReq), /*45*/
-       GEN_CMD_CODE(_SetChannel), /*46*/
-       GEN_CMD_CODE(_SetTxPower),
-       GEN_CMD_CODE(_SwitchAntenna),
-       GEN_CMD_CODE(_SetCrystalCap),
-       GEN_CMD_CODE(_SetSingleCarrierTx), /*50*/
-
-       GEN_CMD_CODE(_SetSingleToneTx),/*51*/
-       GEN_CMD_CODE(_SetCarrierSuppressionTx),
-       GEN_CMD_CODE(_SetContinuousTx),
-       GEN_CMD_CODE(_SwitchBandwidth), /*54*/
-       GEN_CMD_CODE(_TX_Beacon), /*55*/
-
-       GEN_CMD_CODE(_Set_MLME_EVT), /*56*/
-       GEN_CMD_CODE(_Set_Drv_Extra), /*57*/
-       GEN_CMD_CODE(_Set_H2C_MSG), /*58*/
-
-       GEN_CMD_CODE(_SetChannelPlan), /*59*/
-       GEN_CMD_CODE(_LedBlink), /*60*/
-
-       GEN_CMD_CODE(_SetChannelSwitch), /*61*/
-       GEN_CMD_CODE(_TDLS), /*62*/
-
-       MAX_H2CCMD
-};
-
-#define _GetBBReg_CMD_         _Read_BBREG_CMD_
-#define _SetBBReg_CMD_         _Write_BBREG_CMD_
-#define _GetRFReg_CMD_         _Read_RFREG_CMD_
-#define _SetRFReg_CMD_         _Write_RFREG_CMD_
-
-#ifdef _RTW_CMD_C_
-static struct _cmd_callback    rtw_cmd_callback[] = {
-       {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/
-       {GEN_CMD_CODE(_Write_MACREG), NULL},
-       {GEN_CMD_CODE(_Read_BBREG), &rtw_getbbrfreg_cmdrsp_callback},
-       {GEN_CMD_CODE(_Write_BBREG), NULL},
-       {GEN_CMD_CODE(_Read_RFREG), &rtw_getbbrfreg_cmdrsp_callback},
-       {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/
-       {GEN_CMD_CODE(_Read_EEPROM), NULL},
-       {GEN_CMD_CODE(_Write_EEPROM), NULL},
-       {GEN_CMD_CODE(_Read_EFUSE), NULL},
-       {GEN_CMD_CODE(_Write_EFUSE), NULL},
-
-       {GEN_CMD_CODE(_Read_CAM),       NULL},  /*10*/
-       {GEN_CMD_CODE(_Write_CAM),       NULL},
-       {GEN_CMD_CODE(_setBCNITV), NULL},
-       {GEN_CMD_CODE(_setMBIDCFG), NULL},
-       {GEN_CMD_CODE(_JoinBss), &rtw_joinbss_cmd_callback},  /*14*/
-       {GEN_CMD_CODE(_DisConnect), &rtw_disassoc_cmd_callback}, /*15*/
-       {GEN_CMD_CODE(_CreateBss), &rtw_createbss_cmd_callback},
-       {GEN_CMD_CODE(_SetOpMode), NULL},
-       {GEN_CMD_CODE(_SiteSurvey), &rtw_survey_cmd_callback}, /*18*/
-       {GEN_CMD_CODE(_SetAuth), NULL},
-
-       {GEN_CMD_CODE(_SetKey), NULL},  /*20*/
-       {GEN_CMD_CODE(_SetStaKey), &rtw_setstaKey_cmdrsp_callback},
-       {GEN_CMD_CODE(_SetAssocSta), &rtw_setassocsta_cmdrsp_callback},
-       {GEN_CMD_CODE(_DelAssocSta), NULL},
-       {GEN_CMD_CODE(_SetStaPwrState), NULL},
-       {GEN_CMD_CODE(_SetBasicRate), NULL}, /*25*/
-       {GEN_CMD_CODE(_GetBasicRate), NULL},
-       {GEN_CMD_CODE(_SetDataRate), NULL},
-       {GEN_CMD_CODE(_GetDataRate), NULL},
-       {GEN_CMD_CODE(_SetPhyInfo), NULL},
-
-       {GEN_CMD_CODE(_GetPhyInfo), NULL}, /*30*/
-       {GEN_CMD_CODE(_SetPhy), NULL},
-       {GEN_CMD_CODE(_GetPhy), NULL},
-       {GEN_CMD_CODE(_readRssi), NULL},
-       {GEN_CMD_CODE(_readGain), NULL},
-       {GEN_CMD_CODE(_SetAtim), NULL}, /*35*/
-       {GEN_CMD_CODE(_SetPwrMode), NULL},
-       {GEN_CMD_CODE(_JoinbssRpt), NULL},
-       {GEN_CMD_CODE(_SetRaTable), NULL},
-       {GEN_CMD_CODE(_GetRaTable), NULL},
-
-       {GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/
-       {GEN_CMD_CODE(_GetDTMReport),   NULL},
-       {GEN_CMD_CODE(_GetTXRateStatistics), NULL},
-       {GEN_CMD_CODE(_SetUsbSuspend), NULL},
-       {GEN_CMD_CODE(_SetH2cLbk), NULL},
-       {GEN_CMD_CODE(_AddBAReq), NULL}, /*45*/
-       {GEN_CMD_CODE(_SetChannel), NULL},              /*46*/
-       {GEN_CMD_CODE(_SetTxPower), NULL},
-       {GEN_CMD_CODE(_SwitchAntenna), NULL},
-       {GEN_CMD_CODE(_SetCrystalCap), NULL},
-       {GEN_CMD_CODE(_SetSingleCarrierTx), NULL},      /*50*/
-
-       {GEN_CMD_CODE(_SetSingleToneTx), NULL}, /*51*/
-       {GEN_CMD_CODE(_SetCarrierSuppressionTx), NULL},
-       {GEN_CMD_CODE(_SetContinuousTx), NULL},
-       {GEN_CMD_CODE(_SwitchBandwidth), NULL},         /*54*/
-       {GEN_CMD_CODE(_TX_Beacon), NULL},/*55*/
-
-       {GEN_CMD_CODE(_Set_MLME_EVT), NULL},/*56*/
-       {GEN_CMD_CODE(_Set_Drv_Extra), NULL},/*57*/
-       {GEN_CMD_CODE(_Set_H2C_MSG), NULL},/*58*/
-       {GEN_CMD_CODE(_SetChannelPlan), NULL},/*59*/
-       {GEN_CMD_CODE(_LedBlink), NULL},/*60*/
-
-       {GEN_CMD_CODE(_SetChannelSwitch), NULL},/*61*/
-       {GEN_CMD_CODE(_TDLS), NULL},/*62*/
-};
-#endif
-
-#endif /*  _CMD_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_eeprom.h b/drivers/staging/r8188eu/include/rtw_eeprom.h
deleted file mode 100644 (file)
index 94d735b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_EEPROM_H__
-#define __RTW_EEPROM_H__
-
-#include "osdep_service.h"
-#include "drv_types.h"
-
-struct eeprom_priv {
-       u8              bautoload_fail_flag;
-       u8              mac_addr[ETH_ALEN] __aligned(2); /* PermanentAddress */
-};
-
-#endif  /* __RTL871X_EEPROM_H__ */
diff --git a/drivers/staging/r8188eu/include/rtw_efuse.h b/drivers/staging/r8188eu/include/rtw_efuse.h
deleted file mode 100644 (file)
index 3d688a0..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_EFUSE_H__
-#define __RTW_EFUSE_H__
-
-#define                EFUSE_MAX_WORD_UNIT                     4
-
-void ReadEFuseByte(struct adapter *adapter, u16 _offset, u8 *pbuf);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/rtw_event.h b/drivers/staging/r8188eu/include/rtw_event.h
deleted file mode 100644 (file)
index 54dc1ea..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef _RTW_EVENT_H_
-#define _RTW_EVENT_H_
-
-#include "osdep_service.h"
-
-#include "wlan_bssdef.h"
-#include <linux/semaphore.h>
-#include <linux/sem.h>
-
-/*
-Used to report a bss has been scanned
-*/
-struct survey_event    {
-       struct wlan_bssid_ex bss;
-};
-
-/*
-Used to report that the requested site survey has been done.
-
-bss_cnt indicates the number of bss that has been reported.
-
-*/
-struct surveydone_event {
-       unsigned int    bss_cnt;
-
-};
-
-/*
-Used to report the link result of joinning the given bss
-
-join_res:
--1: authentication fail
--2: association fail
-> 0: TID
-
-*/
-struct joinbss_event {
-       struct  wlan_network    network;
-};
-
-/*
-Used to report a given STA has joinned the created BSS.
-It is used in AP/Ad-HoC(M) mode.
-*/
-
-struct stassoc_event {
-       unsigned char macaddr[6];
-       unsigned char rsvd[2];
-       int    cam_id;
-};
-
-struct stadel_event {
-       unsigned char macaddr[6];
-       unsigned char rsvd[2]; /* for reason */
-       int mac_id;
-};
-
-struct addba_event {
-       unsigned int tid;
-};
-
-#define GEN_EVT_CODE(event)    event ## _EVT_
-
-struct fwevent {
-       u32     parmsize;
-       void (*event_callback)(struct adapter *dev, u8 *pbuf);
-};
-
-#define C2HEVENT_SZ                    32
-
-struct event_node {
-       unsigned char *node;
-       unsigned char evt_code;
-       unsigned short evt_sz;
-       int     *caller_ff_tail;
-       int     caller_ff_sz;
-};
-
-struct c2hevent_queue {
-       int     head;
-       int     tail;
-       struct  event_node      nodes[C2HEVENT_SZ];
-       unsigned char   seq;
-};
-
-#define NETWORK_QUEUE_SZ       4
-
-struct network_queue {
-       int     head;
-       int     tail;
-       struct wlan_bssid_ex networks[NETWORK_QUEUE_SZ];
-};
-
-#endif /*  _WLANEVENT_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_fw.h b/drivers/staging/r8188eu/include/rtw_fw.h
deleted file mode 100644 (file)
index 8f74157..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_FW_H__
-#define __RTW_FW_H__
-
-struct rt_firmware {
-       u8 *data;
-       u32 size;
-};
-
-#include "drv_types.h"
-
-int rtl8188e_firmware_download(struct adapter *padapter);
-void rtw_reset_8051(struct adapter *padapter);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/rtw_ht.h b/drivers/staging/r8188eu/include/rtw_ht.h
deleted file mode 100644 (file)
index 2b56b7c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef _RTW_HT_H_
-#define _RTW_HT_H_
-
-#include "osdep_service.h"
-#include "wifi.h"
-
-struct ht_priv {
-       u32     ht_option;
-       u32     ampdu_enable;/* for enable Tx A-MPDU */
-       u32     tx_amsdu_enable;/* for enable Tx A-MSDU */
-       u32     tx_amdsu_maxlen; /*  1: 8k, 0:4k ; default:8k, for tx */
-       u32     rx_ampdu_maxlen; /* for rx reordering ctrl win_sz,
-                                 * updated when join_callback. */
-       u8      bwmode;/*  */
-       u8      ch_offset;/* PRIME_CHNL_OFFSET */
-       u8      sgi;/* short GI */
-
-       /* for processing Tx A-MPDU */
-       u8      agg_enable_bitmap;
-       u8      candidate_tid_bitmap;
-
-       struct ieee80211_ht_cap ht_cap;
-};
-
-#endif /* _RTL871X_HT_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_io.h b/drivers/staging/r8188eu/include/rtw_io.h
deleted file mode 100644 (file)
index e1718f7..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef _RTW_IO_H_
-#define _RTW_IO_H_
-
-#include "osdep_service.h"
-#include "osdep_intf.h"
-
-#include <asm/byteorder.h>
-#include <linux/semaphore.h>
-#include <linux/list.h>
-#include <linux/spinlock.h>
-#include <asm/atomic.h>
-
-#include <linux/usb.h>
-#include <linux/usb/ch9.h>
-
-int __must_check rtw_read8(struct adapter *adapter, u32 addr, u8 *data);
-int __must_check rtw_read16(struct adapter *adapter, u32 addr, u16 *data);
-int __must_check rtw_read32(struct adapter *adapter, u32 addr, u32 *data);
-int rtw_read_port(struct adapter *adapter, struct recv_buf *precvbuf);
-void rtw_read_port_cancel(struct adapter *adapter);
-
-int rtw_write8(struct adapter *adapter, u32 addr, u8 val);
-int rtw_write16(struct adapter *adapter, u32 addr, u16 val);
-int rtw_write32(struct adapter *adapter, u32 addr, u32 val);
-int rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata);
-
-u32 rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
-void rtw_write_port_cancel(struct adapter *adapter);
-
-#endif /* _RTL8711_IO_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_ioctl.h b/drivers/staging/r8188eu/include/rtw_ioctl.h
deleted file mode 100644 (file)
index c704f30..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef _RTW_IOCTL_H_
-#define _RTW_IOCTL_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-
-extern struct iw_handler_def  rtw_handlers_def;
-extern int ui_pid[3];
-
-#endif /*  #ifndef __INC_CEINFO_ */
diff --git a/drivers/staging/r8188eu/include/rtw_ioctl_set.h b/drivers/staging/r8188eu/include/rtw_ioctl_set.h
deleted file mode 100644 (file)
index c3eb247..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_IOCTL_SET_H_
-#define __RTW_IOCTL_SET_H_
-
-#include "drv_types.h"
-
-typedef u8 NDIS_802_11_PMKID_VALUE[16];
-
-u8 rtw_set_802_11_authentication_mode(struct adapter *adapt,
-                                     enum ndis_802_11_auth_mode authmode);
-u8 rtw_set_802_11_bssid(struct adapter *adapter, u8 *bssid);
-u8 rtw_set_802_11_add_wep(struct adapter *adapter, struct ndis_802_11_wep *wep);
-void rtw_set_802_11_disassociate(struct adapter *adapter);
-u8 rtw_set_802_11_bssid_list_scan(struct adapter *adapter,
-                                 struct ndis_802_11_ssid *pssid,
-                                 int ssid_max_num);
-u8 rtw_set_802_11_infrastructure_mode(struct adapter *adapter,
-                                     enum ndis_802_11_network_infra type);
-u8 rtw_set_802_11_ssid(struct adapter *adapt, struct ndis_802_11_ssid *ssid);
-u16 rtw_get_cur_max_rate(struct adapter *adapter);
-int rtw_change_ifname(struct adapter *padapter, const char *ifname);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/rtw_iol.h b/drivers/staging/r8188eu/include/rtw_iol.h
deleted file mode 100644 (file)
index 099f5a0..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_IOL_H_
-#define __RTW_IOL_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-
-#define IOREG_CMD_END_LEN      4
-
-struct ioreg_cfg {
-       u8      length;
-       u8      cmd_id;
-       __le16  address;
-       __le32  data;
-       __le32  mask;
-};
-
-enum ioreg_cmd {
-       IOREG_CMD_LLT           = 0x01,
-       IOREG_CMD_REFUSE        = 0x02,
-       IOREG_CMD_EFUSE_PATH    = 0x03,
-       IOREG_CMD_WB_REG        = 0x04,
-       IOREG_CMD_WW_REG        = 0x05,
-       IOREG_CMD_WD_REG        = 0x06,
-       IOREG_CMD_W_RF          = 0x07,
-       IOREG_CMD_DELAY_US      = 0x10,
-       IOREG_CMD_DELAY_MS      = 0x11,
-       IOREG_CMD_END           = 0xFF,
-};
-
-struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter);
-int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds,
-                       u32 cmd_len);
-bool rtw_IOL_applied(struct adapter  *adapter);
-int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us);
-int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms);
-int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame);
-
-void read_efuse_from_txpktbuf(struct adapter *adapter, int bcnhead,
-                             u8 *content, u16 *size);
-
-int rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr,
-                         u8 value, u8 mask);
-int rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr,
-                         u16 value, u16 mask);
-int rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr,
-                         u32 value, u32 mask);
-int rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path,
-                          u16 addr, u32 value, u32 mask);
-
-u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame);
-
-#endif /* __RTW_IOL_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_led.h b/drivers/staging/r8188eu/include/rtw_led.h
deleted file mode 100644 (file)
index ea5f5ed..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_LED_H_
-#define __RTW_LED_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-
-enum LED_CTL_MODE {
-       LED_CTL_LINK = 2,
-       LED_CTL_NO_LINK = 3,
-       LED_CTL_TX = 4,
-       LED_CTL_RX = 5,
-       LED_CTL_SITE_SURVEY = 6,
-       LED_CTL_POWER_OFF = 7,
-       LED_CTL_START_TO_LINK = 8,
-       LED_CTL_START_WPS = 9,
-       LED_CTL_STOP_WPS = 10,
-       LED_CTL_STOP_WPS_FAIL = 12,
-};
-
-enum LED_STATE_871x {
-       RTW_LED_OFF = 2,
-       LED_BLINK_NORMAL = 3,
-       LED_BLINK_SLOWLY = 4,
-       LED_BLINK_SCAN = 6, /*  LED is blinking during scanning period,
-                            * the # of times to blink is depend on time
-                            * for scanning. */
-       LED_BLINK_TXRX = 9,
-       LED_BLINK_WPS = 10,     /*  LED is blinkg during WPS communication */
-       LED_BLINK_WPS_STOP = 11,
-};
-
-struct led_priv {
-       bool bRegUseLed;
-
-       enum LED_STATE_871x     CurrLedState; /*  Current LED state. */
-
-       bool bLedOn; /*  true if LED is ON, false if LED is OFF. */
-
-       bool bLedBlinkInProgress; /*  true if it is blinking, false o.w.. */
-
-       bool bLedWPSBlinkInProgress;
-
-       u32 BlinkTimes; /*  Number of times to toggle led state for blinking. */
-
-       bool bLedScanBlinkInProgress;
-       struct delayed_work blink_work;
-};
-
-void rtl8188eu_InitSwLeds(struct adapter *padapter);
-void rtl8188eu_DeInitSwLeds(struct adapter *padapter);
-
-void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction);
-
-#endif /* __RTW_LED_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h
deleted file mode 100644 (file)
index 3ff653f..0000000
+++ /dev/null
@@ -1,574 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_MLME_H_
-#define __RTW_MLME_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-#include "wlan_bssdef.h"
-
-#define        MAX_BSS_CNT     128
-#define   MAX_JOIN_TIMEOUT     6500
-
-/* Increase the scanning timeout because of increasing the SURVEY_TO value. */
-
-#define                SCANNING_TIMEOUT        8000
-
-#define        SCAN_INTERVAL   (30) /*  unit:2sec, 30*2=60sec */
-
-#define        SCANQUEUE_LIFETIME 20 /*  unit:sec */
-
-#define        WIFI_NULL_STATE                 0x00000000
-
-#define        WIFI_ASOC_STATE                 0x00000001      /* Under Linked state */
-#define        WIFI_REASOC_STATE               0x00000002
-#define        WIFI_SLEEP_STATE                0x00000004
-#define        WIFI_STATION_STATE              0x00000008
-
-#define        WIFI_AP_STATE                   0x00000010
-#define        WIFI_ADHOC_STATE                0x00000020
-#define WIFI_ADHOC_MASTER_STATE                0x00000040
-#define WIFI_UNDER_LINKING             0x00000080
-
-#define        WIFI_UNDER_WPS                  0x00000100
-#define        WIFI_STA_ALIVE_CHK_STATE        0x00000400
-#define        WIFI_SITE_MONITOR               0x00000800      /* to indicate the station is under site surveying */
-
-#define        WIFI_MP_STATE                   0x00010000
-#define        WIFI_MP_CTX_BACKGROUND          0x00020000      /*  in continuous tx background */
-#define        WIFI_MP_CTX_ST                  0x00040000      /*  in continuous tx with single-tone */
-#define        WIFI_MP_CTX_BACKGROUND_PENDING  0x00080000      /*  pending in continuous tx background due to out of skb */
-#define        WIFI_MP_CTX_CCK_HW              0x00100000      /*  in continuous tx */
-#define        WIFI_MP_CTX_CCK_CS              0x00200000      /*  in continuous tx with carrier suppression */
-#define WIFI_MP_LPBK_STATE             0x00400000
-
-#define _FW_UNDER_LINKING      WIFI_UNDER_LINKING
-#define _FW_LINKED                     WIFI_ASOC_STATE
-#define _FW_UNDER_SURVEY       WIFI_SITE_MONITOR
-
-enum dot11AuthAlgrthmNum {
-       dot11AuthAlgrthm_Open = 0,
-       dot11AuthAlgrthm_Shared,
-       dot11AuthAlgrthm_8021X,
-       dot11AuthAlgrthm_Auto,
-       dot11AuthAlgrthm_WAPI,
-       dot11AuthAlgrthm_MaxNum
-};
-
-/*  Scan type including active and passive scan. */
-enum rt_scan_type {
-       SCAN_PASSIVE,
-       SCAN_ACTIVE,
-       SCAN_MIX,
-};
-
-/*
-there are several "locks" in mlme_priv,
-since mlme_priv is a shared resource between many threads,
-like ISR/Call-Back functions, the OID handlers, and even timer functions.
-
-Each _queue has its own locks, already.
-Other items are protected by mlme_priv.lock.
-
-To avoid possible dead lock, any thread trying to modifiying mlme_priv
-SHALL not lock up more than one lock at a time!
-*/
-
-#define traffic_threshold      10
-#define        traffic_scan_period     500
-
-struct sitesurvey_ctrl {
-       u64     last_tx_pkts;
-       uint    last_rx_pkts;
-       int     traffic_busy;
-       struct timer_list sitesurvey_ctrl_timer;
-};
-
-struct rt_link_detect {
-       u32     NumTxOkInPeriod;
-       u32     NumRxOkInPeriod;
-       u32     NumRxUnicastOkInPeriod;
-       bool    bBusyTraffic;
-       bool    bTxBusyTraffic;
-       bool    bRxBusyTraffic;
-       bool    bHigherBusyTraffic; /*  For interrupt migration purpose. */
-       bool    bHigherBusyRxTraffic; /* We may disable Tx interrupt according
-                                      * to Rx traffic. */
-       bool    bHigherBusyTxTraffic; /* We may disable Tx interrupt according
-                                      * to Tx traffic. */
-};
-
-struct profile_info {
-       u8      ssidlen;
-       u8      ssid[WLAN_SSID_MAXLEN];
-       u8      peermac[ETH_ALEN];
-};
-
-struct tx_invite_req_info {
-       u8      token;
-       u8      benable;
-       u8      go_ssid[WLAN_SSID_MAXLEN];
-       u8      ssidlen;
-       u8      go_bssid[ETH_ALEN];
-       u8      peer_macaddr[ETH_ALEN];
-       u8      operating_ch;   /* This information will be set by using the
-                                * p2p_set op_ch=x */
-       u8      peer_ch;        /* The listen channel for peer P2P device */
-};
-
-struct tx_invite_resp_info {
-       u8      token;  /* Used to record the dialog token of p2p invitation
-                        * request frame. */
-};
-
-struct tx_provdisc_req_info {
-       u16     wps_config_method_request;      /* Used when sending the
-                                                * provisioning request frame*/
-       u16     peer_channel_num[2];            /* The channel number which the
-                                                * receiver stands. */
-       struct ndis_802_11_ssid ssid;
-       u8      peerDevAddr[ETH_ALEN];          /* Peer device address */
-       u8      peerIFAddr[ETH_ALEN];           /* Peer interface address */
-       u8      benable;                        /* This provision discovery
-                                                * request frame is trigger
-                                                * to send or not */
-};
-
-/* When peer device issue prov_disc_req first, we should store the following
- * information */
-/* The UI must know this information to know which config method the
- * remote p2p device needs. */
-struct rx_provdisc_req_info {
-       u8      peerDevAddr[ETH_ALEN];          /* Peer device address */
-       u8      strconfig_method_desc_of_prov_disc_req[4];      /* description
-                       * for the config method located in the provisioning
-                       * discovery request frame. */
-};
-
-struct tx_nego_req_info {
-       u16     peer_channel_num[2];    /* The channel number. */
-       u8      peerDevAddr[ETH_ALEN];  /* Peer device address */
-       u8      benable;                /* This negotiation request frame is
-                                        * trigger to send or not */
-};
-
-struct group_id_info {
-       u8      go_device_addr[ETH_ALEN];       /* The GO's device address of
-                                                * this P2P group */
-       u8      ssid[WLAN_SSID_MAXLEN]; /* The SSID of this P2P group */
-};
-
-struct scan_limit_info {
-       u8      scan_op_ch_only;        /* When this flag is set, the driver
-                                        * should only scan the op. channel */
-       u8      operation_ch[2];        /* Store the op. chan of invitation */
-};
-
-struct wifidirect_info {
-       struct adapter *padapter;
-       struct timer_list find_phase_timer;
-       struct timer_list restore_p2p_state_timer;
-
-       /* Used to do the scanning. After confirming the peer is availalble,
-        * the driver transmits the P2P frame to peer. */
-       struct timer_list pre_tx_scan_timer;
-       struct timer_list reset_ch_sitesurvey;
-       struct timer_list reset_ch_sitesurvey2; /* Just for resetting the scan
-                                        * limit function by using p2p nego */
-       struct tx_provdisc_req_info     tx_prov_disc_info;
-       struct rx_provdisc_req_info rx_prov_disc_info;
-       struct tx_invite_req_info       invitereq_info;
-       /* Store the profile information of persistent group */
-       struct profile_info profileinfo[P2P_MAX_PERSISTENT_GROUP_NUM];
-       struct tx_invite_resp_info      inviteresp_info;
-       struct tx_nego_req_info nego_req_info;
-       /* Store the group id info when doing the group negot handshake. */
-       struct group_id_info groupid_info;
-       /* Used for get the limit scan channel from the Invitation procedure */
-       struct scan_limit_info rx_invitereq_info;
-       /* Used for get the limit scan chan from the P2P negotiation handshake*/
-       struct scan_limit_info p2p_info;
-       enum P2P_ROLE role;
-       enum P2P_STATE pre_p2p_state;
-       enum P2P_STATE p2p_state;
-       /* The device address should be the mac address of this device. */
-       u8 device_addr[ETH_ALEN];
-       u8 interface_addr[ETH_ALEN];
-       u8 social_chan[4];
-       u8 listen_channel;
-       u8 operating_channel;
-       u8 listen_dwell;        /* This value should be between 1 and 3 */
-       u8 support_rate[8];
-       u8 p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN];
-       u8 intent;      /* should only include the intent value. */
-       u8 p2p_peer_interface_addr[ETH_ALEN];
-       u8 p2p_peer_device_addr[ETH_ALEN];
-       u8 peer_intent; /* Included the intent value and tie breaker value. */
-       /* Device name for displaying on searching device screen */
-       u8 device_name[WPS_MAX_DEVICE_NAME_LEN];
-       u8 device_name_len;
-       u8 profileindex; /* Used to point to the index of profileinfo array */
-       u8 peer_operating_ch;
-       u8 find_phase_state_exchange_cnt;
-       /* The device password ID for group negotiation */
-       u16 device_password_id_for_nego;
-       u8 negotiation_dialog_token;
-       /* SSID information for group negotitation */
-       u8 nego_ssid[WLAN_SSID_MAXLEN];
-       u8 nego_ssidlen;
-       u8 p2p_group_ssid[WLAN_SSID_MAXLEN];
-       u8 p2p_group_ssid_len;
-       /* Flag to know if the persistent function should be supported or not.*/
-       u8 persistent_supported;
-       /* In the Sigma test, the Sigma will provide this enable from the
-        * sta_set_p2p CAPI. */
-       /*      0: disable */
-       /*      1: enable */
-       u8 session_available;   /* Flag to set the WFD session available to
-                                * enable or disable "by Sigma" */
-       /* In the Sigma test, the Sigma will disable the session available
-        * by using the sta_preset CAPI. */
-       /*      0: disable */
-       /*      1: enable */
-
-       /* This field will store the WPS value (PIN value or PBC) that UI had
-        * got from the user. */
-       enum    P2P_WPSINFO ui_got_wps_info;
-       u16 supported_wps_cm;   /* This field describes the WPS config method
-                                * which this driver supported. */
-                               /* The value should be the combination of config
-                                * method defined in page104 of WPS v2.0 spec.*/
-       /* This field will contain the length of body of P2P Channel List
-        * attribute of group negotiation response frame. */
-       uint channel_list_attr_len;
-       /* This field will contain the body of P2P Channel List attribute of
-        * group negotitation response frame. */
-       /* We will use the channel_cnt and channel_list fields when constructing
-        * the group negotiation confirm frame. */
-       u8 channel_list_attr[100];
-       enum P2P_PS_MODE p2p_ps_mode; /*  indicate p2p ps mode */
-       enum P2P_PS_STATE p2p_ps_state; /*  indicate p2p ps state */
-       u8 noa_index; /*  Identifies and instance of Notice of Absence timing. */
-       u8 ctwindow; /*  Client traffic window. A period of time in TU after TBTT. */
-       u8 opp_ps; /*  opportunistic power save. */
-       u8 noa_num; /*  number of NoA descriptor in P2P IE. */
-       u8 noa_count[P2P_MAX_NOA_NUM]; /*  Count for owner, Type of client. */
-       /* Max duration for owner, preferred or min acceptable duration for
-        * client. */
-       u32 noa_duration[P2P_MAX_NOA_NUM];
-       /* Length of interval for owner, preferred or max acceptable interval
-        * of client. */
-       u32 noa_interval[P2P_MAX_NOA_NUM];
-       /* schedule expressed in terms of the lower 4 bytes of the TSF timer. */
-       u32 noa_start_time[P2P_MAX_NOA_NUM];
-};
-
-struct tdls_ss_record {        /* signal strength record */
-       u8 macaddr[ETH_ALEN];
-       u8 RxPWDBAll;
-       u8 is_tdls_sta; /*  true: direct link sta, false: else */
-};
-
-struct tdls_info {
-       u8 ap_prohibited;
-       uint setup_state;
-       u8 sta_cnt;
-       u8 sta_maximum; /*  1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */
-       struct tdls_ss_record   ss_record;
-       u8 macid_index; /* macid entry that is ready to write */
-       u8 clear_cam;   /* cam entry that is trying to clear, using it in direct link teardown */
-       u8 ch_sensing;
-       u8 cur_channel;
-       u8 candidate_ch;
-       u8 collect_pkt_num[MAX_CHANNEL_NUM];
-       spinlock_t cmd_lock;
-       spinlock_t hdl_lock;
-       u8 watchdog_count;
-       u8 dev_discovered;              /* WFD_TDLS: for sigma test */
-       u8 enable;
-};
-
-struct qos_priv {
-       /* bit mask option: u-apsd,
-        * s-apsd, ts, block ack... */
-       unsigned int qos_option;
-};
-
-struct mlme_priv {
-       spinlock_t lock;
-       int fw_state;   /* shall we protect this variable? maybe not necessarily... */
-       bool bScanInProcess;
-       u8 to_join; /* flag */
-       u8 to_roaming; /*  roaming trying times */
-
-       u8 *nic_hdl;
-
-       struct list_head *pscanned;
-       struct __queue free_bss_pool;
-       struct __queue scanned_queue;
-       u8 *free_bss_buf;
-       u8      key_mask; /* use to restore wep key after hal_init */
-       u32     num_of_scanned;
-
-       struct ndis_802_11_ssid assoc_ssid;
-       u8      assoc_bssid[6];
-
-       struct wlan_network     cur_network;
-       struct wlan_network *cur_network_scanned;
-
-       u32     scan_interval;
-
-       struct timer_list assoc_timer;
-
-       uint assoc_by_bssid;
-       uint assoc_by_rssi;
-
-       struct timer_list scan_to_timer; /*  driver itself handles scan_timeout status. */
-       u32 scan_start_time; /*  used to evaluate the time spent in scanning */
-
-       struct qos_priv qospriv;
-
-       /* Number of non-HT AP/stations */
-       int num_sta_no_ht;
-
-       /* Number of HT AP/stations 20 MHz */
-       /* int num_sta_ht_20mhz; */
-
-       int num_FortyMHzIntolerant;
-       struct ht_priv  htpriv;
-       struct rt_link_detect LinkDetectInfo;
-       struct timer_list dynamic_chk_timer; /* dynamic/periodic check timer */
-
-       u8      acm_mask; /*  for wmm acm mask */
-       u8      ChannelPlan;
-       enum rt_scan_type scan_mode; /*  active: 1, passive: 0 */
-
-       /* u8 probereq_wpsie[MAX_WPS_IE_LEN];added in probe req */
-       /* int probereq_wpsie_len; */
-       u8 *wps_probe_req_ie;
-       u32 wps_probe_req_ie_len;
-
-       u8 *assoc_req;
-       u32 assoc_req_len;
-
-       /* Number of associated Non-ERP stations (i.e., stations using 802.11b
-        * in 802.11g BSS) */
-       int num_sta_non_erp;
-
-       /* Number of associated stations that do not support Short Slot Time */
-       int num_sta_no_short_slot_time;
-
-       /* Number of associated stations that do not support Short Preamble */
-       int num_sta_no_short_preamble;
-
-       int olbc; /* Overlapping Legacy BSS Condition */
-
-       /* Number of HT assoc sta that do not support greenfield */
-       int num_sta_ht_no_gf;
-
-       /* Number of associated non-HT stations */
-       /* int num_sta_no_ht; */
-
-       /* Number of HT associated stations 20 MHz */
-       int num_sta_ht_20mhz;
-
-       /* Overlapping BSS information */
-       int olbc_ht;
-
-       u16 ht_op_mode;
-
-       u8 *wps_beacon_ie;
-       /* u8 *wps_probe_req_ie; */
-       u8 *wps_probe_resp_ie;
-       u8 *wps_assoc_resp_ie;
-
-       u32 wps_beacon_ie_len;
-       u32 wps_probe_resp_ie_len;
-       u32 wps_assoc_resp_ie_len;
-
-       u8 *p2p_beacon_ie;
-       u8 *p2p_probe_req_ie;
-       u8 *p2p_probe_resp_ie;
-       u8 *p2p_go_probe_resp_ie; /* for GO */
-       u8 *p2p_assoc_req_ie;
-
-       u32 p2p_beacon_ie_len;
-       u32 p2p_probe_req_ie_len;
-       u32 p2p_probe_resp_ie_len;
-       u32 p2p_go_probe_resp_ie_len; /* for GO */
-       u32 p2p_assoc_req_ie_len;
-       spinlock_t bcn_update_lock;
-       u8              update_bcn;
-};
-
-int hostapd_mode_init(struct adapter *padapter);
-void hostapd_mode_unload(struct adapter *padapter);
-
-extern unsigned char WPA_TKIP_CIPHER[4];
-extern unsigned char RSN_TKIP_CIPHER[4];
-extern unsigned char REALTEK_96B_IE[];
-extern unsigned char   MCS_rate_2R[16];
-extern unsigned char   MCS_rate_1R[16];
-
-void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf);
-void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf);
-void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf);
-void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf);
-void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf);
-void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf);
-void indicate_wx_scan_complete_event(struct adapter *padapter);
-void rtw_indicate_wx_assoc_event(struct adapter *padapter);
-void rtw_indicate_wx_disassoc_event(struct adapter *padapter);
-int event_thread(void *context);
-void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall);
-int rtw_init_mlme_priv(struct adapter *adapter);
-void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv);
-int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
-int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv,
-               int keyid, u8 set_tx);
-int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
-
-static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
-{      /* if sta_mode:pmlmepriv->cur_network.network.MacAddress=> bssid */
-       /*  if adhoc_mode:pmlmepriv->cur_network.network.MacAddress=> ibss mac address */
-       return pmlmepriv->cur_network.network.MacAddress;
-}
-
-static inline bool check_fwstate(struct mlme_priv *pmlmepriv, int state)
-{
-       if (pmlmepriv->fw_state & state)
-               return true;
-
-       return false;
-}
-
-/*
- * No Limit on the calling context,
- * therefore set it to be the critical section...
- *
- * ### NOTE:#### (!!!!)
- * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
- */
-static inline void set_fwstate(struct mlme_priv *pmlmepriv, int state)
-{
-       pmlmepriv->fw_state |= state;
-       /* FOR HW integration */
-       if (_FW_UNDER_SURVEY == state)
-               pmlmepriv->bScanInProcess = true;
-}
-
-static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state)
-{
-       pmlmepriv->fw_state &= ~state;
-       /* FOR HW integration */
-       if (_FW_UNDER_SURVEY == state)
-               pmlmepriv->bScanInProcess = false;
-}
-
-/*
- * No Limit on the calling context,
- * therefore set it to be the critical section...
- */
-static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state)
-{
-       spin_lock_bh(&pmlmepriv->lock);
-       if (check_fwstate(pmlmepriv, state))
-               pmlmepriv->fw_state ^= state;
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-
-static inline void clr_fwstate_ex(struct mlme_priv *pmlmepriv, int state)
-{
-       spin_lock_bh(&pmlmepriv->lock);
-       _clr_fwstate_(pmlmepriv, state);
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-
-static inline void up_scanned_network(struct mlme_priv *pmlmepriv)
-{
-       spin_lock_bh(&pmlmepriv->lock);
-       pmlmepriv->num_of_scanned++;
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-
-static inline void down_scanned_network(struct mlme_priv *pmlmepriv)
-{
-       spin_lock_bh(&pmlmepriv->lock);
-       pmlmepriv->num_of_scanned--;
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-
-static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, int val)
-{
-       spin_lock_bh(&pmlmepriv->lock);
-       pmlmepriv->num_of_scanned = val;
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-
-u16 rtw_get_capability(struct wlan_bssid_ex *bss);
-void rtw_update_scanned_network(struct adapter *adapter,
-                               struct wlan_bssid_ex *target);
-void rtw_disconnect_hdl_under_linked(struct adapter *adapter,
-                                    struct sta_info *psta, u8 free_assoc);
-void rtw_generate_random_ibss(u8 *pibss);
-struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr);
-struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue);
-
-void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue);
-void rtw_indicate_disconnect(struct adapter *adapter);
-void rtw_indicate_connect(struct adapter *adapter);
-void rtw_indicate_scan_done(struct adapter *padapter);
-
-int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie,
-                       uint in_len);
-int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie,
-                       uint in_len, uint initial_out_len);
-void rtw_init_registrypriv_dev_network(struct adapter *adapter);
-
-void rtw_update_registrypriv_dev_network(struct adapter *adapter);
-
-void _rtw_join_timeout_handler(struct adapter *adapter);
-void rtw_scan_timeout_handler(struct adapter *adapter);
-
- void rtw_dynamic_check_timer_handlder(struct adapter *adapter);
-
-void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
-
-struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv);
-
-void _rtw_free_network(struct mlme_priv *pmlmepriv,
-                      struct wlan_network *pnetwork, u8 isfreeall);
-
-struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr);
-
-void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall);
-
-int rtw_if_up(struct adapter *padapter);
-
-u8 *rtw_get_capability_from_ie(u8 *ie);
-u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
-
-void rtw_joinbss_reset(struct adapter *padapter);
-
-unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie,
-                                  u8 *out_ie, uint in_len, uint *pout_len);
-void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len);
-void rtw_issue_addbareq_cmd(struct adapter *padapter,
-                           struct xmit_frame *pxmitframe);
-
-int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork);
-int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst);
-
-void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network);
-void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network);
-void rtw_set_roaming(struct adapter *adapter, u8 to_roaming);
-u8 rtw_to_roaming(struct adapter *adapter);
-
-void rtw_set_max_rpt_macid(struct adapter *adapter, u8 macid);
-void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta,
-                             u32 mstatus);
-
-u8 rtw_current_antenna(struct adapter *adapter);
-
-#endif /* __RTL871X_MLME_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
deleted file mode 100644 (file)
index 589de7c..0000000
+++ /dev/null
@@ -1,753 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_MLME_EXT_H_
-#define __RTW_MLME_EXT_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-#include "wlan_bssdef.h"
-
-/*     Commented by Albert 20101105 */
-/*     Increase the SURVEY_TO value from 100 to 150  ( 100ms to 150ms ) */
-/*     The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */
-/*     So, this driver tried to extend the dwell time for each scanning channel. */
-/*     This will increase the chance to receive the probe response from SoftAP. */
-
-#define SURVEY_TO              (100)
-#define REAUTH_TO              (300) /* 50) */
-#define REASSOC_TO             (300) /* 50) */
-/* define DISCONNECT_TO        (3000) */
-#define ADDBA_TO                       (2000)
-
-#define LINKED_TO (1) /* unit:2 sec, 1x2=2 sec */
-
-#define REAUTH_LIMIT   (4)
-#define REASSOC_LIMIT  (4)
-
-#define        DYNAMIC_FUNC_DISABLE                    (0x0)
-
-/*  ====== ODM_ABILITY_E ======== */
-/*  BB ODM section BIT 0-15 */
-#define        DYNAMIC_BB_DIG                          BIT(0)
-
-#define                DYNAMIC_ALL_FUNC_ENABLE         0xFFFFFFF
-
-#define _HW_STATE_NOLINK_              0x00
-#define _HW_STATE_ADHOC_               0x01
-#define _HW_STATE_STATION_     0x02
-#define _HW_STATE_AP_                  0x03
-
-#define                _1M_RATE_       0
-#define                _2M_RATE_       1
-#define                _5M_RATE_       2
-#define                _11M_RATE_      3
-#define                _6M_RATE_       4
-#define                _9M_RATE_       5
-#define                _12M_RATE_      6
-#define                _18M_RATE_      7
-#define                _24M_RATE_      8
-#define                _36M_RATE_      9
-#define                _48M_RATE_      10
-#define                _54M_RATE_      11
-
-extern unsigned char RTW_WPA_OUI[];
-extern unsigned char WMM_OUI[];
-extern unsigned char WPS_OUI[];
-extern unsigned char WFD_OUI[];
-extern unsigned char P2P_OUI[];
-
-extern unsigned char WMM_INFO_OUI[];
-extern unsigned char WMM_PARA_OUI[];
-
-/*  Channel Plan Type. */
-/*  Note: */
-/*     We just add new channel plan when the new channel plan is different
- *      from any of the following channel plan. */
-/*     If you just want to customize the actions(scan period or join actions)
- *      about one of the channel plan, */
-/*     customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */
-enum RT_CHANNEL_DOMAIN {
-       /*  old channel plan mapping =====  */
-       RT_CHANNEL_DOMAIN_FCC = 0x00,
-       RT_CHANNEL_DOMAIN_IC = 0x01,
-       RT_CHANNEL_DOMAIN_ETSI = 0x02,
-       RT_CHANNEL_DOMAIN_SPAIN = 0x03,
-       RT_CHANNEL_DOMAIN_FRANCE = 0x04,
-       RT_CHANNEL_DOMAIN_MKK = 0x05,
-       RT_CHANNEL_DOMAIN_MKK1 = 0x06,
-       RT_CHANNEL_DOMAIN_ISRAEL = 0x07,
-       RT_CHANNEL_DOMAIN_TELEC = 0x08,
-       RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 0x09,
-       RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 0x0A,
-       RT_CHANNEL_DOMAIN_TAIWAN = 0x0B,
-       RT_CHANNEL_DOMAIN_CHINA = 0x0C,
-       RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO = 0x0D,
-       RT_CHANNEL_DOMAIN_KOREA = 0x0E,
-       RT_CHANNEL_DOMAIN_TURKEY = 0x0F,
-       RT_CHANNEL_DOMAIN_JAPAN = 0x10,
-       RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11,
-       RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12,
-       RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14,
-
-       /*  new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */
-       RT_CHANNEL_DOMAIN_WORLD_NULL = 0x20,
-       RT_CHANNEL_DOMAIN_ETSI1_NULL = 0x21,
-       RT_CHANNEL_DOMAIN_FCC1_NULL = 0x22,
-       RT_CHANNEL_DOMAIN_MKK1_NULL = 0x23,
-       RT_CHANNEL_DOMAIN_ETSI2_NULL = 0x24,
-       RT_CHANNEL_DOMAIN_FCC1_FCC1 = 0x25,
-       RT_CHANNEL_DOMAIN_WORLD_ETSI1 = 0x26,
-       RT_CHANNEL_DOMAIN_MKK1_MKK1 = 0x27,
-       RT_CHANNEL_DOMAIN_WORLD_KCC1 = 0x28,
-       RT_CHANNEL_DOMAIN_WORLD_FCC2 = 0x29,
-       RT_CHANNEL_DOMAIN_WORLD_FCC3 = 0x30,
-       RT_CHANNEL_DOMAIN_WORLD_FCC4 = 0x31,
-       RT_CHANNEL_DOMAIN_WORLD_FCC5 = 0x32,
-       RT_CHANNEL_DOMAIN_WORLD_FCC6 = 0x33,
-       RT_CHANNEL_DOMAIN_FCC1_FCC7 = 0x34,
-       RT_CHANNEL_DOMAIN_WORLD_ETSI2 = 0x35,
-       RT_CHANNEL_DOMAIN_WORLD_ETSI3 = 0x36,
-       RT_CHANNEL_DOMAIN_MKK1_MKK2 = 0x37,
-       RT_CHANNEL_DOMAIN_MKK1_MKK3 = 0x38,
-       RT_CHANNEL_DOMAIN_FCC1_NCC1 = 0x39,
-       RT_CHANNEL_DOMAIN_FCC1_NCC2 = 0x40,
-       RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G = 0x41,
-       /*  Add new channel plan above this line=============== */
-       RT_CHANNEL_DOMAIN_MAX,
-       RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F,
-};
-
-enum RT_CHANNEL_DOMAIN_2G {
-       RT_CHANNEL_DOMAIN_2G_WORLD = 0x00,              /* Worldwide 13 */
-       RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01,              /* Europe */
-       RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02,               /* US */
-       RT_CHANNEL_DOMAIN_2G_MKK1 = 0x03,               /* Japan */
-       RT_CHANNEL_DOMAIN_2G_ETSI2 = 0x04,              /* France */
-       RT_CHANNEL_DOMAIN_2G_NULL = 0x05,
-       /*  Add new channel plan above this line=============== */
-       RT_CHANNEL_DOMAIN_2G_MAX,
-};
-
-#define rtw_is_channel_plan_valid(chplan)                      \
-       (chplan < RT_CHANNEL_DOMAIN_MAX ||                      \
-        chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
-
-struct rt_channel_plan {
-       unsigned char   Channel[MAX_CHANNEL_NUM];
-       unsigned char   Len;
-};
-
-struct rt_channel_plan_map {
-       unsigned char   Index2G;
-};
-
-enum Associated_AP {
-       atherosAP       = 0,
-       broadcomAP      = 1,
-       ciscoAP         = 2,
-       marvellAP       = 3,
-       ralinkAP        = 4,
-       realtekAP       = 5,
-       airgocapAP      = 6,
-       unknownAP       = 7,
-       maxAP,
-};
-
-enum HT_IOT_PEER {
-       HT_IOT_PEER_UNKNOWN             = 0,
-       HT_IOT_PEER_REALTEK             = 1,
-       HT_IOT_PEER_REALTEK_92SE        = 2,
-       HT_IOT_PEER_BROADCOM            = 3,
-       HT_IOT_PEER_RALINK              = 4,
-       HT_IOT_PEER_ATHEROS             = 5,
-       HT_IOT_PEER_CISCO               = 6,
-       HT_IOT_PEER_MERU                = 7,
-       HT_IOT_PEER_MARVELL             = 8,
-       HT_IOT_PEER_REALTEK_SOFTAP      = 9,/*  peer is RealTek SOFT_AP */
-       HT_IOT_PEER_SELF_SOFTAP         = 10, /*  Self is SoftAP */
-       HT_IOT_PEER_AIRGO               = 11,
-       HT_IOT_PEER_INTEL               = 12,
-       HT_IOT_PEER_RTK_APCLIENT        = 13,
-       HT_IOT_PEER_REALTEK_81XX        = 14,
-       HT_IOT_PEER_REALTEK_WOW         = 15,
-       HT_IOT_PEER_TENDA               = 16,
-       HT_IOT_PEER_MAX                 = 17
-};
-
-enum SCAN_STATE {
-       SCAN_DISABLE = 0,
-       SCAN_START = 1,
-       SCAN_TXNULL = 2,
-       SCAN_PROCESS = 3,
-       SCAN_COMPLETE = 4,
-       SCAN_STATE_MAX,
-};
-
-typedef void (*mlme_handler)(struct adapter *adapt, struct recv_frame *frame);
-
-struct ss_res {
-       int     state;
-       int     bss_cnt;
-       int     channel_idx;
-       int     scan_mode;
-       u8 ssid_num;
-       u8 ch_num;
-       struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
-       struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
-};
-
-/* define AP_MODE                              0x0C */
-/* define STATION_MODE 0x08 */
-/* define AD_HOC_MODE          0x04 */
-/* define NO_LINK_MODE 0x00 */
-
-#define WIFI_FW_NULL_STATE             _HW_STATE_NOLINK_
-#define        WIFI_FW_STATION_STATE           _HW_STATE_STATION_
-#define        WIFI_FW_AP_STATE                _HW_STATE_AP_
-#define        WIFI_FW_ADHOC_STATE             _HW_STATE_ADHOC_
-
-#define        WIFI_FW_AUTH_NULL               0x00000100
-#define        WIFI_FW_AUTH_STATE              0x00000200
-#define        WIFI_FW_AUTH_SUCCESS            0x00000400
-
-#define        WIFI_FW_ASSOC_STATE             0x00002000
-#define        WIFI_FW_ASSOC_SUCCESS           0x00004000
-
-#define        WIFI_FW_LINKING_STATE           (WIFI_FW_AUTH_NULL |            \
-                                       WIFI_FW_AUTH_STATE |            \
-                                       WIFI_FW_AUTH_SUCCESS |          \
-                                       WIFI_FW_ASSOC_STATE)
-
-struct FW_Sta_Info {
-       struct sta_info *psta;
-       u32     status;
-       u32     rx_pkt;
-       u32     retry;
-       unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
-};
-
-/*
- * Usage:
- * When one iface acted as AP mode and the other iface is STA mode and scanning,
- * it should switch back to AP's operating channel periodically.
- * Parameters info:
- * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to
- * AP's operating channel for
- * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds.
- * Example:
- * For chip supports 2.4G + 5GHz and AP mode is operating in channel 1,
- * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MS is 3 and SURVEY_TO is 100.
- * When it's STA mode gets set_scan command,
- * it would
- * 1. Doing the scan on channel 1.2.3.4.5.6.7.8
- * 2. Back to channel 1 for 300 milliseconds
- * 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52
- * 4. Back to channel 1 for 300 milliseconds
- * 5. ... and so on, till survey done.
- */
-
-struct mlme_ext_info {
-       u32     state;
-       u32     reauth_count;
-       u32     reassoc_count;
-       u32     link_count;
-       u32     auth_seq;
-       u32     auth_algo;      /*  802.11 auth, could be open, shared, auto */
-       u32     authModeToggle;
-       u32     enc_algo;/* encrypt algorithm; */
-       u32     key_index;      /*  this is only valid for legacy wep,
-                                *  0~3 for key id. */
-       u32     iv;
-       u8      chg_txt[128];
-       u16     aid;
-       u16     bcn_interval;
-       u16     capability;
-       u8      assoc_AP_vendor;
-       u8      slotTime;
-       u8      preamble_mode;
-       u8      WMM_enable;
-       u8      ERP_enable;
-       u8      ERP_IE;
-       u8      HT_enable;
-       u8      HT_caps_enable;
-       u8      HT_info_enable;
-       u8      HT_protection;
-       u8      turboMode_cts2self;
-       u8      turboMode_rtsen;
-       u8      SM_PS;
-       u8      agg_enable_bitmap;
-       u8      ADDBA_retry_count;
-       u8      candidate_tid_bitmap;
-       u8      dialogToken;
-       /*  Accept ADDBA Request */
-       bool bAcceptAddbaReq;
-       u8      bwmode_updated;
-       u8      hidden_ssid_mode;
-
-       struct WMM_para_element WMM_param;
-       struct HT_caps_element  HT_caps;
-       struct HT_info_element  HT_info;
-       struct wlan_bssid_ex    network;/* join network or bss_network,
-                                        * if in ap mode, it is the same
-                                        * as cur_network.network */
-       struct FW_Sta_Info      FW_sta_info[NUM_STA];
-};
-
-/*  The channel information about this channel including joining,
- *  scanning, and power constraints. */
-struct rt_channel_info {
-       u8      ChannelNum;     /*  The channel number. */
-       enum rt_scan_type ScanType;     /*  Scan type such as passive
-                                        *  or active scan. */
-       u32     rx_count;
-};
-
-int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch);
-
-/*  P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */
-#define P2P_MAX_REG_CLASSES 10
-
-/*  P2P_MAX_REG_CLASS_CHANNELS - Maximum number of chan per regulatory class */
-#define P2P_MAX_REG_CLASS_CHANNELS 20
-
-/*   struct p2p_channels - List of supported channels */
-struct p2p_channels {
-       /*  struct p2p_reg_class - Supported regulatory class */
-       struct p2p_reg_class {
-               /*  reg_class - Regulatory class (IEEE 802.11-2007, Annex J) */
-               u8 reg_class;
-
-               /*  channel - Supported channels */
-               u8 channel[P2P_MAX_REG_CLASS_CHANNELS];
-
-               /*  channels - Number of channel entries in use */
-               size_t channels;
-       } reg_class[P2P_MAX_REG_CLASSES];
-
-       /*  reg_classes - Number of reg_class entries in use */
-       size_t reg_classes;
-};
-
-struct p2p_oper_class_map {
-       enum hw_mode {IEEE80211G} mode;
-       u8 op_class;
-       u8 min_chan;
-       u8 max_chan;
-       u8 inc;
-       enum {BW20, BW40PLUS, BW40MINUS} bw;
-};
-
-struct mlme_ext_priv {
-       struct adapter  *padapter;
-       u8      mlmeext_init;
-       atomic_t event_seq;
-       u16     mgnt_seq;
-
-       unsigned char   cur_channel;
-       unsigned char   cur_bwmode;
-       unsigned char   cur_ch_offset;/* PRIME_CHNL_OFFSET */
-       unsigned char   cur_wireless_mode;      /*  NETWORK_TYPE */
-
-       unsigned char   oper_channel; /* saved chan info when call
-                                      * set_channel_bw */
-       unsigned char   oper_bwmode;
-       unsigned char   oper_ch_offset;/* PRIME_CHNL_OFFSET */
-
-       unsigned char   max_chan_nums;
-       struct rt_channel_info channel_set[MAX_CHANNEL_NUM];
-       struct p2p_channels channel_list;
-       unsigned char   basicrate[NumRates];
-       unsigned char   datarate[NumRates];
-
-       struct ss_res           sitesurvey_res;
-       struct mlme_ext_info    mlmext_info;/* for sta/adhoc mode, including
-                                            * current scan/connecting/connected
-                                            * related info. For ap mode,
-                                            * network includes ap's cap_info*/
-       struct timer_list survey_timer;
-       struct timer_list link_timer;
-       u16     chan_scan_time;
-
-       u8      scan_abort;
-       u8      tx_rate; /*  TXRATE when USERATE is set. */
-
-       u32     retry; /* retry for issue probereq */
-
-       u64 TSFValue;
-
-       unsigned char bstart_bss;
-       u8 update_channel_plan_by_ap_done;
-       /* recv_decache check for Action_public frame */
-       u8 action_public_dialog_token;
-       u16      action_public_rxseq;
-       u8 active_keep_alive_check;
-};
-
-void init_mlme_ext_priv(struct adapter *adapter);
-int init_hw_mlme_ext(struct adapter *padapter);
-void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext);
-struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv);
-
-unsigned char networktype_to_raid(unsigned char network_type);
-u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int len);
-void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *len);
-
-void Save_DM_Func_Flag(struct adapter *padapter);
-void Restore_DM_Func_Flag(struct adapter *padapter);
-
-void Set_MSR(struct adapter *padapter, u8 type);
-
-u8 rtw_get_oper_ch(struct adapter *adapter);
-void rtw_set_oper_ch(struct adapter *adapter, u8 ch);
-void rtw_set_oper_bw(struct adapter *adapter, u8 bw);
-void rtw_set_oper_choffset(struct adapter *adapter, u8 offset);
-
-void set_channel_bwmode(struct adapter *padapter, unsigned char channel,
-                       unsigned char channel_offset, unsigned short bwmode);
-void SelectChannel(struct adapter *padapter, unsigned char channel);
-void SetBWMode(struct adapter *padapter, unsigned short bwmode,
-              unsigned char channel_offset);
-
-unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval);
-
-void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key);
-void clear_cam_entry(struct adapter *padapter, u8 entry);
-
-void invalidate_cam_all(struct adapter *padapter);
-
-int allocate_fw_sta_entry(struct adapter *padapter);
-void flush_all_cam_entry(struct adapter *padapter);
-
-void rtw_mlme_under_site_survey(struct adapter *adapter);
-void rtw_mlme_site_survey_done(struct adapter *adapter);
-
-void site_survey(struct adapter *padapter);
-u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame,
-                   struct wlan_bssid_ex *bssid);
-void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
-                   struct adapter *adapter, bool update_ie);
-
-u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork);
-u16 get_beacon_interval(struct wlan_bssid_ex *bss);
-
-bool r8188eu_is_client_associated_to_ap(struct adapter *padapter);
-bool r8188eu_is_client_associated_to_ibss(struct adapter *padapter);
-bool r8188eu_is_ibss_empty(struct adapter *padapter);
-
-unsigned char check_assoc_AP(u8 *pframe, uint len);
-
-int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
-void WMMOnAssocRsp(struct adapter *padapter);
-
-void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
-void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
-void HTOnAssocRsp(struct adapter *padapter);
-
-void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
-void VCS_update(struct adapter *padapter, struct sta_info *psta);
-
-void update_beacon_info(struct adapter *padapter, u8 *ie_ptr, uint ie_len, struct sta_info *psta);
-int rtw_check_bcn_info(struct adapter  *Adapter, u8 *pframe, u32 packet_len);
-void update_IOT_info(struct adapter *padapter);
-void update_capinfo(struct adapter *adapter, u16 updatecap);
-void update_wireless_mode(struct adapter *padapter);
-void rtw_set_basic_rate(struct adapter *adapter, u8 *rates);
-void update_tx_basic_rate(struct adapter *padapter, u8 modulation);
-void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id);
-int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie,
-                           uint var_ie_len, int cam_idx);
-
-/* for sta/adhoc mode */
-void update_sta_info(struct adapter *padapter, struct sta_info *psta);
-unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz);
-unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz);
-unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps);
-void Update_RA_Entry(struct adapter *padapter, u32 mac_id);
-void set_sta_rate(struct adapter *padapter, struct sta_info *psta);
-
-void receive_disconnect(struct adapter *padapter, unsigned char *macaddr, unsigned short reason);
-
-unsigned char get_highest_rate_idx(u32 mask);
-int support_short_GI(struct adapter *padapter, struct HT_caps_element *caps);
-bool is_ap_in_tkip(struct adapter *padapter);
-
-void report_join_res(struct adapter *padapter, int res);
-void report_survey_event(struct adapter *padapter, struct recv_frame *precv_frame);
-void report_surveydone_event(struct adapter *padapter);
-void report_del_sta_event(struct adapter *padapter,
-                         unsigned char *addr, unsigned short reason);
-void report_add_sta_event(struct adapter *padapter, unsigned char *addr,
-                         int cam_idx);
-
-void beacon_timing_control(struct adapter *padapter);
-u8 set_tx_beacon_cmd(struct adapter *padapter);
-unsigned int setup_beacon_frame(struct adapter *padapter,
-                               unsigned char *beacon_frame);
-void update_mgnt_tx_rate(struct adapter *padapter, u8 rate);
-void update_mgntframe_attrib(struct adapter *padapter,
-                            struct pkt_attrib *pattrib);
-void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe);
-s32 dump_mgntframe_and_wait(struct adapter *padapter,
-                           struct xmit_frame *pmgntframe, int timeout_ms);
-s32 dump_mgntframe_and_wait_ack(struct adapter *padapter,
-                               struct xmit_frame *pmgntframe);
-
-void issue_probersp_p2p(struct adapter *padapter, unsigned char *da);
-void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid,
-                                u8 ussidlen, u8 *pdev_raddr);
-void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr);
-void issue_probereq_p2p(struct adapter *padapter);
-void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr,
-                                  u8 dialogToken, u8 success);
-void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr);
-void issue_beacon(struct adapter *padapter, int timeout_ms);
-void issue_probersp(struct adapter *padapter, unsigned char *da,
-                   u8 is_valid_p2p_probereq);
-void issue_assocreq(struct adapter *padapter);
-void issue_asocrsp(struct adapter *padapter, unsigned short status,
-                  struct sta_info *pstat, int pkt_type);
-void issue_auth(struct adapter *padapter, struct sta_info *psta,
-               unsigned short status);
-void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid,
-                   u8 *da);
-void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
-int issue_nulldata(struct adapter *padapter, unsigned char *da,
-                  unsigned int power_mode, int try_cnt, int wait_ms);
-int issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
-                      u16 tid, int try_cnt, int wait_ms);
-int issue_deauth(struct adapter *padapter, unsigned char *da,
-                unsigned short reason);
-int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason,
-                   int try_cnt, int wait_ms);
-void issue_action_BA(struct adapter *padapter, unsigned char *raddr, u8 action,
-                    u16 status, struct ieee80211_mgmt *mgmt_req);
-unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr);
-unsigned int send_beacon(struct adapter *padapter);
-bool get_beacon_valid_bit(struct adapter *adapter);
-void clear_beacon_valid_bit(struct adapter *adapter);
-void rtw_resume_tx_beacon(struct adapter *adapt);
-void rtw_stop_tx_beacon(struct adapter *adapt);
-
-void start_clnt_assoc(struct adapter *padapter);
-void start_clnt_auth(struct adapter *padapter);
-void start_clnt_join(struct adapter *padapter);
-void start_create_ibss(struct adapter *padapter);
-
-void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res);
-void mlmeext_sta_del_event_callback(struct adapter *padapter);
-void mlmeext_sta_add_event_callback(struct adapter *padapter,
-                                   struct sta_info *psta);
-
-void linked_status_chk(struct adapter *padapter);
-
-void survey_timer_hdl (struct adapter *padapter);
-void link_timer_hdl (struct adapter *padapter);
-void addba_timer_hdl(struct sta_info *psta);
-
-#define set_survey_timer(mlmeext, ms) \
-       do { \
-               _set_timer(&(mlmeext)->survey_timer, (ms)); \
-       } while (0)
-
-#define set_link_timer(mlmeext, ms) \
-       do { \
-               _set_timer(&(mlmeext)->link_timer, (ms)); \
-       } while (0)
-
-bool cckrates_included(unsigned char *rate, int ratelen);
-bool cckratesonly_included(unsigned char *rate, int ratelen);
-
-struct cmd_hdl {
-       uint    parmsize;
-       u8 (*h2cfuns)(struct adapter  *padapter, u8 *pbuf);
-};
-
-u8 read_macreg_hdl(struct adapter *padapter, u8 *pbuf);
-u8 write_macreg_hdl(struct adapter *padapter, u8 *pbuf);
-u8 read_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
-u8 write_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
-u8 read_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
-u8 write_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
-u8 NULL_hdl(struct adapter *padapter, u8 *pbuf);
-u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf);
-u8 disconnect_hdl(struct adapter *padapter, u8 *pbuf);
-u8 createbss_hdl(struct adapter *padapter, u8 *pbuf);
-u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf);
-u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf);
-u8 setauth_hdl(struct adapter *padapter, u8 *pbuf);
-u8 setkey_hdl(struct adapter *padapter, u8 *pbuf);
-u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf);
-u8 set_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
-u8 del_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
-u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf);
-
-u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf);
-u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf);
-u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf);
-u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf);
-u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf);
-u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf);
-/* Handling DFS channel switch announcement ie. */
-u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf);
-u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf);
-
-#define GEN_DRV_CMD_HANDLER(size, cmd) {size, &cmd ## _hdl},
-#define GEN_MLME_EXT_HANDLER(size, cmd)        {size, cmd},
-
-#ifdef _RTW_CMD_C_
-
-static struct cmd_hdl wlancmds[] = {
-       GEN_DRV_CMD_HANDLER(0, NULL) /*0*/
-       GEN_DRV_CMD_HANDLER(0, NULL)
-       GEN_DRV_CMD_HANDLER(0, NULL)
-       GEN_DRV_CMD_HANDLER(0, NULL)
-       GEN_DRV_CMD_HANDLER(0, NULL)
-       GEN_DRV_CMD_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL) /*10*/
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct joinbss_parm), join_cmd_hdl) /*14*/
-       GEN_MLME_EXT_HANDLER(sizeof (struct disconnect_parm), disconnect_hdl)
-       GEN_MLME_EXT_HANDLER(sizeof (struct createbss_parm), createbss_hdl)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setopmode_parm), setopmode_hdl)
-       GEN_MLME_EXT_HANDLER(sizeof (struct sitesurvey_parm),
-                            sitesurvey_cmd_hdl) /*18*/
-       GEN_MLME_EXT_HANDLER(sizeof (struct setauth_parm), setauth_hdl)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setkey_parm), setkey_hdl) /*20*/
-       GEN_MLME_EXT_HANDLER(sizeof (struct set_stakey_parm), set_stakey_hdl)
-       GEN_MLME_EXT_HANDLER(sizeof (struct set_assocsta_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct del_assocsta_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setstapwrstate_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setbasicrate_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct getbasicrate_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setdatarate_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct getdatarate_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setphyinfo_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct getphyinfo_parm), NULL)  /*30*/
-       GEN_MLME_EXT_HANDLER(sizeof (struct setphy_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct getphy_parm), NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)   /*40*/
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(sizeof(struct addBaReq_parm), add_ba_hdl)
-       GEN_MLME_EXT_HANDLER(sizeof(struct set_ch_parm), set_ch_hdl) /* 46 */
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL) /*50*/
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(sizeof(struct Tx_Beacon_param),
-                            tx_beacon_hdl) /*55*/
-
-       GEN_MLME_EXT_HANDLER(0, mlme_evt_hdl) /*56*/
-       GEN_MLME_EXT_HANDLER(0, rtw_drvextra_cmd_hdl) /*57*/
-
-       GEN_MLME_EXT_HANDLER(0, h2c_msg_hdl) /*58*/
-       GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelPlan_param),
-                            set_chplan_hdl) /*59*/
-       GEN_MLME_EXT_HANDLER(sizeof(struct LedBlink_param),
-                            led_blink_hdl) /*60*/
-
-       GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelSwitch_param),
-                            set_csa_hdl) /*61*/
-       GEN_MLME_EXT_HANDLER(sizeof(struct TDLSoption_param),
-                            tdls_hdl) /*62*/
-};
-
-#endif
-
-struct C2HEvent_Header {
-#ifdef __LITTLE_ENDIAN
-       unsigned int len:16;
-       unsigned int ID:8;
-       unsigned int seq:8;
-#elif defined(__BIG_ENDIAN)
-       unsigned int seq:8;
-       unsigned int ID:8;
-       unsigned int len:16;
-#endif
-       unsigned int rsvd;
-};
-
-enum rtw_c2h_event {
-       GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
-       GEN_EVT_CODE(_Read_BBREG),
-       GEN_EVT_CODE(_Read_RFREG),
-       GEN_EVT_CODE(_Read_EEPROM),
-       GEN_EVT_CODE(_Read_EFUSE),
-       GEN_EVT_CODE(_Read_CAM),        /*5*/
-       GEN_EVT_CODE(_Get_BasicRate),
-       GEN_EVT_CODE(_Get_DataRate),
-       GEN_EVT_CODE(_Survey),   /*8*/
-       GEN_EVT_CODE(_SurveyDone),       /*9*/
-
-       GEN_EVT_CODE(_JoinBss), /*10*/
-       GEN_EVT_CODE(_AddSTA),
-       GEN_EVT_CODE(_DelSTA),
-       GEN_EVT_CODE(_AtimDone),
-       GEN_EVT_CODE(_TX_Report),
-       GEN_EVT_CODE(_CCX_Report),              /*15*/
-       GEN_EVT_CODE(_DTM_Report),
-       GEN_EVT_CODE(_TX_Rate_Statistics),
-       GEN_EVT_CODE(_C2HLBK),
-       GEN_EVT_CODE(_FWDBG),
-       GEN_EVT_CODE(_C2HFEEDBACK),             /*20*/
-       GEN_EVT_CODE(_ADDBA),
-       GEN_EVT_CODE(_C2HBCN),
-       GEN_EVT_CODE(_ReportPwrState),  /* filen: only for PCIE, USB */
-       GEN_EVT_CODE(_CloseRF),         /* filen: only for PCIE,
-                                        * work around ASPM */
-       MAX_C2HEVT
-};
-
-#ifdef _RTW_MLME_EXT_C_
-
-static struct fwevent wlanevents[] = {
-       {0, NULL},      /*0*/
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},
-       {0, &rtw_survey_event_callback},                /*8*/
-       {sizeof (struct surveydone_event), &rtw_surveydone_event_callback},/*9*/
-       {0, &rtw_joinbss_event_callback},               /*10*/
-       {sizeof(struct stassoc_event), &rtw_stassoc_event_callback},
-       {sizeof(struct stadel_event), &rtw_stadel_event_callback},
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},      /*15*/
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},       /*20*/
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},
-       {0, NULL},
-};
-
-#endif/* _RTL_MLME_EXT_C_ */
-
-#endif /* __RTW_MLME_EXT_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_p2p.h b/drivers/staging/r8188eu/include/rtw_p2p.h
deleted file mode 100644 (file)
index b91322a..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_P2P_H_
-#define __RTW_P2P_H_
-
-#include "drv_types.h"
-
-u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo,
-                                  u8 *pbuf, u8 *pssid, u8 ussidlen,
-                                  u8 *pdev_raddr);
-u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo,
-                           u8 *pbuf, u8 status_code);
-u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo,
-                            u8 *pframe, uint len);
-u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo,
-                            u8 *pframe, uint len, struct sta_info *psta);
-u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo,
-                           u8 *pframe, uint len);
-u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo,
-                            u8 *pframe, uint len);
-u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo,
-                           u8 *pframe, uint len);
-u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo,  u8 *pframe);
-u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo,
-                                   u8 *pframe, uint len);
-u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo,
-                                    u8 *pframe, uint len);
-u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo,
-                                       u8 *pframe, uint len);
-u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe,
-                           uint len);
-void p2p_protocol_wk_hdl(struct adapter *padapter, int intcmdtype);
-void process_p2p_ps_ie(struct adapter *padapter, u8 *ies, u32 ielength);
-void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state);
-u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue);
-void reset_global_wifidirect_info(struct adapter *padapter);
-int rtw_init_wifi_display_info(struct adapter *padapter);
-void rtw_init_wifidirect_timers(struct adapter *padapter);
-void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr,
-                              u8 *iface_addr);
-void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role);
-int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role);
-
-static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo,
-                                     enum P2P_STATE state)
-{
-       if (wdinfo->p2p_state != state)
-               wdinfo->p2p_state = state;
-}
-
-static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo,
-                                         enum P2P_STATE state)
-{
-       if (wdinfo->pre_p2p_state != state)
-               wdinfo->pre_p2p_state = state;
-}
-
-static inline void _rtw_p2p_set_role(struct wifidirect_info *wdinfo,
-                                    enum P2P_ROLE role)
-{
-       if (wdinfo->role != role)
-               wdinfo->role = role;
-}
-
-static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo)
-{
-       return wdinfo->p2p_state;
-}
-
-static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo)
-{
-       return wdinfo->pre_p2p_state;
-}
-
-static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo)
-{
-       return wdinfo->role;
-}
-
-static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo,
-                                     enum P2P_STATE state)
-{
-       return wdinfo->p2p_state == state;
-}
-
-static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo,
-                                    enum P2P_ROLE role)
-{
-       return wdinfo->role == role;
-}
-
-#define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state)
-#define rtw_p2p_set_pre_state(wdinfo, state)                           \
-        _rtw_p2p_set_pre_state(wdinfo, state)
-#define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role)
-
-#define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo)
-#define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo)
-#define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo)
-#define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state)
-#define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role)
-
-#define rtw_p2p_findphase_ex_set(wdinfo, value) \
-       ((wdinfo)->find_phase_state_exchange_cnt = (value))
-
-/* is this find phase exchange for social channel scan? */
-#define rtw_p2p_findphase_ex_is_social(wdinfo)   \
-((wdinfo)->find_phase_state_exchange_cnt >= P2P_FINDPHASE_EX_SOCIAL_FIRST)
-
-/* should we need find phase exchange anymore? */
-#define rtw_p2p_findphase_ex_is_needed(wdinfo) \
-       ((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \
-       (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE)
-
-#endif
diff --git a/drivers/staging/r8188eu/include/rtw_pwrctrl.h b/drivers/staging/r8188eu/include/rtw_pwrctrl.h
deleted file mode 100644 (file)
index 9f5cffd..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#ifndef __RTW_PWRCTRL_H_
-#define __RTW_PWRCTRL_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-
-#define XMIT_ALIVE     BIT(0)
-#define RECV_ALIVE     BIT(1)
-#define CMD_ALIVE      BIT(2)
-#define EVT_ALIVE      BIT(3)
-
-enum power_mgnt {
-       PS_MODE_ACTIVE = 0,
-       PS_MODE_MIN,
-       PS_MODE_MAX,
-       PS_MODE_DTIM,
-       PS_MODE_VOIP,
-       PS_MODE_UAPSD_WMM,
-       PM_Card_Disable,
-       PS_MODE_NUM
-};
-
-#define LPS_DELAY_TIME 1*HZ /*  1 sec */
-
-/*  RF state. */
-enum rt_rf_power_state {
-       rf_on,          /*  RF is on after RFSleep or RFOff */
-       rf_sleep,       /*  802.11 Power Save mode */
-       rf_off,         /*  HW/SW Radio OFF or Inactive Power Save */
-       /* Add the new RF state above this line===== */
-       rf_max
-};
-
-enum { /*  for ips_mode */
-       IPS_NONE = 0,
-       IPS_NORMAL,
-       IPS_LEVEL_2,
-};
-
-struct pwrctrl_priv {
-       struct mutex lock; /* Mutex used to protect struct pwrctrl_priv */
-
-       u8      pwr_mode;
-       u8      smart_ps;
-       u8      bcn_ant_mode;
-
-       bool    bpower_saving;
-
-       uint    ips_enter_cnts;
-       uint    ips_leave_cnts;
-
-       u8      ips_mode;
-       u8      ips_mode_req;   /*  used to accept the mode setting request,
-                                *  will update to ipsmode later */
-       uint bips_processing;
-       unsigned long ips_deny_time; /* will deny IPS when system time less than this */
-       u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */
-
-       u8      bLeisurePs;
-       u8      LpsIdleCount;
-       u8      power_mgnt;
-       u8      bFwCurrentInPSMode;
-       u32     DelayLPSLastTimeStamp;
-
-       u8              bInSuspend;
-       u8              bSupportRemoteWakeup;
-       struct timer_list pwr_state_check_timer;
-       int             pwr_state_check_interval;
-
-       enum rt_rf_power_state  rf_pwrstate;/* cur power state */
-
-       u8              bkeepfwalive;
-};
-
-#define rtw_get_ips_mode_req(pwrctrlpriv) \
-       (pwrctrlpriv)->ips_mode_req
-
-#define rtw_ips_mode_req(pwrctrlpriv, ips_mode) \
-       ((pwrctrlpriv)->ips_mode_req = (ips_mode))
-
-#define RTW_PWR_STATE_CHK_INTERVAL 2000
-
-#define _rtw_set_pwr_state_check_timer(pwrctrlpriv, ms) \
-       do { \
-               _set_timer(&(pwrctrlpriv)->pwr_state_check_timer, (ms)); \
-       } while (0)
-
-#define rtw_set_pwr_state_check_timer(pwrctrl)                 \
-       _rtw_set_pwr_state_check_timer((pwrctrl),               \
-                                      (pwrctrl)->pwr_state_check_interval)
-
-void rtw_init_pwrctrl_priv(struct adapter *adapter);
-
-void rtw_set_firmware_ps_mode(struct adapter *adapter, u8 mode);
-void rtw_set_ps_mode(struct adapter *adapter, u8 ps_mode, u8 smart_ps,
-                    u8 bcn_ant_mode);
-void LeaveAllPowerSaveMode(struct adapter *adapter);
-
-void rtw_ps_processor(struct adapter *padapter);
-
-void LPS_Enter(struct adapter *adapter);
-void LPS_Leave(struct adapter *adapter);
-
-int rtw_pwr_wakeup(struct adapter *adapter);
-int rtw_pm_set_ips(struct adapter *adapter, u8 mode);
-int rtw_pm_set_lps(struct adapter *adapter, u8 mode);
-
-#endif  /* __RTL871X_PWRCTRL_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_recv.h b/drivers/staging/r8188eu/include/rtw_recv.h
deleted file mode 100644 (file)
index 1202643..0000000
+++ /dev/null
@@ -1,347 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#ifndef _RTW_RECV_H_
-#define _RTW_RECV_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-
-#define NR_RECVFRAME 256
-
-#define RXFRAME_ALIGN  8
-#define RXFRAME_ALIGN_SZ       (1<<RXFRAME_ALIGN)
-
-#define MAX_RXFRAME_CNT        512
-#define MAX_RX_NUMBLKS         (32)
-#define RECVFRAME_HDR_ALIGN 128
-
-#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
-
-#define MAX_SUBFRAME_COUNT     64
-
-#define LLC_HEADER_SIZE 6
-
-/* for Rx reordering buffer control */
-struct recv_reorder_ctrl {
-       struct adapter  *padapter;
-       u8 enable;
-       u16 indicate_seq;/* wstart_b, init_value=0xffff */
-       u16 wend_b;
-       u8 wsize_b;
-       struct __queue pending_recvframe_queue;
-       struct timer_list reordering_ctrl_timer;
-};
-
-struct stainfo_rxcache {
-       u16     tid_rxseq[16];
-/*
-       unsigned short  tid0_rxseq;
-       unsigned short  tid1_rxseq;
-       unsigned short  tid2_rxseq;
-       unsigned short  tid3_rxseq;
-       unsigned short  tid4_rxseq;
-       unsigned short  tid5_rxseq;
-       unsigned short  tid6_rxseq;
-       unsigned short  tid7_rxseq;
-       unsigned short  tid8_rxseq;
-       unsigned short  tid9_rxseq;
-       unsigned short  tid10_rxseq;
-       unsigned short  tid11_rxseq;
-       unsigned short  tid12_rxseq;
-       unsigned short  tid13_rxseq;
-       unsigned short  tid14_rxseq;
-       unsigned short  tid15_rxseq;
-*/
-};
-
-struct signal_stat {
-       u8      update_req;             /* used to indicate */
-       u8      avg_val;                /* avg of valid elements */
-       u32     total_num;              /* num of valid elements */
-       u32     total_val;              /* sum of valid elements */
-};
-#define MAX_PATH_NUM_92CS              3
-struct phy_info {
-       u8      RxPWDBAll;
-       u8      SignalQuality;   /*  in 0-100 index. */
-       u8      RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/*  in 0~100 index */
-       s8      RxPower; /*  in dBm Translate from PWdB */
-/*  Real power in dBm for this packet, no beautification and aggregation.
- * Keep this raw info to be used for the other procedures. */
-       s8      recvpower;
-       u8      SignalStrength; /*  in 0-100 index. */
-       u8      RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */
-};
-
-struct rx_pkt_attrib {
-       u16     pkt_len;
-       u8      physt;
-       u8      drvinfo_sz;
-       u8      shift_sz;
-       u8      hdrlen; /* the WLAN Header Len */
-       u8      amsdu;
-       bool    qos;
-       u8      priority;
-       u8      pw_save;
-       u8      mdata;
-       u16     seq_num;
-       u8      frag_num;
-       u8      mfrag;
-       u8      order;
-       u8      privacy; /* in frame_ctrl field */
-       u8      bdecrypted;
-       u8      encrypt; /* when 0 indicate no encrypt. when non-zero,
-                         * indicate the encrypt algorithm */
-       u8      iv_len;
-       u8      icv_len;
-       u8      crc_err;
-       u8      icv_err;
-
-       u16 eth_type;
-
-       u8      dst[ETH_ALEN] __aligned(2);
-       u8      src[ETH_ALEN] __aligned(2);
-       u8      ta[ETH_ALEN] __aligned(2);
-       u8      ra[ETH_ALEN] __aligned(2);
-       u8      bssid[ETH_ALEN] __aligned(2);
-
-       u8 ack_policy;
-
-       u8      key_index;
-
-       u8      mcs_rate;
-       u8      rxht;
-       u8      sgi;
-       u8      pkt_rpt_type;
-       u32     MacIDValidEntry[2];     /*  64 bits present 64 entry. */
-
-       struct phy_info phy_info;
-};
-
-/* These definition is used for Rx packet reordering. */
-#define SN_LESS(a, b)          (((a - b) & 0x800) != 0)
-#define SN_EQUAL(a, b) (a == b)
-#define REORDER_WAIT_TIME      (50) /*  (ms) */
-
-#define RECVBUFF_ALIGN_SZ 8
-
-#define RXDESC_SIZE    24
-#define RXDESC_OFFSET RXDESC_SIZE
-
-struct recv_stat {
-       __le32 rxdw0;
-       __le32 rxdw1;
-       __le32 rxdw2;
-       __le32 rxdw3;
-       __le32 rxdw4;
-       __le32 rxdw5;
-};
-
-#define EOR BIT(30)
-
-/*
-accesser of recv_priv: rtw_recv_entry(dispatch / passive level);
-recv_thread(passive) ; returnpkt(dispatch)
-; halt(passive) ;
-
-using enter_critical section to protect
-*/
-struct recv_priv {
-       spinlock_t lock;
-       struct __queue free_recv_queue;
-       struct __queue recv_pending_queue;
-       struct __queue uc_swdec_pending_queue;
-       u8 *pallocated_frame_buf;
-       u8 *precv_frame_buf;
-       uint free_recvframe_cnt;
-       struct adapter  *adapter;
-       u32     bIsAnyNonBEPkts;
-       u64     rx_bytes;
-       u64     rx_pkts;
-       u64     rx_drop;
-       u64     last_rx_bytes;
-
-       uint  rx_icv_err;
-       uint  rx_largepacket_crcerr;
-       uint  rx_smallpacket_crcerr;
-       uint  rx_middlepacket_crcerr;
-       u8      rx_pending_cnt;
-
-       struct tasklet_struct recv_tasklet;
-       struct sk_buff_head free_recv_skb_queue;
-       struct sk_buff_head rx_skb_queue;
-       u8 *pallocated_recv_buf;
-       u8 *precv_buf;    /*  4 alignment */
-       struct __queue free_recv_buf_queue;
-       u32     free_recv_buf_queue_cnt;
-       /* For display the phy information */
-       u8 is_signal_dbg;       /*  for debug */
-       u8 signal_strength_dbg; /*  for debug */
-       s8 rssi;
-       s8 rxpwdb;
-       u8 signal_strength;
-       u8 signal_qual;
-       u8 noise;
-       int RxSNRdB[2];
-       s8 RxRssi[2];
-       int FalseAlmCnt_all;
-
-       struct timer_list signal_stat_timer;
-       u32 signal_stat_sampling_interval;
-       struct signal_stat signal_qual_data;
-       struct signal_stat signal_strength_data;
-};
-
-#define rtw_set_signal_stat_timer(recvpriv)                    \
-       _set_timer(&(recvpriv)->signal_stat_timer,              \
-                  (recvpriv)->signal_stat_sampling_interval)
-
-struct sta_recv_priv {
-       spinlock_t lock;
-       int     option;
-       struct __queue defrag_q; /* keeping the fragment frame until defrag */
-       struct  stainfo_rxcache rxcache;
-};
-
-struct recv_buf {
-       struct adapter *adapter;
-       struct urb *purb;
-       struct sk_buff *pskb;
-       u8      reuse;
-};
-
-/*
-       head  ----->
-
-               data  ----->
-
-                       payload
-
-               tail  ----->
-
-       end   ----->
-
-       len = (unsigned int )(tail - data);
-
-*/
-struct recv_frame {
-       struct list_head list;
-       struct sk_buff   *pkt;
-       struct adapter  *adapter;
-       u8 fragcnt;
-       int frame_tag;
-       struct rx_pkt_attrib attrib;
-       uint  len;
-       u8 *rx_head;
-       u8 *rx_data;
-       u8 *rx_tail;
-       u8 *rx_end;
-       void *precvbuf;
-       struct sta_info *psta;
-       /* for A-MPDU Rx reordering buffer control */
-       struct recv_reorder_ctrl *preorder_ctrl;
-};
-
-int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter);
-void _rtw_free_recv_priv(struct recv_priv *precvpriv);
-s32 rtw_recv_entry(struct recv_frame *precv_frame);
-struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
-struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
-int  rtw_free_recvframe(struct recv_frame *precvframe,
-                       struct __queue *pfree_recv_queue);
-int _rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue);
-int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue);
-void rtw_free_recvframe_queue(struct __queue *pframequeue,
-                             struct __queue *pfree_recv_queue);
-u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter);
-
-void rtw_reordering_ctrl_timeout_handler(void *pcontext);
-
-static inline u8 *get_rxmem(struct recv_frame *precvframe)
-{
-       /* always return rx_head... */
-       if (precvframe == NULL)
-               return NULL;
-       return precvframe->rx_head;
-}
-
-static inline u8 *recvframe_pull(struct recv_frame *precvframe, int sz)
-{
-       /*  rx_data += sz; move rx_data sz bytes  hereafter */
-
-       /* used for extract sz bytes from rx_data, update rx_data and return
-        * the updated rx_data to the caller */
-
-       if (precvframe == NULL)
-               return NULL;
-       precvframe->rx_data += sz;
-       if (precvframe->rx_data > precvframe->rx_tail) {
-               precvframe->rx_data -= sz;
-               return NULL;
-       }
-       precvframe->len -= sz;
-       return precvframe->rx_data;
-}
-
-static inline u8 *recvframe_put(struct recv_frame *precvframe, int sz)
-{
-       /* used for append sz bytes from ptr to rx_tail, update rx_tail
-        * and return the updated rx_tail to the caller */
-       /* after putting, rx_tail must be still larger than rx_end. */
-
-       if (precvframe == NULL)
-               return NULL;
-
-       precvframe->rx_tail += sz;
-
-       if (precvframe->rx_tail > precvframe->rx_end) {
-               precvframe->rx_tail -= sz;
-               return NULL;
-       }
-       precvframe->len += sz;
-       return precvframe->rx_tail;
-}
-
-static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz)
-{
-       /*  rmv data from rx_tail (by yitsen) */
-
-       /* used for extract sz bytes from rx_end, update rx_end and return
-        * the updated rx_end to the caller */
-       /* after pulling, rx_end must be still larger than rx_data. */
-
-       if (precvframe == NULL)
-               return NULL;
-       precvframe->rx_tail -= sz;
-       if (precvframe->rx_tail < precvframe->rx_data) {
-               precvframe->rx_tail += sz;
-               return NULL;
-       }
-       precvframe->len -= sz;
-       return precvframe->rx_tail;
-}
-
-static inline int get_recvframe_len(struct recv_frame *precvframe)
-{
-       return precvframe->len;
-}
-
-static inline s32 translate_percentage_to_dbm(u32 sig_stren_index)
-{
-       s32     power; /*  in dBm. */
-
-       /*  Translate to dBm (x=0.5y-95). */
-       power = (s32)((sig_stren_index + 1) >> 1);
-       power -= 95;
-
-       return power;
-}
-
-struct sta_info;
-
-void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
-
-void  mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/rtw_rf.h b/drivers/staging/r8188eu/include/rtw_rf.h
deleted file mode 100644 (file)
index b7267e7..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef        __RTW_RF_H_
-#define __RTW_RF_H_
-
-#include "rtw_cmd.h"
-
-#define NumRates       (13)
-
-/*  slot time for 11g */
-#define SHORT_SLOT_TIME                        9
-#define NON_SHORT_SLOT_TIME            20
-
-#define        MAX_CHANNEL_NUM                 14      /* 2.4 GHz only */
-
-#define NUM_REGULATORYS        1
-
-struct regulatory_class {
-       u32     starting_freq;                          /* MHz, */
-       u8      channel_set[MAX_CHANNEL_NUM];
-       u8      channel_cck_power[MAX_CHANNEL_NUM];     /* dbm */
-       u8      channel_ofdm_power[MAX_CHANNEL_NUM];    /* dbm */
-       u8      txpower_limit;                          /* dbm */
-       u8      channel_spacing;                        /* MHz */
-       u8      modem;
-};
-
-enum capability {
-       cESS            = 0x0001,
-       cIBSS           = 0x0002,
-       cPollable       = 0x0004,
-       cPollReq        = 0x0008,
-       cPrivacy        = 0x0010,
-       cShortPreamble  = 0x0020,
-       cPBCC           = 0x0040,
-       cChannelAgility = 0x0080,
-       cSpectrumMgnt   = 0x0100,
-       cQos            = 0x0200,       /* For HCCA, use with CF-Pollable
-                                        * and CF-PollReq */
-       cShortSlotTime  = 0x0400,
-       cAPSD           = 0x0800,
-       cRM             = 0x1000,       /*  RRM (Radio Request Measurement) */
-       cDSSS_OFDM      = 0x2000,
-       cDelayedBA      = 0x4000,
-       cImmediateBA    = 0x8000,
-};
-
-enum   _REG_PREAMBLE_MODE {
-       PREAMBLE_LONG   = 1,
-       PREAMBLE_AUTO   = 2,
-       PREAMBLE_SHORT  = 3,
-};
-
-/*  Bandwidth Offset */
-#define HAL_PRIME_CHNL_OFFSET_DONT_CARE        0
-#define HAL_PRIME_CHNL_OFFSET_LOWER    1
-#define HAL_PRIME_CHNL_OFFSET_UPPER    2
-
-/*  Represent Channel Width in HT Capabilities */
-/*  */
-enum ht_channel_width {
-       HT_CHANNEL_WIDTH_20 = 0,
-       HT_CHANNEL_WIDTH_40 = 1,
-};
-
-/*  */
-/*  Represent Extension Channel Offset in HT Capabilities */
-/*  This is available only in 40Mhz mode. */
-/*  */
-enum ht_extchnl_offset {
-       HT_EXTCHNL_OFFSET_NO_EXT = 0,
-       HT_EXTCHNL_OFFSET_UPPER = 1,
-       HT_EXTCHNL_OFFSET_NO_DEF = 2,
-       HT_EXTCHNL_OFFSET_LOWER = 3,
-};
-
-u32 rtw_ch2freq(u32 ch);
-
-#endif /* _RTL8711_RF_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_security.h b/drivers/staging/r8188eu/include/rtw_security.h
deleted file mode 100644 (file)
index 783ae18..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __RTW_SECURITY_H_
-#define __RTW_SECURITY_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-#include <crypto/arc4.h>
-
-#define _NO_PRIVACY_                   0x0
-#define _WEP40_                                0x1
-#define _TKIP_                         0x2
-#define _TKIP_WTMIC_                   0x3
-#define _AES_                          0x4
-#define _WEP104_                       0x5
-#define _SMS4_                         0x06
-
-#define _WPA_IE_ID_    0xdd
-#define _WPA2_IE_ID_   0x30
-
-enum {
-       ENCRYP_PROTOCOL_OPENSYS,   /* open system */
-       ENCRYP_PROTOCOL_WEP,       /* WEP */
-       ENCRYP_PROTOCOL_WPA,       /* WPA */
-       ENCRYP_PROTOCOL_WPA2,      /* WPA2 */
-       ENCRYP_PROTOCOL_WAPI,      /* WAPI: Not support in this version */
-       ENCRYP_PROTOCOL_MAX
-};
-
-#ifndef Ndis802_11AuthModeWPA2
-#define Ndis802_11AuthModeWPA2 (Ndis802_11AuthModeWPANone + 1)
-#endif
-
-#ifndef Ndis802_11AuthModeWPA2PSK
-#define Ndis802_11AuthModeWPA2PSK (Ndis802_11AuthModeWPANone + 2)
-#endif
-
-union pn48     {
-       u64     val;
-
-#ifdef __LITTLE_ENDIAN
-       struct {
-               u8 TSC0;
-               u8 TSC1;
-               u8 TSC2;
-               u8 TSC3;
-               u8 TSC4;
-               u8 TSC5;
-               u8 TSC6;
-               u8 TSC7;
-       } _byte_;
-
-#elif defined(__BIG_ENDIAN)
-
-       struct {
-               u8 TSC7;
-               u8 TSC6;
-               u8 TSC5;
-               u8 TSC4;
-               u8 TSC3;
-               u8 TSC2;
-               u8 TSC1;
-               u8 TSC0;
-       } _byte_;
-#endif
-};
-
-union Keytype {
-       u8   skey[16];
-       u32    lkey[4];
-};
-
-struct rt_pmkid_list {
-       u8      bUsed;
-       u8      Bssid[6];
-       u8      PMKID[16];
-       u8      SsidBuf[33];
-       u8      *ssid_octet;
-       u16     ssid_length;
-};
-
-struct security_priv {
-       u32       dot11AuthAlgrthm;     /*  802.11 auth, could be open,
-                                        * shared, 8021x and authswitch */
-       u32       dot11PrivacyAlgrthm;  /*  This specify the privacy for
-                                        * shared auth. algorithm. */
-       /* WEP */
-       u32       dot11PrivacyKeyIndex; /*  this is only valid for legendary
-                                        * wep, 0~3 for key id.(tx key index) */
-       union Keytype dot11DefKey[4];   /*  this is only valid for def. key */
-       u32     dot11DefKeylen[4];
-       u32 dot118021XGrpPrivacy;       /*  This specify the privacy algthm.
-                                        * used for Grp key */
-       u32     dot118021XGrpKeyid;     /*  key id used for Grp Key
-                                        * ( tx key index) */
-       union Keytype   dot118021XGrpKey[4];    /*  802.1x Group Key,
-                                                * for inx0 and inx1 */
-       union Keytype   dot118021XGrptxmickey[4];
-       union Keytype   dot118021XGrprxmickey[4];
-       union pn48      dot11Grptxpn;           /* PN48 used for Grp Key xmit.*/
-       union pn48      dot11Grprxpn;           /* PN48 used for Grp Key recv.*/
-
-       struct arc4_ctx xmit_arc4_ctx;
-       struct arc4_ctx recv_arc4_ctx;
-
-       /* extend security capabilities for AP_MODE */
-       unsigned int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
-       unsigned int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
-       unsigned int wpa_group_cipher;
-       unsigned int wpa2_group_cipher;
-       unsigned int wpa_pairwise_cipher;
-       unsigned int wpa2_pairwise_cipher;
-       u8 wps_ie[MAX_WPS_IE_LEN];/* added in assoc req */
-       int wps_ie_len;
-       u8      binstallGrpkey;
-       u8      busetkipkey;
-       u8      bcheck_grpkey;
-       u8      bgrpkey_handshake;
-       s32     sw_encrypt;/* from registry_priv */
-       s32     sw_decrypt;/* from registry_priv */
-       s32     hw_decrypted;/* if the rx packets is hw_decrypted==false,i
-                             * it means the hw has not been ready. */
-
-       /* keeps the auth_type & enc_status from upper layer
-        * ioctl(wpa_supplicant or wzc) */
-       u32 ndisauthtype;       /*  NDIS_802_11_AUTHENTICATION_MODE */
-       u32 ndisencryptstatus;  /*  NDIS_802_11_ENCRYPTION_STATUS */
-       struct wlan_bssid_ex sec_bss;  /* for joinbss (h2c buffer) usage */
-       struct ndis_802_11_wep ndiswep;
-       u8 assoc_info[600];
-       u8 szofcapability[256]; /* for wpa2 usage */
-       u8 oidassociation[512]; /* for wpa/wpa2 usage */
-       u8 authenticator_ie[256];  /* store ap security information element */
-       u8 supplicant_ie[256];  /* store sta security information element */
-
-       /* for tkip countermeasure */
-       u32 last_mic_err_time;
-       u8      btkip_countermeasure;
-       u8      btkip_wait_report;
-       u32 btkip_countermeasure_time;
-
-       /*  */
-       /*  For WPA2 Pre-Authentication. */
-       /*  */
-       struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE];
-       u8      PMKIDIndex;
-       u8 bWepDefaultKeyIdxSet;
-};
-
-#define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst)         \
-do {                                                                   \
-       switch (psecuritypriv->dot11AuthAlgrthm) {                      \
-       case dot11AuthAlgrthm_Open:                                     \
-       case dot11AuthAlgrthm_Shared:                                   \
-       case dot11AuthAlgrthm_Auto:                                     \
-               encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm;    \
-               break;                                                  \
-       case dot11AuthAlgrthm_8021X:                                    \
-               if (bmcst)                                              \
-                       encry_algo = (u8)psecuritypriv->dot118021XGrpPrivacy;\
-               else                                                    \
-                       encry_algo = (u8)psta->dot118021XPrivacy;       \
-               break;                                                  \
-       case dot11AuthAlgrthm_WAPI:                                     \
-               encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm;    \
-               break;                                                  \
-       }                                                               \
-} while (0)
-
-#define SET_ICE_IV_LEN(iv_len, icv_len, encrypt)                       \
-do {                                                                   \
-       switch (encrypt) {                                              \
-       case _WEP40_:                                                   \
-       case _WEP104_:                                                  \
-               iv_len = 4;                                             \
-               icv_len = 4;                                            \
-               break;                                                  \
-       case _TKIP_:                                                    \
-               iv_len = 8;                                             \
-               icv_len = 4;                                            \
-               break;                                                  \
-       case _AES_:                                                     \
-               iv_len = 8;                                             \
-               icv_len = 8;                                            \
-               break;                                                  \
-       case _SMS4_:                                                    \
-               iv_len = 18;                                            \
-               icv_len = 16;                                           \
-               break;                                                  \
-       default:                                                        \
-               iv_len = 0;                                             \
-               icv_len = 0;                                            \
-               break;                                                  \
-       }                                                               \
-} while (0)
-
-#define GET_TKIP_PN(iv, dot11txpn)                                     \
-do {                                                                   \
-       dot11txpn._byte_.TSC0 = iv[2];                                  \
-       dot11txpn._byte_.TSC1 = iv[0];                                  \
-       dot11txpn._byte_.TSC2 = iv[4];                                  \
-       dot11txpn._byte_.TSC3 = iv[5];                                  \
-       dot11txpn._byte_.TSC4 = iv[6];                                  \
-       dot11txpn._byte_.TSC5 = iv[7];                                  \
-} while (0)
-
-#define ROL32(A, n)    (((A) << (n)) | (((A)>>(32-(n)))  & ((1UL << (n)) - 1)))
-#define ROR32(A, n)    ROL32((A), 32-(n))
-
-struct mic_data {
-       u32  K0, K1;         /*  Key */
-       u32  L, R;           /*  Current state */
-       u32  M;              /*  Message accumulator (single word) */
-       u32  nBytesInM;      /*  # bytes in M */
-};
-
-void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key);
-void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b);
-void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nBytes);
-void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst);
-void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len,
-                       u8 *Miccode, u8   priority);
-u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe);
-u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe);
-void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe);
-u32 rtw_aes_decrypt(struct adapter *padapter, struct recv_frame *precvframe);
-u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe);
-void rtw_wep_decrypt(struct adapter *padapter, struct recv_frame *precvframe);
-
-#endif /* __RTL871X_SECURITY_H_ */
diff --git a/drivers/staging/r8188eu/include/rtw_xmit.h b/drivers/staging/r8188eu/include/rtw_xmit.h
deleted file mode 100644 (file)
index feeac85..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef _RTW_XMIT_H_
-#define _RTW_XMIT_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-
-#define NR_XMITFRAME           256
-#define WMM_XMIT_THRESHOLD     (NR_XMITFRAME * 2 / 5)
-
-#define MAX_XMITBUF_SZ (20480) /*  20k */
-#define NR_XMITBUFF            (4)
-
-#define XMITBUF_ALIGN_SZ       4
-
-/*  xmit extension buff defination */
-#define MAX_XMIT_EXTBUF_SZ     (1536)
-#define NR_XMIT_EXTBUFF                (32)
-
-#define MAX_NUMBLKS            (1)
-
-#define XMIT_VO_QUEUE          (0)
-#define XMIT_VI_QUEUE          (1)
-#define XMIT_BE_QUEUE          (2)
-#define XMIT_BK_QUEUE          (3)
-
-#define VO_QUEUE_INX           0
-#define VI_QUEUE_INX           1
-#define BE_QUEUE_INX           2
-#define BK_QUEUE_INX           3
-#define BCN_QUEUE_INX          4
-#define MGT_QUEUE_INX          5
-#define HIGH_QUEUE_INX         6
-#define TXCMD_QUEUE_INX                7
-
-#define HW_QUEUE_ENTRY         8
-
-#define WEP_IV(pattrib_iv, dot11txpn, keyidx)\
-do {\
-       pattrib_iv[0] = dot11txpn._byte_.TSC0;\
-       pattrib_iv[1] = dot11txpn._byte_.TSC1;\
-       pattrib_iv[2] = dot11txpn._byte_.TSC2;\
-       pattrib_iv[3] = ((keyidx & 0x3)<<6);\
-       dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : (dot11txpn.val+1);\
-} while (0)
-
-#define TKIP_IV(pattrib_iv, dot11txpn, keyidx)\
-do {\
-       pattrib_iv[0] = dot11txpn._byte_.TSC1;\
-       pattrib_iv[1] = (dot11txpn._byte_.TSC1 | 0x20) & 0x7f;\
-       pattrib_iv[2] = dot11txpn._byte_.TSC0;\
-       pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
-       pattrib_iv[4] = dot11txpn._byte_.TSC2;\
-       pattrib_iv[5] = dot11txpn._byte_.TSC3;\
-       pattrib_iv[6] = dot11txpn._byte_.TSC4;\
-       pattrib_iv[7] = dot11txpn._byte_.TSC5;\
-       dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\
-} while (0)
-
-#define AES_IV(pattrib_iv, dot11txpn, keyidx)\
-do {                                                   \
-       pattrib_iv[0] = dot11txpn._byte_.TSC0;          \
-       pattrib_iv[1] = dot11txpn._byte_.TSC1;          \
-       pattrib_iv[2] = 0;                              \
-       pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);   \
-       pattrib_iv[4] = dot11txpn._byte_.TSC2;          \
-       pattrib_iv[5] = dot11txpn._byte_.TSC3;          \
-       pattrib_iv[6] = dot11txpn._byte_.TSC4;          \
-       pattrib_iv[7] = dot11txpn._byte_.TSC5;          \
-       dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\
-} while (0)
-
-#define HWXMIT_ENTRY   4
-
-#define TXDESC_SIZE 32
-
-#define PACKET_OFFSET_SZ (8)
-#define TXDESC_OFFSET (TXDESC_SIZE + PACKET_OFFSET_SZ)
-
-struct tx_desc {
-       /* DWORD 0 */
-       __le32 txdw0;
-       __le32 txdw1;
-       __le32 txdw2;
-       __le32 txdw3;
-       __le32 txdw4;
-       __le32 txdw5;
-       __le32 txdw6;
-       __le32 txdw7;
-};
-
-union txdesc {
-       struct tx_desc txdesc;
-       unsigned int value[TXDESC_SIZE>>2];
-};
-
-struct hw_xmit {
-       struct list_head *sta_list;
-       int     accnt;
-};
-
-/* reduce size */
-struct pkt_attrib {
-       u8      type;
-       u8      subtype;
-       u8      bswenc;
-       u8      dhcp_pkt;
-       u16     ether_type;
-       u16     seqnum;
-       u16     pkt_hdrlen;     /* the original 802.3 pkt header len */
-       u16     hdrlen;         /* the WLAN Header Len */
-       u32     pktlen;         /* the original 802.3 pkt raw_data len (not include
-                                * ether_hdr data) */
-       u32     last_txcmdsz;
-       u8      nr_frags;
-       u8      encrypt;        /* when 0 indicate no encrypt. when non-zero,
-                                * indicate the encrypt algorithm */
-       u8      iv_len;
-       u8      icv_len;
-       u8      iv[18];
-       u8      icv[16];
-       u8      priority;
-       u8      ack_policy;
-       u8      mac_id;
-       u8      vcs_mode;       /* virtual carrier sense method */
-       u8      dst[ETH_ALEN] __aligned(2);
-       u8      src[ETH_ALEN] __aligned(2);
-       u8      ta[ETH_ALEN] __aligned(2);
-       u8      ra[ETH_ALEN] __aligned(2);
-       u8      key_idx;
-       u8      qos_en;
-       u8      ht_en;
-       u8      raid;/* rate adpative id */
-       u8      bwmode;
-       u8      ch_offset;/* PRIME_CHNL_OFFSET */
-       u8      sgi;/* short GI */
-       u8      ampdu_en;/* tx ampdu enable */
-       u8      mdata;/* more data bit */
-       u8      pctrl;/* per packet txdesc control enable */
-       u8      triggered;/* for ap mode handling Power Saving sta */
-       u8      qsel;
-       u8      eosp;
-       u8      rate;
-       u8      intel_proxim;
-       u8      retry_ctrl;
-       struct sta_info *psta;
-};
-
-#define WLANHDR_OFFSET 64
-
-#define NULL_FRAMETAG          (0x0)
-#define DATA_FRAMETAG          0x01
-#define MGNT_FRAMETAG          0x03
-
-#define TXAGG_FRAMETAG 0x08
-
-struct  submit_ctx {
-       u32 submit_time; /* */
-       u32 timeout_ms; /* <0: not synchronous, 0: wait forever, >0: up to ms waiting */
-       int status; /* status for operation */
-       struct completion done;
-};
-
-enum {
-       RTW_SCTX_SUBMITTED = -1,
-       RTW_SCTX_DONE_SUCCESS = 0,
-       RTW_SCTX_DONE_UNKNOWN,
-       RTW_SCTX_DONE_TIMEOUT,
-       RTW_SCTX_DONE_BUF_ALLOC,
-       RTW_SCTX_DONE_BUF_FREE,
-       RTW_SCTX_DONE_WRITE_PORT_ERR,
-       RTW_SCTX_DONE_TX_DESC_NA,
-       RTW_SCTX_DONE_TX_DENY,
-       RTW_SCTX_DONE_CCX_PKT_FAIL,
-       RTW_SCTX_DONE_DRV_STOP,
-       RTW_SCTX_DONE_DEV_REMOVE,
-};
-
-void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms);
-int rtw_sctx_wait(struct submit_ctx *sctx);
-void rtw_sctx_done_err(struct submit_ctx **sctx, int status);
-
-struct xmit_buf {
-       struct list_head list;
-       struct adapter *padapter;
-       u8 *pallocated_buf;
-       u8 *pbuf;
-       void *priv_data;
-       u16 ext_tag; /*  0: Normal xmitbuf, 1: extension xmitbuf. */
-       bool high_queue;
-       u32 alloc_sz;
-       u32  len;
-       struct submit_ctx *sctx;
-       struct urb *pxmit_urb;
-       int last[8];
-};
-
-struct xmit_frame {
-       struct list_head list;
-       struct pkt_attrib attrib;
-       struct sk_buff *pkt;
-       int     frame_tag;
-       struct adapter *padapter;
-       u8      *buf_addr;
-       struct xmit_buf *pxmitbuf;
-
-       u8      agg_num;
-       s8      pkt_offset;
-       u8 ack_report;
-};
-
-struct tx_servq {
-       struct list_head tx_pending;
-       struct list_head sta_pending;
-       int qcnt;
-};
-
-struct sta_xmit_priv {
-       spinlock_t lock;
-       struct tx_servq be_q;                   /* priority == 0,3 */
-       struct tx_servq bk_q;                   /* priority == 1,2 */
-       struct tx_servq vi_q;                   /* priority == 4,5 */
-       struct tx_servq vo_q;                   /* priority == 6,7 */
-       u16 txseq_tid[16];
-};
-
-struct hw_txqueue {
-       volatile int    head;
-       volatile int    tail;
-       volatile int    free_sz;        /* in units of 64 bytes */
-       volatile int      free_cmdsz;
-       volatile int     txsz[8];
-       uint    ff_hwaddr;
-       uint    cmd_hwaddr;
-       int     ac_tag;
-};
-
-struct xmit_priv {
-       spinlock_t lock;
-       struct list_head be_pending;
-       struct list_head bk_pending;
-       struct list_head vi_pending;
-       struct list_head vo_pending;
-       u8 *pallocated_frame_buf;
-       u8 *pxmit_frame_buf;
-       uint free_xmitframe_cnt;
-       struct __queue free_xmit_queue;
-       uint    frag_len;
-       struct adapter  *adapter;
-       u64     tx_bytes;
-       u64     tx_pkts;
-       u64     tx_drop;
-       u64     last_tx_bytes;
-       u64     last_tx_pkts;
-       struct hw_xmit *hwxmits;
-       u8      wmm_para_seq[4];/* sequence for wmm ac parameter strength
-                                * from large to small. it's value is 0->vo,
-                                * 1->vi, 2->be, 3->bk. */
-       struct tasklet_struct xmit_tasklet;
-       struct __queue free_xmitbuf_queue;
-       struct __queue pending_xmitbuf_queue;
-       u8 *pallocated_xmitbuf;
-       u8 *pxmitbuf;
-       uint free_xmitbuf_cnt;
-       struct __queue free_xmit_extbuf_queue;
-       u8 *pallocated_xmit_extbuf;
-       u8 *pxmit_extbuf;
-       uint free_xmit_extbuf_cnt;
-       u16     nqos_ssn;
-       int     ack_tx;
-       struct mutex ack_tx_mutex;
-       struct submit_ctx ack_tx_ops;
-};
-
-struct pkt_file {
-       struct sk_buff *pkt;
-       size_t pkt_len;  /* the remainder length of the open_file */
-       unsigned char *cur_buffer;
-       u8 *buf_start;
-       u8 *cur_addr;
-       size_t buf_len;
-};
-
-struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv);
-s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv,
-                        struct xmit_buf *pxmitbuf);
-struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
-s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv,
-                    struct xmit_buf *pxmitbuf);
-void rtw_count_tx_stats(struct adapter *padapter,
-                       struct xmit_frame *pxmitframe, int sz);
-s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr,
-                    struct pkt_attrib *pattrib);
-s32 rtw_put_snap(u8 *data, u16 h_proto);
-
-struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv);
-s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv,
-                      struct xmit_frame *pxmitframe);
-void rtw_free_xmitframe_list(struct xmit_priv *pxmitpriv, struct list_head *xframe_list);
-struct tx_servq *rtw_get_sta_pending(struct adapter *padapter,
-                                    struct sta_info *psta, int up, u8 *ac);
-struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv,
-                                     struct hw_xmit *phwxmit_i);
-
-s32 rtw_xmit_classifier(struct adapter *padapter,
-                       struct xmit_frame *pxmitframe);
-s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt,
-                          struct xmit_frame *pxmitframe);
-s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
-void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
-s32 rtw_txframes_pending(struct adapter *padapter);
-s32 rtw_txframes_sta_ac_pending(struct adapter *padapter,
-                               struct pkt_attrib *pattrib);
-int _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter);
-void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv);
-int rtw_alloc_hwxmits(struct adapter *padapter);
-s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt);
-
-int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe);
-void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta);
-void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta);
-void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta);
-
-u8     qos_acm(u8 acm_mask, u8 priority);
-u32    rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe);
-int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms);
-void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status);
-
-void rtw_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe);
-netdev_tx_t rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev);
-
-#endif /* _RTL871X_XMIT_H_ */
diff --git a/drivers/staging/r8188eu/include/sta_info.h b/drivers/staging/r8188eu/include/sta_info.h
deleted file mode 100644 (file)
index e42f4b4..0000000
+++ /dev/null
@@ -1,313 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __STA_INFO_H_
-#define __STA_INFO_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-#include "wifi.h"
-
-#define IBSS_START_MAC_ID      2
-#define NUM_STA 32
-#define NUM_ACL 16
-
-/* if mode ==0, then the sta is allowed once the addr is hit. */
-/* if mode ==1, then the sta is rejected once the addr is non-hit. */
-struct rtw_wlan_acl_node {
-       struct list_head list;
-       u8       addr[ETH_ALEN];
-       u8       valid;
-};
-
-/* mode=0, disable */
-/* mode=1, accept unless in deny list */
-/* mode=2, deny unless in accept list */
-struct wlan_acl_pool {
-       int mode;
-       int num;
-       struct rtw_wlan_acl_node aclnode[NUM_ACL];
-       struct __queue acl_node_q;
-};
-
-struct rssi_sta {
-       s32     UndecoratedSmoothedPWDB;
-       s32     UndecoratedSmoothedCCK;
-       s32     UndecoratedSmoothedOFDM;
-       u64     PacketMap;
-       u8      ValidBit;
-};
-
-struct stainfo_stats   {
-       u64 rx_mgnt_pkts;
-       u64 rx_beacon_pkts;
-       u64 rx_probereq_pkts;
-       u64 rx_probersp_pkts;
-       u64 rx_probersp_bm_pkts;
-       u64 rx_probersp_uo_pkts;
-       u64 rx_ctrl_pkts;
-       u64 rx_data_pkts;
-
-       u64 last_rx_beacon_pkts;
-       u64 last_rx_probereq_pkts;
-       u64 last_rx_probersp_pkts;
-       u64 last_rx_probersp_bm_pkts;
-       u64 last_rx_probersp_uo_pkts;
-       u64     last_rx_ctrl_pkts;
-       u64     last_rx_data_pkts;
-       u64     rx_bytes;
-       u64     rx_drops;
-       u64     tx_pkts;
-       u64     tx_bytes;
-       u64  tx_drops;
-};
-
-struct sta_info {
-       spinlock_t lock;
-       struct list_head list; /* free_sta_queue */
-       struct list_head hash_list; /* sta_hash */
-
-       struct sta_xmit_priv sta_xmitpriv;
-       struct sta_recv_priv sta_recvpriv;
-
-       struct __queue sleep_q;
-       unsigned int sleepq_len;
-
-       uint state;
-       uint aid;
-       uint mac_id;
-       uint qos_option;
-       u8      hwaddr[ETH_ALEN];
-
-       uint    ieee8021x_blocked;      /* 0: allowed, 1:blocked */
-       uint    dot118021XPrivacy; /* aes, tkip... */
-       union Keytype   dot11tkiptxmickey;
-       union Keytype   dot11tkiprxmickey;
-       union Keytype   dot118021x_UncstKey;
-       union pn48              dot11txpn;                      /*  PN48 used for Unicast xmit. */
-       union pn48              dot11rxpn;                      /*  PN48 used for Unicast recv. */
-       u8      bssrateset[16];
-       u32     bssratelen;
-       s32  rssi;
-       s32     signal_quality;
-
-       u8      cts2self;
-       u8      rtsen;
-
-       u8      raid;
-       u8      init_rate;
-       u32     ra_mask;
-       u8      wireless_mode;  /*  NETWORK_TYPE */
-       struct stainfo_stats sta_stats;
-
-       /* for A-MPDU TX, ADDBA timeout check */
-       struct timer_list addba_retry_timer;
-
-       /* for A-MPDU Rx reordering buffer control */
-       struct recv_reorder_ctrl recvreorder_ctrl[16];
-
-       /* for A-MPDU Tx */
-       /* unsigned char                ampdu_txen_bitmap; */
-       u16     BA_starting_seqctrl[16];
-
-       struct ht_priv  htpriv;
-
-       /* Notes: */
-       /* STA_Mode: */
-       /* curr_network(mlme_priv/security_priv/qos/ht) +
-        * sta_info: (STA & AP) CAP/INFO */
-       /* scan_q: AP CAP/INFO */
-
-       /* AP_Mode: */
-       /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
-       /* sta_info: (AP & STA) CAP/INFO */
-
-       struct list_head asoc_list;
-       struct list_head auth_list;
-
-       unsigned int expire_to;
-       unsigned int auth_seq;
-       unsigned int authalg;
-       unsigned char chg_txt[128];
-
-       u16 capability;
-       int flags;
-
-       int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
-       int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
-       int wpa_group_cipher;
-       int wpa2_group_cipher;
-       int wpa_pairwise_cipher;
-       int wpa2_pairwise_cipher;
-
-       u8 bpairwise_key_installed;
-
-       u8 wpa_ie[32];
-
-       u8 nonerp_set;
-       u8 no_short_slot_time_set;
-       u8 no_short_preamble_set;
-       u8 no_ht_gf_set;
-       u8 no_ht_set;
-       u8 ht_20mhz_set;
-
-       unsigned int tx_ra_bitmap;
-       u8 qos_info;
-
-       u8 max_sp_len;
-       u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
-       u8 uapsd_be;
-       u8 uapsd_vi;
-       u8 uapsd_vo;
-
-       u8 has_legacy_ac;
-       unsigned int sleepq_ac_len;
-
-       /* p2p priv data */
-       u8 is_p2p_device;
-       u8 p2p_status_code;
-
-       /* p2p client info */
-       u8 dev_addr[ETH_ALEN];
-       u8 dev_cap;
-       u16 config_methods;
-       u8 primary_dev_type[8];
-       u8 num_of_secdev_type;
-       u8 secdev_types_list[32];/*  32/8 == 4; */
-       u16 dev_name_len;
-       u8 dev_name[32];
-       u8 under_exist_checking;
-       u8 keep_alive_trycnt;
-
-       /* for DM */
-       struct rssi_sta rssi_stat;
-
-       /*  ================ODM Relative Info======================= */
-       /*  Please be careful, don't declare too much structure here.
-        *  It will cost memory * STA support num. */
-       /*  2011/10/20 MH Add for ODM STA info. */
-       /*  Driver Write */
-       u8      bValid;         /*  record the sta status link or not? */
-       u8      IOTPeer;        /*  Enum value. HT_IOT_PEER_E */
-       u8      rssi_level;     /* for Refresh RA mask */
-       /*  ODM Write */
-       /* 1 PHY_STATUS_INFO */
-       u8              RSSI_Path[4];           /*  */
-       u8              RSSI_Ave;
-       u8              RXEVM[4];
-       u8              RXSNR[4];
-
-       /*  ================ODM Relative Info======================= */
-       /*  */
-
-       /* To store the sequence number of received management frame */
-       u16 RxMgmtFrameSeqNum;
-};
-
-#define sta_rx_pkts(sta) \
-       (sta->sta_stats.rx_mgnt_pkts \
-       + sta->sta_stats.rx_ctrl_pkts \
-       + sta->sta_stats.rx_data_pkts)
-
-#define sta_rx_data_pkts(sta) \
-       (sta->sta_stats.rx_data_pkts)
-
-#define sta_last_rx_data_pkts(sta) \
-       (sta->sta_stats.last_rx_data_pkts)
-
-#define sta_rx_beacon_pkts(sta) \
-       (sta->sta_stats.rx_beacon_pkts)
-
-#define sta_last_rx_beacon_pkts(sta) \
-       (sta->sta_stats.last_rx_beacon_pkts)
-
-#define sta_rx_probersp_pkts(sta) \
-       (sta->sta_stats.rx_probersp_pkts)
-
-#define sta_last_rx_probersp_pkts(sta) \
-       (sta->sta_stats.last_rx_probersp_pkts)
-
-#define sta_update_last_rx_pkts(sta) \
-do { \
-       sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
-       sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
-       sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
-       sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
-       sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
-       sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
-       sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
-} while (0)
-
-struct sta_priv {
-       u8 *pallocated_stainfo_buf;
-       u8 *pstainfo_buf;
-       struct __queue free_sta_queue;
-
-       spinlock_t sta_hash_lock;
-       struct list_head sta_hash[NUM_STA];
-       int asoc_sta_count;
-       struct __queue sleep_q;
-       struct __queue wakeup_q;
-
-       struct adapter *padapter;
-
-       spinlock_t asoc_list_lock;
-       struct list_head asoc_list;
-
-       struct list_head auth_list;
-       spinlock_t auth_list_lock;
-       u8 asoc_list_cnt;
-       u8 auth_list_cnt;
-
-       unsigned int auth_to;  /* sec, time to expire in authenticating. */
-       unsigned int assoc_to; /* sec, time to expire before associating. */
-       unsigned int expire_to; /* sec , time to expire after associated. */
-
-       /* pointers to STA info; based on allocated AID or NULL if AID free
-        * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
-        * and so on
-        */
-       struct sta_info *sta_aid[NUM_STA];
-
-       u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap
-                          * for sleeping sta. */
-       u16 tim_bitmap; /* only support 15 stations, aid=0~15 mapping
-                        * bit0~bit15 */
-
-       u16 max_num_sta;
-
-       struct wlan_acl_pool acl_list;
-};
-
-static inline u32 wifi_mac_hash(u8 *mac)
-{
-       u32 x;
-
-       x = mac[0];
-       x = (x << 2) ^ mac[1];
-       x = (x << 2) ^ mac[2];
-       x = (x << 2) ^ mac[3];
-       x = (x << 2) ^ mac[4];
-       x = (x << 2) ^ mac[5];
-
-       x ^= x >> 8;
-       x  = x & (NUM_STA - 1);
-       return x;
-}
-
-int _rtw_init_sta_priv(struct sta_priv *pstapriv);
-void _rtw_free_sta_priv(struct sta_priv *pstapriv);
-
-#define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
-int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
-struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int off);
-
-struct sta_info *rtw_alloc_stainfo(struct sta_priv *stapriv, u8 *hwaddr);
-void rtw_free_stainfo(struct adapter *adapt, struct sta_info *psta);
-void rtw_free_all_stainfo(struct adapter *adapt);
-struct sta_info *rtw_get_stainfo(struct sta_priv *stapriv, u8 *hwaddr);
-u32 rtw_init_bcmc_stainfo(struct adapter *adapt);
-struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter);
-u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
-
-#endif /* _STA_INFO_H_ */
diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h
deleted file mode 100644 (file)
index 5bd8ce3..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __USB_OPS_H_
-#define __USB_OPS_H_
-
-#include "osdep_service.h"
-#include "drv_types.h"
-#include "osdep_intf.h"
-
-#define REALTEK_USB_VENQT_READ         (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
-#define REALTEK_USB_VENQT_WRITE                (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
-#define REALTEK_USB_VENQT_CMD_REQ      0x05
-#define REALTEK_USB_VENQT_CMD_IDX      0x00
-
-#define ALIGNMENT_UNIT                 16
-#define MAX_VENDOR_REQ_CMD_SIZE        254     /* 8188cu SIE Support */
-#define MAX_USB_IO_CTL_SIZE    (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
-
-/*
- * Increase and check if the continual_urb_error of this @param dvobjprivei
- * is larger than MAX_CONTINUAL_URB_ERR
- * @return true:
- * @return false:
- */
-static inline bool rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj)
-{
-       int value = atomic_inc_return(&dvobj->continual_urb_error);
-
-       if (value > MAX_CONTINUAL_URB_ERR)
-               return true;
-
-       return false;
-}
-
-/*
-* Set the continual_urb_error of this @param dvobjprive to 0
-*/
-static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj)
-{
-       atomic_set(&dvobj->continual_urb_error, 0);
-}
-
-#define USB_HIGH_SPEED_BULK_SIZE       512
-#define USB_FULL_SPEED_BULK_SIZE       64
-
-static inline bool rtw_usb_bulk_size_boundary(struct adapter *padapter, int buf_len)
-{
-       struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
-
-       if (pdvobjpriv->pusbdev->speed == USB_SPEED_HIGH)
-               return buf_len % USB_HIGH_SPEED_BULK_SIZE == 0;
-       else
-               return buf_len % USB_FULL_SPEED_BULK_SIZE == 0;
-}
-
-#endif /* __USB_OPS_H_ */
diff --git a/drivers/staging/r8188eu/include/usb_osintf.h b/drivers/staging/r8188eu/include/usb_osintf.h
deleted file mode 100644 (file)
index f271e93..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __USB_OSINTF_H
-#define __USB_OSINTF_H
-
-#include "osdep_service.h"
-#include "drv_types.h"
-
-extern char *rtw_initmac;
-extern int rtw_mc2u_disable;
-
-#define USBD_HALTED(Status) ((u32)(Status) >> 30 == 3)
-
-void netdev_br_init(struct net_device *netdev);
-void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb);
-void *scdb_findEntry(struct adapter *priv, unsigned char *ipAddr);
-void nat25_db_expire(struct adapter *priv);
-int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method);
-
-#endif
diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h
deleted file mode 100644 (file)
index 254a4bc..0000000
+++ /dev/null
@@ -1,773 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#ifndef _WIFI_H_
-#define _WIFI_H_
-
-#include <linux/bits.h>
-#include <linux/ieee80211.h>
-
-#define WLAN_ETHHDR_LEN                14
-#define WLAN_HDR_A3_LEN                24
-#define WLAN_HDR_A3_QOS_LEN    26
-#define WLAN_SSID_MAXLEN       32
-
-enum WIFI_FRAME_SUBTYPE {
-       /*  below is for mgt frame */
-       WIFI_ASSOCREQ       = (0 | IEEE80211_FTYPE_MGMT),
-       WIFI_ASSOCRSP       = (BIT(4) | IEEE80211_FTYPE_MGMT),
-       WIFI_REASSOCREQ     = (BIT(5) | IEEE80211_FTYPE_MGMT),
-       WIFI_REASSOCRSP     = (BIT(5) | BIT(4) | IEEE80211_FTYPE_MGMT),
-       WIFI_PROBEREQ       = (BIT(6) | IEEE80211_FTYPE_MGMT),
-       WIFI_PROBERSP       = (BIT(6) | BIT(4) | IEEE80211_FTYPE_MGMT),
-       WIFI_BEACON         = (BIT(7) | IEEE80211_FTYPE_MGMT),
-       WIFI_ATIM           = (BIT(7) | BIT(4) | IEEE80211_FTYPE_MGMT),
-       WIFI_DISASSOC       = (BIT(7) | BIT(5) | IEEE80211_FTYPE_MGMT),
-       WIFI_AUTH           = (BIT(7) | BIT(5) | BIT(4) | IEEE80211_FTYPE_MGMT),
-       WIFI_DEAUTH         = (BIT(7) | BIT(6) | IEEE80211_FTYPE_MGMT),
-       WIFI_ACTION         = (BIT(7) | BIT(6) | BIT(4) | IEEE80211_FTYPE_MGMT),
-
-       /*  below is for control frame */
-       WIFI_PSPOLL         = (BIT(7) | BIT(5) | IEEE80211_FTYPE_CTL),
-
-       /*  below is for data frame */
-       WIFI_DATA           = (0 | IEEE80211_FTYPE_DATA),
-       WIFI_DATA_CFACK     = (BIT(4) | IEEE80211_FTYPE_DATA),
-       WIFI_DATA_CFPOLL    = (BIT(5) | IEEE80211_FTYPE_DATA),
-       WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | IEEE80211_FTYPE_DATA),
-       WIFI_DATA_NULL      = (BIT(6) | IEEE80211_FTYPE_DATA),
-       WIFI_QOS_DATA_NULL      = (BIT(6) | IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA),
-};
-
-enum WIFI_REASON_CODE  {
-       _RSON_RESERVED_                 = 0,
-       _RSON_UNSPECIFIED_              = 1,
-       _RSON_AUTH_NO_LONGER_VALID_     = 2,
-       _RSON_DEAUTH_STA_LEAVING_       = 3,
-       _RSON_INACTIVITY_               = 4,
-       _RSON_UNABLE_HANDLE_            = 5,
-       _RSON_CLS2_                     = 6,
-       _RSON_CLS3_                     = 7,
-       _RSON_DISAOC_STA_LEAVING_       = 8,
-       _RSON_ASOC_NOT_AUTH_            = 9,
-
-       /*  WPA reason */
-       _RSON_INVALID_IE_               = 13,
-       _RSON_MIC_FAILURE_              = 14,
-       _RSON_4WAY_HNDSHK_TIMEOUT_      = 15,
-       _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16,
-       _RSON_DIFF_IE_                  = 17,
-       _RSON_MLTCST_CIPHER_NOT_VALID_  = 18,
-       _RSON_UNICST_CIPHER_NOT_VALID_  = 19,
-       _RSON_AKMP_NOT_VALID_           = 20,
-       _RSON_UNSUPPORT_RSNE_VER_       = 21,
-       _RSON_INVALID_RSNE_CAP_         = 22,
-       _RSON_IEEE_802DOT1X_AUTH_FAIL_  = 23,
-
-       /* belowing are Realtek definition */
-       _RSON_PMK_NOT_AVAILABLE_        = 24,
-       _RSON_TDLS_TEAR_TOOFAR_         = 25,
-       _RSON_TDLS_TEAR_UN_RSN_         = 26,
-};
-
-enum WIFI_STATUS_CODE {
-       _STATS_SUCCESSFUL_              = 0,
-       _STATS_FAILURE_                 = 1,
-       _STATS_CAP_FAIL_                = 10,
-       _STATS_NO_ASOC_                 = 11,
-       _STATS_OTHER_                   = 12,
-       _STATS_NO_SUPP_ALG_             = 13,
-       _STATS_OUT_OF_AUTH_SEQ_         = 14,
-       _STATS_CHALLENGE_FAIL_          = 15,
-       _STATS_AUTH_TIMEOUT_            = 16,
-       _STATS_UNABLE_HANDLE_STA_       = 17,
-       _STATS_RATE_FAIL_               = 18,
-};
-
-/* entended */
-/* IEEE 802.11b */
-#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
-#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
-#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
-/* IEEE 802.11h */
-#define WLAN_STATUS_SPEC_MGMT_REQUIRED 22
-#define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23
-#define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24
-/* IEEE 802.11g */
-#define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25
-#define WLAN_STATUS_ASSOC_DENIED_NO_ER_PBCC 26
-#define WLAN_STATUS_ASSOC_DENIED_NO_DSSS_OFDM 27
-/* IEEE 802.11w */
-#define WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY 30
-#define WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION 31
-/* IEEE 802.11i */
-#define WLAN_STATUS_INVALID_IE 40
-#define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41
-#define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42
-#define WLAN_STATUS_AKMP_NOT_VALID 43
-#define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44
-#define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45
-#define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46
-#define WLAN_STATUS_TS_NOT_CREATED 47
-#define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48
-#define WLAN_STATUS_DEST_STA_NOT_PRESENT 49
-#define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50
-#define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51
-/* IEEE 802.11r */
-#define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52
-#define WLAN_STATUS_INVALID_PMKID 53
-#define WLAN_STATUS_INVALID_MDIE 54
-#define WLAN_STATUS_INVALID_FTIE 55
-
-enum WIFI_REG_DOMAIN {
-       DOMAIN_FCC      = 1,
-       DOMAIN_IC       = 2,
-       DOMAIN_ETSI     = 3,
-       DOMAIN_SPA      = 4,
-       DOMAIN_FRANCE   = 5,
-       DOMAIN_MKK      = 6,
-       DOMAIN_ISRAEL   = 7,
-       DOMAIN_MKK1     = 8,
-       DOMAIN_MKK2     = 9,
-       DOMAIN_MKK3     = 10,
-       DOMAIN_MAX
-};
-
-#define _TO_DS_                BIT(8)
-#define _FROM_DS_      BIT(9)
-#define _MORE_FRAG_    BIT(10)
-#define _RETRY_                BIT(11)
-#define _PWRMGT_       BIT(12)
-#define _MORE_DATA_    BIT(13)
-#define _PRIVACY_      BIT(14)
-
-#define SetToDs(pbuf)  \
-       *(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_)
-
-#define GetToDs(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0)
-
-#define SetFrDs(pbuf)  \
-       *(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_)
-
-#define GetFrDs(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0)
-
-#define SetMFrag(pbuf) \
-       *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_)
-
-#define ClearMFrag(pbuf)       \
-       *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_))
-
-#define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0)
-
-#define SetPwrMgt(pbuf)        \
-       *(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_)
-
-#define GetPwrMgt(pbuf)        (((*(__le16 *)(pbuf)) & cpu_to_le16(_PWRMGT_)) != 0)
-
-#define SetMData(pbuf) \
-       *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_)
-
-#define SetPrivacy(pbuf)       \
-       *(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_)
-
-#define GetFrameType(pbuf)                             \
-       (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2)))
-
-#define GetFrameSubType(pbuf)  (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(7) |\
-        BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2)))
-
-#define SetFrameSubType(pbuf, type) \
-       do {    \
-               *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) |    \
-                BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
-               *(__le16 *)(pbuf) |= cpu_to_le16(type); \
-       } while (0)
-
-#define SetSeqNum(pbuf, num) \
-       do {    \
-               *(__le16 *)((size_t)(pbuf) + 22) = \
-                       ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \
-                       cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \
-       } while (0)
-
-#define SetDuration(pbuf, dur) \
-       *(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur))
-
-#define SetPriority(pbuf, tid) \
-       *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf)
-
-#define SetEOSP(pbuf, eosp)    \
-               *(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4)
-
-#define SetAckpolicy(pbuf, ack)        \
-       *(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5)
-
-#define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3)
-
-#define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1)
-
-#define GetAddr1Ptr(pbuf)      ((unsigned char *)((size_t)(pbuf) + 4))
-
-#define GetAddr2Ptr(pbuf)      ((unsigned char *)((size_t)(pbuf) + 10))
-
-#define GetAddr3Ptr(pbuf)      ((unsigned char *)((size_t)(pbuf) + 16))
-
-#define GetAddr4Ptr(pbuf)      ((unsigned char *)((size_t)(pbuf) + 24))
-
-static inline unsigned char *get_sa(unsigned char *pframe)
-{
-       unsigned char   *sa;
-       unsigned int    to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
-
-       switch (to_fr_ds) {
-       case 0x00:      /*  ToDs=0, FromDs=0 */
-               sa = GetAddr2Ptr(pframe);
-               break;
-       case 0x01:      /*  ToDs=0, FromDs=1 */
-               sa = GetAddr3Ptr(pframe);
-               break;
-       case 0x02:      /*  ToDs=1, FromDs=0 */
-               sa = GetAddr2Ptr(pframe);
-               break;
-       default:        /*  ToDs=1, FromDs=1 */
-               sa = GetAddr4Ptr(pframe);
-               break;
-       }
-       return sa;
-}
-
-static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
-{
-       unsigned char   *sa;
-       unsigned int    to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
-
-       switch (to_fr_ds) {
-       case 0x00:      /*  ToDs=0, FromDs=0 */
-               sa = GetAddr3Ptr(pframe);
-               break;
-       case 0x01:      /*  ToDs=0, FromDs=1 */
-               sa = GetAddr2Ptr(pframe);
-               break;
-       case 0x02:      /*  ToDs=1, FromDs=0 */
-               sa = GetAddr1Ptr(pframe);
-               break;
-       case 0x03:      /*  ToDs=1, FromDs=1 */
-               sa = GetAddr1Ptr(pframe);
-               break;
-       default:
-               sa = NULL; /*  */
-               break;
-       }
-       return sa;
-}
-
-/*-----------------------------------------------------------------------------
-                       Below is for the security related definition
-------------------------------------------------------------------------------*/
-#define _RESERVED_FRAME_TYPE_          0
-#define _SKB_FRAME_TYPE_               2
-#define _PRE_ALLOCMEM_                 1
-#define _PRE_ALLOCHDR_                 3
-#define _PRE_ALLOCLLCHDR_              4
-#define _PRE_ALLOCICVHDR_              5
-#define _PRE_ALLOCMICHDR_              6
-
-#define _SIFSTIME_                             \
-       (priv->pmib->dot11BssType.net_work_type = 10)
-#define _ACKCTSLNG_            14      /* 14 bytes long, including crclng */
-#define _CRCLNG_               4
-
-#define _ASOCREQ_IE_OFFSET_    4       /*  excluding wlan_hdr */
-#define        _ASOCRSP_IE_OFFSET_     6
-#define _REASOCREQ_IE_OFFSET_  10
-#define _REASOCRSP_IE_OFFSET_  6
-#define _PROBEREQ_IE_OFFSET_   0
-#define        _PROBERSP_IE_OFFSET_    12
-#define _AUTH_IE_OFFSET_       6
-#define _DEAUTH_IE_OFFSET_     0
-#define _BEACON_IE_OFFSET_     12
-#define _PUBLIC_ACTION_IE_OFFSET_      8
-
-#define _FIXED_IE_LENGTH_      _BEACON_IE_OFFSET_
-
-#define _SSID_IE_              0
-#define _SUPPORTEDRATES_IE_    1
-#define _DSSET_IE_             3
-#define _TIM_IE_               5
-#define _IBSS_PARA_IE_         6
-#define _COUNTRY_IE_           7
-#define _CHLGETXT_IE_          16
-#define _SUPPORTED_CH_IE_      36
-#define _CH_SWTICH_ANNOUNCE_   37      /* Secondary Channel Offset */
-#define _RSN_IE_2_             48
-#define _SSN_IE_1_             221
-#define _ERPINFO_IE_           42
-#define _EXT_SUPPORTEDRATES_IE_        50
-
-#define _HT_CAPABILITY_IE_     45
-#define _FTIE_                 55
-#define _TIMEOUT_ITVL_IE_      56
-#define _SRC_IE_               59
-#define _HT_EXTRA_INFO_IE_     61
-#define _HT_ADD_INFO_IE_       61 /* _HT_EXTRA_INFO_IE_ */
-#define _WAPI_IE_              68
-
-#define        EID_BSSCoexistence      72 /*  20/40 BSS Coexistence */
-#define        EID_BSSIntolerantChlReport      73
-#define _RIC_Descriptor_IE_    75
-
-#define _LINK_ID_IE_           101
-#define _CH_SWITCH_TIMING_     104
-#define _PTI_BUFFER_STATUS_    106
-#define _EXT_CAP_IE_           127
-#define _VENDOR_SPECIFIC_IE_   221
-
-#define        _RESERVED47_            47
-
-/* ---------------------------------------------------------------------------
-                                       Below is the fixed elements...
------------------------------------------------------------------------------*/
-#define _AUTH_ALGM_NUM_                2
-#define _AUTH_SEQ_NUM_         2
-#define _BEACON_ITERVAL_       2
-#define _CAPABILITY_           2
-#define _CURRENT_APADDR_       6
-#define _LISTEN_INTERVAL_      2
-#define _RSON_CODE_            2
-#define _ASOC_ID_              2
-#define _STATUS_CODE_          2
-#define _TIMESTAMP_            8
-
-#define cap_ESS                BIT(0)
-#define cap_IBSS       BIT(1)
-#define cap_CFPollable BIT(2)
-#define cap_CFRequest  BIT(3)
-#define cap_Privacy    BIT(4)
-#define cap_ShortPremble BIT(5)
-#define cap_PBCC       BIT(6)
-#define cap_ChAgility  BIT(7)
-#define cap_SpecMgmt   BIT(8)
-#define cap_QoSi       BIT(9)
-#define cap_ShortSlot  BIT(10)
-
-/*-----------------------------------------------------------------------------
-                               Below is the definition for 802.11i / 802.1x
-------------------------------------------------------------------------------*/
-#define _IEEE8021X_MGT_                        1       /*  WPA */
-#define _IEEE8021X_PSK_                        2       /*  WPA with pre-shared key */
-
-/*-----------------------------------------------------------------------------
-                               Below is the definition for WMM
-------------------------------------------------------------------------------*/
-#define _WMM_IE_Length_                                7  /*  for WMM STA */
-#define _WMM_Para_Element_Length_              24
-
-/*-----------------------------------------------------------------------------
-                               Below is the definition for 802.11n
-------------------------------------------------------------------------------*/
-
-/**
- * struct rtw_ieee80211_bar - HT Block Ack Request
- *
- * This structure refers to "HT BlockAckReq" as
- * described in 802.11n draft section 7.2.1.7.1
- */
-struct rtw_ieee80211_bar {
-       __le16 frame_control;
-       __le16 duration;
-       unsigned char ra[ETH_ALEN];
-       unsigned char ta[ETH_ALEN];
-       __le16 control;
-       __le16 start_seq_num;
-} __packed;
-
-/**
- * struct ieee80211_ht_cap - HT additional information
- *
- * This structure refers to "HT information element" as
- * described in 802.11n draft section 7.3.2.53
- */
-struct ieee80211_ht_addt_info {
-       unsigned char   control_chan;
-       unsigned char   ht_param;
-       __le16  operation_mode;
-       __le16  stbc_param;
-       unsigned char   basic_set[16];
-} __packed;
-
-struct HT_caps_element {
-       union {
-               struct {
-                       __le16  HT_caps_info;
-                       unsigned char   AMPDU_para;
-                       unsigned char   MCS_rate[16];
-                       __le16  HT_ext_caps;
-                       __le16  Beamforming_caps;
-                       unsigned char   ASEL_caps;
-               } HT_cap_element;
-               unsigned char HT_cap[26];
-       } u;
-} __packed;
-
-struct HT_info_element {
-       unsigned char   primary_channel;
-       unsigned char   infos[5];
-       unsigned char   MCS_rate[16];
-} __packed;
-
-struct AC_param {
-       unsigned char           ACI_AIFSN;
-       unsigned char           CW;
-       __le16  TXOP_limit;
-} __packed;
-
-struct WMM_para_element {
-       unsigned char           QoS_info;
-       unsigned char           reserved;
-       struct AC_param ac_param[4];
-} __packed;
-
-#define MAX_AMPDU_FACTOR_64K   3
-
-/* Spatial Multiplexing Power Save Modes */
-#define WLAN_HT_CAP_SM_PS_STATIC       0
-#define WLAN_HT_CAP_SM_PS_DYNAMIC      1
-#define WLAN_HT_CAP_SM_PS_INVALID      2
-#define WLAN_HT_CAP_SM_PS_DISABLED     3
-
-#define OP_MODE_PURE                    0
-#define OP_MODE_MAY_BE_LEGACY_STAS      1
-#define OP_MODE_20MHZ_HT_STA_ASSOCED    2
-#define OP_MODE_MIXED                   3
-
-#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK       ((u8) BIT(0) | BIT(1))
-#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE          ((u8) BIT(0))
-#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW          ((u8) BIT(0) | BIT(1))
-#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH          ((u8) BIT(2))
-#define HT_INFO_HT_PARAM_RIFS_MODE                     ((u8) BIT(3))
-#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY              ((u8) BIT(4))
-#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY      ((u8) BIT(5))
-
-#define HT_INFO_OPERATION_MODE_OP_MODE_MASK    \
-               ((u16) (0x0001 | 0x0002))
-#define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET          0
-#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT     ((u8) BIT(2))
-#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT    ((u8) BIT(3))
-#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT      ((u8) BIT(4))
-
-/*     ===============WPS Section=============== */
-/*     For WPSv1.0 */
-#define WPSOUI                                 0x0050f204
-/*     WPS attribute ID */
-#define WPS_ATTR_VER1                          0x104A
-#define WPS_ATTR_SIMPLE_CONF_STATE             0x1044
-#define WPS_ATTR_RESP_TYPE                     0x103B
-#define WPS_ATTR_UUID_E                                0x1047
-#define WPS_ATTR_MANUFACTURER                  0x1021
-#define WPS_ATTR_MODEL_NAME                    0x1023
-#define WPS_ATTR_MODEL_NUMBER                  0x1024
-#define WPS_ATTR_SERIAL_NUMBER                 0x1042
-#define WPS_ATTR_PRIMARY_DEV_TYPE              0x1054
-#define WPS_ATTR_SEC_DEV_TYPE_LIST             0x1055
-#define WPS_ATTR_DEVICE_NAME                   0x1011
-#define WPS_ATTR_CONF_METHOD                   0x1008
-#define WPS_ATTR_RF_BANDS                      0x103C
-#define WPS_ATTR_DEVICE_PWID                   0x1012
-#define WPS_ATTR_REQUEST_TYPE                  0x103A
-#define WPS_ATTR_ASSOCIATION_STATE             0x1002
-#define WPS_ATTR_CONFIG_ERROR                  0x1009
-#define WPS_ATTR_VENDOR_EXT                    0x1049
-#define WPS_ATTR_SELECTED_REGISTRAR            0x1041
-
-/*     Value of WPS attribute "WPS_ATTR_DEVICE_NAME */
-#define WPS_MAX_DEVICE_NAME_LEN                        32
-
-/*     Value of WPS Request Type Attribute */
-#define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY                0x00
-#define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X       0x01
-#define WPS_REQ_TYPE_REGISTRAR                 0x02
-#define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR    0x03
-
-/*     Value of WPS Response Type Attribute */
-#define WPS_RESPONSE_TYPE_INFO_ONLY    0x00
-#define WPS_RESPONSE_TYPE_8021X                0x01
-#define WPS_RESPONSE_TYPE_REGISTRAR    0x02
-#define WPS_RESPONSE_TYPE_AP           0x03
-
-/*     Value of WPS WiFi Simple Configuration State Attribute */
-#define WPS_WSC_STATE_NOT_CONFIG       0x01
-#define WPS_WSC_STATE_CONFIG           0x02
-
-/*     Value of WPS Version Attribute */
-#define WPS_VERSION_1                  0x10
-
-/*     Value of WPS Configuration Method Attribute */
-#define WPS_CONFIG_METHOD_FLASH                0x0001
-#define WPS_CONFIG_METHOD_ETHERNET     0x0002
-#define WPS_CONFIG_METHOD_LABEL                0x0004
-#define WPS_CONFIG_METHOD_DISPLAY      0x0008
-#define WPS_CONFIG_METHOD_E_NFC                0x0010
-#define WPS_CONFIG_METHOD_I_NFC                0x0020
-#define WPS_CONFIG_METHOD_NFC          0x0040
-#define WPS_CONFIG_METHOD_PBC          0x0080
-#define WPS_CONFIG_METHOD_KEYPAD       0x0100
-#define WPS_CONFIG_METHOD_VPBC         0x0280
-#define WPS_CONFIG_METHOD_PPBC         0x0480
-#define WPS_CONFIG_METHOD_VDISPLAY     0x2008
-#define WPS_CONFIG_METHOD_PDISPLAY     0x4008
-
-/*     Value of Category ID of WPS Primary Device Type Attribute */
-#define WPS_PDT_CID_DISPLAYS           0x0007
-#define WPS_PDT_CID_MULIT_MEDIA                0x0008
-#define WPS_PDT_CID_RTK_WIDI           WPS_PDT_CID_MULIT_MEDIA
-
-/*     Value of Sub Category ID of WPS Primary Device Type Attribute */
-#define WPS_PDT_SCID_MEDIA_SERVER      0x0005
-#define WPS_PDT_SCID_RTK_DMP           WPS_PDT_SCID_MEDIA_SERVER
-
-/*     Value of Device Password ID */
-#define WPS_DPID_P                     0x0000
-#define WPS_DPID_USER_SPEC             0x0001
-#define WPS_DPID_MACHINE_SPEC          0x0002
-#define WPS_DPID_REKEY                 0x0003
-#define WPS_DPID_PBC                   0x0004
-#define WPS_DPID_REGISTRAR_SPEC                0x0005
-
-/*     Value of WPS RF Bands Attribute */
-#define WPS_RF_BANDS_2_4_GHZ           0x01
-#define WPS_RF_BANDS_5_GHZ             0x02
-
-/*     Value of WPS Association State Attribute */
-#define WPS_ASSOC_STATE_NOT_ASSOCIATED         0x00
-#define WPS_ASSOC_STATE_CONNECTION_SUCCESS     0x01
-#define WPS_ASSOC_STATE_CONFIGURATION_FAILURE  0x02
-#define WPS_ASSOC_STATE_ASSOCIATION_FAILURE    0x03
-#define WPS_ASSOC_STATE_IP_FAILURE             0x04
-
-/*     =====================P2P Section===================== */
-/*     For P2P */
-#define        P2POUI                                  0x506F9A09
-
-/*     P2P Attribute ID */
-#define        P2P_ATTR_STATUS                         0x00
-#define        P2P_ATTR_MINOR_REASON_CODE              0x01
-#define        P2P_ATTR_CAPABILITY                     0x02
-#define        P2P_ATTR_DEVICE_ID                      0x03
-#define        P2P_ATTR_GO_INTENT                      0x04
-#define        P2P_ATTR_CONF_TIMEOUT                   0x05
-#define        P2P_ATTR_LISTEN_CH                      0x06
-#define        P2P_ATTR_GROUP_BSSID                    0x07
-#define        P2P_ATTR_EX_LISTEN_TIMING               0x08
-#define        P2P_ATTR_INTENTED_IF_ADDR               0x09
-#define        P2P_ATTR_MANAGEABILITY                  0x0A
-#define        P2P_ATTR_CH_LIST                        0x0B
-#define        P2P_ATTR_NOA                            0x0C
-#define        P2P_ATTR_DEVICE_INFO                    0x0D
-#define        P2P_ATTR_GROUP_INFO                     0x0E
-#define        P2P_ATTR_GROUP_ID                       0x0F
-#define        P2P_ATTR_INTERFACE                      0x10
-#define        P2P_ATTR_OPERATING_CH                   0x11
-#define        P2P_ATTR_INVITATION_FLAGS               0x12
-
-/*     Value of Status Attribute */
-#define        P2P_STATUS_SUCCESS                              0x00
-#define        P2P_STATUS_FAIL_INFO_UNAVAILABLE                0x01
-#define        P2P_STATUS_FAIL_INCOMPATIBLE_PARAM              0x02
-#define        P2P_STATUS_FAIL_LIMIT_REACHED                   0x03
-#define        P2P_STATUS_FAIL_INVALID_PARAM                   0x04
-#define        P2P_STATUS_FAIL_REQUEST_UNABLE                  0x05
-#define        P2P_STATUS_FAIL_PREVOUS_PROTO_ERR               0x06
-#define        P2P_STATUS_FAIL_NO_COMMON_CH                    0x07
-#define        P2P_STATUS_FAIL_UNKNOWN_P2PGROUP                0x08
-#define        P2P_STATUS_FAIL_BOTH_GOINTENT_15                0x09
-#define        P2P_STATUS_FAIL_INCOMPATIBLE_PROVSION           0x0A
-#define        P2P_STATUS_FAIL_USER_REJECT                     0x0B
-
-/*     Value of Inviation Flags Attribute */
-#define        P2P_INVITATION_FLAGS_PERSISTENT                 BIT(0)
-
-#define        DMP_P2P_DEVCAP_SUPPORT  (P2P_DEVCAP_SERVICE_DISCOVERY | \
-                               P2P_DEVCAP_CLIENT_DISCOVERABILITY | \
-                               P2P_DEVCAP_CONCURRENT_OPERATION | \
-                               P2P_DEVCAP_INVITATION_PROC)
-
-#define        DMP_P2P_GRPCAP_SUPPORT  (P2P_GRPCAP_INTRABSS)
-
-/*     Value of Device Capability Bitmap */
-#define        P2P_DEVCAP_SERVICE_DISCOVERY            BIT(0)
-#define        P2P_DEVCAP_CLIENT_DISCOVERABILITY       BIT(1)
-#define        P2P_DEVCAP_CONCURRENT_OPERATION         BIT(2)
-#define        P2P_DEVCAP_INFRA_MANAGED                BIT(3)
-#define        P2P_DEVCAP_DEVICE_LIMIT                 BIT(4)
-#define        P2P_DEVCAP_INVITATION_PROC              BIT(5)
-
-/*     Value of Group Capability Bitmap */
-#define        P2P_GRPCAP_GO                           BIT(0)
-#define        P2P_GRPCAP_PERSISTENT_GROUP             BIT(1)
-#define        P2P_GRPCAP_GROUP_LIMIT                  BIT(2)
-#define        P2P_GRPCAP_INTRABSS                     BIT(3)
-#define        P2P_GRPCAP_CROSS_CONN                   BIT(4)
-#define        P2P_GRPCAP_PERSISTENT_RECONN            BIT(5)
-#define        P2P_GRPCAP_GROUP_FORMATION              BIT(6)
-
-/*     P2P Public Action Frame (Management Frame) */
-#define        P2P_PUB_ACTION_ACTION                   0x09
-
-/*     P2P Public Action Frame Type */
-#define        P2P_GO_NEGO_REQ                         0
-#define        P2P_GO_NEGO_RESP                        1
-#define        P2P_GO_NEGO_CONF                        2
-#define        P2P_INVIT_REQ                           3
-#define        P2P_INVIT_RESP                          4
-#define        P2P_DEVDISC_REQ                         5
-#define        P2P_DEVDISC_RESP                        6
-#define        P2P_PROVISION_DISC_REQ                  7
-#define        P2P_PROVISION_DISC_RESP                 8
-
-/*     P2P Action Frame Type */
-#define        P2P_NOTICE_OF_ABSENCE                   0
-#define        P2P_PRESENCE_REQUEST                    1
-#define        P2P_PRESENCE_RESPONSE                   2
-#define        P2P_GO_DISC_REQUEST                     3
-
-#define        P2P_MAX_PERSISTENT_GROUP_NUM            10
-
-#define        P2P_PROVISIONING_SCAN_CNT               3
-
-#define        P2P_WILDCARD_SSID_LEN                   7
-
-/* default value, used when: (1)p2p disabled or (2)p2p enabled
- * but only do 1 scan phase */
-#define        P2P_FINDPHASE_EX_NONE           0
-/*  used when p2p enabled and want to do 1 scan phase and
- *  P2P_FINDPHASE_EX_MAX-1 find phase */
-#define        P2P_FINDPHASE_EX_FULL           1
-#define        P2P_FINDPHASE_EX_SOCIAL_FIRST   (P2P_FINDPHASE_EX_FULL+1)
-#define        P2P_FINDPHASE_EX_MAX            4
-#define        P2P_FINDPHASE_EX_SOCIAL_LAST    P2P_FINDPHASE_EX_MAX
-
-/* 5 seconds timeout for sending the provision discovery request */
-#define        P2P_PROVISION_TIMEOUT           5000
-/* 3 seconds timeout for sending the prov disc request concurrent mode */
-#define        P2P_CONCURRENT_PROVISION_TIME   3000
-/* 5 seconds timeout for receiving the group negotiation response */
-#define        P2P_GO_NEGO_TIMEOUT             5000
-/* 3 seconds timeout for sending the negotiation request under concurrent mode */
-#define        P2P_CONCURRENT_GO_NEGO_TIME     3000
-/* 100ms */
-#define        P2P_TX_PRESCAN_TIMEOUT          100
-/* 5 seconds timeout for sending the invitation request */
-#define        P2P_INVITE_TIMEOUT              5000
-/* 3 seconds timeout for sending the invitation request under concurrent mode */
-#define        P2P_CONCURRENT_INVITE_TIME      3000
-/* 25 seconds timeout to reset the scan channel (based on channel plan) */
-#define        P2P_RESET_SCAN_CH               25000
-#define        P2P_MAX_INTENT                  15
-
-#define        P2P_MAX_NOA_NUM                 2
-
-/*     WPS Configuration Method */
-#define        WPS_CM_NONE                     0x0000
-#define        WPS_CM_LABEL                    0x0004
-#define        WPS_CM_DISPLYA                  0x0008
-#define        WPS_CM_EXTERNAL_NFC_TOKEN       0x0010
-#define        WPS_CM_INTEGRATED_NFC_TOKEN     0x0020
-#define        WPS_CM_NFC_INTERFACE            0x0040
-#define        WPS_CM_PUSH_BUTTON              0x0080
-#define        WPS_CM_KEYPAD                   0x0100
-#define        WPS_CM_SW_PUHS_BUTTON           0x0280
-#define        WPS_CM_HW_PUHS_BUTTON           0x0480
-#define        WPS_CM_SW_DISPLAY_P             0x2008
-#define        WPS_CM_LCD_DISPLAY_P            0x4008
-
-enum P2P_ROLE {
-       P2P_ROLE_DISABLE = 0,
-       P2P_ROLE_DEVICE = 1,
-       P2P_ROLE_CLIENT = 2,
-       P2P_ROLE_GO = 3
-};
-
-enum P2P_STATE {
-       P2P_STATE_NONE = 0,                     /* P2P disable */
-       /* P2P had enabled and do nothing */
-       P2P_STATE_IDLE = 1,
-       P2P_STATE_LISTEN = 2,                   /* In pure listen state */
-       P2P_STATE_SCAN = 3,                     /* In scan phase */
-       /* In the listen state of find phase */
-       P2P_STATE_FIND_PHASE_LISTEN = 4,
-       /* In the search state of find phase */
-       P2P_STATE_FIND_PHASE_SEARCH = 5,
-       /* In P2P provisioning discovery */
-       P2P_STATE_TX_PROVISION_DIS_REQ = 6,
-       P2P_STATE_RX_PROVISION_DIS_RSP = 7,
-       P2P_STATE_RX_PROVISION_DIS_REQ = 8,
-       /* Doing the group owner negotiation handshake */
-       P2P_STATE_GONEGO_ING = 9,
-       /* finish the group negotiation handshake with success */
-       P2P_STATE_GONEGO_OK = 10,
-       /* finish the group negotiation handshake with failure */
-       P2P_STATE_GONEGO_FAIL = 11,
-       /* receiving the P2P Inviation request and match with the profile. */
-       P2P_STATE_RECV_INVITE_REQ_MATCH = 12,
-       /* Doing the P2P WPS */
-       P2P_STATE_PROVISIONING_ING = 13,
-       /* Finish the P2P WPS */
-       P2P_STATE_PROVISIONING_DONE = 14,
-       /* Transmit the P2P Invitation request */
-       P2P_STATE_TX_INVITE_REQ = 15,
-       /* Receiving the P2P Invitation response */
-       P2P_STATE_RX_INVITE_RESP_OK = 16,
-       /* receiving the P2P Inviation request and dismatch with the profile. */
-       P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17,
-       /* receiving the P2P Inviation request and this wifi is GO. */
-       P2P_STATE_RECV_INVITE_REQ_GO = 18,
-       /* receiving the P2P Inviation request to join an existing P2P Group. */
-       P2P_STATE_RECV_INVITE_REQ_JOIN = 19,
-       /* recveing the P2P Inviation response with failure */
-       P2P_STATE_RX_INVITE_RESP_FAIL = 20,
-       /* receiving p2p negotiation response with information is not available */
-       P2P_STATE_RX_INFOR_NOREADY = 21,
-       /* sending p2p negotiation response with information is not available */
-       P2P_STATE_TX_INFOR_NOREADY = 22,
-};
-
-enum P2P_WPSINFO {
-       P2P_NO_WPSINFO                          = 0,
-       P2P_GOT_WPSINFO_PEER_DISPLAY_PIN        = 1,
-       P2P_GOT_WPSINFO_SELF_DISPLAY_PIN        = 2,
-       P2P_GOT_WPSINFO_PBC                     = 3,
-};
-
-#define        P2P_PRIVATE_IOCTL_SET_LEN               64
-
-enum P2P_PROTO_WK_ID {
-       P2P_FIND_PHASE_WK = 0,
-       P2P_RESTORE_STATE_WK = 1,
-       P2P_PRE_TX_PROVDISC_PROCESS_WK = 2,
-       P2P_PRE_TX_NEGOREQ_PROCESS_WK = 3,
-       P2P_PRE_TX_INVITEREQ_PROCESS_WK = 4,
-       P2P_AP_P2P_CH_SWITCH_PROCESS_WK = 5,
-       P2P_RO_CH_WK = 6,
-};
-
-enum P2P_PS_STATE {
-       P2P_PS_DISABLE = 0,
-       P2P_PS_ENABLE = 1,
-       P2P_PS_SCAN = 2,
-       P2P_PS_SCAN_DONE = 3,
-       P2P_PS_ALLSTASLEEP = 4, /*  for P2P GO */
-};
-
-enum P2P_PS_MODE {
-       P2P_PS_NONE = 0,
-       P2P_PS_CTWINDOW = 1,
-       P2P_PS_NOA       = 2,
-       P2P_PS_MIX = 3, /*  CTWindow and NoA */
-};
-
-#define IP_MCAST_MAC(mac)                              \
-       ((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x5e))
-#define ICMPV6_MCAST_MAC(mac)                          \
-       ((mac[0] == 0x33) && (mac[1] == 0x33) && (mac[2] != 0xff))
-
-#endif /*  _WIFI_H_ */
diff --git a/drivers/staging/r8188eu/include/wlan_bssdef.h b/drivers/staging/r8188eu/include/wlan_bssdef.h
deleted file mode 100644 (file)
index ffeafa1..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#ifndef __WLAN_BSSDEF_H__
-#define __WLAN_BSSDEF_H__
-
-#define MAX_IE_SZ                      768
-
-#define NDIS_802_11_LENGTH_SSID         32
-#define NDIS_802_11_LENGTH_RATES        8
-#define NDIS_802_11_LENGTH_RATES_EX     16
-
-#define NDIS_802_11_RSSI long           /*  in dBm */
-
-struct ndis_802_11_ssid {
-       u32  SsidLength;
-       u8  Ssid[32];
-};
-
-struct ndis_802_11_config_fh {
-       u32           Length;           /*  Length of structure */
-       u32           HopPattern;       /*  As defined by 802.11, MSB set */
-       u32           HopSet;           /*  to one if non-802.11 */
-       u32           DwellTime;        /*  units are Kusec */
-};
-
-/*
- *     FW will only save the channel number in DSConfig.
- *     ODI Handler will convert the channel number to freq. number.
- */
-struct ndis_802_11_config {
-       u32           Length;             /*  Length of structure */
-       u32           BeaconPeriod;       /*  units are Kusec */
-       u32           ATIMWindow;         /*  units are Kusec */
-       u32           DSConfig;           /*  Frequency, units are kHz */
-       struct ndis_802_11_config_fh    FHConfig;
-};
-
-enum ndis_802_11_network_infra {
-       Ndis802_11IBSS,
-       Ndis802_11Infrastructure,
-       Ndis802_11AutoUnknown,
-       Ndis802_11InfrastructureMax,     /*  dummy upper bound */
-       Ndis802_11APMode
-};
-
-struct ndis_802_11_fixed_ie {
-       u8  Timestamp[8];
-       u16  BeaconInterval;
-       u16  Capabilities;
-};
-
-struct ndis_802_11_var_ie {
-       u8  ElementID;
-       u8  Length;
-       u8  data[];
-};
-
-/*
- * Length is the 4 bytes multiples of the sume of
- *     [ETH_ALEN] + 2 + sizeof (struct ndis_802_11_ssid) + sizeof (u32)
- *     + sizeof (NDIS_802_11_RSSI) + sizeof (enum NDIS_802_11_NETWORK_TYPE)
- *     + sizeof (struct ndis_802_11_config)
- *     + NDIS_802_11_LENGTH_RATES_EX + IELength
- *
- * Except the IELength, all other fields are fixed length.
- * Therefore, we can define a macro to represent the partial sum. */
-
-enum ndis_802_11_auth_mode {
-       Ndis802_11AuthModeOpen,
-       Ndis802_11AuthModeShared,
-       Ndis802_11AuthModeAutoSwitch,
-       Ndis802_11AuthModeWPA,
-       Ndis802_11AuthModeWPAPSK,
-       Ndis802_11AuthModeWPANone,
-       Ndis802_11AuthModeWAPI,
-       Ndis802_11AuthModeMax   /*  Not a real mode, upper bound */
-};
-
-enum ndis_802_11_wep_status {
-       Ndis802_11WEPEnabled,
-       Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
-       Ndis802_11WEPDisabled,
-       Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
-       Ndis802_11WEPKeyAbsent,
-       Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
-       Ndis802_11WEPNotSupported,
-       Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
-       Ndis802_11Encryption2Enabled,
-       Ndis802_11Encryption2KeyAbsent,
-       Ndis802_11Encryption3Enabled,
-       Ndis802_11Encryption3KeyAbsent,
-       Ndis802_11_EncryptionWAPI
-};
-
-#define NDIS_802_11_AI_REQFI_CAPABILITIES      1
-#define NDIS_802_11_AI_REQFI_LISTENINTERVAL    2
-#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS  4
-
-#define NDIS_802_11_AI_RESFI_CAPABILITIES      1
-#define NDIS_802_11_AI_RESFI_STATUSCODE        2
-#define NDIS_802_11_AI_RESFI_ASSOCIATIONID     4
-
-struct ndis_802_11_ai_reqfi {
-    u16 Capabilities;
-    u16 ListenInterval;
-    unsigned char CurrentAPAddress[ETH_ALEN];
-};
-
-struct ndis_802_11_ai_resfi {
-    u16 Capabilities;
-    u16 StatusCode;
-    u16 AssociationId;
-};
-
-struct ndis_802_11_assoc_info {
-       u32  Length;
-       u16 AvailableRequestFixedIEs;
-       struct ndis_802_11_ai_reqfi    RequestFixedIEs;
-       u32  RequestIELength;
-       u32  OffsetRequestIEs;
-       u16 AvailableResponseFixedIEs;
-       struct ndis_802_11_ai_resfi    ResponseFixedIEs;
-       u32  ResponseIELength;
-       u32  OffsetResponseIEs;
-};
-
-/*  Key mapping keys require a BSSID */
-struct ndis_802_11_key {
-       u32           Length;             /*  Length of this structure */
-       u32           KeyIndex;
-       u32           KeyLength;          /*  length of key in bytes */
-       unsigned char BSSID[ETH_ALEN];
-       unsigned long long KeyRSC;
-       u8           KeyMaterial[32];  /* var len depending on above field */
-};
-
-struct ndis_802_11_remove_key {
-       u32                   Length;        /*  Length */
-       u32                   KeyIndex;
-       unsigned char BSSID[ETH_ALEN];
-};
-
-struct ndis_802_11_wep {
-       u32     Length;        /*  Length of this structure */
-       u32     KeyIndex;      /*  0 is the per-client key,
-                                 * 1-N are the global keys */
-       u32     KeyLength;     /*  length of key in bytes */
-       u8     KeyMaterial[16];/*  variable len depending on above field */
-};
-
-struct ndis_802_11_auth_req {
-       u32 Length;            /*  Length of structure */
-       unsigned char Bssid[ETH_ALEN];
-       u32 Flags;
-};
-
-enum ndis_802_11_status_type {
-       Ndis802_11StatusType_Authentication,
-       Ndis802_11StatusType_MediaStreamMode,
-       Ndis802_11StatusType_PMKID_CandidateList,
-       Ndis802_11StatusTypeMax    /*  not a real type, defined as
-                                   * an upper bound */
-};
-
-struct ndis_802_11_status_ind {
-       enum ndis_802_11_status_type StatusType;
-};
-
-/*  mask for authentication/integrity fields */
-#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS           0x0f
-#define NDIS_802_11_AUTH_REQUEST_REAUTH                        0x01
-#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE             0x02
-#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR                0x06
-#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR           0x0E
-
-/*  MIC check time, 60 seconds. */
-#define MIC_CHECK_TIME 60000000
-
-#ifndef Ndis802_11APMode
-#define Ndis802_11APMode (Ndis802_11InfrastructureMax+1)
-#endif
-
-struct wlan_phy_info {
-       u8      SignalStrength;/* in percentage) */
-       u8      SignalQuality;/* in percentage) */
-       u8      Optimum_antenna;  /* for Antenna diversity */
-       u8      Reserved_0;
-};
-
-struct wlan_bcn_info {
-       /* these infor get from rtw_get_encrypt_info when
-        *       * translate scan to UI */
-       u8 encryp_protocol;/* ENCRYP_PROTOCOL_E: OPEN/WEP/WPA/WPA2/WAPI */
-       int group_cipher; /* WPA/WPA2 group cipher */
-       int pairwise_cipher;/* WPA/WPA2/WEP pairwise cipher */
-       int is_8021x;
-
-       /* bwmode 20/40 and ch_offset UP/LOW */
-       unsigned short  ht_cap_info;
-       unsigned char   ht_info_infos_0;
-};
-
-/* temporally add #pragma pack for structure alignment issue of
-*   struct wlan_bssid_ex and get_struct wlan_bssid_ex_sz()
-*/
-struct wlan_bssid_ex {
-       u32  Length;
-       unsigned char MacAddress[ETH_ALEN];
-       u8  Reserved[2];/* 0]: IS beacon frame */
-       struct ndis_802_11_ssid  Ssid;
-       u32  Privacy;
-       NDIS_802_11_RSSI  Rssi;/* in dBM,raw data ,get from PHY) */
-       struct ndis_802_11_config  Configuration;
-       enum ndis_802_11_network_infra  InfrastructureMode;
-       unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
-       struct wlan_phy_info    PhyInfo;
-       u32  IELength;
-       u8  IEs[MAX_IE_SZ];     /* timestamp, beacon interval, and
-                                * capability information) */
-} __packed;
-
-static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss)
-{
-       return sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + bss->IELength;
-}
-
-struct wlan_network {
-       struct list_head list;
-       int     network_type;   /* refer to ieee80211.h for WIRELESS_11B/G */
-       int     fixed;          /*  set fixed when not to be removed
-                                *  in site-surveying */
-       unsigned long   last_scanned; /* timestamp for the network */
-       int     aid;            /* will only be valid when a BSS is joinned. */
-       int     join_res;
-       struct wlan_bssid_ex    network; /* must be the last item */
-       struct wlan_bcn_info    BcnInfo;
-};
-
-enum VRTL_CARRIER_SENSE {
-       DISABLE_VCS,
-       ENABLE_VCS,
-       AUTO_VCS
-};
-
-enum VCS_TYPE {
-       NONE_VCS,
-       RTS_CTS,
-       CTS_TO_SELF
-};
-
-#define PWR_CAM 0
-#define PWR_MINPS 1
-#define PWR_MAXPS 2
-#define PWR_UAPSD 3
-#define PWR_VOIP 4
-
-enum UAPSD_MAX_SP {
-       NO_LIMIT,
-       TWO_MSDU,
-       FOUR_MSDU,
-       SIX_MSDU
-};
-
-#define NUM_PRE_AUTH_KEY 16
-#define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY
-
-u8 key_2char2num(u8 hch, u8 lch);
-u8 key_char2num(u8 ch);
-u8 str_2char2num(u8 hch, u8 lch);
-
-#endif /* ifndef WLAN_BSSDEF_H_ */
diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
deleted file mode 100644 (file)
index e0a8199..0000000
+++ /dev/null
@@ -1,3775 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/wlan_bssdef.h"
-#include "../include/wifi.h"
-#include "../include/rtw_mlme.h"
-#include "../include/rtw_mlme_ext.h"
-#include "../include/rtw_ioctl.h"
-#include "../include/rtw_ioctl_set.h"
-#include "../include/usb_ops.h"
-#include "../include/rtl8188e_hal.h"
-#include "../include/rtw_led.h"
-
-#include "../include/rtw_iol.h"
-
-#define RTL_IOCTL_WPA_SUPPLICANT       (SIOCIWFIRSTPRIV + 30)
-
-#define SCAN_ITEM_SIZE 768
-#define MAX_CUSTOM_LEN 64
-#define RATE_COUNT 4
-
-/*  combo scan */
-#define WEXT_CSCAN_AMOUNT 9
-#define WEXT_CSCAN_BUF_LEN             360
-#define WEXT_CSCAN_HEADER              "CSCAN S\x01\x00\x00S\x00"
-#define WEXT_CSCAN_HEADER_SIZE         12
-#define WEXT_CSCAN_SSID_SECTION                'S'
-#define WEXT_CSCAN_CHANNEL_SECTION     'C'
-#define WEXT_CSCAN_NPROBE_SECTION      'N'
-#define WEXT_CSCAN_ACTV_DWELL_SECTION  'A'
-#define WEXT_CSCAN_PASV_DWELL_SECTION  'P'
-#define WEXT_CSCAN_HOME_DWELL_SECTION  'H'
-#define WEXT_CSCAN_TYPE_SECTION                'T'
-
-static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000,
-       6000000, 9000000, 12000000, 18000000, 24000000, 36000000,
-       48000000, 54000000};
-
-void indicate_wx_scan_complete_event(struct adapter *padapter)
-{
-       union iwreq_data wrqu;
-
-       memset(&wrqu, 0, sizeof(union iwreq_data));
-       wireless_send_event(padapter->pnetdev, SIOCGIWSCAN, &wrqu, NULL);
-}
-
-void rtw_indicate_wx_assoc_event(struct adapter *padapter)
-{
-       union iwreq_data wrqu;
-       struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       memset(&wrqu, 0, sizeof(union iwreq_data));
-
-       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-
-       memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.MacAddress, ETH_ALEN);
-
-       wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL);
-}
-
-void rtw_indicate_wx_disassoc_event(struct adapter *padapter)
-{
-       union iwreq_data wrqu;
-
-       memset(&wrqu, 0, sizeof(union iwreq_data));
-
-       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-       memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
-
-       wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL);
-}
-
-static char *translate_scan(struct adapter *padapter,
-                           struct iw_request_info *info,
-                           struct wlan_network *pnetwork,
-                           char *start, char *stop)
-{
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct iw_event iwe;
-       u16 cap;
-       __le16 le_tmp;
-       u32 ht_ielen = 0;
-       char *custom;
-       char *p;
-       u16 max_rate = 0, rate, ht_cap = false;
-       u32 i = 0;
-       u8 bw_40MHz = 0, short_GI = 0;
-       u16 mcs_rate = 0;
-       u8 ss, sq;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-               u32     blnGotP2PIE = false;
-
-               /*      User is doing the P2P device discovery */
-               /*      The prefix of SSID should be "DIRECT-" and the IE should contains the P2P IE. */
-               /*      If not, the driver should ignore this AP and go to the next AP. */
-
-               /*      Verifying the SSID */
-               if (!memcmp(pnetwork->network.Ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN)) {
-                       u32     p2pielen = 0;
-
-                       if (pnetwork->network.Reserved[0] == 2) {/*  Probe Request */
-                               /*      Verifying the P2P IE */
-                               if (rtw_get_p2p_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &p2pielen))
-                                       blnGotP2PIE = true;
-                       } else {/*  Beacon or Probe Respones */
-                               /*      Verifying the P2P IE */
-                               if (rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen))
-                                       blnGotP2PIE = true;
-                       }
-               }
-
-               if (!blnGotP2PIE)
-                       return start;
-       }
-
-       /*  AP MAC address  */
-       iwe.cmd = SIOCGIWAP;
-       iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-
-       memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.MacAddress, ETH_ALEN);
-       start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN);
-
-       /* Add the ESSID */
-       iwe.cmd = SIOCGIWESSID;
-       iwe.u.data.flags = 1;
-       iwe.u.data.length = min_t(u16, pnetwork->network.Ssid.SsidLength, 32);
-       start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid);
-
-       /* parsing HT_CAP_IE */
-       p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength - 12);
-
-       if (p && ht_ielen > 0) {
-               struct ieee80211_ht_cap *pht_capie;
-
-               ht_cap = true;
-               pht_capie = (struct ieee80211_ht_cap *)(p + 2);
-               memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2);
-               bw_40MHz = (le16_to_cpu(pht_capie->cap_info) &
-                           IEEE80211_HT_CAP_SUP_WIDTH_20_40) ? 1 : 0;
-               short_GI = (le16_to_cpu(pht_capie->cap_info) &
-                           (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)) ? 1 : 0;
-       }
-
-       /* Add the protocol name */
-       iwe.cmd = SIOCGIWNAME;
-       if ((rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates))) {
-               if (ht_cap)
-                       snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn");
-               else
-               snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b");
-       } else if ((rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates))) {
-               if (ht_cap)
-                       snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn");
-               else
-                       snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg");
-       } else {
-               if (ht_cap)
-                       snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn");
-               else
-                       snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g");
-       }
-
-       start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN);
-
-         /* Add mode */
-       iwe.cmd = SIOCGIWMODE;
-       memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.IEs), 2);
-
-       cap = le16_to_cpu(le_tmp);
-
-       if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) {
-               if (cap & WLAN_CAPABILITY_BSS)
-                       iwe.u.mode = IW_MODE_MASTER;
-               else
-                       iwe.u.mode = IW_MODE_ADHOC;
-
-               start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN);
-       }
-
-       if (pnetwork->network.Configuration.DSConfig < 1)
-               pnetwork->network.Configuration.DSConfig = 1;
-
-        /* Add frequency/channel */
-       iwe.cmd = SIOCGIWFREQ;
-       iwe.u.freq.m = rtw_ch2freq(pnetwork->network.Configuration.DSConfig) * 100000;
-       iwe.u.freq.e = 1;
-       iwe.u.freq.i = pnetwork->network.Configuration.DSConfig;
-       start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN);
-
-       /* Add encryption capability */
-       iwe.cmd = SIOCGIWENCODE;
-       if (cap & WLAN_CAPABILITY_PRIVACY)
-               iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-       else
-               iwe.u.data.flags = IW_ENCODE_DISABLED;
-       iwe.u.data.length = 0;
-       start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid);
-
-       /*Add basic and extended rates */
-       max_rate = 0;
-       custom = kzalloc(MAX_CUSTOM_LEN, GFP_ATOMIC);
-       if (!custom)
-               return start;
-       p = custom;
-       p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): ");
-       while (pnetwork->network.SupportedRates[i] != 0) {
-               rate = pnetwork->network.SupportedRates[i] & 0x7F;
-               if (rate > max_rate)
-                       max_rate = rate;
-               p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
-                             "%d%s ", rate >> 1, (rate & 1) ? ".5" : "");
-               i++;
-       }
-
-       if (ht_cap) {
-               if (mcs_rate & 0x8000)/* MCS15 */
-                       max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130);
-               else if (mcs_rate & 0x0080)/* MCS7 */
-                       ;
-               else/* default MCS7 */
-                       max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) : ((short_GI) ? 72 : 65);
-
-               max_rate = max_rate * 2;/* Mbps/2; */
-       }
-
-       iwe.cmd = SIOCGIWRATE;
-       iwe.u.bitrate.fixed = 0;
-       iwe.u.bitrate.disabled = 0;
-       iwe.u.bitrate.value = max_rate * 500000;
-       start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN);
-
-       /* parsing WPA/WPA2 IE */
-       {
-               u8 *buf;
-               u8 *wpa_ie, *rsn_ie;
-               u16 wpa_len = 0, rsn_len = 0;
-               u8 *p;
-
-               buf = kzalloc(MAX_WPA_IE_LEN, GFP_ATOMIC);
-               if (!buf)
-                       goto exit;
-               wpa_ie = kzalloc(255, GFP_ATOMIC);
-               if (!wpa_ie) {
-                       kfree(buf);
-                       goto exit;
-               }
-               rsn_ie = kzalloc(255, GFP_ATOMIC);
-               if (!rsn_ie) {
-                       kfree(buf);
-                       kfree(wpa_ie);
-                       goto exit;
-               }
-               rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, rsn_ie, &rsn_len, wpa_ie, &wpa_len);
-
-               if (wpa_len > 0) {
-                       p = buf;
-                       memset(buf, 0, MAX_WPA_IE_LEN);
-                       p += sprintf(p, "wpa_ie =");
-                       for (i = 0; i < wpa_len; i++)
-                               p += sprintf(p, "%02x", wpa_ie[i]);
-
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = IWEVCUSTOM;
-                       iwe.u.data.length = strlen(buf);
-                       start = iwe_stream_add_point(info, start, stop, &iwe, buf);
-
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = IWEVGENIE;
-                       iwe.u.data.length = wpa_len;
-                       start = iwe_stream_add_point(info, start, stop, &iwe, wpa_ie);
-               }
-               if (rsn_len > 0) {
-                       p = buf;
-                       memset(buf, 0, MAX_WPA_IE_LEN);
-                       p += sprintf(p, "rsn_ie =");
-                       for (i = 0; i < rsn_len; i++)
-                               p += sprintf(p, "%02x", rsn_ie[i]);
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = IWEVCUSTOM;
-                       iwe.u.data.length = strlen(buf);
-                       start = iwe_stream_add_point(info, start, stop, &iwe, buf);
-
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = IWEVGENIE;
-                       iwe.u.data.length = rsn_len;
-                       start = iwe_stream_add_point(info, start, stop, &iwe, rsn_ie);
-               }
-               kfree(buf);
-               kfree(wpa_ie);
-               kfree(rsn_ie);
-       }
-
-       {/* parsing WPS IE */
-               uint cnt = 0, total_ielen;
-               u8 *wpsie_ptr = NULL;
-               uint wps_ielen = 0;
-
-               u8 *ie_ptr = pnetwork->network.IEs + _FIXED_IE_LENGTH_;
-               total_ielen = pnetwork->network.IELength - _FIXED_IE_LENGTH_;
-
-               while (cnt < total_ielen) {
-                       if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen > 2)) {
-                               wpsie_ptr = &ie_ptr[cnt];
-                               iwe.cmd = IWEVGENIE;
-                               iwe.u.data.length = (u16)wps_ielen;
-                               start = iwe_stream_add_point(info, start, stop, &iwe, wpsie_ptr);
-                       }
-                       cnt += ie_ptr[cnt + 1] + 2; /* goto next */
-               }
-       }
-
-       /* Add quality statistics */
-       iwe.cmd = IWEVQUAL;
-       iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID;
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED) &&
-           is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network)) {
-               ss = padapter->recvpriv.signal_strength;
-               sq = padapter->recvpriv.signal_qual;
-       } else {
-               ss = pnetwork->network.PhyInfo.SignalStrength;
-               sq = pnetwork->network.PhyInfo.SignalQuality;
-       }
-
-       iwe.u.qual.level = (u8)ss;
-       iwe.u.qual.qual = (u8)sq;   /*  signal quality */
-       iwe.u.qual.noise = 0; /*  noise level */
-       start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN);
-exit:
-       kfree(custom);
-       return start;
-}
-
-static int wpa_set_auth_algs(struct net_device *dev, u32 value)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       int ret = 0;
-
-       if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) {
-               padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
-               padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch;
-               padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto;
-       } else if (value & AUTH_ALG_SHARED_KEY) {
-               padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
-
-               padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared;
-               padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared;
-       } else if (value & AUTH_ALG_OPEN_SYSTEM) {
-               if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) {
-                       padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
-                       padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
-               }
-       } else if (!(value & AUTH_ALG_LEAP)) {
-               ret = -EINVAL;
-       }
-       return ret;
-}
-
-static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len)
-{
-       int ret = 0;
-       u32 wep_key_idx, wep_key_len, wep_total_len;
-       struct ndis_802_11_wep   *pwep = NULL;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       param->u.crypt.err = 0;
-       param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
-
-       if (param_len < (u32)((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) {
-               ret =  -EINVAL;
-               goto exit;
-       }
-
-       if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-           param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-           param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
-               if (param->u.crypt.idx >= WEP_KEYS) {
-                       ret = -EINVAL;
-                       goto exit;
-               }
-       } else {
-               ret = -EINVAL;
-               goto exit;
-       }
-
-       if (strcmp(param->u.crypt.alg, "WEP") == 0) {
-               padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
-               padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_;
-               padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_;
-
-               wep_key_idx = param->u.crypt.idx;
-               wep_key_len = param->u.crypt.key_len;
-
-               if (wep_key_idx > WEP_KEYS)
-                       return -EINVAL;
-
-               if (wep_key_len > 0) {
-                       wep_key_len = wep_key_len <= 5 ? 5 : 13;
-                       wep_total_len = wep_key_len + sizeof(*pwep);
-                       pwep = kzalloc(wep_total_len, GFP_KERNEL);
-                       if (!pwep)
-                               goto exit;
-
-                       pwep->KeyLength = wep_key_len;
-                       pwep->Length = wep_total_len;
-                       if (wep_key_len == 13) {
-                               padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_;
-                               padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_;
-                       }
-               } else {
-                       ret = -EINVAL;
-                       goto exit;
-               }
-               pwep->KeyIndex = wep_key_idx;
-               pwep->KeyIndex |= 0x80000000;
-               memcpy(pwep->KeyMaterial,  param->u.crypt.key, pwep->KeyLength);
-               if (param->u.crypt.set_tx) {
-                       if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL)
-                               ret = -EOPNOTSUPP;
-               } else {
-                       if (wep_key_idx >= WEP_KEYS) {
-                               ret = -EOPNOTSUPP;
-                               goto exit;
-                       }
-                       memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength);
-                       psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength;
-                       rtw_set_key(padapter, psecuritypriv, wep_key_idx, 0);
-               }
-               goto exit;
-       }
-
-       if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { /*  802_1x */
-               struct sta_info *psta, *pbcmc_sta;
-               struct sta_priv *pstapriv = &padapter->stapriv;
-
-               if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE)) { /* sta mode */
-                       psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv));
-                       if (!psta) {
-                               ;
-                       } else {
-                               if (strcmp(param->u.crypt.alg, "none") != 0)
-                                       psta->ieee8021x_blocked = false;
-
-                               if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) ||
-                                   (padapter->securitypriv.ndisencryptstatus ==  Ndis802_11Encryption3Enabled))
-                                       psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
-
-                               if (param->u.crypt.set_tx == 1) { /* pairwise key */
-                                       memcpy(psta->dot118021x_UncstKey.skey,  param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
-
-                                       if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */
-                                               memcpy(psta->dot11tkiptxmickey.skey, &param->u.crypt.key[16], 8);
-                                               memcpy(psta->dot11tkiprxmickey.skey, &param->u.crypt.key[24], 8);
-                                               padapter->securitypriv.busetkipkey = false;
-                                       }
-
-                                       rtw_setstakey_cmd(padapter, (unsigned char *)psta, true);
-                               } else { /* group key */
-                                       memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey,  param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
-                                       memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &param->u.crypt.key[16], 8);
-                                       memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &param->u.crypt.key[24], 8);
-                                       padapter->securitypriv.binstallGrpkey = true;
-
-                                       padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx;
-
-                                       rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1);
-                                       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING))
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_DONE);
-                               }
-                       }
-                       pbcmc_sta = rtw_get_bcmc_stainfo(padapter);
-                       if (!pbcmc_sta) {
-                               ;
-                       } else {
-                               /* Jeff: don't disable ieee8021x_blocked while clearing key */
-                               if (strcmp(param->u.crypt.alg, "none") != 0)
-                                       pbcmc_sta->ieee8021x_blocked = false;
-
-                               if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) ||
-                                   (padapter->securitypriv.ndisencryptstatus ==  Ndis802_11Encryption3Enabled))
-                                       pbcmc_sta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
-                       }
-               }
-       }
-
-exit:
-
-       kfree(pwep);
-
-       return ret;
-}
-
-static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ielen)
-{
-       u8 *buf = NULL;
-       int group_cipher = 0, pairwise_cipher = 0;
-       int ret = 0;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if (ielen > MAX_WPA_IE_LEN || !pie) {
-               _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS);
-               if (!pie)
-                       return ret;
-               else
-                       return -EINVAL;
-       }
-
-       if (ielen) {
-               buf = kmemdup(pie, ielen, GFP_KERNEL);
-               if (!buf) {
-                       ret =  -ENOMEM;
-                       goto exit;
-               }
-
-               if (ielen < RSN_HEADER_LEN) {
-                       ret  = -1;
-                       goto exit;
-               }
-
-               if (rtw_parse_wpa_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) {
-                       padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
-                       padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK;
-                       memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen);
-               }
-
-               if (rtw_parse_wpa2_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) {
-                       padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
-                       padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK;
-                       memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen);
-               }
-
-               switch (group_cipher) {
-               case WPA_CIPHER_NONE:
-                       padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
-                       break;
-               case WPA_CIPHER_WEP40:
-                       padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_;
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
-                       break;
-               case WPA_CIPHER_TKIP:
-                       padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_;
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled;
-                       break;
-               case WPA_CIPHER_CCMP:
-                       padapter->securitypriv.dot118021XGrpPrivacy = _AES_;
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled;
-                       break;
-               case WPA_CIPHER_WEP104:
-                       padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_;
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
-                       break;
-               }
-
-               switch (pairwise_cipher) {
-               case WPA_CIPHER_NONE:
-                       padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
-                       break;
-               case WPA_CIPHER_WEP40:
-                       padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_;
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
-                       break;
-               case WPA_CIPHER_TKIP:
-                       padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_;
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled;
-                       break;
-               case WPA_CIPHER_CCMP:
-                       padapter->securitypriv.dot11PrivacyAlgrthm = _AES_;
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled;
-                       break;
-               case WPA_CIPHER_WEP104:
-                       padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_;
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
-                       break;
-               }
-
-               _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS);
-               {/* set wps_ie */
-                       u16 cnt = 0;
-                       u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
-
-                       while (cnt < ielen) {
-                               eid = buf[cnt];
-                               if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt + 2], wps_oui, 4))) {
-                                       padapter->securitypriv.wps_ie_len = ((buf[cnt + 1] + 2) < (MAX_WPA_IE_LEN << 2)) ? (buf[cnt + 1] + 2) : (MAX_WPA_IE_LEN << 2);
-
-                                       memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len);
-
-                                       set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS);
-                                       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_OK))
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_ING);
-                                       cnt += buf[cnt + 1] + 2;
-                                       break;
-                               } else {
-                                       cnt += buf[cnt + 1] + 2; /* goto next */
-                               }
-                       }
-               }
-       }
-
-exit:
-       kfree(buf);
-       return ret;
-}
-
-typedef unsigned char   NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];
-
-static int rtw_wx_get_name(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u32 ht_ielen = 0;
-       char *p;
-       u8 ht_cap = false;
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_bssid_ex  *pcur_bss = &pmlmepriv->cur_network.network;
-       NDIS_802_11_RATES_EX *prates = NULL;
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) {
-               /* parsing HT_CAP_IE */
-               p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength - 12);
-               if (p && ht_ielen > 0)
-                       ht_cap = true;
-
-               prates = &pcur_bss->SupportedRates;
-
-               if (rtw_is_cckratesonly_included((u8 *)prates)) {
-                       if (ht_cap)
-                               snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn");
-                       else
-                               snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b");
-               } else if (rtw_is_cckrates_included((u8 *)prates)) {
-                       if (ht_cap)
-                               snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn");
-                       else
-                               snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg");
-               } else {
-                       if (ht_cap)
-                               snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn");
-                       else
-                               snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g");
-               }
-       } else {
-               snprintf(wrqu->name, IFNAMSIZ, "unassociated");
-       }
-
-
-
-       return 0;
-}
-
-static int rtw_wx_get_freq(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_bssid_ex  *pcur_bss = &pmlmepriv->cur_network.network;
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-               /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; */
-               wrqu->freq.m = rtw_ch2freq(pcur_bss->Configuration.DSConfig) * 100000;
-               wrqu->freq.e = 1;
-               wrqu->freq.i = pcur_bss->Configuration.DSConfig;
-       } else {
-               wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000;
-               wrqu->freq.e = 1;
-               wrqu->freq.i = padapter->mlmeextpriv.cur_channel;
-       }
-
-       return 0;
-}
-
-static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
-                            union iwreq_data *wrqu, char *b)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       enum ndis_802_11_network_infra networkType;
-       int ret = 0;
-
-       ret = rtw_pwr_wakeup(padapter);
-       if (ret)
-               goto exit;
-
-       if (!padapter->hw_init_completed) {
-               ret = -EPERM;
-               goto exit;
-       }
-
-       switch (wrqu->mode) {
-       case IW_MODE_AUTO:
-               networkType = Ndis802_11AutoUnknown;
-               break;
-       case IW_MODE_ADHOC:
-               networkType = Ndis802_11IBSS;
-               break;
-       case IW_MODE_MASTER:
-               networkType = Ndis802_11APMode;
-               break;
-       case IW_MODE_INFRA:
-               networkType = Ndis802_11Infrastructure;
-               break;
-       default:
-               ret = -EINVAL;
-               goto exit;
-       }
-       if (!rtw_set_802_11_infrastructure_mode(padapter, networkType)) {
-               ret = -EPERM;
-               goto exit;
-       }
-       rtw_setopmode_cmd(padapter, networkType);
-exit:
-
-       return ret;
-}
-
-static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
-                            union iwreq_data *wrqu, char *b)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
-               wrqu->mode = IW_MODE_INFRA;
-       else if  ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) ||
-                 (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)))
-               wrqu->mode = IW_MODE_ADHOC;
-       else if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
-               wrqu->mode = IW_MODE_MASTER;
-       else
-               wrqu->mode = IW_MODE_AUTO;
-
-
-
-       return 0;
-}
-
-static int rtw_wx_set_pmkid(struct net_device *dev,
-                           struct iw_request_info *a,
-                           union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u8   j, blInserted = false;
-       int  ret = false;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct iw_pmksa *pPMK = (struct iw_pmksa *)extra;
-       u8     strZeroMacAddress[ETH_ALEN] = {0x00};
-       u8     strIssueBssid[ETH_ALEN] = {0x00};
-
-       memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN);
-       if (pPMK->cmd == IW_PMKSA_ADD) {
-               if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN))
-                       return ret;
-               else
-                       ret = true;
-               blInserted = false;
-
-               /* overwrite PMKID */
-               for (j = 0; j < NUM_PMKID_CACHE; j++) {
-                       if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) {
-                               /*  BSSID is matched, the same AP => rewrite with new PMKID. */
-                               memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN);
-                               psecuritypriv->PMKIDList[j].bUsed = true;
-                               psecuritypriv->PMKIDIndex = j + 1;
-                               blInserted = true;
-                               break;
-                       }
-               }
-
-               if (!blInserted) {
-                       /*  Find a new entry */
-                       memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN);
-                       memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN);
-
-                       psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].bUsed = true;
-                       psecuritypriv->PMKIDIndex++;
-                       if (psecuritypriv->PMKIDIndex == 16)
-                               psecuritypriv->PMKIDIndex = 0;
-               }
-       } else if (pPMK->cmd == IW_PMKSA_REMOVE) {
-               ret = true;
-               for (j = 0; j < NUM_PMKID_CACHE; j++) {
-                       if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) {
-                               /*  BSSID is matched, the same AP => Remove this PMKID information and reset it. */
-                               memset(psecuritypriv->PMKIDList[j].Bssid, 0x00, ETH_ALEN);
-                               psecuritypriv->PMKIDList[j].bUsed = false;
-                               break;
-                       }
-              }
-       } else if (pPMK->cmd == IW_PMKSA_FLUSH) {
-               memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
-               psecuritypriv->PMKIDIndex = 0;
-               ret = true;
-       }
-       return ret;
-}
-
-static int rtw_wx_get_sens(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       wrqu->sens.value = 0;
-       wrqu->sens.fixed = 0;   /* no auto select */
-       wrqu->sens.disabled = 1;
-       return 0;
-}
-
-static int rtw_wx_get_range(struct net_device *dev,
-                               struct iw_request_info *info,
-                               union iwreq_data *wrqu, char *extra)
-{
-       struct iw_range *range = (struct iw_range *)extra;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-
-       u16 val;
-       int i;
-
-       wrqu->data.length = sizeof(*range);
-       memset(range, 0, sizeof(*range));
-
-       /* Let's try to keep this struct in the same order as in
-        * linux/include/wireless.h
-        */
-
-       /* TODO: See what values we can set, and remove the ones we can't
-        * set, or fill them with some default data.
-        */
-
-       /* ~5 Mb/s real (802.11b) */
-       range->throughput = 5 * 1000 * 1000;
-
-       /* signal level threshold range */
-
-       /* percent values between 0 and 100. */
-       range->max_qual.qual = 100;
-       range->max_qual.level = 100;
-       range->max_qual.noise = 100;
-       range->max_qual.updated = 7; /* Updated all three */
-
-       range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */
-       /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
-       range->avg_qual.level = 178; /* -78 dBm */
-       range->avg_qual.noise = 0;
-       range->avg_qual.updated = 7; /* Updated all three */
-
-       range->num_bitrates = RATE_COUNT;
-
-       for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++)
-               range->bitrate[i] = rtw_rates[i];
-
-       range->min_frag = MIN_FRAG_THRESHOLD;
-       range->max_frag = MAX_FRAG_THRESHOLD;
-
-       range->pm_capa = 0;
-
-       range->we_version_compiled = WIRELESS_EXT;
-       range->we_version_source = 16;
-
-       for (i = 0, val = 0; i < MAX_CHANNEL_NUM; i++) {
-               /*  Include only legal frequencies for some countries */
-               if (pmlmeext->channel_set[i].ChannelNum != 0) {
-                       range->freq[val].i = pmlmeext->channel_set[i].ChannelNum;
-                       range->freq[val].m = rtw_ch2freq(pmlmeext->channel_set[i].ChannelNum) * 100000;
-                       range->freq[val].e = 1;
-                       val++;
-               }
-
-               if (val == IW_MAX_FREQUENCIES)
-                       break;
-       }
-
-       range->num_channels = val;
-       range->num_frequency = val;
-
-/*  The following code will proivde the security capability to network manager. */
-/*  If the driver doesn't provide this capability to network manager, */
-/*  the WPA/WPA2 routers can't be chosen in the network manager. */
-
-/*
-#define IW_SCAN_CAPA_NONE              0x00
-#define IW_SCAN_CAPA_ESSID             0x01
-#define IW_SCAN_CAPA_BSSID             0x02
-#define IW_SCAN_CAPA_CHANNEL           0x04
-#define IW_SCAN_CAPA_MODE              0x08
-#define IW_SCAN_CAPA_RATE              0x10
-#define IW_SCAN_CAPA_TYPE              0x20
-#define IW_SCAN_CAPA_TIME              0x40
-*/
-
-       range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
-                         IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
-
-       range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE |
-                          IW_SCAN_CAPA_BSSID | IW_SCAN_CAPA_CHANNEL |
-                          IW_SCAN_CAPA_MODE | IW_SCAN_CAPA_RATE;
-
-
-       return 0;
-}
-
-/* set bssid flow */
-/* s1. rtw_set_802_11_infrastructure_mode() */
-/* s2. rtw_set_802_11_authentication_mode() */
-/* s3. set_802_11_encryption_mode() */
-/* s4. rtw_set_802_11_bssid() */
-static int rtw_wx_set_wap(struct net_device *dev,
-                        struct iw_request_info *info,
-                        union iwreq_data *awrq,
-                        char *extra)
-{
-       uint ret = 0;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct sockaddr *temp = (struct sockaddr *)awrq;
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-       struct list_head *phead;
-       u8 *dst_bssid, *src_bssid;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       enum ndis_802_11_auth_mode      authmode;
-
-       ret = rtw_pwr_wakeup(padapter);
-       if (ret)
-               goto exit;
-
-       if (!padapter->bup) {
-               ret = -1;
-               goto exit;
-       }
-
-       if (temp->sa_family != ARPHRD_ETHER) {
-               ret = -EINVAL;
-               goto exit;
-       }
-
-       authmode = padapter->securitypriv.ndisauthtype;
-       spin_lock_bh(&queue->lock);
-       phead = get_list_head(queue);
-       pmlmepriv->pscanned = phead->next;
-
-       while (phead != pmlmepriv->pscanned) {
-
-               pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list);
-
-               pmlmepriv->pscanned = pmlmepriv->pscanned->next;
-
-               dst_bssid = pnetwork->network.MacAddress;
-
-               src_bssid = temp->sa_data;
-
-               if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) {
-                       if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) {
-                               ret = -1;
-                               spin_unlock_bh(&queue->lock);
-                               goto exit;
-                       }
-
-                       break;
-               }
-       }
-       spin_unlock_bh(&queue->lock);
-
-       rtw_set_802_11_authentication_mode(padapter, authmode);
-       /* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */
-       if (!rtw_set_802_11_bssid(padapter, temp->sa_data)) {
-               ret = -1;
-               goto exit;
-       }
-
-exit:
-
-
-
-       return ret;
-}
-
-static int rtw_wx_get_wap(struct net_device *dev,
-                           struct iw_request_info *info,
-                           union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_bssid_ex  *pcur_bss = &pmlmepriv->cur_network.network;
-
-       wrqu->ap_addr.sa_family = ARPHRD_ETHER;
-
-       memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED) ||
-           check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
-           check_fwstate(pmlmepriv, WIFI_AP_STATE))
-               memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
-       else
-               memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
-
-
-
-       return 0;
-}
-
-static int rtw_wx_set_mlme(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct iw_mlme *mlme = (struct iw_mlme *)extra;
-
-       if (!mlme)
-               return -1;
-
-       switch (mlme->cmd) {
-       case IW_MLME_DEAUTH:
-               rtw_set_802_11_disassociate(padapter);
-               break;
-       case IW_MLME_DISASSOC:
-               rtw_set_802_11_disassociate(padapter);
-               break;
-       default:
-               return -EOPNOTSUPP;
-       }
-       return 0;
-}
-
-static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
-                            union iwreq_data *wrqu, char *extra)
-{
-       u8 _status = false;
-       int ret = 0;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       ret = rtw_pwr_wakeup(padapter);
-       if (ret)
-               goto exit;
-
-       if (padapter->bDriverStopped) {
-               ret = -1;
-               goto exit;
-       }
-
-       if (!padapter->bup) {
-               ret = -1;
-               goto exit;
-       }
-
-       if (!padapter->hw_init_completed) {
-               ret = -1;
-               goto exit;
-       }
-
-       /*  When Busy Traffic, driver do not site survey. So driver return success. */
-       /*  wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. */
-       /*  modify by thomas 2011-02-22. */
-       if (pmlmepriv->LinkDetectInfo.bBusyTraffic) {
-               indicate_wx_scan_complete_event(padapter);
-               goto exit;
-       }
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) {
-               indicate_wx_scan_complete_event(padapter);
-               goto exit;
-       }
-
-/*     For the DMP WiFi Display project, the driver won't to scan because */
-/*     the pmlmepriv->scan_interval is always equal to 3. */
-/*     So, the wpa_supplicant won't find out the WPS SoftAP. */
-
-       if (pwdinfo->p2p_state != P2P_STATE_NONE) {
-               rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH);
-               rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_FULL);
-               rtw_free_network_queue(padapter, true);
-       }
-
-       memset(ssid, 0, sizeof(struct ndis_802_11_ssid) * RTW_SSID_SCAN_AMOUNT);
-
-       if (wrqu->data.length == sizeof(struct iw_scan_req)) {
-               struct iw_scan_req *req = (struct iw_scan_req *)extra;
-
-               if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
-                       int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE);
-
-                       memcpy(ssid[0].Ssid, req->essid, len);
-                       ssid[0].SsidLength = len;
-
-                       spin_lock_bh(&pmlmepriv->lock);
-
-                       _status = rtw_sitesurvey_cmd(padapter, ssid, 1);
-
-                       spin_unlock_bh(&pmlmepriv->lock);
-               }
-       } else {
-               if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE &&
-                   !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) {
-                       int len = wrqu->data.length - WEXT_CSCAN_HEADER_SIZE;
-                       char *pos = extra + WEXT_CSCAN_HEADER_SIZE;
-                       char section;
-                       char sec_len;
-                       int ssid_index = 0;
-
-                       while (len >= 1) {
-                               section = *(pos++);
-                               len -= 1;
-
-                               switch (section) {
-                               case WEXT_CSCAN_SSID_SECTION:
-                                       if (len < 1) {
-                                               len = 0;
-                                               break;
-                                       }
-                                       sec_len = *(pos++); len -= 1;
-                                       if (sec_len > 0 &&
-                                           sec_len <= len &&
-                                           sec_len <= 32) {
-                                               ssid[ssid_index].SsidLength = sec_len;
-                                               memcpy(ssid[ssid_index].Ssid, pos, sec_len);
-                                               ssid_index++;
-                                       }
-                                       pos += sec_len;
-                                       len -= sec_len;
-                                       break;
-                               case WEXT_CSCAN_TYPE_SECTION:
-                               case WEXT_CSCAN_CHANNEL_SECTION:
-                                       pos += 1;
-                                       len -= 1;
-                                       break;
-                               case WEXT_CSCAN_PASV_DWELL_SECTION:
-                               case WEXT_CSCAN_HOME_DWELL_SECTION:
-                               case WEXT_CSCAN_ACTV_DWELL_SECTION:
-                                       pos += 2;
-                                       len -= 2;
-                                       break;
-                               default:
-                                       len = 0; /*  stop parsing */
-                               }
-                       }
-
-                       /* it has still some scan parameter to parse, we only do this now... */
-                       _status = rtw_set_802_11_bssid_list_scan(padapter, ssid, RTW_SSID_SCAN_AMOUNT);
-               } else {
-                       _status = rtw_set_802_11_bssid_list_scan(padapter, NULL, 0);
-               }
-       }
-
-       if (!_status)
-               ret = -1;
-
-exit:
-
-       return ret;
-}
-
-static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
-                            union iwreq_data *wrqu, char *extra)
-{
-       struct list_head *plist, *phead;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       char *ev = extra;
-       char *stop = ev + wrqu->data.length;
-       u32 ret = 0;
-       u32 cnt = 0;
-       u32 wait_for_surveydone;
-       int wait_status;
-       struct  wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-               /*      P2P is enabled */
-               wait_for_surveydone = 200;
-       } else {
-               /*      P2P is disabled */
-               wait_for_surveydone = 100;
-       }
-
-       wait_status = _FW_UNDER_SURVEY | _FW_UNDER_LINKING;
-
-       while (check_fwstate(pmlmepriv, wait_status)) {
-               msleep(30);
-               cnt++;
-               if (cnt > wait_for_surveydone)
-                       break;
-       }
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               if ((stop - ev) < SCAN_ITEM_SIZE) {
-                       ret = -E2BIG;
-                       break;
-               }
-
-               pnetwork = container_of(plist, struct wlan_network, list);
-
-               /* report network only if the current channel set contains the channel to which this network belongs */
-               if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0)
-                       ev = translate_scan(padapter, a, pnetwork, ev, stop);
-
-               plist = plist->next;
-       }
-
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       wrqu->data.length = ev - extra;
-       wrqu->data.flags = 0;
-
-       return ret;
-}
-
-/* set ssid flow */
-/* s1. rtw_set_802_11_infrastructure_mode() */
-/* s2. set_802_11_authenticaion_mode() */
-/* s3. set_802_11_encryption_mode() */
-/* s4. rtw_set_802_11_ssid() */
-static int rtw_wx_set_essid(struct net_device *dev,
-                             struct iw_request_info *a,
-                             union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct __queue *queue = &pmlmepriv->scanned_queue;
-       struct list_head *phead;
-       struct wlan_network *pnetwork = NULL;
-       enum ndis_802_11_auth_mode authmode;
-       struct ndis_802_11_ssid ndis_ssid;
-       u8 *dst_ssid, *src_ssid;
-
-       uint ret = 0, len;
-
-       ret = rtw_pwr_wakeup(padapter);
-       if (ret)
-               goto exit;
-
-       if (!padapter->bup) {
-               ret = -1;
-               goto exit;
-       }
-
-       if (wrqu->essid.length > IW_ESSID_MAX_SIZE) {
-               ret = -E2BIG;
-               goto exit;
-       }
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               ret = -1;
-               goto exit;
-       }
-
-       authmode = padapter->securitypriv.ndisauthtype;
-       if (wrqu->essid.flags && wrqu->essid.length) {
-               len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE;
-
-               memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid));
-               ndis_ssid.SsidLength = len;
-               memcpy(ndis_ssid.Ssid, extra, len);
-               src_ssid = ndis_ssid.Ssid;
-
-               spin_lock_bh(&queue->lock);
-               phead = get_list_head(queue);
-               pmlmepriv->pscanned = phead->next;
-
-               while (phead != pmlmepriv->pscanned) {
-                       pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list);
-
-                       pmlmepriv->pscanned = pmlmepriv->pscanned->next;
-
-                       dst_ssid = pnetwork->network.Ssid.Ssid;
-
-                       if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) &&
-                           (pnetwork->network.Ssid.SsidLength == ndis_ssid.SsidLength)) {
-
-                               if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-                                       if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode)
-                                               continue;
-                               }
-
-                               if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) {
-                                       ret = -1;
-                                       spin_unlock_bh(&queue->lock);
-                                       goto exit;
-                               }
-
-                               break;
-                       }
-               }
-               spin_unlock_bh(&queue->lock);
-               rtw_set_802_11_authentication_mode(padapter, authmode);
-               if (!rtw_set_802_11_ssid(padapter, &ndis_ssid)) {
-                       ret = -1;
-                       goto exit;
-               }
-       }
-
-exit:
-       return ret;
-}
-
-static int rtw_wx_get_essid(struct net_device *dev,
-                             struct iw_request_info *a,
-                             union iwreq_data *wrqu, char *extra)
-{
-       u32 len;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_bssid_ex  *pcur_bss = &pmlmepriv->cur_network.network;
-
-       if ((check_fwstate(pmlmepriv, _FW_LINKED)) ||
-           (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) {
-               len = pcur_bss->Ssid.SsidLength;
-               memcpy(extra, pcur_bss->Ssid.Ssid, len);
-       } else {
-               len = 0;
-               *extra = 0;
-       }
-       wrqu->essid.length = len;
-       wrqu->essid.flags = 1;
-
-       return 0;
-}
-
-static int rtw_wx_set_rate(struct net_device *dev,
-                             struct iw_request_info *a,
-                             union iwreq_data *wrqu, char *extra)
-{
-       int i;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u8 datarates[NumRates];
-       u32     target_rate = wrqu->bitrate.value;
-       u32     fixed = wrqu->bitrate.fixed;
-       u32     ratevalue = 0;
-       u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff};
-
-       if (target_rate == -1) {
-               ratevalue = 11;
-               goto set_rate;
-       }
-       target_rate = target_rate / 100000;
-
-       switch (target_rate) {
-       case 10:
-               ratevalue = 0;
-               break;
-       case 20:
-               ratevalue = 1;
-               break;
-       case 55:
-               ratevalue = 2;
-               break;
-       case 60:
-               ratevalue = 3;
-               break;
-       case 90:
-               ratevalue = 4;
-               break;
-       case 110:
-               ratevalue = 5;
-               break;
-       case 120:
-               ratevalue = 6;
-               break;
-       case 180:
-               ratevalue = 7;
-               break;
-       case 240:
-               ratevalue = 8;
-               break;
-       case 360:
-               ratevalue = 9;
-               break;
-       case 480:
-               ratevalue = 10;
-               break;
-       case 540:
-               ratevalue = 11;
-               break;
-       default:
-               ratevalue = 11;
-               break;
-       }
-
-set_rate:
-
-       for (i = 0; i < NumRates; i++) {
-               if (ratevalue == mpdatarate[i]) {
-                       datarates[i] = mpdatarate[i];
-                       if (fixed == 0)
-                               break;
-               } else {
-                       datarates[i] = 0xff;
-               }
-       }
-
-       return rtw_setdatarate_cmd(padapter, datarates);
-}
-
-static int rtw_wx_get_rate(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       u16 max_rate = 0;
-
-       max_rate = rtw_get_cur_max_rate((struct adapter *)rtw_netdev_priv(dev));
-
-       if (max_rate == 0)
-               return -EPERM;
-
-       wrqu->bitrate.fixed = 0;        /* no auto select */
-       wrqu->bitrate.value = max_rate * 100000;
-
-       return 0;
-}
-
-static int rtw_wx_set_rts(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-
-
-
-       if (wrqu->rts.disabled) {
-               padapter->registrypriv.rts_thresh = 2347;
-       } else {
-               if (wrqu->rts.value < 0 ||
-                   wrqu->rts.value > 2347)
-                       return -EINVAL;
-
-               padapter->registrypriv.rts_thresh = wrqu->rts.value;
-       }
-
-       return 0;
-}
-
-static int rtw_wx_get_rts(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-
-
-
-       wrqu->rts.value = padapter->registrypriv.rts_thresh;
-       wrqu->rts.fixed = 0;    /* no auto select */
-       /* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */
-
-
-
-       return 0;
-}
-
-static int rtw_wx_set_frag(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-
-
-
-       if (wrqu->frag.disabled) {
-               padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD;
-       } else {
-               if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
-                   wrqu->frag.value > MAX_FRAG_THRESHOLD)
-                       return -EINVAL;
-
-               padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1;
-       }
-
-       return 0;
-}
-
-static int rtw_wx_get_frag(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-
-
-
-       wrqu->frag.value = padapter->xmitpriv.frag_len;
-       wrqu->frag.fixed = 0;   /* no auto select */
-
-
-
-       return 0;
-}
-
-static int rtw_wx_get_retry(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       wrqu->retry.value = 7;
-       wrqu->retry.fixed = 0;  /* no auto select */
-       wrqu->retry.disabled = 1;
-
-       return 0;
-}
-
-static int rtw_wx_set_enc(struct net_device *dev,
-                           struct iw_request_info *info,
-                           union iwreq_data *wrqu, char *keybuf)
-{
-       u32 key, ret = 0;
-       u32 keyindex_provided;
-       struct ndis_802_11_wep   wep;
-       enum ndis_802_11_auth_mode authmode;
-
-       struct iw_point *erq = &wrqu->encoding;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-
-       memset(&wep, 0, sizeof(struct ndis_802_11_wep));
-
-       key = erq->flags & IW_ENCODE_INDEX;
-
-
-
-       if (erq->flags & IW_ENCODE_DISABLED) {
-               padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
-               padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
-               padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
-               padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
-               authmode = Ndis802_11AuthModeOpen;
-               padapter->securitypriv.ndisauthtype = authmode;
-
-               goto exit;
-       }
-
-       if (key) {
-               if (key > WEP_KEYS)
-                       return -EINVAL;
-               key--;
-               keyindex_provided = 1;
-       } else {
-               keyindex_provided = 0;
-               key = padapter->securitypriv.dot11PrivacyKeyIndex;
-       }
-
-       /* set authentication mode */
-       if (erq->flags & IW_ENCODE_OPEN) {
-               padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */
-               padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
-               padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
-               padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
-               authmode = Ndis802_11AuthModeOpen;
-               padapter->securitypriv.ndisauthtype = authmode;
-       } else if (erq->flags & IW_ENCODE_RESTRICTED) {
-               padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
-               padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared;
-               padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_;
-               padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_;
-               authmode = Ndis802_11AuthModeShared;
-               padapter->securitypriv.ndisauthtype = authmode;
-       } else {
-               padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */
-               padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
-               padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
-               padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
-               authmode = Ndis802_11AuthModeOpen;
-               padapter->securitypriv.ndisauthtype = authmode;
-       }
-
-       wep.KeyIndex = key;
-       if (erq->length > 0) {
-               wep.KeyLength = erq->length <= 5 ? 5 : 13;
-
-               wep.Length = wep.KeyLength + offsetof(struct ndis_802_11_wep, KeyMaterial);
-       } else {
-               wep.KeyLength = 0;
-
-               if (keyindex_provided == 1) {
-                       /*  set key_id only, no given KeyMaterial(erq->length == 0). */
-                       padapter->securitypriv.dot11PrivacyKeyIndex = key;
-
-                       switch (padapter->securitypriv.dot11DefKeylen[key]) {
-                       case 5:
-                               padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_;
-                               break;
-                       case 13:
-                               padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_;
-                               break;
-                       default:
-                               padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
-                               break;
-                       }
-
-                       goto exit;
-               }
-       }
-
-       wep.KeyIndex |= 0x80000000;
-
-       memcpy(wep.KeyMaterial, keybuf, wep.KeyLength);
-
-       if (!rtw_set_802_11_add_wep(padapter, &wep)) {
-               if (rf_on == pwrpriv->rf_pwrstate)
-                       ret = -EOPNOTSUPP;
-               goto exit;
-       }
-
-exit:
-
-
-
-       return ret;
-}
-
-static int rtw_wx_get_enc(struct net_device *dev,
-                           struct iw_request_info *info,
-                           union iwreq_data *wrqu, char *keybuf)
-{
-       uint key;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct iw_point *erq = &wrqu->encoding;
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-
-
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED) != true) {
-               if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
-                       erq->length = 0;
-                       erq->flags |= IW_ENCODE_DISABLED;
-                       return 0;
-               }
-       }
-
-       key = erq->flags & IW_ENCODE_INDEX;
-
-       if (key) {
-               if (key > WEP_KEYS)
-                       return -EINVAL;
-               key--;
-       } else {
-               key = padapter->securitypriv.dot11PrivacyKeyIndex;
-       }
-
-       erq->flags = key + 1;
-
-       switch (padapter->securitypriv.ndisencryptstatus) {
-       case Ndis802_11EncryptionNotSupported:
-       case Ndis802_11EncryptionDisabled:
-               erq->length = 0;
-               erq->flags |= IW_ENCODE_DISABLED;
-               break;
-       case Ndis802_11Encryption1Enabled:
-               erq->length = padapter->securitypriv.dot11DefKeylen[key];
-               if (erq->length) {
-                       memcpy(keybuf, padapter->securitypriv.dot11DefKey[key].skey, padapter->securitypriv.dot11DefKeylen[key]);
-
-                       erq->flags |= IW_ENCODE_ENABLED;
-
-                       if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen)
-                               erq->flags |= IW_ENCODE_OPEN;
-                       else if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeShared)
-                               erq->flags |= IW_ENCODE_RESTRICTED;
-               } else {
-                       erq->length = 0;
-                       erq->flags |= IW_ENCODE_DISABLED;
-               }
-               break;
-       case Ndis802_11Encryption2Enabled:
-       case Ndis802_11Encryption3Enabled:
-               erq->length = 16;
-               erq->flags |= (IW_ENCODE_ENABLED | IW_ENCODE_OPEN | IW_ENCODE_NOKEY);
-               break;
-       default:
-               erq->length = 0;
-               erq->flags |= IW_ENCODE_DISABLED;
-               break;
-       }
-
-
-       return 0;
-}
-
-static int rtw_wx_get_power(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       wrqu->power.value = 0;
-       wrqu->power.fixed = 0;  /* no auto select */
-       wrqu->power.disabled = 1;
-
-       return 0;
-}
-
-static int rtw_wx_set_gen_ie(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       int ret;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-
-       ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
-       return ret;
-}
-
-static int rtw_wx_set_auth(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct iw_param *param = (struct iw_param *)&wrqu->param;
-       int ret = 0;
-
-       switch (param->flags & IW_AUTH_INDEX) {
-       case IW_AUTH_WPA_VERSION:
-               break;
-       case IW_AUTH_CIPHER_PAIRWISE:
-
-               break;
-       case IW_AUTH_CIPHER_GROUP:
-
-               break;
-       case IW_AUTH_KEY_MGMT:
-               /*
-                *  ??? does not use these parameters
-                */
-               break;
-       case IW_AUTH_TKIP_COUNTERMEASURES:
-               if (param->value) {
-                       /*  wpa_supplicant is enabling the tkip countermeasure. */
-                       padapter->securitypriv.btkip_countermeasure = true;
-               } else {
-                       /*  wpa_supplicant is disabling the tkip countermeasure. */
-                       padapter->securitypriv.btkip_countermeasure = false;
-               }
-               break;
-       case IW_AUTH_DROP_UNENCRYPTED:
-               /* HACK:
-                *
-                * wpa_supplicant calls set_wpa_enabled when the driver
-                * is loaded and unloaded, regardless of if WPA is being
-                * used.  No other calls are made which can be used to
-                * determine if encryption will be used or not prior to
-                * association being expected.  If encryption is not being
-                * used, drop_unencrypted is set to false, else true -- we
-                * can use this to determine if the CAP_PRIVACY_ON bit should
-                * be set.
-                */
-
-               if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled)
-                       break;/* it means init value, or using wep, ndisencryptstatus = Ndis802_11Encryption1Enabled, */
-                                       /*  then it needn't reset it; */
-
-               if (param->value) {
-                       padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
-                       padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
-                       padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
-                       padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
-                       padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
-               }
-
-               break;
-       case IW_AUTH_80211_AUTH_ALG:
-               /*
-                *  It's the starting point of a link layer connection using wpa_supplicant
-               */
-               if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
-                       LeaveAllPowerSaveMode(padapter);
-                       rtw_disassoc_cmd(padapter, 500, false);
-                       rtw_indicate_disconnect(padapter);
-                       rtw_free_assoc_resources(padapter, 1);
-               }
-               ret = wpa_set_auth_algs(dev, (u32)param->value);
-               break;
-       case IW_AUTH_WPA_ENABLED:
-               break;
-       case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-               break;
-       case IW_AUTH_PRIVACY_INVOKED:
-               break;
-       default:
-               return -EOPNOTSUPP;
-       }
-
-       return ret;
-}
-
-static int rtw_wx_set_enc_ext(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
-{
-       char *alg_name;
-       u32 param_len;
-       struct ieee_param *param = NULL;
-       struct iw_point *pencoding = &wrqu->encoding;
-       struct iw_encode_ext *pext = (struct iw_encode_ext *)extra;
-       int ret = -1;
-
-       param_len = sizeof(struct ieee_param) + pext->key_len;
-       param = kzalloc(param_len, GFP_KERNEL);
-       if (!param)
-               return -ENOMEM;
-
-       param->cmd = IEEE_CMD_SET_ENCRYPTION;
-       memset(param->sta_addr, 0xff, ETH_ALEN);
-
-       switch (pext->alg) {
-       case IW_ENCODE_ALG_NONE:
-               /* todo: remove key */
-               /* remove = 1; */
-               alg_name = "none";
-               break;
-       case IW_ENCODE_ALG_WEP:
-               alg_name = "WEP";
-               break;
-       case IW_ENCODE_ALG_TKIP:
-               alg_name = "TKIP";
-               break;
-       case IW_ENCODE_ALG_CCMP:
-               alg_name = "CCMP";
-               break;
-       default:
-               goto out;
-       }
-
-       strscpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
-
-       if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
-               param->u.crypt.set_tx = 1;
-
-       /* cliW: WEP does not have group key
-        * just not checking GROUP key setting
-        */
-       if ((pext->alg != IW_ENCODE_ALG_WEP) &&
-           (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY))
-               param->u.crypt.set_tx = 0;
-
-       param->u.crypt.idx = (pencoding->flags & 0x00FF) - 1;
-
-       if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
-               memcpy(param->u.crypt.seq, pext->rx_seq, 8);
-
-       if (pext->key_len) {
-               param->u.crypt.key_len = pext->key_len;
-               memcpy(param->u.crypt.key, pext + 1, pext->key_len);
-       }
-
-       ret =  wpa_set_encryption(dev, param, param_len);
-
-out:
-       kfree(param);
-       return ret;
-}
-
-static int rtw_wx_get_nick(struct net_device *dev,
-                          struct iw_request_info *info,
-                          union iwreq_data *wrqu, char *extra)
-{
-       if (extra) {
-               wrqu->data.length = 14;
-               wrqu->data.flags = 1;
-               memcpy(extra, "<WIFI@REALTEK>", 14);
-       }
-
-       /* dump debug info here */
-       return 0;
-}
-
-static int rtw_wx_read_rf(struct net_device *dev,
-                           struct iw_request_info *info,
-                           union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u32 path, addr, data32;
-
-       path = *(u32 *)extra;
-       if (path != RF_PATH_A)
-               return -EINVAL;
-
-       addr = *((u32 *)extra + 1);
-       data32 = rtl8188e_PHY_QueryRFReg(padapter, addr, 0xFFFFF);
-       /*
-        * IMPORTANT!!
-        * Only when wireless private ioctl is at odd order,
-        * "extra" would be copied to user space.
-        */
-       sprintf(extra, "0x%05x", data32);
-
-       return 0;
-}
-
-static int rtw_wx_write_rf(struct net_device *dev,
-                           struct iw_request_info *info,
-                           union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u32 path, addr, data32;
-
-       path = *(u32 *)extra;
-       if (path != RF_PATH_A)
-               return -EINVAL;
-
-       addr = *((u32 *)extra + 1);
-       data32 = *((u32 *)extra + 2);
-       rtl8188e_PHY_SetRFReg(padapter, addr, 0xFFFFF, data32);
-
-       return 0;
-}
-
-static int rtw_wx_set_channel_plan(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u8 channel_plan_req = (u8)(*((int *)wrqu));
-
-       if (rtw_set_chplan_cmd(padapter, channel_plan_req) != _SUCCESS)
-               return -EPERM;
-
-       return 0;
-}
-
-static int rtw_get_ap_info(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-       u32 cnt = 0, wpa_ielen;
-       struct list_head *plist, *phead;
-       unsigned char *pbuf;
-       u8 bssid[ETH_ALEN];
-       char data[32];
-       struct wlan_network *pnetwork = NULL;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct __queue *queue = &pmlmepriv->scanned_queue;
-       struct iw_point *pdata = &wrqu->data;
-
-       if (padapter->bDriverStopped || !pdata) {
-               ret = -EINVAL;
-               goto exit;
-       }
-
-       while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY | _FW_UNDER_LINKING)))) {
-               msleep(30);
-               cnt++;
-               if (cnt > 100)
-                       break;
-       }
-       pdata->flags = 0;
-       if (pdata->length >= 32) {
-               if (copy_from_user(data, pdata->pointer, 32)) {
-                       ret = -EINVAL;
-                       goto exit;
-               }
-       } else {
-               ret = -EINVAL;
-               goto exit;
-       }
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               pnetwork = container_of(plist, struct wlan_network, list);
-
-               if (!mac_pton(data, bssid)) {
-                       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-                       return -EINVAL;
-               }
-
-               if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) {
-                       /* BSSID match, then check if supporting wpa/wpa2 */
-                       pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength - 12);
-                       if (pbuf && (wpa_ielen > 0)) {
-                               pdata->flags = 1;
-                               break;
-                       }
-
-                       pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength - 12);
-                       if (pbuf && (wpa_ielen > 0)) {
-                               pdata->flags = 2;
-                               break;
-                       }
-               }
-
-               plist = plist->next;
-       }
-
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       if (pdata->length >= 34) {
-               if (copy_to_user(pdata->pointer + 32, (u8 *)&pdata->flags, 1)) {
-                       ret = -EINVAL;
-                       goto exit;
-               }
-       }
-
-exit:
-
-       return ret;
-}
-
-static int rtw_set_pid(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-       struct adapter *padapter = rtw_netdev_priv(dev);
-       int *pdata = (int *)wrqu;
-       int selector;
-
-       if (padapter->bDriverStopped || !pdata) {
-               ret = -EINVAL;
-               goto exit;
-       }
-
-       selector = *pdata;
-       if (selector < 3 && selector >= 0) {
-               padapter->pid[selector] = *(pdata + 1);
-               ui_pid[selector] = *(pdata + 1);
-       }
-exit:
-       return ret;
-}
-
-static int rtw_wps_start(struct net_device *dev,
-                        struct iw_request_info *info,
-                        union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct iw_point *pdata = &wrqu->data;
-       u32   u32wps_start = 0;
-
-       if (!pdata)
-               return -EINVAL;
-       ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4);
-       if (ret) {
-               ret = -EINVAL;
-               goto exit;
-       }
-
-       if (padapter->bDriverStopped) {
-               ret = -EINVAL;
-               goto exit;
-       }
-
-       if (u32wps_start == 0)
-               u32wps_start = *extra;
-
-       if (u32wps_start == 1) /*  WPS Start */
-               rtw_led_control(padapter, LED_CTL_START_WPS);
-       else if (u32wps_start == 2) /*  WPS Stop because of wps success */
-               rtw_led_control(padapter, LED_CTL_STOP_WPS);
-       else if (u32wps_start == 3) /*  WPS Stop because of wps fail */
-               rtw_led_control(padapter, LED_CTL_STOP_WPS_FAIL);
-
-exit:
-       return ret;
-}
-
-static int rtw_wext_p2p_enable(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       int ret;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       enum P2P_ROLE init_role = P2P_ROLE_DISABLE;
-
-       if (*extra == '0')
-               init_role = P2P_ROLE_DISABLE;
-       else if (*extra == '1')
-               init_role = P2P_ROLE_DEVICE;
-       else if (*extra == '2')
-               init_role = P2P_ROLE_CLIENT;
-       else if (*extra == '3')
-               init_role = P2P_ROLE_GO;
-
-       ret = rtw_p2p_enable(padapter, init_role);
-       if (ret)
-               return ret;
-
-       /* set channel/bandwidth */
-       if (init_role != P2P_ROLE_DISABLE) {
-               u8 channel, ch_offset;
-               u16 bwmode;
-
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN)) {
-                       /*      Stay at the listen state and wait for discovery. */
-                       channel = pwdinfo->listen_channel;
-                       pwdinfo->operating_channel = pwdinfo->listen_channel;
-                       ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-                       bwmode = HT_CHANNEL_WIDTH_20;
-               } else {
-                       pwdinfo->operating_channel = pmlmeext->cur_channel;
-
-                       channel = pwdinfo->operating_channel;
-                       ch_offset = pmlmeext->cur_ch_offset;
-                       bwmode = pmlmeext->cur_bwmode;
-               }
-
-               set_channel_bwmode(padapter, channel, ch_offset, bwmode);
-       }
-
-       return 0;
-}
-
-static void rtw_p2p_set_go_nego_ssid(struct net_device *dev,
-                                    struct iw_request_info *info,
-                                    union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       memcpy(pwdinfo->nego_ssid, extra, strlen(extra));
-       pwdinfo->nego_ssidlen = strlen(extra);
-}
-
-static int rtw_p2p_set_intent(struct net_device *dev,
-                             struct iw_request_info *info,
-                             union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8 intent = pwdinfo->intent;
-
-       switch (wrqu->data.length) {
-       case 1:
-               intent = extra[0] - '0';
-               break;
-       case 2:
-               intent = str_2char2num(extra[0], extra[1]);
-               break;
-       }
-       if (intent <= 15)
-               pwdinfo->intent = intent;
-       else
-               ret = -1;
-       return ret;
-}
-
-static int rtw_p2p_set_listen_ch(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8 listen_ch = pwdinfo->listen_channel; /*      Listen channel number */
-
-       switch (wrqu->data.length) {
-       case 1:
-               listen_ch = extra[0] - '0';
-               break;
-       case 2:
-               listen_ch = str_2char2num(extra[0], extra[1]);
-               break;
-       }
-
-       if ((listen_ch == 1) || (listen_ch == 6) || (listen_ch == 11)) {
-               pwdinfo->listen_channel = listen_ch;
-               set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-       } else {
-               ret = -1;
-       }
-
-       return ret;
-}
-
-static int rtw_p2p_set_op_ch(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-/*     Commented by Albert 20110524 */
-/*     This function is used to set the operating channel if the driver will become the group owner */
-
-       int ret = 0;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8 op_ch = pwdinfo->operating_channel;  /*      Operating channel number */
-
-       switch (wrqu->data.length) {
-       case 1:
-               op_ch = extra[0] - '0';
-               break;
-       case 2:
-               op_ch = str_2char2num(extra[0], extra[1]);
-               break;
-       }
-
-       if (op_ch > 0)
-               pwdinfo->operating_channel = op_ch;
-       else
-               ret = -1;
-
-       return ret;
-}
-
-static int rtw_p2p_profilefound(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       /*      Comment by Albert 2010/10/13 */
-       /*      Input data format: */
-       /*      Ex:  0 */
-       /*      Ex:  1XX:XX:XX:XX:XX:XXYYSSID */
-       /*      0 => Reflush the profile record list. */
-       /*      1 => Add the profile list */
-       /*      XX:XX:XX:XX:XX:XX => peer's MAC Address (ex: 00:E0:4C:00:00:01) */
-       /*      YY => SSID Length */
-       /*      SSID => SSID for persistence group */
-
-       /*      The upper application should pass the SSID to driver by using this rtw_p2p_profilefound function. */
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-               if (extra[0] == '0') {
-                       /*      Remove all the profile information of wifidirect_info structure. */
-                       memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM);
-                       pwdinfo->profileindex = 0;
-               } else {
-                       if (pwdinfo->profileindex >= P2P_MAX_PERSISTENT_GROUP_NUM) {
-                               ret = -1;
-                       } else {
-                               int jj, kk;
-
-                               /*      Add this profile information into pwdinfo->profileinfo */
-                               /*      Ex:  1XX:XX:XX:XX:XX:XXYYSSID */
-                               for (jj = 0, kk = 1; jj < ETH_ALEN; jj++, kk += 3)
-                                       pwdinfo->profileinfo[pwdinfo->profileindex].peermac[jj] = key_2char2num(extra[kk], extra[kk + 1]);
-
-                               pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen = (extra[18] - '0') * 10 + (extra[19] - '0');
-                               memcpy(pwdinfo->profileinfo[pwdinfo->profileindex].ssid, &extra[20], pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen);
-                               pwdinfo->profileindex++;
-                       }
-               }
-       }
-
-       return ret;
-}
-
-static void rtw_p2p_setDN(struct net_device *dev,
-                         struct iw_request_info *info,
-                         union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN);
-       memcpy(pwdinfo->device_name, extra, wrqu->data.length - 1);
-       pwdinfo->device_name_len = wrqu->data.length - 1;
-}
-
-static int rtw_p2p_get_wps_configmethod(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u8 peerMAC[ETH_ALEN] = {0x00};
-       int jj, kk;
-       u8 peerMACStr[17] = {0x00};
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct list_head *plist, *phead;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       u8 blnMatch = 0;
-       u16     attr_content = 0;
-       uint attr_contentlen = 0;
-       /* 6 is the string "wpsCM =", 17 is the MAC addr, we have to clear it at wrqu->data.pointer */
-       u8 attr_content_str[6 + 17] = {0x00};
-
-       /*      Commented by Albert 20110727 */
-       /*      The input data is the MAC address which the application wants to know its WPS config method. */
-       /*      After knowing its WPS config method, the application can decide the config method for provisioning discovery. */
-       /*      Format: iwpriv wlanx p2p_get_wpsCM 00:E0:4C:00:00:05 */
-
-       if (copy_from_user(peerMACStr, wrqu->data.pointer + 6, 17))
-               return -EFAULT;
-
-       for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
-               peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]);
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               pnetwork = container_of(plist, struct wlan_network, list);
-               if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
-                       u8 *wpsie;
-                       uint wpsie_len = 0;
-                       __be16 be_tmp;
-
-                       /*  The mac address is matched. */
-                       wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len);
-                       if (wpsie) {
-                               rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_CONF_METHOD, (u8 *)&be_tmp, &attr_contentlen);
-                               if (attr_contentlen) {
-                                       attr_content = be16_to_cpu(be_tmp);
-                                       sprintf(attr_content_str, "\n\nM =%.4d", attr_content);
-                                       blnMatch = 1;
-                               }
-                       }
-                       break;
-               }
-               plist = plist->next;
-       }
-
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       if (!blnMatch)
-               sprintf(attr_content_str, "\n\nM = 0000");
-
-       if (copy_to_user(wrqu->data.pointer, attr_content_str, 6 + 17))
-               return -EFAULT;
-       return 0;
-}
-
-static int rtw_p2p_get_go_device_address(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u8 peerMAC[ETH_ALEN] = {0x00};
-       int jj, kk;
-       u8 peerMACStr[17] = {0x00};
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct list_head *plist, *phead;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       u8 blnMatch = 0;
-       u8 *p2pie;
-       uint p2pielen = 0, attr_contentlen = 0;
-       u8 attr_content[100] = {0x00};
-
-       u8 go_devadd_str[100 + 10] = {0x00};
-       /*  +10 is for the str "go_devadd =", we have to clear it at wrqu->data.pointer */
-
-       /*      Commented by Albert 20121209 */
-       /*      The input data is the GO's interface address which the application wants to know its device address. */
-       /*      Format: iwpriv wlanx p2p_get2 go_devadd = 00:E0:4C:00:00:05 */
-
-       if (copy_from_user(peerMACStr, wrqu->data.pointer + 10, 17))
-               return -EFAULT;
-
-       for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
-               peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]);
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               pnetwork = container_of(plist, struct wlan_network, list);
-               if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
-                       /*      Commented by Albert 2011/05/18 */
-                       /*      Match the device address located in the P2P IE */
-                       /*      This is for the case that the P2P device address is not the same as the P2P interface address. */
-
-                       p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen);
-                       if (p2pie) {
-                               while (p2pie) {
-                                       /*      The P2P Device ID attribute is included in the Beacon frame. */
-                                       /*      The P2P Device Info attribute is included in the probe response frame. */
-
-                                       memset(attr_content, 0x00, 100);
-                                       if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) {
-                                               /*      Handle the P2P Device ID attribute of Beacon first */
-                                               blnMatch = 1;
-                                               break;
-                                       } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) {
-                                               /*      Handle the P2P Device Info attribute of probe response */
-                                               blnMatch = 1;
-                                               break;
-                                       }
-
-                                       /* Get the next P2P IE */
-                                       p2pie = rtw_get_p2p_ie(p2pie + p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen);
-                               }
-                       }
-            }
-
-               plist = plist->next;
-       }
-
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       if (!blnMatch)
-               sprintf(go_devadd_str, "\n\ndev_add = NULL");
-       else
-               sprintf(go_devadd_str, "\ndev_add =%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
-                       attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]);
-
-       if (copy_to_user(wrqu->data.pointer, go_devadd_str, 10 + 17))
-               return -EFAULT;
-       return 0;
-}
-
-static int rtw_p2p_get_device_type(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u8 peerMAC[ETH_ALEN] = {0x00};
-       int jj, kk;
-       u8 peerMACStr[17] = {0x00};
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct list_head *plist, *phead;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       u8 blnMatch = 0;
-       u8 dev_type[8] = {0x00};
-       uint dev_type_len = 0;
-       u8 dev_type_str[17 + 9] = {0x00};       /*  +9 is for the str "dev_type =", we have to clear it at wrqu->data.pointer */
-
-       /*      Commented by Albert 20121209 */
-       /*      The input data is the MAC address which the application wants to know its device type. */
-       /*      Such user interface could know the device type. */
-       /*      Format: iwpriv wlanx p2p_get2 dev_type = 00:E0:4C:00:00:05 */
-
-       if (copy_from_user(peerMACStr, wrqu->data.pointer + 9, 17))
-               return -EFAULT;
-
-       for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
-               peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]);
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               pnetwork = container_of(plist, struct wlan_network, list);
-               if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
-                       u8 *wpsie;
-                       uint wpsie_len = 0;
-
-               /*      The mac address is matched. */
-
-                       wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12],
-                                              pnetwork->network.IELength - 12,
-                                              NULL, &wpsie_len);
-                       if (wpsie) {
-                               rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_PRIMARY_DEV_TYPE, dev_type, &dev_type_len);
-                               if (dev_type_len) {
-                                       u16     type = 0;
-                                       __be16 be_tmp;
-
-                                       memcpy(&be_tmp, dev_type, 2);
-                                       type = be16_to_cpu(be_tmp);
-                                       sprintf(dev_type_str, "\n\nN =%.2d", type);
-                                       blnMatch = 1;
-                               }
-                       }
-                       break;
-            }
-
-               plist = plist->next;
-       }
-
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       if (!blnMatch)
-               sprintf(dev_type_str, "\n\nN = 00");
-
-       if (copy_to_user(wrqu->data.pointer, dev_type_str, 9 + 17)) {
-               return -EFAULT;
-       }
-
-       return 0;
-}
-
-static int rtw_p2p_get_device_name(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u8 peerMAC[ETH_ALEN] = {0x00};
-       int jj, kk;
-       u8 peerMACStr[17] = {0x00};
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct list_head *plist, *phead;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       u8 blnMatch = 0;
-       u8 dev_name[WPS_MAX_DEVICE_NAME_LEN] = {0x00};
-       uint dev_len = 0;
-       u8 dev_name_str[WPS_MAX_DEVICE_NAME_LEN + 5] = {0x00};  /*  +5 is for the str "devN =", we have to clear it at wrqu->data.pointer */
-
-       /*      Commented by Albert 20121225 */
-       /*      The input data is the MAC address which the application wants to know its device name. */
-       /*      Such user interface could show peer device's device name instead of ssid. */
-       /*      Format: iwpriv wlanx p2p_get2 devN = 00:E0:4C:00:00:05 */
-
-       if (copy_from_user(peerMACStr, wrqu->data.pointer + 5, 17))
-               return -EFAULT;
-
-       for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
-               peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]);
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               pnetwork = container_of(plist, struct wlan_network, list);
-               if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
-                       u8 *wpsie;
-                       uint wpsie_len = 0;
-
-                       /*      The mac address is matched. */
-                       wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len);
-                       if (wpsie) {
-                               rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_DEVICE_NAME, dev_name, &dev_len);
-                               if (dev_len) {
-                                       sprintf(dev_name_str, "\n\nN =%s", dev_name);
-                                       blnMatch = 1;
-                               }
-                       }
-                       break;
-               }
-
-               plist = plist->next;
-       }
-
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       if (!blnMatch)
-               sprintf(dev_name_str, "\n\nN = 0000");
-
-       if (copy_to_user(wrqu->data.pointer, dev_name_str, 5 + ((dev_len > 17) ? dev_len : 17)))
-               return -EFAULT;
-       return 0;
-}
-
-static int rtw_p2p_get_invitation_procedure(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       u8 peerMAC[ETH_ALEN] = {0x00};
-       int jj, kk;
-       u8 peerMACStr[17] = {0x00};
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct list_head *plist, *phead;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       u8 blnMatch = 0;
-       u8 *p2pie;
-       uint p2pielen = 0, attr_contentlen = 0;
-       u8 attr_content[2] = {0x00};
-
-       u8 inv_proc_str[17 + 8] = {0x00};
-       /*  +8 is for the str "InvProc =", we have to clear it at wrqu->data.pointer */
-
-       /*      Commented by Ouden 20121226 */
-       /*      The application wants to know P2P initiation procedure is supported or not. */
-       /*      Format: iwpriv wlanx p2p_get2 InvProc = 00:E0:4C:00:00:05 */
-
-       if (copy_from_user(peerMACStr, wrqu->data.pointer + 8, 17))
-               return -EFAULT;
-
-       for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
-               peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]);
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               pnetwork = container_of(plist, struct wlan_network, list);
-               if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
-                       /*      Commented by Albert 20121226 */
-                       /*      Match the device address located in the P2P IE */
-                       /*      This is for the case that the P2P device address is not the same as the P2P interface address. */
-
-                       p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen);
-                       if (p2pie) {
-                               while (p2pie) {
-                                       if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_CAPABILITY, attr_content, &attr_contentlen)) {
-                                               /*      Handle the P2P capability attribute */
-                                               blnMatch = 1;
-                                               break;
-                                       }
-
-                                       /* Get the next P2P IE */
-                                       p2pie = rtw_get_p2p_ie(p2pie + p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen);
-                               }
-                       }
-               }
-               plist = plist->next;
-       }
-
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       if (!blnMatch) {
-               sprintf(inv_proc_str, "\nIP =-1");
-       } else {
-               if (attr_content[0] & 0x20)
-                       sprintf(inv_proc_str, "\nIP = 1");
-               else
-                       sprintf(inv_proc_str, "\nIP = 0");
-       }
-       if (copy_to_user(wrqu->data.pointer, inv_proc_str, 8 + 17))
-               return -EFAULT;
-       return 0;
-}
-
-static int rtw_p2p_connect(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8 peerMAC[ETH_ALEN] = {0x00};
-       int jj, kk;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct list_head *plist, *phead;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       u32 peer_channel = 0;
-
-       /*      Commented by Albert 20110304 */
-       /*      The input data contains two information. */
-       /*      1. First information is the MAC address which wants to formate with */
-       /*      2. Second information is the WPS PINCode or "pbc" string for push button method */
-       /*      Format: 00:E0:4C:00:00:05 */
-       /*      Format: 00:E0:4C:00:00:05 */
-
-       if (pwdinfo->p2p_state == P2P_STATE_NONE)
-               return ret;
-
-       if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO)
-               return -1;
-
-       for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
-               peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]);
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               pnetwork = container_of(plist, struct wlan_network, list);
-               if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
-                       peer_channel = pnetwork->network.Configuration.DSConfig;
-                       break;
-               }
-
-               plist = plist->next;
-       }
-
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       if (peer_channel) {
-               memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info));
-               memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info));
-
-               pwdinfo->nego_req_info.peer_channel_num[0] = peer_channel;
-               memcpy(pwdinfo->nego_req_info.peerDevAddr, pnetwork->network.MacAddress, ETH_ALEN);
-               pwdinfo->nego_req_info.benable = true;
-
-               _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer);
-               if (rtw_p2p_state(pwdinfo) != P2P_STATE_GONEGO_OK) {
-                       /*      Restore to the listen state if the current p2p state is not nego OK */
-                       rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN);
-               }
-
-               rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING);
-
-               _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT);
-               _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_GO_NEGO_TIMEOUT);
-       } else {
-               ret = -1;
-       }
-       return ret;
-}
-
-static void rtw_p2p_invite_req(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       int jj, kk;
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct list_head *plist, *phead;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       uint peer_channel = 0;
-       u8 attr_content[50] = {0x00};
-       u8 *p2pie;
-       uint p2pielen = 0, attr_contentlen = 0;
-       struct tx_invite_req_info *pinvite_req_info = &pwdinfo->invitereq_info;
-
-       /*      The input data contains two information items. */
-       /*      1. First information is the P2P device address which you want to send to. */
-       /*      2. Second information is the group id which combines with GO's mac address, space and GO's ssid. */
-       /*      Command line sample: iwpriv wlan0 p2p_set invite ="00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy" */
-       /*      Format: 00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy */
-
-       if (wrqu->data.length <=  37)
-               return;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-               return;
-       } else {
-               /*      Reset the content of struct tx_invite_req_info */
-               pinvite_req_info->benable = false;
-               memset(pinvite_req_info->go_bssid, 0x00, ETH_ALEN);
-               memset(pinvite_req_info->go_ssid, 0x00, WLAN_SSID_MAXLEN);
-               pinvite_req_info->ssidlen = 0x00;
-               pinvite_req_info->operating_ch = pwdinfo->operating_channel;
-               memset(pinvite_req_info->peer_macaddr, 0x00, ETH_ALEN);
-               pinvite_req_info->token = 3;
-       }
-
-       for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
-               pinvite_req_info->peer_macaddr[jj] = key_2char2num(extra[kk], extra[kk + 1]);
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               pnetwork = container_of(plist, struct wlan_network, list);
-
-               /*      Commented by Albert 2011/05/18 */
-               /*      Match the device address located in the P2P IE */
-               /*      This is for the case that the P2P device address is not the same as the P2P interface address. */
-
-               p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen);
-               if (p2pie) {
-                       /*      The P2P Device ID attribute is included in the Beacon frame. */
-                       /*      The P2P Device Info attribute is included in the probe response frame. */
-
-                       if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) {
-                               /*      Handle the P2P Device ID attribute of Beacon first */
-                               if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) {
-                                       peer_channel = pnetwork->network.Configuration.DSConfig;
-                                       break;
-                               }
-                       } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) {
-                               /*      Handle the P2P Device Info attribute of probe response */
-                               if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) {
-                                       peer_channel = pnetwork->network.Configuration.DSConfig;
-                                       break;
-                               }
-                       }
-               }
-               plist = plist->next;
-       }
-
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       if (peer_channel) {
-               /*      Store the GO's bssid */
-               for (jj = 0, kk = 18; jj < ETH_ALEN; jj++, kk += 3)
-                       pinvite_req_info->go_bssid[jj] = key_2char2num(extra[kk], extra[kk + 1]);
-
-               /*      Store the GO's ssid */
-               pinvite_req_info->ssidlen = wrqu->data.length - 36;
-               memcpy(pinvite_req_info->go_ssid, &extra[36], (u32)pinvite_req_info->ssidlen);
-               pinvite_req_info->benable = true;
-               pinvite_req_info->peer_ch = peer_channel;
-
-               rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INVITE_REQ);
-
-               set_channel_bwmode(padapter, peer_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-
-               _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT);
-
-               _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_INVITE_TIMEOUT);
-       }
-}
-
-static void rtw_p2p_set_persistent(struct net_device *dev,
-                                  struct iw_request_info *info,
-                                  union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       /*      The input data is 0 or 1 */
-       /*      0: disable persistent group functionality */
-       /*      1: enable persistent group founctionality */
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-               return;
-       } else {
-               if (extra[0] == '0')    /*      Disable the persistent group function. */
-                       pwdinfo->persistent_supported = false;
-               else if (extra[0] == '1')       /*      Enable the persistent group function. */
-                       pwdinfo->persistent_supported = true;
-               else
-                       pwdinfo->persistent_supported = false;
-       }
-       pr_info("[%s] persistent_supported = %d\n", __func__, pwdinfo->persistent_supported);
-}
-
-static void rtw_p2p_prov_disc(struct net_device *dev,
-                             struct iw_request_info *info,
-                             union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8 peerMAC[ETH_ALEN] = {0x00};
-       int jj, kk;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct list_head *plist, *phead;
-       struct __queue *queue   = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       uint peer_channel = 0;
-       u8 attr_content[100] = {0x00};
-       u8 *p2pie;
-       uint p2pielen = 0, attr_contentlen = 0;
-
-       /*      The input data contains two information items. */
-       /*      1. First information is the MAC address which wants to issue the provisioning discovery request frame. */
-       /*      2. Second information is the WPS configuration method which wants to discovery */
-       /*      Format: 00:E0:4C:00:00:05_display */
-       /*      Format: 00:E0:4C:00:00:05_keypad */
-       /*      Format: 00:E0:4C:00:00:05_pbc */
-       /*      Format: 00:E0:4C:00:00:05_label */
-
-       if (pwdinfo->p2p_state == P2P_STATE_NONE) {
-               return;
-       } else {
-               /*      Reset the content of struct tx_provdisc_req_info excluded the wps_config_method_request. */
-               memset(pwdinfo->tx_prov_disc_info.peerDevAddr, 0x00, ETH_ALEN);
-               memset(pwdinfo->tx_prov_disc_info.peerIFAddr, 0x00, ETH_ALEN);
-               memset(&pwdinfo->tx_prov_disc_info.ssid, 0x00, sizeof(struct ndis_802_11_ssid));
-               pwdinfo->tx_prov_disc_info.peer_channel_num[0] = 0;
-               pwdinfo->tx_prov_disc_info.peer_channel_num[1] = 0;
-               pwdinfo->tx_prov_disc_info.benable = false;
-       }
-
-       for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
-               peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]);
-
-       if (!memcmp(&extra[18], "display", 7))
-               pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_DISPLYA;
-       else if (!memcmp(&extra[18], "keypad", 7))
-               pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_KEYPAD;
-       else if (!memcmp(&extra[18], "pbc", 3))
-               pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_PUSH_BUTTON;
-       else if (!memcmp(&extra[18], "label", 5))
-               pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_LABEL;
-       else
-               return;
-
-       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-
-       phead = get_list_head(queue);
-       plist = phead->next;
-
-       while (phead != plist) {
-               if (peer_channel != 0)
-                       break;
-
-               pnetwork = container_of(plist, struct wlan_network, list);
-
-               /*      Commented by Albert 2011/05/18 */
-               /*      Match the device address located in the P2P IE */
-               /*      This is for the case that the P2P device address is not the same as the P2P interface address. */
-
-               p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen);
-               if (p2pie) {
-                       while (p2pie) {
-                               /*      The P2P Device ID attribute is included in the Beacon frame. */
-                               /*      The P2P Device Info attribute is included in the probe response frame. */
-
-                               if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) {
-                                       /*      Handle the P2P Device ID attribute of Beacon first */
-                                       if (!memcmp(attr_content, peerMAC, ETH_ALEN)) {
-                                               peer_channel = pnetwork->network.Configuration.DSConfig;
-                                               break;
-                                       }
-                               } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) {
-                                       /*      Handle the P2P Device Info attribute of probe response */
-                                       if (!memcmp(attr_content, peerMAC, ETH_ALEN)) {
-                                               peer_channel = pnetwork->network.Configuration.DSConfig;
-                                               break;
-                                       }
-                               }
-
-                               /* Get the next P2P IE */
-                               p2pie = rtw_get_p2p_ie(p2pie + p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen);
-                       }
-               }
-
-               plist = plist->next;
-       }
-
-       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-
-       if (peer_channel) {
-               memcpy(pwdinfo->tx_prov_disc_info.peerIFAddr, pnetwork->network.MacAddress, ETH_ALEN);
-               memcpy(pwdinfo->tx_prov_disc_info.peerDevAddr, peerMAC, ETH_ALEN);
-               pwdinfo->tx_prov_disc_info.peer_channel_num[0] = (u16)peer_channel;
-               pwdinfo->tx_prov_disc_info.benable = true;
-               rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ);
-
-               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) {
-                       memcpy(&pwdinfo->tx_prov_disc_info.ssid, &pnetwork->network.Ssid, sizeof(struct ndis_802_11_ssid));
-               } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                       memcpy(pwdinfo->tx_prov_disc_info.ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN);
-                       pwdinfo->tx_prov_disc_info.ssid.SsidLength = P2P_WILDCARD_SSID_LEN;
-               }
-
-               set_channel_bwmode(padapter, peer_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-
-               _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT);
-
-               _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT);
-       }
-}
-
-/*     This function is used to inform the driver the user had specified the pin code value or pbc */
-/*     to application. */
-
-static void rtw_p2p_got_wpsinfo(struct net_device *dev,
-                               struct iw_request_info *info,
-                               union iwreq_data *wrqu, char *extra)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       /*      Added by Albert 20110328 */
-       /*      if the input data is P2P_NO_WPSINFO -> reset the wpsinfo */
-       /*      if the input data is P2P_GOT_WPSINFO_PEER_DISPLAY_PIN -> the utility just input the PIN code got from the peer P2P device. */
-       /*      if the input data is P2P_GOT_WPSINFO_SELF_DISPLAY_PIN -> the utility just got the PIN code from itself. */
-       /*      if the input data is P2P_GOT_WPSINFO_PBC -> the utility just determine to use the PBC */
-
-       if (*extra == '0')
-               pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO;
-       else if (*extra == '1')
-               pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PEER_DISPLAY_PIN;
-       else if (*extra == '2')
-               pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_SELF_DISPLAY_PIN;
-       else if (*extra == '3')
-               pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PBC;
-       else
-               pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO;
-}
-
-static int rtw_p2p_set(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       if (!memcmp(extra, "enable =", 7)) {
-               rtw_wext_p2p_enable(dev, info, wrqu, &extra[7]);
-       } else if (!memcmp(extra, "setDN =", 6)) {
-               wrqu->data.length -= 6;
-               rtw_p2p_setDN(dev, info, wrqu, &extra[6]);
-       } else if (!memcmp(extra, "profilefound =", 13)) {
-               wrqu->data.length -= 13;
-               rtw_p2p_profilefound(dev, info, wrqu, &extra[13]);
-       } else if (!memcmp(extra, "prov_disc =", 10)) {
-               wrqu->data.length -= 10;
-               rtw_p2p_prov_disc(dev, info, wrqu, &extra[10]);
-       } else if (!memcmp(extra, "nego =", 5)) {
-               wrqu->data.length -= 5;
-               rtw_p2p_connect(dev, info, wrqu, &extra[5]);
-       } else if (!memcmp(extra, "intent =", 7)) {
-               /*      Commented by Albert 2011/03/23 */
-               /*      The wrqu->data.length will include the null character */
-               /*      So, we will decrease 7 + 1 */
-               wrqu->data.length -= 8;
-               rtw_p2p_set_intent(dev, info, wrqu, &extra[7]);
-       } else if (!memcmp(extra, "ssid =", 5)) {
-               wrqu->data.length -= 5;
-               rtw_p2p_set_go_nego_ssid(dev, info, wrqu, &extra[5]);
-       } else if (!memcmp(extra, "got_wpsinfo =", 12)) {
-               wrqu->data.length -= 12;
-               rtw_p2p_got_wpsinfo(dev, info, wrqu, &extra[12]);
-       } else if (!memcmp(extra, "listen_ch =", 10)) {
-               /*      Commented by Albert 2011/05/24 */
-               /*      The wrqu->data.length will include the null character */
-               /*      So, we will decrease (10 + 1) */
-               wrqu->data.length -= 11;
-               rtw_p2p_set_listen_ch(dev, info, wrqu, &extra[10]);
-       } else if (!memcmp(extra, "op_ch =", 6)) {
-               /*      Commented by Albert 2011/05/24 */
-               /*      The wrqu->data.length will include the null character */
-               /*      So, we will decrease (6 + 1) */
-               wrqu->data.length -= 7;
-               rtw_p2p_set_op_ch(dev, info, wrqu, &extra[6]);
-       } else if (!memcmp(extra, "invite =", 7)) {
-               wrqu->data.length -= 8;
-               rtw_p2p_invite_req(dev, info, wrqu, &extra[7]);
-       } else if (!memcmp(extra, "persistent =", 11)) {
-               wrqu->data.length -= 11;
-               rtw_p2p_set_persistent(dev, info, wrqu, &extra[11]);
-       }
-
-       return 0;
-}
-
-static int rtw_p2p_get2(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-
-       if (!memcmp(extra, "wpsCM =", 6)) {
-               wrqu->data.length -= 6;
-               ret = rtw_p2p_get_wps_configmethod(dev, info, wrqu,  &extra[6]);
-       } else if (!memcmp(extra, "devN =", 5)) {
-               wrqu->data.length -= 5;
-               ret = rtw_p2p_get_device_name(dev, info, wrqu, &extra[5]);
-       } else if (!memcmp(extra, "dev_type =", 9)) {
-               wrqu->data.length -= 9;
-               ret = rtw_p2p_get_device_type(dev, info, wrqu, &extra[9]);
-       } else if (!memcmp(extra, "go_devadd =", 10)) {
-               wrqu->data.length -= 10;
-               ret = rtw_p2p_get_go_device_address(dev, info, wrqu, &extra[10]);
-       } else if (!memcmp(extra, "InvProc =", 8)) {
-               wrqu->data.length -= 8;
-               ret = rtw_p2p_get_invitation_procedure(dev, info, wrqu, &extra[8]);
-       }
-
-       return ret;
-}
-
-static int rtw_rereg_nd_name(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-       struct adapter *padapter = rtw_netdev_priv(dev);
-       struct rereg_nd_name_data *rereg_priv = &padapter->rereg_nd_name_priv;
-       char new_ifname[IFNAMSIZ];
-
-       if (rereg_priv->old_ifname[0] == 0) {
-               char *reg_ifname;
-               reg_ifname = padapter->registrypriv.if2name;
-
-               strscpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ);
-       }
-
-       if (wrqu->data.length > IFNAMSIZ)
-               return -EFAULT;
-
-       if (copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ))
-               return -EFAULT;
-
-       if (0 == strcmp(rereg_priv->old_ifname, new_ifname))
-               return ret;
-
-       ret = rtw_change_ifname(padapter, new_ifname);
-       if (0 != ret)
-               goto exit;
-
-       if (!memcmp(rereg_priv->old_ifname, "disable%d", 9)) {
-               padapter->ledpriv.bRegUseLed = rereg_priv->old_bRegUseLed;
-               rtl8188eu_InitSwLeds(padapter);
-               rtw_ips_mode_req(&padapter->pwrctrlpriv, rereg_priv->old_ips_mode);
-       }
-
-       strscpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ);
-
-       if (!memcmp(new_ifname, "disable%d", 9)) {
-               /*  free network queue for Android's timming issue */
-               rtw_free_network_queue(padapter, true);
-
-               /*  close led */
-               rtw_led_control(padapter, LED_CTL_POWER_OFF);
-               rereg_priv->old_bRegUseLed = padapter->ledpriv.bRegUseLed;
-               padapter->ledpriv.bRegUseLed = false;
-               rtl8188eu_DeInitSwLeds(padapter);
-
-               /*  the interface is being "disabled", we can do deeper IPS */
-               rereg_priv->old_ips_mode = rtw_get_ips_mode_req(&padapter->pwrctrlpriv);
-               rtw_ips_mode_req(&padapter->pwrctrlpriv, IPS_NORMAL);
-       }
-exit:
-       return ret;
-}
-
-static void mac_reg_dump(struct adapter *padapter)
-{
-       int i, j = 1;
-       u32 reg;
-       int res;
-
-       pr_info("\n ======= MAC REG =======\n");
-       for (i = 0x0; i < 0x300; i += 4) {
-               if (j % 4 == 1)
-                       pr_info("0x%02x", i);
-
-               res = rtw_read32(padapter, i, &reg);
-               if (!res)
-                       pr_info(" 0x%08x ", reg);
-
-               if ((j++) % 4 == 0)
-                       pr_info("\n");
-       }
-       for (i = 0x400; i < 0x800; i += 4) {
-               if (j % 4 == 1)
-                       pr_info("0x%02x", i);
-
-               res = rtw_read32(padapter, i, &reg);
-               if (!res)
-                       pr_info(" 0x%08x ", reg);
-
-               if ((j++) % 4 == 0)
-                       pr_info("\n");
-       }
-}
-
-static void bb_reg_dump(struct adapter *padapter)
-{
-       int i, j = 1, res;
-       u32 reg;
-
-       pr_info("\n ======= BB REG =======\n");
-       for (i = 0x800; i < 0x1000; i += 4) {
-               if (j % 4 == 1)
-                       pr_info("0x%02x", i);
-
-               res = rtw_read32(padapter, i, &reg);
-               if (!res)
-                       pr_info(" 0x%08x ", reg);
-
-               if ((j++) % 4 == 0)
-                       pr_info("\n");
-       }
-}
-
-static void rf_reg_dump(struct adapter *padapter)
-{
-       int i, j = 1;
-       u32 value;
-
-       pr_info("\n ======= RF REG =======\n");
-       pr_info("\nRF_Path(%x)\n", RF_PATH_A);
-       for (i = 0; i < 0x100; i++) {
-               value = rtl8188e_PHY_QueryRFReg(padapter, i, 0xffffffff);
-               if (j % 4 == 1)
-                       pr_info("0x%02x ", i);
-               pr_info(" 0x%08x ", value);
-               if ((j++) % 4 == 0)
-                       pr_info("\n");
-       }
-}
-
-static void rtw_set_dynamic_functions(struct adapter *adapter, u8 dm_func)
-{
-       struct hal_data_8188e *haldata = &adapter->haldata;
-       struct odm_dm_struct *odmpriv = &haldata->odmpriv;
-       int res;
-
-       switch (dm_func) {
-       case 0:
-               /* disable all dynamic func */
-               odmpriv->SupportAbility = DYNAMIC_FUNC_DISABLE;
-               break;
-       case 1:
-               /* disable DIG */
-               odmpriv->SupportAbility &= (~DYNAMIC_BB_DIG);
-               break;
-       case 6:
-               /* turn on all dynamic func */
-               if (!(odmpriv->SupportAbility & DYNAMIC_BB_DIG)) {
-                       struct rtw_dig *digtable = &odmpriv->DM_DigTable;
-
-                       res = rtw_read8(adapter, 0xc50, &digtable->CurIGValue);
-                       (void)res;
-                       /* FIXME: return an error to caller */
-               }
-               odmpriv->SupportAbility = DYNAMIC_ALL_FUNC_ENABLE;
-               break;
-       default:
-               break;
-       }
-}
-
-static void rtw_set_dm_func_flag(struct adapter *adapter, u32 odm_flag)
-{
-       struct hal_data_8188e *haldata = &adapter->haldata;
-       struct odm_dm_struct *odmpriv = &haldata->odmpriv;
-
-       odmpriv->SupportAbility = odm_flag;
-}
-
-static int rtw_dbg_port(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-       u8 major_cmd, minor_cmd;
-       u16 arg;
-       s32 extra_arg;
-       u32 *pdata, val32;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct wlan_network *cur_network = &pmlmepriv->cur_network;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       pdata = (u32 *)&wrqu->data;
-
-       val32 = *pdata;
-       arg = (u16)(val32 & 0x0000ffff);
-       major_cmd = (u8)(val32 >> 24);
-       minor_cmd = (u8)((val32 >> 16) & 0x00ff);
-
-       extra_arg = *(pdata + 1);
-
-       switch (major_cmd) {
-       case 0x70:/* read_reg */
-               switch (minor_cmd) {
-               case 1:
-                       break;
-               case 2:
-                       break;
-               case 4:
-                       break;
-               }
-               break;
-       case 0x71:/* write_reg */
-               switch (minor_cmd) {
-               case 1:
-                       rtw_write8(padapter, arg, extra_arg);
-                       break;
-               case 2:
-                       rtw_write16(padapter, arg, extra_arg);
-                       break;
-               case 4:
-                       rtw_write32(padapter, arg, extra_arg);
-                       break;
-               }
-               break;
-       case 0x72:/* read_bb */
-               break;
-       case 0x73:/* write_bb */
-               rtl8188e_PHY_SetBBReg(padapter, arg, 0xffffffff, extra_arg);
-               break;
-       case 0x74:/* read_rf */
-               if (minor_cmd != RF_PATH_A) {
-                       ret = -EINVAL;
-                       break;
-               }
-               break;
-       case 0x75:/* write_rf */
-               if (minor_cmd != RF_PATH_A) {
-                       ret = -EINVAL;
-                       break;
-               }
-               rtl8188e_PHY_SetRFReg(padapter, arg, 0xffffffff, extra_arg);
-               break;
-
-       case 0x76:
-               switch (minor_cmd) {
-               case 0x00: /* normal mode, */
-                       padapter->recvpriv.is_signal_dbg = 0;
-                       break;
-               case 0x01: /* dbg mode */
-                       padapter->recvpriv.is_signal_dbg = 1;
-                       extra_arg = extra_arg > 100 ? 100 : extra_arg;
-                       extra_arg = extra_arg < 0 ? 0 : extra_arg;
-                       padapter->recvpriv.signal_strength_dbg = extra_arg;
-                       break;
-               }
-               break;
-       case 0x78: /* IOL test */
-               switch (minor_cmd) {
-               case 0x04: /* LLT table initialization test */
-               {
-                       struct xmit_frame       *xmit_frame;
-
-                       xmit_frame = rtw_IOL_accquire_xmit_frame(padapter);
-                       if (!xmit_frame) {
-                               ret = -ENOMEM;
-                               break;
-                       }
-
-                       if (rtl8188e_IOL_exec_cmds_sync(padapter, xmit_frame, 500, 0) != _SUCCESS)
-                               ret = -EPERM;
-               }
-                       break;
-               case 0x05: /* blink LED test */
-               {
-                       u16 reg = 0x4c;
-                       u32 blink_num = 50;
-                       u32 blink_delay_ms = 200;
-                       int i;
-                       struct xmit_frame       *xmit_frame;
-
-                       xmit_frame = rtw_IOL_accquire_xmit_frame(padapter);
-                       if (!xmit_frame) {
-                               ret = -ENOMEM;
-                               break;
-                       }
-
-                       for (i = 0; i < blink_num; i++) {
-                               rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x00, 0xff);
-                               rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms);
-                               rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x08, 0xff);
-                               rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms);
-                       }
-                       if (rtl8188e_IOL_exec_cmds_sync(padapter, xmit_frame, (blink_delay_ms * blink_num * 2) + 200, 0) != _SUCCESS)
-                               ret = -EPERM;
-               }
-                       break;
-
-               case 0x06: /* continuous write byte test */
-               {
-                       u16 reg = arg;
-                       u16 start_value = 0;
-                       u32 write_num = extra_arg;
-                       int i, res;
-                       struct xmit_frame       *xmit_frame;
-                       u8 val8;
-
-                       xmit_frame = rtw_IOL_accquire_xmit_frame(padapter);
-                       if (!xmit_frame) {
-                               ret = -ENOMEM;
-                               break;
-                       }
-
-                       for (i = 0; i < write_num; i++)
-                               rtw_IOL_append_WB_cmd(xmit_frame, reg, i + start_value, 0xFF);
-                       if (rtl8188e_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0) != _SUCCESS)
-                               ret = -EPERM;
-
-                       /* FIXME: is this read necessary? */
-                       res = rtw_read8(padapter, reg, &val8);
-                       (void)res;
-               }
-                       break;
-
-               case 0x07: /* continuous write word test */
-               {
-                       u16 reg = arg;
-                       u16 start_value = 200;
-                       u32 write_num = extra_arg;
-                       u16 val16;
-                       int i, res;
-                       struct xmit_frame       *xmit_frame;
-
-                       xmit_frame = rtw_IOL_accquire_xmit_frame(padapter);
-                       if (!xmit_frame) {
-                               ret = -ENOMEM;
-                               break;
-                       }
-
-                       for (i = 0; i < write_num; i++)
-                               rtw_IOL_append_WW_cmd(xmit_frame, reg, i + start_value, 0xFFFF);
-                       if (rtl8188e_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0) != _SUCCESS)
-                               ret = -EPERM;
-
-                       /* FIXME: is this read necessary? */
-                       res = rtw_read16(padapter, reg, &val16);
-                       (void)res;
-               }
-                       break;
-               case 0x08: /* continuous write dword test */
-               {
-                       u16 reg = arg;
-                       u32 start_value = 0x110000c7;
-                       u32 write_num = extra_arg;
-
-                       int i;
-                       struct xmit_frame       *xmit_frame;
-
-                       xmit_frame = rtw_IOL_accquire_xmit_frame(padapter);
-                       if (!xmit_frame) {
-                               ret = -ENOMEM;
-                               break;
-                       }
-
-                       for (i = 0; i < write_num; i++)
-                               rtw_IOL_append_WD_cmd(xmit_frame, reg, i + start_value, 0xFFFFFFFF);
-                       if (rtl8188e_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0) != _SUCCESS)
-                               ret = -EPERM;
-
-                       /* FIXME: is this read necessary? */
-                       ret = rtw_read32(padapter, reg, &write_num);
-               }
-                       break;
-               }
-               break;
-       case 0x79:
-               {
-                       /*
-                       * dbg 0x79000000 [value], set RESP_TXAGC to + value, value:0~15
-                       * dbg 0x79010000 [value], set RESP_TXAGC to - value, value:0~15
-                       */
-                       u8 value =  extra_arg & 0x0f;
-                       u8 sign = minor_cmd;
-                       u16 write_value = 0;
-
-                       if (sign)
-                               value = value | 0x10;
-
-                       write_value = value | (value << 5);
-                       rtw_write16(padapter, 0x6d9, write_value);
-               }
-               break;
-       case 0x7a:
-               receive_disconnect(padapter, pmlmeinfo->network.MacAddress
-                       , WLAN_REASON_EXPIRATION_CHK);
-               break;
-       case 0x7F:
-               switch (minor_cmd) {
-               case 0x0:
-                       break;
-               case 0x01:
-                       break;
-               case 0x02:
-                       break;
-               case 0x03:
-                       break;
-               case 0x04:
-                       break;
-               case 0x05:
-                       rtw_get_stainfo(pstapriv, cur_network->network.MacAddress);
-                       break;
-               case 0x06:
-                       {
-                               u32 ODMFlag = (u32)(0x0f & arg);
-                               rtw_set_dm_func_flag(padapter, ODMFlag);
-                       }
-                       break;
-               case 0x07:
-                       break;
-               case 0x08:
-                       break;
-               case 0x09:
-                       break;
-               case 0x15:
-                       break;
-               case 0x10:/*  driver version display */
-                       break;
-               case 0x11:
-                       padapter->bRxRSSIDisplay = extra_arg;
-                       break;
-               case 0x12: /* set rx_stbc */
-               {
-                       struct registry_priv    *pregpriv = &padapter->registrypriv;
-                       /*  0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */
-                       /* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */
-                       if (extra_arg == 0 ||
-                           extra_arg == 1 ||
-                           extra_arg == 2 ||
-                           extra_arg == 3)
-                               pregpriv->rx_stbc = extra_arg;
-               }
-                       break;
-               case 0x13: /* set ampdu_enable */
-               {
-                       struct registry_priv    *pregpriv = &padapter->registrypriv;
-                       /*  0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */
-                       if (extra_arg >= 0 && extra_arg < 3)
-                               pregpriv->ampdu_enable = extra_arg;
-               }
-                       break;
-               case 0x14: /* get wifi_spec */
-                       break;
-               case 0x23:
-                       padapter->bNotifyChannelChange = extra_arg;
-                       break;
-               case 0x24:
-                       padapter->bShowGetP2PState = extra_arg;
-                       break;
-               case 0xdd:/* registers dump, 0 for mac reg, 1 for bb reg, 2 for rf reg */
-                       if (extra_arg == 0)
-                               mac_reg_dump(padapter);
-                       else if (extra_arg == 1)
-                               bb_reg_dump(padapter);
-                       else if (extra_arg == 2)
-                               rf_reg_dump(padapter);
-                       break;
-               case 0xee:/* turn on/off dynamic funcs */
-                       if (extra_arg != 0xf) {
-                               /* extra_arg = 0  - disable all dynamic func
-                                * extra_arg = 1  - disable DIG
-                                * extra_arg = 6  - turn on all dynamic func
-                                */
-                               rtw_set_dynamic_functions(padapter, extra_arg);
-                       }
-                       break;
-               case 0xfd:
-                       rtw_write8(padapter, 0xc50, arg);
-                       rtw_write8(padapter, 0xc58, arg);
-                       break;
-               case 0xfe:
-                       break;
-               case 0xff:
-                       break;
-               }
-               break;
-       default:
-               break;
-       }
-       return ret;
-}
-
-static int rtw_wx_set_priv(struct net_device *dev,
-                               struct iw_request_info *info,
-                               union iwreq_data *awrq,
-                               char *extra)
-{
-       int ret = 0;
-       int len = 0;
-       char *ext;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct iw_point *dwrq = (struct iw_point *)awrq;
-
-       if (dwrq->length == 0)
-               return -EFAULT;
-
-       len = dwrq->length;
-       ext = vmalloc(len);
-       if (!ext)
-               return -ENOMEM;
-
-       if (copy_from_user(ext, dwrq->pointer, len)) {
-               vfree(ext);
-               return -EFAULT;
-       }
-
-       /* added for wps2.0 @20110524 */
-       if (dwrq->flags == 0x8766 && len > 8) {
-               u32 cp_sz;
-               struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-               u8 *probereq_wpsie = ext;
-               int probereq_wpsie_len = len;
-               u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
-
-               if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) &&
-                   (!memcmp(&probereq_wpsie[2], wps_oui, 4))) {
-                       cp_sz = min(probereq_wpsie_len, MAX_WPS_IE_LEN);
-
-                       pmlmepriv->wps_probe_req_ie_len = 0;
-                       kfree(pmlmepriv->wps_probe_req_ie);
-                       pmlmepriv->wps_probe_req_ie = NULL;
-
-                       pmlmepriv->wps_probe_req_ie = kmemdup(probereq_wpsie, cp_sz, GFP_KERNEL);
-                       if (!pmlmepriv->wps_probe_req_ie) {
-                               ret =  -EINVAL;
-                               goto FREE_EXT;
-                       }
-                       pmlmepriv->wps_probe_req_ie_len = cp_sz;
-               }
-               goto FREE_EXT;
-       }
-
-       if (len >= WEXT_CSCAN_HEADER_SIZE &&
-           !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) {
-               ret = rtw_wx_set_scan(dev, info, awrq, ext);
-               goto FREE_EXT;
-       }
-
-FREE_EXT:
-
-       vfree(ext);
-
-       return ret;
-}
-
-static int rtw_pm_set(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       int ret = 0;
-       unsigned        mode = 0;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-
-       if (!memcmp(extra, "lps =", 4)) {
-               sscanf(extra + 4, "%u", &mode);
-               ret = rtw_pm_set_lps(padapter, mode);
-       } else if (!memcmp(extra, "ips =", 4)) {
-               sscanf(extra + 4, "%u", &mode);
-               ret = rtw_pm_set_ips(padapter, mode);
-       } else {
-               ret = -EINVAL;
-       }
-
-       return ret;
-}
-
-static iw_handler rtw_handlers[] = {
-       IW_HANDLER(SIOCGIWNAME, rtw_wx_get_name),
-       IW_HANDLER(SIOCGIWFREQ, rtw_wx_get_freq),
-       IW_HANDLER(SIOCSIWMODE, rtw_wx_set_mode),
-       IW_HANDLER(SIOCGIWMODE, rtw_wx_get_mode),
-       IW_HANDLER(SIOCGIWSENS, rtw_wx_get_sens),
-       IW_HANDLER(SIOCGIWRANGE, rtw_wx_get_range),
-       IW_HANDLER(SIOCSIWPRIV, rtw_wx_set_priv),
-       IW_HANDLER(SIOCSIWAP, rtw_wx_set_wap),
-       IW_HANDLER(SIOCGIWAP, rtw_wx_get_wap),
-       IW_HANDLER(SIOCSIWMLME, rtw_wx_set_mlme),
-       IW_HANDLER(SIOCSIWSCAN, rtw_wx_set_scan),
-       IW_HANDLER(SIOCGIWSCAN, rtw_wx_get_scan),
-       IW_HANDLER(SIOCSIWESSID, rtw_wx_set_essid),
-       IW_HANDLER(SIOCGIWESSID, rtw_wx_get_essid),
-       IW_HANDLER(SIOCGIWNICKN, rtw_wx_get_nick),
-       IW_HANDLER(SIOCSIWRATE, rtw_wx_set_rate),
-       IW_HANDLER(SIOCGIWRATE, rtw_wx_get_rate),
-       IW_HANDLER(SIOCSIWRTS, rtw_wx_set_rts),
-       IW_HANDLER(SIOCGIWRTS, rtw_wx_get_rts),
-       IW_HANDLER(SIOCSIWFRAG, rtw_wx_set_frag),
-       IW_HANDLER(SIOCGIWFRAG, rtw_wx_get_frag),
-       IW_HANDLER(SIOCGIWRETRY, rtw_wx_get_retry),
-       IW_HANDLER(SIOCSIWENCODE, rtw_wx_set_enc),
-       IW_HANDLER(SIOCGIWENCODE, rtw_wx_get_enc),
-       IW_HANDLER(SIOCGIWPOWER, rtw_wx_get_power),
-       IW_HANDLER(SIOCSIWGENIE, rtw_wx_set_gen_ie),
-       IW_HANDLER(SIOCSIWAUTH, rtw_wx_set_auth),
-       IW_HANDLER(SIOCSIWENCODEEXT, rtw_wx_set_enc_ext),
-       IW_HANDLER(SIOCSIWPMKSA, rtw_wx_set_pmkid),
-};
-
-static const struct iw_priv_args rtw_private_args[] = {
-       {
-               SIOCIWFIRSTPRIV + 0x0,
-               IW_PRIV_TYPE_CHAR | 0x7FF, 0, "write"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0x1,
-               IW_PRIV_TYPE_CHAR | 0x7FF,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "read"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0x2, 0, 0, "driver_ext"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0x4,
-               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "apinfo"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0x5,
-               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setpid"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0x6,
-               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_start"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0xA,
-               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "channel_plan"
-       },
-
-       {
-               SIOCIWFIRSTPRIV + 0xB,
-               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "dbg"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0xC,
-               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "rfw"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0xD,
-               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "rfr"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0x10,
-               IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, 0, "p2p_set"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0x11,
-               IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "p2p_get"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0x12,
-               IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IFNAMSIZ, "p2p_get2"
-       },
-       {
-               SIOCIWFIRSTPRIV + 0x16,
-               IW_PRIV_TYPE_CHAR | 64, 0, "pm_set"
-       },
-
-       {SIOCIWFIRSTPRIV + 0x18, IW_PRIV_TYPE_CHAR | IFNAMSIZ, 0, "rereg_nd_name"},
-};
-
-static iw_handler rtw_private_handler[] = {
-       NULL,                           /* 0x00 */
-       NULL,                           /* 0x01 */
-       NULL,                           /* 0x02 */
-NULL,                                  /* 0x03 */
-/*  for MM DTV platform */
-       rtw_get_ap_info,                /* 0x04 */
-
-       rtw_set_pid,                    /* 0x05 */
-       rtw_wps_start,                  /* 0x06 */
-
-       NULL,                           /* 0x07 */
-       NULL,                           /* 0x08 */
-       NULL,                           /* 0x09 */
-
-/*  Set Channel depend on the country code */
-       rtw_wx_set_channel_plan,        /* 0x0A */
-
-       rtw_dbg_port,                   /* 0x0B */
-       rtw_wx_write_rf,                /* 0x0C */
-       rtw_wx_read_rf,                 /* 0x0D */
-       NULL,                           /* 0x0E */
-       NULL,                           /* 0x0F */
-
-       rtw_p2p_set,                    /* 0x10 */
-       NULL,                           /* 0x11 */
-       rtw_p2p_get2,                   /* 0x12 */
-
-       NULL,                           /* 0x13 */
-       NULL,                           /* 0x14 */
-       NULL,                           /* 0x15 */
-
-       rtw_pm_set,                     /* 0x16 */
-       NULL,                           /* 0x17 */
-       rtw_rereg_nd_name,              /* 0x18 */
-};
-
-static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
-       struct iw_statistics *piwstats = &padapter->iwstats;
-       int tmp_noise = 0;
-       int tmp;
-
-       if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
-               piwstats->qual.qual = 0;
-               piwstats->qual.level = 0;
-               piwstats->qual.noise = 0;
-       } else {
-               tmp_noise = padapter->recvpriv.noise;
-
-               piwstats->qual.level = padapter->signal_strength;
-               tmp = 219 + 3 * padapter->signal_strength;
-               tmp = min(100, tmp);
-               tmp = max(0, tmp);
-               piwstats->qual.qual = tmp;
-               piwstats->qual.noise = tmp_noise;
-       }
-       piwstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
-       return &padapter->iwstats;
-}
-
-struct iw_handler_def rtw_handlers_def = {
-       .standard = rtw_handlers,
-       .num_standard = ARRAY_SIZE(rtw_handlers),
-       .private = rtw_private_handler,
-       .private_args = (struct iw_priv_args *)rtw_private_args,
-       .num_private = ARRAY_SIZE(rtw_private_handler),
-       .num_private_args = ARRAY_SIZE(rtw_private_args),
-       .get_wireless_stats = rtw_get_wireless_stats,
-};
diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
deleted file mode 100644 (file)
index dc419fd..0000000
+++ /dev/null
@@ -1,807 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#define _OS_INTFS_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/hal_intf.h"
-#include "../include/rtw_ioctl.h"
-#include "../include/usb_osintf.h"
-#include "../include/rtw_br_ext.h"
-#include "../include/rtw_led.h"
-#include "../include/rtl8188e_dm.h"
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Realtek Wireless Lan Driver");
-MODULE_AUTHOR("Realtek Semiconductor Corp.");
-MODULE_FIRMWARE(FW_RTL8188EU);
-
-#define CONFIG_BR_EXT_BRNAME "br0"
-#define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */
-
-/* module param defaults */
-static int rtw_rfintfs = HWPI;
-static int rtw_lbkmode;/* RTL8712_AIR_TRX; */
-static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure; infra, ad-hoc, auto */
-static int rtw_channel = 1;/* ad-hoc support requirement */
-static int rtw_wireless_mode = WIRELESS_11BG_24N;
-static int rtw_vrtl_carrier_sense = AUTO_VCS;
-static int rtw_vcs_type = RTS_CTS;/*  */
-static int rtw_rts_thresh = 2347;/*  */
-static int rtw_frag_thresh = 2346;/*  */
-static int rtw_preamble = PREAMBLE_LONG;/* long, short, auto */
-static int rtw_scan_mode = 1;/* active, passive */
-static int rtw_adhoc_tx_pwr = 1;
-static int rtw_soft_ap;
-static int rtw_power_mgnt = 1;
-static int rtw_ips_mode = IPS_NORMAL;
-
-static int rtw_smart_ps = 2;
-
-module_param(rtw_ips_mode, int, 0644);
-MODULE_PARM_DESC(rtw_ips_mode, "The default IPS mode");
-
-static int rtw_radio_enable = 1;
-static int rtw_long_retry_lmt = 7;
-static int rtw_short_retry_lmt = 7;
-static int rtw_busy_thresh = 40;
-static int rtw_ack_policy = NORMAL_ACK;
-
-static int rtw_software_encrypt;
-static int rtw_software_decrypt;
-
-static int rtw_acm_method;/*  0:By SW 1:By HW. */
-
-static int rtw_wmm_enable = 1;/*  default is set to enable the wmm. */
-static int rtw_uapsd_enable;
-static int rtw_uapsd_max_sp = NO_LIMIT;
-static int rtw_uapsd_acbk_en;
-static int rtw_uapsd_acbe_en;
-static int rtw_uapsd_acvi_en;
-static int rtw_uapsd_acvo_en;
-
-static int rtw_led_enable = 1;
-
-static int rtw_ht_enable = 1;
-static int rtw_cbw40_enable = 3; /*  0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */
-static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */
-static int rtw_rx_stbc = 1;/*  0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */
-static int rtw_ampdu_amsdu;/*  0: disabled, 1:enabled, 2:auto */
-
-static int rtw_lowrate_two_xmit = 1;/* Use 2 path Tx to transmit MCS0~7 and legacy mode */
-
-static int rtw_low_power;
-static int rtw_wifi_spec;
-static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX;
-static int rtw_AcceptAddbaReq = true;/*  0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */
-
-static int rtw_antdiv_cfg = 2; /*  0:OFF , 1:ON, 2:decide by Efuse config */
-static int rtw_antdiv_type; /* 0:decide by efuse  1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2:  for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */
-
-
-static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */
-
-static int rtw_hwpwrp_detect; /* HW power  ping detect 0:disable , 1:enable */
-
-static int rtw_hw_wps_pbc = 1;
-
-int rtw_mc2u_disable;
-
-static int rtw_80211d;
-
-static char *ifname = "wlan%d";
-module_param(ifname, charp, 0644);
-MODULE_PARM_DESC(ifname, "The default name to allocate for first interface");
-
-static char *if2name = "wlan%d";
-module_param(if2name, charp, 0644);
-MODULE_PARM_DESC(if2name, "The default name to allocate for second interface");
-
-char *rtw_initmac;  /*  temp mac address if users want to use instead of the mac address in Efuse */
-
-module_param(rtw_initmac, charp, 0644);
-module_param(rtw_channel_plan, int, 0644);
-module_param(rtw_rfintfs, int, 0644);
-module_param(rtw_lbkmode, int, 0644);
-module_param(rtw_network_mode, int, 0644);
-module_param(rtw_channel, int, 0644);
-module_param(rtw_wmm_enable, int, 0644);
-module_param(rtw_vrtl_carrier_sense, int, 0644);
-module_param(rtw_vcs_type, int, 0644);
-module_param(rtw_busy_thresh, int, 0644);
-module_param(rtw_led_enable, int, 0644);
-module_param(rtw_ht_enable, int, 0644);
-module_param(rtw_cbw40_enable, int, 0644);
-module_param(rtw_ampdu_enable, int, 0644);
-module_param(rtw_rx_stbc, int, 0644);
-module_param(rtw_ampdu_amsdu, int, 0644);
-module_param(rtw_lowrate_two_xmit, int, 0644);
-module_param(rtw_power_mgnt, int, 0644);
-module_param(rtw_smart_ps, int, 0644);
-module_param(rtw_low_power, int, 0644);
-module_param(rtw_wifi_spec, int, 0644);
-module_param(rtw_antdiv_cfg, int, 0644);
-module_param(rtw_antdiv_type, int, 0644);
-module_param(rtw_hwpdn_mode, int, 0644);
-module_param(rtw_hwpwrp_detect, int, 0644);
-module_param(rtw_hw_wps_pbc, int, 0644);
-
-static uint rtw_max_roaming_times = 2;
-module_param(rtw_max_roaming_times, uint, 0644);
-MODULE_PARM_DESC(rtw_max_roaming_times, "The max roaming times to try");
-
-static int rtw_fw_iol = 1;/*  0:Disable, 1:enable, 2:by usb speed */
-module_param(rtw_fw_iol, int, 0644);
-MODULE_PARM_DESC(rtw_fw_iol, "FW IOL");
-
-module_param(rtw_mc2u_disable, int, 0644);
-
-module_param(rtw_80211d, int, 0644);
-MODULE_PARM_DESC(rtw_80211d, "Enable 802.11d mechanism");
-
-static uint rtw_notch_filter = RTW_NOTCH_FILTER;
-module_param(rtw_notch_filter, uint, 0644);
-MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P");
-
-static uint loadparam(struct adapter *padapter)
-{
-       struct registry_priv  *registry_par = &padapter->registrypriv;
-
-       registry_par->rfintfs = (u8)rtw_rfintfs;
-       registry_par->lbkmode = (u8)rtw_lbkmode;
-       registry_par->network_mode  = (u8)rtw_network_mode;
-
-       memcpy(registry_par->ssid.Ssid, "ANY", 3);
-       registry_par->ssid.SsidLength = 3;
-
-       registry_par->channel = (u8)rtw_channel;
-       registry_par->wireless_mode = (u8)rtw_wireless_mode;
-       registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense;
-       registry_par->vcs_type = (u8)rtw_vcs_type;
-       registry_par->rts_thresh = (u16)rtw_rts_thresh;
-       registry_par->frag_thresh = (u16)rtw_frag_thresh;
-       registry_par->preamble = (u8)rtw_preamble;
-       registry_par->scan_mode = (u8)rtw_scan_mode;
-       registry_par->adhoc_tx_pwr = (u8)rtw_adhoc_tx_pwr;
-       registry_par->soft_ap =  (u8)rtw_soft_ap;
-       registry_par->smart_ps =  (u8)rtw_smart_ps;
-       registry_par->power_mgnt = (u8)rtw_power_mgnt;
-       registry_par->ips_mode = (u8)rtw_ips_mode;
-       registry_par->radio_enable = (u8)rtw_radio_enable;
-       registry_par->long_retry_lmt = (u8)rtw_long_retry_lmt;
-       registry_par->short_retry_lmt = (u8)rtw_short_retry_lmt;
-       registry_par->busy_thresh = (u16)rtw_busy_thresh;
-       registry_par->ack_policy = (u8)rtw_ack_policy;
-       registry_par->software_encrypt = (u8)rtw_software_encrypt;
-       registry_par->software_decrypt = (u8)rtw_software_decrypt;
-       registry_par->acm_method = (u8)rtw_acm_method;
-
-        /* UAPSD */
-       registry_par->wmm_enable = (u8)rtw_wmm_enable;
-       registry_par->uapsd_enable = (u8)rtw_uapsd_enable;
-       registry_par->uapsd_max_sp = (u8)rtw_uapsd_max_sp;
-       registry_par->uapsd_acbk_en = (u8)rtw_uapsd_acbk_en;
-       registry_par->uapsd_acbe_en = (u8)rtw_uapsd_acbe_en;
-       registry_par->uapsd_acvi_en = (u8)rtw_uapsd_acvi_en;
-       registry_par->uapsd_acvo_en = (u8)rtw_uapsd_acvo_en;
-
-       registry_par->led_enable = (u8)rtw_led_enable;
-
-       registry_par->ht_enable = (u8)rtw_ht_enable;
-       registry_par->cbw40_enable = (u8)rtw_cbw40_enable;
-       registry_par->ampdu_enable = (u8)rtw_ampdu_enable;
-       registry_par->rx_stbc = (u8)rtw_rx_stbc;
-       registry_par->ampdu_amsdu = (u8)rtw_ampdu_amsdu;
-       registry_par->lowrate_two_xmit = (u8)rtw_lowrate_two_xmit;
-       registry_par->low_power = (u8)rtw_low_power;
-       registry_par->wifi_spec = (u8)rtw_wifi_spec;
-       registry_par->channel_plan = (u8)rtw_channel_plan;
-       registry_par->bAcceptAddbaReq = (u8)rtw_AcceptAddbaReq;
-       registry_par->antdiv_cfg = (u8)rtw_antdiv_cfg;
-       registry_par->antdiv_type = (u8)rtw_antdiv_type;
-       registry_par->hwpdn_mode = (u8)rtw_hwpdn_mode;/* 0:disable, 1:enable, 2:by EFUSE config */
-       registry_par->hwpwrp_detect = (u8)rtw_hwpwrp_detect;/* 0:disable, 1:enable */
-       registry_par->hw_wps_pbc = (u8)rtw_hw_wps_pbc;
-
-       registry_par->max_roaming_times = (u8)rtw_max_roaming_times;
-
-       registry_par->fw_iol = rtw_fw_iol;
-
-       registry_par->enable80211d = (u8)rtw_80211d;
-       snprintf(registry_par->ifname, 16, "%s", ifname);
-       snprintf(registry_par->if2name, 16, "%s", if2name);
-       registry_par->notch_filter = (u8)rtw_notch_filter;
-
-       return _SUCCESS;
-}
-
-static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
-       struct sockaddr *addr = p;
-
-       if (!padapter->bup)
-               memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN);
-
-       return 0;
-}
-
-static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct recv_priv *precvpriv = &padapter->recvpriv;
-
-       padapter->stats.tx_packets = pxmitpriv->tx_pkts;/* pxmitpriv->tx_pkts++; */
-       padapter->stats.rx_packets = precvpriv->rx_pkts;/* precvpriv->rx_pkts++; */
-       padapter->stats.tx_dropped = pxmitpriv->tx_drop;
-       padapter->stats.rx_dropped = precvpriv->rx_drop;
-       padapter->stats.tx_bytes = pxmitpriv->tx_bytes;
-       padapter->stats.rx_bytes = precvpriv->rx_bytes;
-       return &padapter->stats;
-}
-
-/*
- * AC to queue mapping
- *
- * AC_VO -> queue 0
- * AC_VI -> queue 1
- * AC_BE -> queue 2
- * AC_BK -> queue 3
- */
-static const u16 rtw_1d_to_queue[8] = { 2, 3, 3, 2, 1, 1, 0, 0 };
-
-/* Given a data frame determine the 802.1p/1d tag to use. */
-static unsigned int rtw_classify8021d(struct sk_buff *skb)
-{
-       unsigned int dscp;
-
-       /* skb->priority values from 256->263 are magic values to
-        * directly indicate a specific 802.1d priority.  This is used
-        * to allow 802.1d priority to be passed directly in from VLAN
-        * tags, etc.
-        */
-       if (skb->priority >= 256 && skb->priority <= 263)
-               return skb->priority - 256;
-
-       switch (skb->protocol) {
-       case htons(ETH_P_IP):
-               dscp = ip_hdr(skb)->tos & 0xfc;
-               break;
-       default:
-               return 0;
-       }
-
-       return dscp >> 5;
-}
-
-static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev)
-{
-       struct adapter  *padapter = rtw_netdev_priv(dev);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       skb->priority = rtw_classify8021d(skb);
-
-       if (pmlmepriv->acm_mask != 0)
-               skb->priority = qos_acm(pmlmepriv->acm_mask, skb->priority);
-
-       return rtw_1d_to_queue[skb->priority];
-}
-
-u16 rtw_recv_select_queue(struct sk_buff *skb)
-{
-       struct iphdr *piphdr;
-       unsigned int dscp;
-       __be16  eth_type;
-       u32 priority;
-       u8 *pdata = skb->data;
-
-       memcpy(&eth_type, pdata + (ETH_ALEN << 1), 2);
-
-       switch (eth_type) {
-       case htons(ETH_P_IP):
-               piphdr = (struct iphdr *)(pdata + ETH_HLEN);
-               dscp = piphdr->tos & 0xfc;
-               priority = dscp >> 5;
-               break;
-       default:
-               priority = 0;
-       }
-
-       return rtw_1d_to_queue[priority];
-}
-
-static const struct net_device_ops rtw_netdev_ops = {
-       .ndo_open = netdev_open,
-       .ndo_stop = netdev_close,
-       .ndo_start_xmit = rtw_xmit_entry,
-       .ndo_select_queue       = rtw_select_queue,
-       .ndo_set_mac_address = rtw_net_set_mac_address,
-       .ndo_get_stats = rtw_net_get_stats,
-};
-
-int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname)
-{
-       int err;
-
-       err = dev_alloc_name(pnetdev, ifname);
-       if (err < 0)
-               return err;
-
-       netif_carrier_off(pnetdev);
-       return 0;
-}
-
-static const struct device_type wlan_type = {
-       .name = "wlan",
-};
-
-struct net_device *rtw_init_netdev(struct adapter *old_padapter)
-{
-       struct adapter *padapter;
-       struct net_device *pnetdev;
-
-       if (old_padapter)
-               pnetdev = rtw_alloc_etherdev_with_old_priv(sizeof(struct adapter), (void *)old_padapter);
-       else
-               pnetdev = rtw_alloc_etherdev(sizeof(struct adapter));
-
-       if (!pnetdev)
-               return NULL;
-
-       pnetdev->dev.type = &wlan_type;
-       padapter = rtw_netdev_priv(pnetdev);
-       padapter->pnetdev = pnetdev;
-       pnetdev->netdev_ops = &rtw_netdev_ops;
-       pnetdev->watchdog_timeo = HZ * 3; /* 3 second timeout */
-       pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def;
-
-       /* step 2. */
-       loadparam(padapter);
-
-       return pnetdev;
-}
-
-int rtw_start_drv_threads(struct adapter *padapter)
-{
-       padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD");
-       if (IS_ERR(padapter->cmdThread))
-               return PTR_ERR(padapter->cmdThread);
-
-       /* wait for rtw_cmd_thread() to start running */
-       wait_for_completion(&padapter->cmdpriv.start_cmd_thread);
-
-       return 0;
-}
-
-void rtw_stop_drv_threads(struct adapter *padapter)
-{
-       /* Below is to termindate rtw_cmd_thread & event_thread... */
-       complete(&padapter->cmdpriv.enqueue_cmd);
-       if (padapter->cmdThread)
-               /* wait for rtw_cmd_thread() to stop running */
-               wait_for_completion(&padapter->cmdpriv.stop_cmd_thread);
-}
-
-static void rtw_init_default_value(struct adapter *padapter)
-{
-       struct registry_priv *pregistrypriv = &padapter->registrypriv;
-       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-
-       /* xmit_priv */
-       pxmitpriv->frag_len = pregistrypriv->frag_thresh;
-
-       /* mlme_priv */
-       pmlmepriv->scan_interval = SCAN_INTERVAL;/*  30*2 sec = 60sec */
-       pmlmepriv->scan_mode = SCAN_ACTIVE;
-
-       /* ht_priv */
-       pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */
-
-       /* security_priv */
-       psecuritypriv->binstallGrpkey = false;
-       psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt;
-       psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt;
-       psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
-       psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
-       psecuritypriv->dot11PrivacyKeyIndex = 0;
-       psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
-       psecuritypriv->dot118021XGrpKeyid = 1;
-       psecuritypriv->ndisauthtype = Ndis802_11AuthModeOpen;
-       psecuritypriv->ndisencryptstatus = Ndis802_11WEPDisabled;
-
-       /* registry_priv */
-       rtw_init_registrypriv_dev_network(padapter);
-       rtw_update_registrypriv_dev_network(padapter);
-
-       /* hal_priv */
-       rtl8188eu_init_default_value(padapter);
-
-       /* misc. */
-       padapter->bReadPortCancel = false;
-       padapter->bWritePortCancel = false;
-       padapter->bRxRSSIDisplay = 0;
-       padapter->bNotifyChannelChange = 0;
-       padapter->bShowGetP2PState = 1;
-}
-
-void rtw_reset_drv_sw(struct adapter *padapter)
-{
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       /* hal_priv */
-       rtl8188eu_init_default_value(padapter);
-       padapter->bReadPortCancel = false;
-       padapter->bWritePortCancel = false;
-       padapter->bRxRSSIDisplay = 0;
-       pmlmepriv->scan_interval = SCAN_INTERVAL;/*  30*2 sec = 60sec */
-
-       padapter->xmitpriv.tx_pkts = 0;
-       padapter->recvpriv.rx_pkts = 0;
-
-       pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
-
-       _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING);
-
-       /* mlmeextpriv */
-       padapter->mlmeextpriv.sitesurvey_res.state = SCAN_DISABLE;
-
-       rtw_set_signal_stat_timer(&padapter->recvpriv);
-}
-
-u8 rtw_init_drv_sw(struct adapter *padapter)
-{
-       if (rtw_init_cmd_priv(&padapter->cmdpriv)) {
-               dev_err(dvobj_to_dev(padapter->dvobj), "rtw_init_cmd_priv failed\n");
-               return _FAIL;
-       }
-
-       padapter->cmdpriv.padapter = padapter;
-
-       if (rtw_init_evt_priv(&padapter->evtpriv)) {
-               dev_err(dvobj_to_dev(padapter->dvobj), "rtw_init_evt_priv failed\n");
-               goto free_cmd_priv;
-       }
-
-       if (rtw_init_mlme_priv(padapter)) {
-               dev_err(dvobj_to_dev(padapter->dvobj), "rtw_init_mlme_priv failed\n");
-               goto free_evt_priv;
-       }
-
-       rtw_init_wifidirect_timers(padapter);
-       init_wifidirect_info(padapter, P2P_ROLE_DISABLE);
-       reset_global_wifidirect_info(padapter);
-
-       init_mlme_ext_priv(padapter);
-
-       if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter)) {
-               dev_err(dvobj_to_dev(padapter->dvobj), "_rtw_init_xmit_priv failed\n");
-               goto free_mlme_ext;
-       }
-
-       if (_rtw_init_recv_priv(&padapter->recvpriv, padapter)) {
-               dev_err(dvobj_to_dev(padapter->dvobj), "_rtw_init_recv_priv failed\n");
-               goto free_xmit_priv;
-       }
-
-       if (_rtw_init_sta_priv(&padapter->stapriv)) {
-               dev_err(dvobj_to_dev(padapter->dvobj), "_rtw_init_sta_priv failed\n");
-               goto free_recv_priv;
-       }
-
-       padapter->stapriv.padapter = padapter;
-
-       rtw_init_bcmc_stainfo(padapter);
-
-       rtw_init_pwrctrl_priv(padapter);
-
-       rtw_init_default_value(padapter);
-
-       rtl8188e_init_dm_priv(padapter);
-       rtl8188eu_InitSwLeds(padapter);
-
-       spin_lock_init(&padapter->br_ext_lock);
-
-       return _SUCCESS;
-
-free_recv_priv:
-       _rtw_free_recv_priv(&padapter->recvpriv);
-
-free_xmit_priv:
-       _rtw_free_xmit_priv(&padapter->xmitpriv);
-
-free_mlme_ext:
-       free_mlme_ext_priv(&padapter->mlmeextpriv);
-
-       rtw_free_mlme_priv(&padapter->mlmepriv);
-
-free_evt_priv:
-       rtw_free_evt_priv(&padapter->evtpriv);
-
-free_cmd_priv:
-       rtw_free_cmd_priv(&padapter->cmdpriv);
-
-       return _FAIL;
-}
-
-void rtw_cancel_all_timer(struct adapter *padapter)
-{
-       _cancel_timer_ex(&padapter->mlmepriv.assoc_timer);
-
-       _cancel_timer_ex(&padapter->mlmepriv.scan_to_timer);
-
-       _cancel_timer_ex(&padapter->mlmepriv.dynamic_chk_timer);
-
-       /*  cancel sw led timer */
-       rtl8188eu_DeInitSwLeds(padapter);
-
-       _cancel_timer_ex(&padapter->pwrctrlpriv.pwr_state_check_timer);
-
-       _cancel_timer_ex(&padapter->recvpriv.signal_stat_timer);
-}
-
-void rtw_free_drv_sw(struct adapter *padapter)
-{
-       /* we can call rtw_p2p_enable here, but: */
-       /*  1. rtw_p2p_enable may have IO operation */
-       /*  2. rtw_p2p_enable is bundled with wext interface */
-       {
-               struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-               if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-                       _cancel_timer_ex(&pwdinfo->find_phase_timer);
-                       _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer);
-                       _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer);
-                       rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE);
-               }
-       }
-
-       free_mlme_ext_priv(&padapter->mlmeextpriv);
-
-       rtw_free_cmd_priv(&padapter->cmdpriv);
-
-       rtw_free_evt_priv(&padapter->evtpriv);
-
-       rtw_free_mlme_priv(&padapter->mlmepriv);
-       _rtw_free_xmit_priv(&padapter->xmitpriv);
-
-       _rtw_free_sta_priv(&padapter->stapriv); /* will free bcmc_stainfo here */
-
-       _rtw_free_recv_priv(&padapter->recvpriv);
-
-       /* free the old_pnetdev */
-       if (padapter->rereg_nd_name_priv.old_pnetdev) {
-               free_netdev(padapter->rereg_nd_name_priv.old_pnetdev);
-               padapter->rereg_nd_name_priv.old_pnetdev = NULL;
-       }
-
-       /*  clear pbuddystruct adapter to avoid access wrong pointer. */
-       if (padapter->pbuddy_adapter)
-               padapter->pbuddy_adapter->pbuddy_adapter = NULL;
-}
-
-void netdev_br_init(struct net_device *netdev)
-{
-       struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev);
-
-       rcu_read_lock();
-
-       if (rcu_dereference(adapter->pnetdev->rx_handler_data)) {
-               struct net_device *br_netdev;
-               struct net *devnet = NULL;
-
-               devnet = dev_net(netdev);
-               br_netdev = dev_get_by_name(devnet, CONFIG_BR_EXT_BRNAME);
-               if (br_netdev) {
-                       memcpy(adapter->br_mac, br_netdev->dev_addr, ETH_ALEN);
-                       dev_put(br_netdev);
-               } else {
-                       pr_info("%s()-%d: dev_get_by_name(%s) failed!",
-                               __func__, __LINE__, CONFIG_BR_EXT_BRNAME);
-               }
-       }
-       adapter->ethBrExtInfo.addPPPoETag = 1;
-
-       rcu_read_unlock();
-}
-
-static int _netdev_open(struct net_device *pnetdev)
-{
-       uint status;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
-
-       if (!padapter->bup) {
-               padapter->bDriverStopped = false;
-               padapter->bSurpriseRemoved = false;
-
-               status = rtw_hal_init(padapter);
-               if (status == _FAIL)
-                       goto netdev_open_error;
-
-               netdev_dbg(pnetdev, "MAC Address = %pM\n", pnetdev->dev_addr);
-
-               if (rtw_start_drv_threads(padapter)) {
-                       pr_info("Initialize driver software resource Failed!\n");
-                       goto netdev_open_error;
-               }
-
-               if (init_hw_mlme_ext(padapter) == _FAIL) {
-                       pr_info("can't init mlme_ext_priv\n");
-                       goto netdev_open_error;
-               }
-               if (rtl8188eu_inirp_init(padapter))
-                       goto netdev_open_error;
-
-               rtw_led_control(padapter, LED_CTL_NO_LINK);
-
-               padapter->bup = true;
-       }
-       padapter->net_closed = false;
-
-       _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000);
-
-       padapter->pwrctrlpriv.bips_processing = false;
-       rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
-
-       if (!rtw_netif_queue_stopped(pnetdev))
-               netif_tx_start_all_queues(pnetdev);
-       else
-               netif_tx_wake_all_queues(pnetdev);
-
-       netdev_br_init(pnetdev);
-
-       return 0;
-
-netdev_open_error:
-       padapter->bup = false;
-       netif_carrier_off(pnetdev);
-       netif_tx_stop_all_queues(pnetdev);
-       return -1;
-}
-
-int netdev_open(struct net_device *pnetdev)
-{
-       int ret;
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
-
-       mutex_lock(padapter->hw_init_mutex);
-       ret = _netdev_open(pnetdev);
-       mutex_unlock(padapter->hw_init_mutex);
-       return ret;
-}
-
-static int  ips_netdrv_open(struct adapter *padapter)
-{
-       int status = _SUCCESS;
-       padapter->net_closed = false;
-
-       padapter->bDriverStopped = false;
-       padapter->bSurpriseRemoved = false;
-
-       status = rtw_hal_init(padapter);
-       if (status == _FAIL)
-               goto netdev_open_error;
-
-       if (rtl8188eu_inirp_init(padapter))
-               goto netdev_open_error;
-
-       rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
-       _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 5000);
-
-       return _SUCCESS;
-
-netdev_open_error:
-       return _FAIL;
-}
-
-int rtw_ips_pwr_up(struct adapter *padapter)
-{
-       int result;
-       rtw_reset_drv_sw(padapter);
-
-       result = ips_netdrv_open(padapter);
-
-       rtw_led_control(padapter, LED_CTL_NO_LINK);
-
-       return result;
-}
-
-void rtw_ips_pwr_down(struct adapter *padapter)
-{
-       padapter->net_closed = true;
-
-       rtw_led_control(padapter, LED_CTL_POWER_OFF);
-
-       rtw_ips_dev_unload(padapter);
-}
-
-static void rtw_fifo_cleanup(struct adapter *adapter)
-{
-       struct pwrctrl_priv *pwrpriv = &adapter->pwrctrlpriv;
-       u8 trycnt = 100;
-       int res;
-       u32 reg;
-
-       /* pause tx */
-       rtw_write8(adapter, REG_TXPAUSE, 0xff);
-
-       /* keep sn */
-       /* FIXME: return an error to caller */
-       res = rtw_read16(adapter, REG_NQOS_SEQ, &adapter->xmitpriv.nqos_ssn);
-       if (res)
-               return;
-
-       if (!pwrpriv->bkeepfwalive) {
-               /* RX DMA stop */
-               res = rtw_read32(adapter, REG_RXPKT_NUM, &reg);
-               if (res)
-                       return;
-
-               rtw_write32(adapter, REG_RXPKT_NUM,
-                           (reg | RW_RELEASE_EN));
-               do {
-                       res = rtw_read32(adapter, REG_RXPKT_NUM, &reg);
-                       if (res)
-                               continue;
-
-                       if (!(reg & RXDMA_IDLE))
-                               break;
-               } while (trycnt--);
-
-               /* RQPN Load 0 */
-               rtw_write16(adapter, REG_RQPN_NPQ, 0x0);
-               rtw_write32(adapter, REG_RQPN, 0x80000000);
-               mdelay(10);
-       }
-}
-
-void rtw_ips_dev_unload(struct adapter *padapter)
-{
-       rtw_fifo_cleanup(padapter);
-
-       rtw_read_port_cancel(padapter);
-       rtw_write_port_cancel(padapter);
-
-       /* s5. */
-       if (!padapter->bSurpriseRemoved)
-               rtw_hal_deinit(padapter);
-}
-
-int netdev_close(struct net_device *pnetdev)
-{
-       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
-       struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
-
-       padapter->net_closed = true;
-
-       if (padapter->pwrctrlpriv.rf_pwrstate == rf_on) {
-               /* s1. */
-               if (pnetdev) {
-                       if (!rtw_netif_queue_stopped(pnetdev))
-                               netif_tx_stop_all_queues(pnetdev);
-               }
-
-               /* s2. */
-               LeaveAllPowerSaveMode(padapter);
-               rtw_disassoc_cmd(padapter, 500, false);
-               /* s2-2.  indicate disconnect to os */
-               rtw_indicate_disconnect(padapter);
-               /* s2-3. */
-               rtw_free_assoc_resources(padapter, 1);
-               /* s2-4. */
-               rtw_free_network_queue(padapter, true);
-               /*  Close LED */
-               rtw_led_control(padapter, LED_CTL_POWER_OFF);
-       }
-
-       nat25_db_cleanup(padapter);
-
-       rtw_p2p_enable(padapter, P2P_ROLE_DISABLE);
-
-       kfree(dvobj->firmware.data);
-       dvobj->firmware.data = NULL;
-
-       return 0;
-}
diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c
deleted file mode 100644 (file)
index 88271f9..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _OSDEP_SERVICE_C_
-
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/rtw_ioctl_set.h"
-
-/*
-* Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE
-* @return: one of RTW_STATUS_CODE
-*/
-inline int RTW_STATUS_CODE(int error_code)
-{
-       if (error_code >= 0)
-               return _SUCCESS;
-       return _FAIL;
-}
-
-void *rtw_malloc2d(int h, int w, int size)
-{
-       int j;
-
-       void **a = kzalloc(h * sizeof(void *) + h * w * size, GFP_KERNEL);
-       if (!a)
-               return NULL;
-
-       for (j = 0; j < h; j++)
-               a[j] = ((char *)(a + h)) + j * w * size;
-
-       return a;
-}
-
-/*
-For the following list_xxx operations,
-caller must guarantee the atomic context.
-Otherwise, there will be racing condition.
-*/
-/*
-Caller must check if the list is empty before calling rtw_list_delete
-*/
-
-static const struct device_type wlan_type = {
-       .name = "wlan",
-};
-
-struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv,
-                                                   void *old_priv)
-{
-       struct net_device *pnetdev;
-       struct rtw_netdev_priv_indicator *pnpi;
-
-       pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4);
-       if (!pnetdev)
-               return NULL;
-
-       pnetdev->dev.type = &wlan_type;
-       pnpi = netdev_priv(pnetdev);
-       pnpi->priv = old_priv;
-       pnpi->sizeof_priv = sizeof_priv;
-
-       return pnetdev;
-}
-
-struct net_device *rtw_alloc_etherdev(int sizeof_priv)
-{
-       struct net_device *pnetdev;
-       struct rtw_netdev_priv_indicator *pnpi;
-
-       pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4);
-       if (!pnetdev)
-               return NULL;
-
-       pnpi = netdev_priv(pnetdev);
-
-       pnpi->priv = vzalloc(sizeof_priv);
-       if (!pnpi->priv) {
-               free_netdev(pnetdev);
-               return NULL;
-       }
-
-       pnpi->sizeof_priv = sizeof_priv;
-
-       return pnetdev;
-}
-
-void rtw_free_netdev(struct net_device *netdev)
-{
-       struct rtw_netdev_priv_indicator *pnpi;
-
-       pnpi = netdev_priv(netdev);
-
-       vfree(pnpi->priv);
-       free_netdev(netdev);
-}
-
-int rtw_change_ifname(struct adapter *padapter, const char *ifname)
-{
-       struct net_device *pnetdev;
-       struct net_device *cur_pnetdev;
-       struct rereg_nd_name_data *rereg_priv;
-       int ret;
-
-       if (!padapter)
-               goto error;
-
-       cur_pnetdev = padapter->pnetdev;
-       rereg_priv = &padapter->rereg_nd_name_priv;
-
-       /* free the old_pnetdev */
-       if (rereg_priv->old_pnetdev) {
-               free_netdev(rereg_priv->old_pnetdev);
-               rereg_priv->old_pnetdev = NULL;
-       }
-
-       if (!rtnl_is_locked())
-               unregister_netdev(cur_pnetdev);
-       else
-               unregister_netdevice(cur_pnetdev);
-
-       rereg_priv->old_pnetdev = cur_pnetdev;
-
-       pnetdev = rtw_init_netdev(padapter);
-       if (!pnetdev)  {
-               ret = -1;
-               goto error;
-       }
-
-       SET_NETDEV_DEV(pnetdev, dvobj_to_dev(adapter_to_dvobj(padapter)));
-
-       rtw_init_netdev_name(pnetdev, ifname);
-
-       eth_hw_addr_set(pnetdev, padapter->eeprompriv.mac_addr);
-
-       if (!rtnl_is_locked())
-               ret = register_netdev(pnetdev);
-       else
-               ret = register_netdevice(pnetdev);
-       if (ret != 0)
-               goto error;
-
-       return 0;
-error:
-       return -1;
-}
-
-void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len)
-{
-       u32 dup_len = 0;
-       u8 *ori = NULL;
-       u8 *dup = NULL;
-
-       if (!buf || !buf_len)
-               return;
-
-       if (!src || !src_len)
-               goto keep_ori;
-
-       /* duplicate src */
-       dup = kmalloc(src_len, GFP_ATOMIC);
-       if (dup) {
-               dup_len = src_len;
-               memcpy(dup, src, dup_len);
-       }
-
-keep_ori:
-       ori = *buf;
-
-       /* replace buf with dup */
-       *buf_len = 0;
-       *buf = dup;
-       *buf_len = dup_len;
-
-       /* free ori */
-       kfree(ori);
-}
-
-/**
- * rtw_cbuf_empty - test if cbuf is empty
- * @cbuf: pointer of struct rtw_cbuf
- *
- * Returns: true if cbuf is empty
- */
-inline bool rtw_cbuf_empty(struct rtw_cbuf *cbuf)
-{
-       return cbuf->write == cbuf->read;
-}
-
-/**
- * rtw_cbuf_pop - pop a pointer from cbuf
- * @cbuf: pointer of struct rtw_cbuf
- *
- * Lock free operation, be careful of the use scheme
- * Returns: pointer popped out
- */
-void *rtw_cbuf_pop(struct rtw_cbuf *cbuf)
-{
-       void *buf;
-       if (rtw_cbuf_empty(cbuf))
-               return NULL;
-
-       buf = cbuf->bufs[cbuf->read];
-       cbuf->read = (cbuf->read + 1) % cbuf->size;
-
-       return buf;
-}
-
-/**
- * rtw_cbuf_alloc - allocate a rtw_cbuf with given size and do initialization
- * @size: size of pointer
- *
- * Returns: pointer of srtuct rtw_cbuf, NULL for allocation failure
- */
-struct rtw_cbuf *rtw_cbuf_alloc(u32 size)
-{
-       struct rtw_cbuf *cbuf;
-
-       cbuf = kmalloc(struct_size(cbuf, bufs, size), GFP_KERNEL);
-
-       if (cbuf) {
-               cbuf->write = 0;
-               cbuf->read = 0;
-               cbuf->size = size;
-       }
-       return cbuf;
-}
diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
deleted file mode 100644 (file)
index 74a16d1..0000000
+++ /dev/null
@@ -1,445 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2011 Realtek Corporation. */
-
-#include <linux/usb.h>
-#include "../include/osdep_service.h"
-#include "../include/drv_types.h"
-#include "../include/hal_intf.h"
-#include "../include/osdep_intf.h"
-#include "../include/usb_ops.h"
-#include "../include/usb_osintf.h"
-#include "../include/rtw_ioctl.h"
-#include "../include/rtl8188e_hal.h"
-
-int ui_pid[3] = {0, 0, 0};
-
-static int rtw_suspend(struct usb_interface *intf, pm_message_t message);
-static int rtw_resume(struct usb_interface *intf);
-
-static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid);
-static void rtw_dev_remove(struct usb_interface *pusb_intf);
-
-#define USB_VENDER_ID_REALTEK          0x0bda
-
-/* DID_USB_v916_20130116 */
-static struct usb_device_id rtw_usb_id_tbl[] = {
-       /*=== Realtek demoboard ===*/
-       {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8179)}, /* 8188EUS */
-       {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */
-       {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill USB-N150 Nano */
-       /*=== Customer ID ===*/
-       /****** 8188EUS ********/
-       {USB_DEVICE(0x07B8, 0x8179)}, /* Abocom - Abocom */
-       {USB_DEVICE(0x0DF6, 0x0076)}, /* Sitecom N150 v2 */
-       {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
-       {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
-       {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */
-       {USB_DEVICE(0x2001, 0x331B)}, /* D-Link DWA-121 rev B1 */
-       {USB_DEVICE(0x056E, 0x4008)}, /* Elecom WDC-150SU2M */
-       {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */
-       {USB_DEVICE(0x2357, 0x0111)}, /* TP-Link TL-WN727N v5.21 */
-       {USB_DEVICE(0x2C4E, 0x0102)}, /* MERCUSYS MW150US v2 */
-       {USB_DEVICE(0x0B05, 0x18F0)}, /* ASUS USB-N10 Nano B1 */
-       {USB_DEVICE(0x7392, 0xb811)}, /* Edimax EW-7811Un V2 */
-       {}      /* Terminating entry */
-};
-
-MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl);
-
-struct rtw_usb_drv {
-       struct usb_driver usbdrv;
-       int drv_registered;
-       struct mutex hw_init_mutex;
-};
-
-static struct rtw_usb_drv rtl8188e_usb_drv = {
-       .usbdrv.name = KBUILD_MODNAME,
-       .usbdrv.probe = rtw_drv_init,
-       .usbdrv.disconnect = rtw_dev_remove,
-       .usbdrv.id_table = rtw_usb_id_tbl,
-       .usbdrv.suspend =  rtw_suspend,
-       .usbdrv.resume = rtw_resume,
-       .usbdrv.reset_resume   = rtw_resume,
-};
-
-static struct rtw_usb_drv *usb_drv = &rtl8188e_usb_drv;
-
-static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
-{
-       int     i;
-       u8      rt_num_in_pipes = 0;
-       struct dvobj_priv *pdvobjpriv;
-       struct usb_host_config          *phost_conf;
-       struct usb_config_descriptor    *pconf_desc;
-       struct usb_host_interface       *phost_iface;
-       struct usb_interface_descriptor *piface_desc;
-       struct usb_endpoint_descriptor  *pendp_desc;
-       struct usb_device       *pusbd;
-
-       pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL);
-       if (!pdvobjpriv)
-               goto err;
-
-       pdvobjpriv->pusbintf = usb_intf;
-       pusbd = interface_to_usbdev(usb_intf);
-       pdvobjpriv->pusbdev = pusbd;
-       usb_set_intfdata(usb_intf, pdvobjpriv);
-
-       pdvobjpriv->RtNumOutPipes = 0;
-
-       phost_conf = pusbd->actconfig;
-       pconf_desc = &phost_conf->desc;
-
-       phost_iface = &usb_intf->altsetting[0];
-       piface_desc = &phost_iface->desc;
-
-       pdvobjpriv->NumInterfaces = pconf_desc->bNumInterfaces;
-       pdvobjpriv->InterfaceNumber = piface_desc->bInterfaceNumber;
-
-       for (i = 0; i < piface_desc->bNumEndpoints; i++) {
-               int ep_num;
-               pendp_desc = &phost_iface->endpoint[i].desc;
-
-               ep_num = usb_endpoint_num(pendp_desc);
-
-               if (usb_endpoint_is_bulk_in(pendp_desc)) {
-                       pdvobjpriv->RtInPipe = ep_num;
-                       rt_num_in_pipes++;
-               } else if (usb_endpoint_is_bulk_out(pendp_desc)) {
-                       pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] =
-                               ep_num;
-                       pdvobjpriv->RtNumOutPipes++;
-               }
-       }
-
-       if (rt_num_in_pipes != 1)
-               goto err;
-
-       /* 3 misc */
-       rtw_reset_continual_urb_error(pdvobjpriv);
-
-       usb_get_dev(pusbd);
-       return pdvobjpriv;
-
-err:
-       kfree(pdvobjpriv);
-       return NULL;
-}
-
-static void usb_dvobj_deinit(struct usb_interface *usb_intf)
-{
-       struct dvobj_priv *dvobj = usb_get_intfdata(usb_intf);
-
-       usb_set_intfdata(usb_intf, NULL);
-       if (dvobj) {
-               /* Modify condition for 92DU DMDP 2010.11.18, by Thomas */
-               if ((dvobj->NumInterfaces != 2 &&
-                   dvobj->NumInterfaces != 3) ||
-           (dvobj->InterfaceNumber == 1)) {
-                       if (interface_to_usbdev(usb_intf)->state !=
-                           USB_STATE_NOTATTACHED)
-                               /* If we didn't unplug usb dongle and
-                                * remove/insert module, driver fails
-                                * on sitesurvey for the first time when
-                                * device is up . Reset usb port for sitesurvey
-                                * fail issue. */
-                               usb_reset_device(interface_to_usbdev(usb_intf));
-               }
-               kfree(dvobj);
-       }
-
-       usb_put_dev(interface_to_usbdev(usb_intf));
-
-}
-
-static void rtw_dev_unload(struct adapter *padapter)
-{
-       if (padapter->bup) {
-               padapter->bDriverStopped = true;
-               if (padapter->xmitpriv.ack_tx)
-                       rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_DRV_STOP);
-               /* s3. */
-               rtw_read_port_cancel(padapter);
-               rtw_write_port_cancel(padapter);
-
-               /* s4. */
-               rtw_stop_drv_threads(padapter);
-
-               /* s5. */
-               if (!padapter->bSurpriseRemoved) {
-                       rtw_hal_deinit(padapter);
-                       padapter->bSurpriseRemoved = true;
-               }
-
-               padapter->bup = false;
-       }
-}
-
-static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
-{
-       struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
-       struct adapter *padapter = dvobj->if1;
-       struct net_device *pnetdev = padapter->pnetdev;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-
-       if ((!padapter->bup) || (padapter->bDriverStopped) ||
-           (padapter->bSurpriseRemoved))
-               goto exit;
-
-       pwrpriv->bInSuspend = true;
-       rtw_cancel_all_timer(padapter);
-       LeaveAllPowerSaveMode(padapter);
-
-       mutex_lock(&pwrpriv->lock);
-       /* s1. */
-       if (pnetdev) {
-               netif_carrier_off(pnetdev);
-               netif_tx_stop_all_queues(pnetdev);
-       }
-
-       /* s2. */
-       rtw_disassoc_cmd(padapter, 0, false);
-
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) &&
-           check_fwstate(pmlmepriv, _FW_LINKED))
-               pmlmepriv->to_roaming = 1;
-       /* s2-2.  indicate disconnect to os */
-       rtw_indicate_disconnect(padapter);
-       /* s2-3. */
-       rtw_free_assoc_resources(padapter, 1);
-       /* s2-4. */
-       rtw_free_network_queue(padapter, true);
-
-       rtw_dev_unload(padapter);
-       mutex_unlock(&pwrpriv->lock);
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
-               rtw_indicate_scan_done(padapter);
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
-               rtw_indicate_disconnect(padapter);
-
-exit:
-               return 0;
-}
-
-static int rtw_resume(struct usb_interface *pusb_intf)
-{
-       struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
-       struct adapter *padapter = dvobj->if1;
-       struct net_device *pnetdev;
-       struct pwrctrl_priv *pwrpriv = NULL;
-       int ret = -1;
-
-       pnetdev = padapter->pnetdev;
-       pwrpriv = &padapter->pwrctrlpriv;
-
-       mutex_lock(&pwrpriv->lock);
-       rtw_reset_drv_sw(padapter);
-       if (pwrpriv)
-               pwrpriv->bkeepfwalive = false;
-
-       if (netdev_open(pnetdev) != 0) {
-               mutex_unlock(&pwrpriv->lock);
-               goto exit;
-       }
-
-       netif_device_attach(pnetdev);
-       netif_carrier_on(pnetdev);
-
-       mutex_unlock(&pwrpriv->lock);
-
-       if (padapter->pid[1] != 0)
-               rtw_signal_process(padapter->pid[1], SIGUSR2);
-
-       rtw_roaming(padapter, NULL);
-
-       ret = 0;
-exit:
-       if (pwrpriv)
-               pwrpriv->bInSuspend = false;
-
-       return ret;
-}
-
-/*
- * drv_init() - a device potentially for us
- *
- * notes: drv_init() is called when the bus driver has located
- * a card for us to support.
- *        We accept the new device by returning 0.
- */
-
-static int rtw_usb_if1_init(struct dvobj_priv *dvobj, struct usb_interface *pusb_intf)
-{
-       struct adapter *padapter = NULL;
-       struct net_device *pnetdev = NULL;
-       int ret;
-
-       padapter = vzalloc(sizeof(*padapter));
-       if (!padapter)
-               return -ENOMEM;
-
-       padapter->dvobj = dvobj;
-       dvobj->if1 = padapter;
-
-       padapter->bDriverStopped = true;
-
-       padapter->hw_init_mutex = &usb_drv->hw_init_mutex;
-
-       rtw_handle_dualmac(padapter, 1);
-
-       pnetdev = rtw_init_netdev(padapter);
-       if (!pnetdev) {
-               ret = -ENODEV;
-               goto handle_dualmac;
-       }
-       SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj));
-       padapter = rtw_netdev_priv(pnetdev);
-
-       /* step read_chip_version */
-       rtl8188e_read_chip_version(padapter);
-
-       /* step usb endpoint mapping */
-       ret = rtl8188eu_interface_configure(padapter);
-       if (ret)
-               goto handle_dualmac;
-
-       /* step read efuse/eeprom data and get mac_addr */
-       ret = ReadAdapterInfo8188EU(padapter);
-       if (ret)
-               goto handle_dualmac;
-
-       /* step 5. */
-       if (rtw_init_drv_sw(padapter) == _FAIL) {
-               ret = -ENODEV;
-               goto handle_dualmac;
-       }
-
-#ifdef CONFIG_PM
-       if (padapter->pwrctrlpriv.bSupportRemoteWakeup) {
-               dvobj->pusbdev->do_remote_wakeup = 1;
-               pusb_intf->needs_remote_wakeup = 1;
-               device_init_wakeup(&pusb_intf->dev, 1);
-       }
-#endif
-
-       /* 2012-07-11 Move here to prevent the 8723AS-VAU BT auto
-        * suspend influence */
-       usb_autopm_get_interface(pusb_intf);
-
-       /*  alloc dev name after read efuse. */
-       ret = rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname);
-       if (ret)
-               goto free_drv_sw;
-       rtw_macaddr_cfg(padapter->eeprompriv.mac_addr);
-       rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr,
-                                 padapter->eeprompriv.mac_addr);
-       eth_hw_addr_set(pnetdev, padapter->eeprompriv.mac_addr);
-
-       /* step 6. Tell the network stack we exist */
-       ret = register_netdev(pnetdev);
-       if (ret)
-               goto free_drv_sw;
-
-       return 0;
-
-free_drv_sw:
-       rtw_cancel_all_timer(padapter);
-       rtw_free_drv_sw(padapter);
-handle_dualmac:
-       rtw_handle_dualmac(padapter, 0);
-       if (pnetdev)
-               rtw_free_netdev(pnetdev);
-       else
-               vfree(padapter);
-
-       return ret;
-}
-
-static void rtw_usb_if1_deinit(struct adapter *if1)
-{
-       struct net_device *pnetdev = if1->pnetdev;
-       struct mlme_priv *pmlmepriv = &if1->mlmepriv;
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED))
-               rtw_disassoc_cmd(if1, 0, false);
-
-       free_mlme_ap_info(if1);
-
-       if (pnetdev) {
-               /* will call netdev_close() */
-               unregister_netdev(pnetdev);
-       }
-       rtw_cancel_all_timer(if1);
-
-       rtw_dev_unload(if1);
-       rtw_handle_dualmac(if1, 0);
-       rtw_free_drv_sw(if1);
-       if (pnetdev)
-               rtw_free_netdev(pnetdev);
-}
-
-static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
-{
-       struct dvobj_priv *dvobj;
-       int ret;
-
-       /* Initialize dvobj_priv */
-       dvobj = usb_dvobj_init(pusb_intf);
-       if (!dvobj)
-               return -ENODEV;
-
-       ret = rtw_usb_if1_init(dvobj, pusb_intf);
-       if (ret) {
-               usb_dvobj_deinit(pusb_intf);
-               return ret;
-       }
-
-       if (ui_pid[1] != 0)
-               rtw_signal_process(ui_pid[1], SIGUSR2);
-
-       return 0;
-}
-
-/*
- * dev_remove() - our device is being removed
-*/
-/* rmmod module & unplug(SurpriseRemoved) will call r871xu_dev_remove() => how to recognize both */
-static void rtw_dev_remove(struct usb_interface *pusb_intf)
-{
-       struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
-       struct adapter *padapter = dvobj->if1;
-
-       if (usb_drv->drv_registered)
-               padapter->bSurpriseRemoved = true;
-
-       rtw_pm_set_ips(padapter, IPS_NONE);
-       rtw_pm_set_lps(padapter, PS_MODE_ACTIVE);
-
-       LeaveAllPowerSaveMode(padapter);
-
-       rtw_usb_if1_deinit(padapter);
-
-       usb_dvobj_deinit(pusb_intf);
-}
-
-static int __init rtw_drv_entry(void)
-{
-       mutex_init(&usb_drv->hw_init_mutex);
-
-       usb_drv->drv_registered = true;
-       return usb_register(&usb_drv->usbdrv);
-}
-
-static void __exit rtw_drv_halt(void)
-{
-       usb_drv->drv_registered = false;
-       usb_deregister(&usb_drv->usbdrv);
-
-       mutex_destroy(&usb_drv->hw_init_mutex);
-}
-
-module_init(rtw_drv_entry);
-module_exit(rtw_drv_halt);
diff --git a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c
deleted file mode 100644 (file)
index ca09f7e..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2007 - 2012 Realtek Corporation. */
-
-#define _USB_OPS_LINUX_C_
-
-#include "../include/drv_types.h"
-#include "../include/rtl8188e_recv.h"
-
-static unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr)
-{
-       unsigned int pipe = 0, ep_num = 0;
-       struct usb_device *pusbd = pdvobj->pusbdev;
-
-       if (addr < HW_QUEUE_ENTRY) {
-               ep_num = pdvobj->Queue2Pipe[addr];
-               pipe = usb_sndbulkpipe(pusbd, ep_num);
-       }
-
-       return pipe;
-}
-
-void rtw_read_port_cancel(struct adapter *padapter)
-{
-       int i;
-       struct recv_buf *precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf;
-
-       padapter->bReadPortCancel = true;
-
-       for (i = 0; i < NR_RECVBUFF; i++) {
-               precvbuf->reuse = true;
-               usb_kill_urb(precvbuf->purb);
-               precvbuf++;
-       }
-}
-
-static void usb_write_port_complete(struct urb *purb)
-{
-       struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context;
-       struct adapter *padapter = pxmitbuf->padapter;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-
-       if (pxmitbuf->high_queue)
-               rtw_chk_hi_queue_cmd(padapter);
-
-       switch (purb->status) {
-       case 0:
-       case -EINPROGRESS:
-       case -ENOENT:
-       case -ECONNRESET:
-       case -EPIPE:
-       case -EPROTO:
-               break;
-       case -ESHUTDOWN:
-               padapter->bDriverStopped = true;
-               break;
-       default:
-               padapter->bSurpriseRemoved = true;
-               break;
-       }
-
-       rtw_sctx_done_err(&pxmitbuf->sctx,
-                         purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS);
-       rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
-       tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
-}
-
-u32 rtw_write_port(struct adapter *padapter, u32 addr, u32 cnt, u8 *wmem)
-{
-       unsigned long irqL;
-       unsigned int pipe;
-       int status;
-       u32 ret = _FAIL;
-       struct urb *purb = NULL;
-       struct dvobj_priv       *pdvobj = adapter_to_dvobj(padapter);
-       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
-       struct xmit_buf *pxmitbuf = (struct xmit_buf *)wmem;
-       struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data;
-       struct usb_device *pusbd = pdvobj->pusbdev;
-
-       if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
-               rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY);
-               goto exit;
-       }
-
-       spin_lock_irqsave(&pxmitpriv->lock, irqL);
-       pxmitbuf->high_queue = (addr == HIGH_QUEUE_INX);
-       spin_unlock_irqrestore(&pxmitpriv->lock, irqL);
-
-       purb    = pxmitbuf->pxmit_urb;
-
-       /* translate DMA FIFO addr to pipehandle */
-       pipe = ffaddr2pipehdl(pdvobj, addr);
-
-       usb_fill_bulk_urb(purb, pusbd, pipe,
-                         pxmitframe->buf_addr, /*  pxmitbuf->pbuf */
-                         cnt,
-                         usb_write_port_complete,
-                         pxmitbuf);/* context is pxmitbuf */
-
-       status = usb_submit_urb(purb, GFP_ATOMIC);
-       if (status) {
-               rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR);
-               if (status == -ENODEV)
-                       padapter->bDriverStopped = true;
-               goto exit;
-       }
-
-       ret = _SUCCESS;
-
-/*    We add the URB_ZERO_PACKET flag to urb so that the host will send the zero packet automatically. */
-
-exit:
-       if (ret != _SUCCESS)
-               rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
-
-       return ret;
-}
-
-void rtw_write_port_cancel(struct adapter *padapter)
-{
-       int i;
-       struct xmit_buf *pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmitbuf;
-
-       padapter->bWritePortCancel = true;
-
-       for (i = 0; i < NR_XMITBUFF; i++) {
-               usb_kill_urb(pxmitbuf->pxmit_urb);
-               pxmitbuf++;
-       }
-
-       pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmit_extbuf;
-       for (i = 0; i < NR_XMIT_EXTBUFF; i++) {
-               usb_kill_urb(pxmitbuf->pxmit_urb);
-               pxmitbuf++;
-       }
-}
index d8455b23e555441a071cbad3085aebda6b9ebed9..d8408acfc763f3199e73a84f25211da9d08706a9 100644 (file)
@@ -185,7 +185,6 @@ static void _rtl92e_dm_init_fsync(struct net_device *dev);
 static void _rtl92e_dm_deinit_fsync(struct net_device *dev);
 
 static void _rtl92e_dm_check_txrateandretrycount(struct net_device *dev);
-static  void _rtl92e_dm_check_ac_dc_power(struct net_device *dev);
 static void _rtl92e_dm_check_fsync(struct net_device *dev);
 static void _rtl92e_dm_check_rf_ctrl_gpio(void *data);
 static void _rtl92e_dm_fsync_timer_callback(struct timer_list *t);
@@ -236,8 +235,6 @@ void rtl92e_dm_watchdog(struct net_device *dev)
        if (priv->being_init_adapter)
                return;
 
-       _rtl92e_dm_check_ac_dc_power(dev);
-
        _rtl92e_dm_check_txrateandretrycount(dev);
        _rtl92e_dm_check_edca_turbo(dev);
 
@@ -255,26 +252,6 @@ void rtl92e_dm_watchdog(struct net_device *dev)
        _rtl92e_dm_cts_to_self(dev);
 }
 
-static void _rtl92e_dm_check_ac_dc_power(struct net_device *dev)
-{
-       struct r8192_priv *priv = rtllib_priv(dev);
-       static const char ac_dc_script[] = "/etc/acpi/wireless-rtl-ac-dc-power.sh";
-       char *argv[] = {(char *)ac_dc_script, DRV_NAME, NULL};
-       static char *envp[] = {"HOME=/",
-                       "TERM=linux",
-                       "PATH=/usr/bin:/bin",
-                        NULL};
-
-       if (priv->rst_progress == RESET_TYPE_SILENT)
-               return;
-       if (priv->rtllib->state != RTLLIB_LINKED)
-               return;
-       call_usermodehelper(ac_dc_script, argv, envp, UMH_WAIT_PROC);
-
-       return;
-};
-
-
 void rtl92e_init_adaptive_rate(struct net_device *dev)
 {
 
@@ -1660,10 +1637,6 @@ static void _rtl92e_dm_check_rf_ctrl_gpio(void *data)
        u8 tmp1byte;
        enum rt_rf_power_state rf_power_state_to_set;
        bool bActuallySet = false;
-       char *argv[3];
-       static const char RadioPowerPath[] = "/etc/acpi/events/RadioPower.sh";
-       static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin",
-                              NULL};
 
        bActuallySet = false;
 
@@ -1693,14 +1666,6 @@ static void _rtl92e_dm_check_rf_ctrl_gpio(void *data)
                mdelay(1000);
                priv->hw_rf_off_action = 1;
                rtl92e_set_rf_state(dev, rf_power_state_to_set, RF_CHANGE_BY_HW);
-               if (priv->hw_radio_off)
-                       argv[1] = "RFOFF";
-               else
-                       argv[1] = "RFON";
-
-               argv[0] = (char *)RadioPowerPath;
-               argv[2] = NULL;
-               call_usermodehelper(RadioPowerPath, argv, envp, UMH_WAIT_PROC);
        }
 }
 
index a68b7385846235faf11c79dd6930c8a86af95ed3..7587fa88852741bc1262691324ef43ed9aab3fbb 100644 (file)
@@ -107,13 +107,13 @@ struct security_priv {
 
        u32 dot118021XGrpPrivacy;       /*  This specify the privacy algthm. used for Grp key */
        u32 dot118021XGrpKeyid;         /*  key id used for Grp Key (tx key index) */
-       union Keytype   dot118021XGrpKey[BIP_MAX_KEYID];        /*  802.1x Group Key, for inx0 and inx1 */
-       union Keytype   dot118021XGrptxmickey[BIP_MAX_KEYID];
-       union Keytype   dot118021XGrprxmickey[BIP_MAX_KEYID];
+       union Keytype   dot118021XGrpKey[BIP_MAX_KEYID + 1];    /*  802.1x Group Key, for inx0 and inx1 */
+       union Keytype   dot118021XGrptxmickey[BIP_MAX_KEYID + 1];
+       union Keytype   dot118021XGrprxmickey[BIP_MAX_KEYID + 1];
        union pn48              dot11Grptxpn;                   /*  PN48 used for Grp Key xmit. */
        union pn48              dot11Grprxpn;                   /*  PN48 used for Grp Key recv. */
        u32 dot11wBIPKeyid;                                             /*  key id used for BIP Key (tx key index) */
-       union Keytype   dot11wBIPKey[6];                /*  BIP Key, for index4 and index5 */
+       union Keytype   dot11wBIPKey[BIP_MAX_KEYID + 1];        /*  BIP Key, for index4 and index5 */
        union pn48              dot11wBIPtxpn;                  /*  PN48 used for Grp Key xmit. */
        union pn48              dot11wBIPrxpn;                  /*  PN48 used for Grp Key recv. */
 
index 54004f846cf0fd25b940c40b169c08d54eebe24d..84a9f4dd8f95456e2abfec04674f146788b4647b 100644 (file)
@@ -350,7 +350,7 @@ int rtw_cfg80211_check_bss(struct adapter *padapter)
        bss = cfg80211_get_bss(padapter->rtw_wdev->wiphy, notify_channel,
                        pnetwork->mac_address, pnetwork->ssid.ssid,
                        pnetwork->ssid.ssid_length,
-                       WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
+                       IEEE80211_BSS_TYPE_ANY, IEEE80211_PRIVACY_ANY);
 
        cfg80211_put_bss(padapter->rtw_wdev->wiphy, bss);
 
@@ -711,6 +711,7 @@ exit:
 static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len)
 {
        int ret = 0;
+       u8 max_idx;
        u32 wep_key_idx, wep_key_len;
        struct adapter *padapter = rtw_netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -724,26 +725,29 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
                goto exit;
        }
 
-       if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-           param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-           param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
-               if (param->u.crypt.idx >= WEP_KEYS
-                       || param->u.crypt.idx >= BIP_MAX_KEYID) {
-                       ret = -EINVAL;
-                       goto exit;
-               }
-       } else {
-               {
+       if (param->sta_addr[0] != 0xff || param->sta_addr[1] != 0xff ||
+           param->sta_addr[2] != 0xff || param->sta_addr[3] != 0xff ||
+           param->sta_addr[4] != 0xff || param->sta_addr[5] != 0xff) {
                ret = -EINVAL;
                goto exit;
        }
+
+       if (strcmp(param->u.crypt.alg, "WEP") == 0)
+               max_idx = WEP_KEYS - 1;
+       else
+               max_idx = BIP_MAX_KEYID;
+
+       if (param->u.crypt.idx > max_idx) {
+               netdev_err(dev, "Error crypt.idx %d > %d\n", param->u.crypt.idx, max_idx);
+               ret = -EINVAL;
+               goto exit;
        }
 
        if (strcmp(param->u.crypt.alg, "WEP") == 0) {
                wep_key_idx = param->u.crypt.idx;
                wep_key_len = param->u.crypt.key_len;
 
-               if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0)) {
+               if (wep_key_len <= 0) {
                        ret = -EINVAL;
                        goto exit;
                }
@@ -1135,8 +1139,8 @@ void rtw_cfg80211_unlink_bss(struct adapter *padapter, struct wlan_network *pnet
 
        bss = cfg80211_get_bss(wiphy, NULL/*notify_channel*/,
                select_network->mac_address, select_network->ssid.ssid,
-               select_network->ssid.ssid_length, 0/*WLAN_CAPABILITY_ESS*/,
-               0/*WLAN_CAPABILITY_ESS*/);
+               select_network->ssid.ssid_length, IEEE80211_BSS_TYPE_ANY,
+               IEEE80211_PRIVACY_ANY);
 
        if (bss) {
                cfg80211_unlink_bss(wiphy, bss);
index 30374a820496e6a137f934f5d53d5e9ad8b41988..40a3157fb73597cfde38a0bb6ae84745155ce32d 100644 (file)
@@ -46,6 +46,7 @@ static int wpa_set_auth_algs(struct net_device *dev, u32 value)
 static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len)
 {
        int ret = 0;
+       u8 max_idx;
        u32 wep_key_idx, wep_key_len, wep_total_len;
        struct ndis_802_11_wep   *pwep = NULL;
        struct adapter *padapter = rtw_netdev_priv(dev);
@@ -60,19 +61,22 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
                goto exit;
        }
 
-       if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-           param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-           param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
-               if (param->u.crypt.idx >= WEP_KEYS ||
-                   param->u.crypt.idx >= BIP_MAX_KEYID) {
-                       ret = -EINVAL;
-                       goto exit;
-               }
-       } else {
-               {
-                       ret = -EINVAL;
-                       goto exit;
-               }
+       if (param->sta_addr[0] != 0xff || param->sta_addr[1] != 0xff ||
+           param->sta_addr[2] != 0xff || param->sta_addr[3] != 0xff ||
+           param->sta_addr[4] != 0xff || param->sta_addr[5] != 0xff) {
+               ret = -EINVAL;
+               goto exit;
+       }
+
+       if (strcmp(param->u.crypt.alg, "WEP") == 0)
+               max_idx = WEP_KEYS - 1;
+       else
+               max_idx = BIP_MAX_KEYID;
+
+       if (param->u.crypt.idx > max_idx) {
+               netdev_err(dev, "Error crypt.idx %d > %d\n", param->u.crypt.idx, max_idx);
+               ret = -EINVAL;
+               goto exit;
        }
 
        if (strcmp(param->u.crypt.alg, "WEP") == 0) {
@@ -84,9 +88,6 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
                wep_key_idx = param->u.crypt.idx;
                wep_key_len = param->u.crypt.key_len;
 
-               if (wep_key_idx > WEP_KEYS)
-                       return -EINVAL;
-
                if (wep_key_len > 0) {
                        wep_key_len = wep_key_len <= 5 ? 5 : 13;
                        wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, key_material);
index 2317fb077db0eb70e59b619d7ede6337b7bc919b..557516c642c3b037e8ffd04393c24b0b37e4a27e 100644 (file)
@@ -1262,18 +1262,20 @@ static struct iscsi_param *iscsi_check_key(
                return param;
 
        if (!(param->phase & phase)) {
-               pr_err("Key \"%s\" may not be negotiated during ",
-                               param->name);
+               char *phase_name;
+
                switch (phase) {
                case PHASE_SECURITY:
-                       pr_debug("Security phase.\n");
+                       phase_name = "Security";
                        break;
                case PHASE_OPERATIONAL:
-                       pr_debug("Operational phase.\n");
+                       phase_name = "Operational";
                        break;
                default:
-                       pr_debug("Unknown phase.\n");
+                       phase_name = "Unknown";
                }
+               pr_err("Key \"%s\" may not be negotiated during %s phase.\n",
+                               param->name, phase_name);
                return NULL;
        }
 
index 40725cbc6eb0cdcf1381ad71644085d00656bd5e..90526f46c9b1104d5d0f28c76cf5e500741ba75c 100644 (file)
@@ -166,7 +166,6 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp
        proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_THRES_0, _temp);
        proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 1);
 
-       thermal_zone_device_enable(tzd);
        pci_info->stored_thres = temp;
 
        return 0;
@@ -268,6 +267,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
                goto err_free_vectors;
        }
 
+       ret = thermal_zone_device_enable(pci_info->tzone);
+       if (ret)
+               goto err_free_vectors;
+
        return 0;
 
 err_free_vectors:
index 29c94be0915962b2184829be6d83418bc4fbcce6..abad091baeeaef273d3e923bd168f51a1f9435ac 100644 (file)
@@ -1666,9 +1666,9 @@ MODULE_ALIAS("spi:sc16is7xx");
 #endif
 
 #ifdef CONFIG_SERIAL_SC16IS7XX_I2C
-static int sc16is7xx_i2c_probe(struct i2c_client *i2c,
-                              const struct i2c_device_id *id)
+static int sc16is7xx_i2c_probe(struct i2c_client *i2c)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
        const struct sc16is7xx_devtype *devtype;
        struct regmap *regmap;
 
@@ -1709,7 +1709,7 @@ static struct i2c_driver sc16is7xx_i2c_uart_driver = {
                .name           = SC16IS7XX_NAME,
                .of_match_table = sc16is7xx_dt_ids,
        },
-       .probe          = sc16is7xx_i2c_probe,
+       .probe_new      = sc16is7xx_i2c_probe,
        .remove         = sc16is7xx_i2c_remove,
        .id_table       = sc16is7xx_i2c_id_table,
 };
index 172d25fef740d354a73f156acdbc37a1febb9b00..05eac965ee2759ccef20c3120727a5acb3fac94e 100644 (file)
@@ -10512,4 +10512,5 @@ module_exit(ufshcd_core_exit);
 MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>");
 MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
 MODULE_DESCRIPTION("Generic UFS host controller driver Core");
+MODULE_SOFTDEP("pre: governor_simpleondemand");
 MODULE_LICENSE("GPL");
index 34fc453f3eb1f23c39bebb6695e12641de95edf1..a02cd866e2f8a0940d1a036e2b3623815619c8f3 100644 (file)
@@ -1177,7 +1177,7 @@ static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba,
                        err = ufs_qcom_clk_scale_down_post_change(hba);
 
 
-               if (err || !dev_req_params) {
+               if (err) {
                        ufshcd_uic_hibern8_exit(hba);
                        return err;
                }
@@ -1451,8 +1451,8 @@ static int ufs_qcom_mcq_config_resource(struct ufs_hba *hba)
                if (IS_ERR(res->base)) {
                        dev_err(hba->dev, "Failed to map res %s, err=%d\n",
                                         res->name, (int)PTR_ERR(res->base));
-                       res->base = NULL;
                        ret = PTR_ERR(res->base);
+                       res->base = NULL;
                        return ret;
                }
        }
@@ -1466,7 +1466,7 @@ static int ufs_qcom_mcq_config_resource(struct ufs_hba *hba)
        /* Explicitly allocate MCQ resource from ufs_mem */
        res_mcq = devm_kzalloc(hba->dev, sizeof(*res_mcq), GFP_KERNEL);
        if (!res_mcq)
-               return ret;
+               return -ENOMEM;
 
        res_mcq->start = res_mem->start +
                         MCQ_SQATTR_OFFSET(hba->mcq_capabilities);
@@ -1478,7 +1478,7 @@ static int ufs_qcom_mcq_config_resource(struct ufs_hba *hba)
        if (ret) {
                dev_err(hba->dev, "Failed to insert MCQ resource, err=%d\n",
                        ret);
-               goto insert_res_err;
+               return ret;
        }
 
        res->base = devm_ioremap_resource(hba->dev, res_mcq);
@@ -1495,8 +1495,6 @@ out:
 ioremap_err:
        res->base = NULL;
        remove_resource(res_mcq);
-insert_res_err:
-       devm_kfree(hba->dev, res_mcq);
        return ret;
 }
 
index 62c44616d8a922637e92f89d79d0fd7f8a8858ea..3d8b51316bef0fad53d5607be7bec3fac9850e60 100644 (file)
@@ -442,8 +442,7 @@ static u8 ds2482_w1_set_pullup(void *data, int delay)
 }
 
 
-static int ds2482_probe(struct i2c_client *client,
-                       const struct i2c_device_id *id)
+static int ds2482_probe(struct i2c_client *client)
 {
        struct ds2482_data *data;
        int err = -ENODEV;
@@ -553,7 +552,7 @@ static struct i2c_driver ds2482_driver = {
        .driver = {
                .name   = "ds2482",
        },
-       .probe          = ds2482_probe,
+       .probe_new      = ds2482_probe,
        .remove         = ds2482_remove,
        .id_table       = ds2482_id,
 };
index d8b90f95b1575c31359ad16d9b9d70287a2b4164..726592868e9c5ced71af2a4ade91b965634de882 100644 (file)
@@ -287,7 +287,7 @@ static void btrfs_log_dev_io_error(struct bio *bio, struct btrfs_device *dev)
 
        if (btrfs_op(bio) == BTRFS_MAP_WRITE)
                btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS);
-       if (!(bio->bi_opf & REQ_RAHEAD))
+       else if (!(bio->bi_opf & REQ_RAHEAD))
                btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_READ_ERRS);
        if (bio->bi_opf & REQ_PREFLUSH)
                btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_FLUSH_ERRS);
index 5b10401d803b3d5dd563b271ec46ad33922d6c8a..0ef8b8926bfa7209a6e82145ee1c2b5f81b407c7 100644 (file)
@@ -558,14 +558,15 @@ u64 add_new_free_space(struct btrfs_block_group *block_group, u64 start, u64 end
 static int sample_block_group_extent_item(struct btrfs_caching_control *caching_ctl,
                                          struct btrfs_block_group *block_group,
                                          int index, int max_index,
-                                         struct btrfs_key *key)
+                                         struct btrfs_key *found_key)
 {
        struct btrfs_fs_info *fs_info = block_group->fs_info;
        struct btrfs_root *extent_root;
-       int ret = 0;
        u64 search_offset;
        u64 search_end = block_group->start + block_group->length;
        struct btrfs_path *path;
+       struct btrfs_key search_key;
+       int ret = 0;
 
        ASSERT(index >= 0);
        ASSERT(index <= max_index);
@@ -585,37 +586,24 @@ static int sample_block_group_extent_item(struct btrfs_caching_control *caching_
        path->reada = READA_FORWARD;
 
        search_offset = index * div_u64(block_group->length, max_index);
-       key->objectid = block_group->start + search_offset;
-       key->type = BTRFS_EXTENT_ITEM_KEY;
-       key->offset = 0;
+       search_key.objectid = block_group->start + search_offset;
+       search_key.type = BTRFS_EXTENT_ITEM_KEY;
+       search_key.offset = 0;
 
-       while (1) {
-               ret = btrfs_search_forward(extent_root, key, path, 0);
-               if (ret != 0)
-                       goto out;
+       btrfs_for_each_slot(extent_root, &search_key, found_key, path, ret) {
                /* Success; sampled an extent item in the block group */
-               if (key->type == BTRFS_EXTENT_ITEM_KEY &&
-                   key->objectid >= block_group->start &&
-                   key->objectid + key->offset <= search_end)
-                       goto out;
+               if (found_key->type == BTRFS_EXTENT_ITEM_KEY &&
+                   found_key->objectid >= block_group->start &&
+                   found_key->objectid + found_key->offset <= search_end)
+                       break;
 
                /* We can't possibly find a valid extent item anymore */
-               if (key->objectid >= search_end) {
+               if (found_key->objectid >= search_end) {
                        ret = 1;
                        break;
                }
-               if (key->type < BTRFS_EXTENT_ITEM_KEY)
-                       key->type = BTRFS_EXTENT_ITEM_KEY;
-               else
-                       key->objectid++;
-               btrfs_release_path(path);
-               up_read(&fs_info->commit_root_sem);
-               mutex_unlock(&caching_ctl->mutex);
-               cond_resched();
-               mutex_lock(&caching_ctl->mutex);
-               down_read(&fs_info->commit_root_sem);
        }
-out:
+
        lockdep_assert_held(&caching_ctl->mutex);
        lockdep_assert_held_read(&fs_info->commit_root_sem);
        btrfs_free_path(path);
@@ -659,6 +647,7 @@ out:
 static int load_block_group_size_class(struct btrfs_caching_control *caching_ctl,
                                       struct btrfs_block_group *block_group)
 {
+       struct btrfs_fs_info *fs_info = block_group->fs_info;
        struct btrfs_key key;
        int i;
        u64 min_size = block_group->length;
@@ -668,6 +657,8 @@ static int load_block_group_size_class(struct btrfs_caching_control *caching_ctl
        if (!btrfs_block_group_should_use_size_class(block_group))
                return 0;
 
+       lockdep_assert_held(&caching_ctl->mutex);
+       lockdep_assert_held_read(&fs_info->commit_root_sem);
        for (i = 0; i < 5; ++i) {
                ret = sample_block_group_extent_item(caching_ctl, block_group, i, 5, &key);
                if (ret < 0)
@@ -682,7 +673,6 @@ static int load_block_group_size_class(struct btrfs_caching_control *caching_ctl
                block_group->size_class = size_class;
                spin_unlock(&block_group->lock);
        }
-
 out:
        return ret;
 }
@@ -1836,7 +1826,8 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
 
                btrfs_info(fs_info,
                        "reclaiming chunk %llu with %llu%% used %llu%% unusable",
-                               bg->start, div_u64(bg->used * 100, bg->length),
+                               bg->start,
+                               div64_u64(bg->used * 100, bg->length),
                                div64_u64(zone_unusable * 100, bg->length));
                trace_btrfs_reclaim_block_group(bg);
                ret = btrfs_relocate_chunk(fs_info, bg->start);
@@ -2493,18 +2484,29 @@ static int insert_block_group_item(struct btrfs_trans_handle *trans,
        struct btrfs_block_group_item bgi;
        struct btrfs_root *root = btrfs_block_group_root(fs_info);
        struct btrfs_key key;
+       u64 old_commit_used;
+       int ret;
 
        spin_lock(&block_group->lock);
        btrfs_set_stack_block_group_used(&bgi, block_group->used);
        btrfs_set_stack_block_group_chunk_objectid(&bgi,
                                                   block_group->global_root_id);
        btrfs_set_stack_block_group_flags(&bgi, block_group->flags);
+       old_commit_used = block_group->commit_used;
+       block_group->commit_used = block_group->used;
        key.objectid = block_group->start;
        key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
        key.offset = block_group->length;
        spin_unlock(&block_group->lock);
 
-       return btrfs_insert_item(trans, root, &key, &bgi, sizeof(bgi));
+       ret = btrfs_insert_item(trans, root, &key, &bgi, sizeof(bgi));
+       if (ret < 0) {
+               spin_lock(&block_group->lock);
+               block_group->commit_used = old_commit_used;
+               spin_unlock(&block_group->lock);
+       }
+
+       return ret;
 }
 
 static int insert_dev_extent(struct btrfs_trans_handle *trans,
index 0095c6e4c3d1cebb3b4cf752b723daa2ad811d8e..6b457b010cbc4ae204bc211c521f389ad46ded4c 100644 (file)
@@ -1048,7 +1048,7 @@ again:
         * so there is only one iref. The case that several irefs are
         * in the same item doesn't exist.
         */
-       btrfs_del_item(trans, root, path);
+       ret = btrfs_del_item(trans, root, path);
 out:
        btrfs_release_delayed_iref(node);
        btrfs_release_path(path);
index be94030e1dfbf34a356326c4812206be711073f3..138afa955370bc6dd651cd7c2ada6388a6a2f7f9 100644 (file)
@@ -763,7 +763,13 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end,
                        goto next;
                }
 
+               flags = em->flags;
                clear_bit(EXTENT_FLAG_PINNED, &em->flags);
+               /*
+                * In case we split the extent map, we want to preserve the
+                * EXTENT_FLAG_LOGGING flag on our extent map, but we don't want
+                * it on the new extent maps.
+                */
                clear_bit(EXTENT_FLAG_LOGGING, &flags);
                modified = !list_empty(&em->list);
 
@@ -774,7 +780,6 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end,
                if (em->start >= start && em_end <= end)
                        goto remove_em;
 
-               flags = em->flags;
                gen = em->generation;
                compressed = test_bit(EXTENT_FLAG_COMPRESSED, &em->flags);
 
index 84626c8ad5bf55a97d1a5265436934c100bd8493..a0ef1a1784c79be72102a5146c1d016633e6b46c 100644 (file)
@@ -2859,6 +2859,7 @@ static long btrfs_ioctl_dev_info(struct btrfs_fs_info *fs_info,
        di_args->bytes_used = btrfs_device_get_bytes_used(dev);
        di_args->total_bytes = btrfs_device_get_total_bytes(dev);
        memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));
+       memcpy(di_args->fsid, dev->fs_devices->fsid, BTRFS_UUID_SIZE);
        if (dev->name)
                strscpy(di_args->path, btrfs_dev_name(dev), sizeof(di_args->path));
        else
index 8c5efa5813b3779552fcffbf23bcad2c0ed9e7b6..37fc58a7f27edf789143f9b97323f36f6cdb6138 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/bug.h>
+#include <linux/list.h>
 #include <crypto/hash.h>
 #include "messages.h"
 #include "ctree.h"
@@ -778,6 +779,45 @@ static ssize_t btrfs_chunk_size_store(struct kobject *kobj,
        return len;
 }
 
+static ssize_t btrfs_size_classes_show(struct kobject *kobj,
+                                      struct kobj_attribute *a, char *buf)
+{
+       struct btrfs_space_info *sinfo = to_space_info(kobj);
+       struct btrfs_block_group *bg;
+       u32 none = 0;
+       u32 small = 0;
+       u32 medium = 0;
+       u32 large = 0;
+
+       for (int i = 0; i < BTRFS_NR_RAID_TYPES; ++i) {
+               down_read(&sinfo->groups_sem);
+               list_for_each_entry(bg, &sinfo->block_groups[i], list) {
+                       if (!btrfs_block_group_should_use_size_class(bg))
+                               continue;
+                       switch (bg->size_class) {
+                       case BTRFS_BG_SZ_NONE:
+                               none++;
+                               break;
+                       case BTRFS_BG_SZ_SMALL:
+                               small++;
+                               break;
+                       case BTRFS_BG_SZ_MEDIUM:
+                               medium++;
+                               break;
+                       case BTRFS_BG_SZ_LARGE:
+                               large++;
+                               break;
+                       }
+               }
+               up_read(&sinfo->groups_sem);
+       }
+       return sysfs_emit(buf, "none %u\n"
+                              "small %u\n"
+                              "medium %u\n"
+                              "large %u\n",
+                              none, small, medium, large);
+}
+
 #ifdef CONFIG_BTRFS_DEBUG
 /*
  * Request chunk allocation with current chunk size.
@@ -835,6 +875,7 @@ SPACE_INFO_ATTR(bytes_zone_unusable);
 SPACE_INFO_ATTR(disk_used);
 SPACE_INFO_ATTR(disk_total);
 BTRFS_ATTR_RW(space_info, chunk_size, btrfs_chunk_size_show, btrfs_chunk_size_store);
+BTRFS_ATTR(space_info, size_classes, btrfs_size_classes_show);
 
 static ssize_t btrfs_sinfo_bg_reclaim_threshold_show(struct kobject *kobj,
                                                     struct kobj_attribute *a,
@@ -887,6 +928,7 @@ static struct attribute *space_info_attrs[] = {
        BTRFS_ATTR_PTR(space_info, disk_total),
        BTRFS_ATTR_PTR(space_info, bg_reclaim_threshold),
        BTRFS_ATTR_PTR(space_info, chunk_size),
+       BTRFS_ATTR_PTR(space_info, size_classes),
 #ifdef CONFIG_BTRFS_DEBUG
        BTRFS_ATTR_PTR(space_info, force_chunk_alloc),
 #endif
index e16545849ea7f3e6c49718479918e218b0e47411..c08c0f578bc694eb449e355fc60a80d553395b53 100644 (file)
@@ -376,7 +376,7 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
                if (bdev)
                        blksize_mask = bdev_logical_block_size(bdev) - 1;
                else
-                       blksize_mask = (1 << inode->i_blkbits) - 1;
+                       blksize_mask = i_blocksize(inode) - 1;
 
                if ((iocb->ki_pos | iov_iter_count(to) |
                     iov_iter_alignment(to)) & blksize_mask)
index 091fd5adf818f0026f67f70e323fe7b2a7531062..d38e19c112704c958cc7d4e618df5169ad4c3ed1 100644 (file)
@@ -47,7 +47,7 @@ void z_erofs_lzma_exit(void)
        }
 }
 
-int z_erofs_lzma_init(void)
+int __init z_erofs_lzma_init(void)
 {
        unsigned int i;
 
@@ -278,7 +278,7 @@ again:
                }
        }
        if (no < nrpages_out && strm->buf.out)
-               kunmap(rq->in[no]);
+               kunmap(rq->out[no]);
        if (ni < nrpages_in)
                kunmap(rq->in[ni]);
        /* 4. push back LZMA stream context to the global list */
index 3f3561d37d1b2469c70c2fa697a014cca9274dcb..1db018f8c2e89d459155fb8447f73ac558daa7b2 100644 (file)
@@ -486,7 +486,7 @@ static inline void *erofs_vm_map_ram(struct page **pages, unsigned int count)
 void *erofs_get_pcpubuf(unsigned int requiredpages);
 void erofs_put_pcpubuf(void *ptr);
 int erofs_pcpubuf_growsize(unsigned int nrpages);
-void erofs_pcpubuf_init(void);
+void __init erofs_pcpubuf_init(void);
 void erofs_pcpubuf_exit(void);
 
 int erofs_register_sysfs(struct super_block *sb);
@@ -545,7 +545,7 @@ static inline int z_erofs_fill_inode(struct inode *inode) { return -EOPNOTSUPP;
 #endif /* !CONFIG_EROFS_FS_ZIP */
 
 #ifdef CONFIG_EROFS_FS_ZIP_LZMA
-int z_erofs_lzma_init(void);
+int __init z_erofs_lzma_init(void);
 void z_erofs_lzma_exit(void);
 int z_erofs_load_lzma_config(struct super_block *sb,
                             struct erofs_super_block *dsb,
index a2efd833d1b6c32791c3ed380d5792361160fd05..c7a4b1d77069d9e7b749a08aec36988e7fa92d3f 100644 (file)
@@ -114,7 +114,7 @@ out:
        return ret;
 }
 
-void erofs_pcpubuf_init(void)
+void __init erofs_pcpubuf_init(void)
 {
        int cpu;
 
index 3247d2422beae75d71d95345287d78135e5bc50f..f1708c77a9912ec8f05adf194dde1c1e9e90573e 100644 (file)
@@ -1312,12 +1312,12 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
 
        if (!be->decompressed_pages)
                be->decompressed_pages =
-                       kcalloc(be->nr_pages, sizeof(struct page *),
-                               GFP_KERNEL | __GFP_NOFAIL);
+                       kvcalloc(be->nr_pages, sizeof(struct page *),
+                                GFP_KERNEL | __GFP_NOFAIL);
        if (!be->compressed_pages)
                be->compressed_pages =
-                       kcalloc(pclusterpages, sizeof(struct page *),
-                               GFP_KERNEL | __GFP_NOFAIL);
+                       kvcalloc(pclusterpages, sizeof(struct page *),
+                                GFP_KERNEL | __GFP_NOFAIL);
 
        z_erofs_parse_out_bvecs(be);
        err2 = z_erofs_parse_in_bvecs(be, &overlapped);
@@ -1365,7 +1365,7 @@ out:
        }
        if (be->compressed_pages < be->onstack_pages ||
            be->compressed_pages >= be->onstack_pages + Z_EROFS_ONSTACK_PAGES)
-               kfree(be->compressed_pages);
+               kvfree(be->compressed_pages);
        z_erofs_fill_other_copies(be, err);
 
        for (i = 0; i < be->nr_pages; ++i) {
@@ -1384,7 +1384,7 @@ out:
        }
 
        if (be->decompressed_pages != be->onstack_pages)
-               kfree(be->decompressed_pages);
+               kvfree(be->decompressed_pages);
 
        pcl->length = 0;
        pcl->partial = true;
index 8bf6d30518b64834de5e3c859825f3680efc675d..655da4d739cb68ea2e83cf2ed69e9ba1927bfc14 100644 (file)
@@ -757,9 +757,6 @@ int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map,
        err = z_erofs_do_map_blocks(inode, map, flags);
 out:
        trace_z_erofs_map_blocks_iter_exit(inode, map, flags, err);
-
-       /* aggressively BUG_ON iff CONFIG_EROFS_FS_DEBUG is on */
-       DBG_BUGON(err < 0 && err != -ENOMEM);
        return err;
 }
 
index 4eeb02d456a958b7f8809e7d884378a23d0e4c0b..08b29c289da4d15bc7ac8b3ed9c17fc8574c4bc2 100644 (file)
@@ -1387,7 +1387,7 @@ struct ext4_super_block {
        __le32  s_first_meta_bg;        /* First metablock block group */
        __le32  s_mkfs_time;            /* When the filesystem was created */
        __le32  s_jnl_blocks[17];       /* Backup of the journal inode */
-       /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
+       /* 64bit support valid if EXT4_FEATURE_INCOMPAT_64BIT */
 /*150*/        __le32  s_blocks_count_hi;      /* Blocks count */
        __le32  s_r_blocks_count_hi;    /* Reserved blocks count */
        __le32  s_free_blocks_count_hi; /* Free blocks count */
index 4493ef0c715e9d1a1e8166feefc0a532339f6dd0..cdf9bfe10137ff4804c49fc85a666478e9c937cd 100644 (file)
@@ -486,6 +486,8 @@ static int ext4_getfsmap_datadev(struct super_block *sb,
                keys[0].fmr_physical = bofs;
        if (keys[1].fmr_physical >= eofs)
                keys[1].fmr_physical = eofs - 1;
+       if (keys[1].fmr_physical < keys[0].fmr_physical)
+               return 0;
        start_fsb = keys[0].fmr_physical;
        end_fsb = keys[1].fmr_physical;
 
index 2b42ececa46d8fe5e0e621ee1845d7d3c2b4e39a..1602d74b5eeb35f0090afb0ec566ed5f00c21ecc 100644 (file)
@@ -159,7 +159,6 @@ int ext4_find_inline_data_nolock(struct inode *inode)
                                        (void *)ext4_raw_inode(&is.iloc));
                EXT4_I(inode)->i_inline_size = EXT4_MIN_INLINE_DATA_SIZE +
                                le32_to_cpu(is.s.here->e_value_size);
-               ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
        }
 out:
        brelse(is.iloc.bh);
index d251d705c2763ca82aea53e7f9ab41e8f743dbb0..bf0b7dea4900afed9d81496c47a7aa741a76c32b 100644 (file)
@@ -4797,8 +4797,13 @@ static inline int ext4_iget_extra_inode(struct inode *inode,
 
        if (EXT4_INODE_HAS_XATTR_SPACE(inode)  &&
            *magic == cpu_to_le32(EXT4_XATTR_MAGIC)) {
+               int err;
+
                ext4_set_inode_state(inode, EXT4_STATE_XATTR);
-               return ext4_find_inline_data_nolock(inode);
+               err = ext4_find_inline_data_nolock(inode);
+               if (!err && ext4_has_inline_data(inode))
+                       ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
+               return err;
        } else
                EXT4_I(inode)->i_inline_off = 0;
        return 0;
index 12435d61f09eff9d85e23907588d21fd3c0be734..f9a430152063238a8b18d24651a28556192f6ed7 100644 (file)
@@ -431,6 +431,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
                ei_bl->i_flags = 0;
                inode_set_iversion(inode_bl, 1);
                i_size_write(inode_bl, 0);
+               EXT4_I(inode_bl)->i_disksize = inode_bl->i_size;
                inode_bl->i_mode = S_IFREG;
                if (ext4_has_feature_extents(sb)) {
                        ext4_set_inode_flag(inode_bl, EXT4_INODE_EXTENTS);
index 94608b7df7e8a0fb01e656ec1616244d72744758..31e21de56432d194e1e95eaa5d326e32c0cbcdc2 100644 (file)
@@ -1595,11 +1595,10 @@ static struct buffer_head *__ext4_find_entry(struct inode *dir,
                int has_inline_data = 1;
                ret = ext4_find_inline_entry(dir, fname, res_dir,
                                             &has_inline_data);
-               if (has_inline_data) {
-                       if (inlined)
-                               *inlined = 1;
+               if (inlined)
+                       *inlined = has_inline_data;
+               if (has_inline_data)
                        goto cleanup_and_exit;
-               }
        }
 
        if ((namelen <= 2) && (name[0] == '.') &&
@@ -3646,7 +3645,8 @@ static void ext4_resetent(handle_t *handle, struct ext4_renament *ent,
         * so the old->de may no longer valid and need to find it again
         * before reset old inode info.
         */
-       old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL);
+       old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de,
+                                &old.inlined);
        if (IS_ERR(old.bh))
                retval = PTR_ERR(old.bh);
        if (!old.bh)
@@ -3813,9 +3813,20 @@ static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                        return retval;
        }
 
-       old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL);
-       if (IS_ERR(old.bh))
-               return PTR_ERR(old.bh);
+       /*
+        * We need to protect against old.inode directory getting converted
+        * from inline directory format into a normal one.
+        */
+       if (S_ISDIR(old.inode->i_mode))
+               inode_lock_nested(old.inode, I_MUTEX_NONDIR2);
+
+       old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de,
+                                &old.inlined);
+       if (IS_ERR(old.bh)) {
+               retval = PTR_ERR(old.bh);
+               goto unlock_moved_dir;
+       }
+
        /*
         *  Check for inode number is _not_ due to possible IO errors.
         *  We might rmdir the source, keep it as pwd of some process
@@ -3872,11 +3883,6 @@ static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                        if (new.dir != old.dir && EXT4_DIR_LINK_MAX(new.dir))
                                goto end_rename;
                }
-               /*
-                * We need to protect against old.inode directory getting
-                * converted from inline directory format into a normal one.
-                */
-               inode_lock_nested(old.inode, I_MUTEX_NONDIR2);
                retval = ext4_rename_dir_prepare(handle, &old);
                if (retval) {
                        inode_unlock(old.inode);
@@ -4013,12 +4019,15 @@ end_rename:
        } else {
                ext4_journal_stop(handle);
        }
-       if (old.dir_bh)
-               inode_unlock(old.inode);
 release_bh:
        brelse(old.dir_bh);
        brelse(old.bh);
        brelse(new.bh);
+
+unlock_moved_dir:
+       if (S_ISDIR(old.inode->i_mode))
+               inode_unlock(old.inode);
+
        return retval;
 }
 
index beaec6d81074a7e21c5ea3123700bd8332859a58..1e4db96a04e630b9a118d34580fa5c23c2db14a6 100644 (file)
@@ -409,7 +409,8 @@ static void io_submit_init_bio(struct ext4_io_submit *io,
 
 static void io_submit_add_bh(struct ext4_io_submit *io,
                             struct inode *inode,
-                            struct page *page,
+                            struct page *pagecache_page,
+                            struct page *bounce_page,
                             struct buffer_head *bh)
 {
        int ret;
@@ -421,10 +422,11 @@ submit_and_retry:
        }
        if (io->io_bio == NULL)
                io_submit_init_bio(io, bh);
-       ret = bio_add_page(io->io_bio, page, bh->b_size, bh_offset(bh));
+       ret = bio_add_page(io->io_bio, bounce_page ?: pagecache_page,
+                          bh->b_size, bh_offset(bh));
        if (ret != bh->b_size)
                goto submit_and_retry;
-       wbc_account_cgroup_owner(io->io_wbc, page, bh->b_size);
+       wbc_account_cgroup_owner(io->io_wbc, pagecache_page, bh->b_size);
        io->io_next_block++;
 }
 
@@ -561,8 +563,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
        do {
                if (!buffer_async_write(bh))
                        continue;
-               io_submit_add_bh(io, inode,
-                                bounce_page ? bounce_page : page, bh);
+               io_submit_add_bh(io, inode, page, bounce_page, bh);
        } while ((bh = bh->b_this_page) != head);
 unlock:
        unlock_page(page);
index 88f7b8a88c76b6d5d34d9740d58ffe26136dc5dd..f43e526112ae837498c918637f50d7e15a004a0a 100644 (file)
@@ -5726,6 +5726,28 @@ static struct inode *ext4_get_journal_inode(struct super_block *sb,
        return journal_inode;
 }
 
+static int ext4_journal_bmap(journal_t *journal, sector_t *block)
+{
+       struct ext4_map_blocks map;
+       int ret;
+
+       if (journal->j_inode == NULL)
+               return 0;
+
+       map.m_lblk = *block;
+       map.m_len = 1;
+       ret = ext4_map_blocks(NULL, journal->j_inode, &map, 0);
+       if (ret <= 0) {
+               ext4_msg(journal->j_inode->i_sb, KERN_CRIT,
+                        "journal bmap failed: block %llu ret %d\n",
+                        *block, ret);
+               jbd2_journal_abort(journal, ret ? ret : -EIO);
+               return ret;
+       }
+       *block = map.m_pblk;
+       return 0;
+}
+
 static journal_t *ext4_get_journal(struct super_block *sb,
                                   unsigned int journal_inum)
 {
@@ -5746,6 +5768,7 @@ static journal_t *ext4_get_journal(struct super_block *sb,
                return NULL;
        }
        journal->j_private = sb;
+       journal->j_bmap = ext4_journal_bmap;
        ext4_init_journal_params(sb, journal);
        return journal;
 }
@@ -5920,6 +5943,7 @@ static int ext4_load_journal(struct super_block *sb,
                err = jbd2_journal_wipe(journal, !really_read_only);
        if (!err) {
                char *save = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL);
+
                if (save)
                        memcpy(save, ((char *) es) +
                               EXT4_S_ERR_START, EXT4_S_ERR_LEN);
@@ -5928,6 +5952,14 @@ static int ext4_load_journal(struct super_block *sb,
                        memcpy(((char *) es) + EXT4_S_ERR_START,
                               save, EXT4_S_ERR_LEN);
                kfree(save);
+               es->s_state |= cpu_to_le16(EXT4_SB(sb)->s_mount_state &
+                                          EXT4_ERROR_FS);
+               /* Write out restored error information to the superblock */
+               if (!bdev_read_only(sb->s_bdev)) {
+                       int err2;
+                       err2 = ext4_commit_super(sb);
+                       err = err ? : err2;
+               }
        }
 
        if (err) {
@@ -6157,11 +6189,13 @@ static int ext4_clear_journal_err(struct super_block *sb,
                errstr = ext4_decode_error(sb, j_errno, nbuf);
                ext4_warning(sb, "Filesystem error recorded "
                             "from previous mount: %s", errstr);
-               ext4_warning(sb, "Marking fs in need of filesystem check.");
 
                EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
                es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
-               ext4_commit_super(sb);
+               j_errno = ext4_commit_super(sb);
+               if (j_errno)
+                       return j_errno;
+               ext4_warning(sb, "Marked fs in need of filesystem check.");
 
                jbd2_journal_clear_err(journal);
                jbd2_journal_update_sb_errno(journal);
index e2b8b3437c589734553eb6abf73066b7cc8f347d..12d6252e3e226dfdf5ee2f61512b23b213c1b503 100644 (file)
@@ -501,13 +501,13 @@ static const struct sysfs_ops ext4_attr_ops = {
        .store  = ext4_attr_store,
 };
 
-static struct kobj_type ext4_sb_ktype = {
+static const struct kobj_type ext4_sb_ktype = {
        .default_groups = ext4_groups,
        .sysfs_ops      = &ext4_attr_ops,
        .release        = ext4_sb_release,
 };
 
-static struct kobj_type ext4_feat_ktype = {
+static const struct kobj_type ext4_feat_ktype = {
        .default_groups = ext4_feat_groups,
        .sysfs_ops      = &ext4_attr_ops,
        .release        = ext4_feat_release,
index 62f2ec599218354caf9ea8ef4600cb59a200a0a8..767454d74cd696fbd20c4a0d925b645b893c70a6 100644 (file)
@@ -2852,6 +2852,9 @@ shift:
                        (void *)header, total_ino);
        EXT4_I(inode)->i_extra_isize = new_extra_isize;
 
+       if (ext4_has_inline_data(inode))
+               error = ext4_find_inline_data_nolock(inode);
+
 cleanup:
        if (error && (mnt_count != le16_to_cpu(sbi->s_es->s_mnt_count))) {
                ext4_warning(inode->i_sb, "Unable to expand inode %lu. Delete some EAs or run e2fsck.",
index c942c89ca4cda90b94eaf724a2dabd63853bb52e..7893ea161d77075ca0ab524d7c8021ab668c0978 100644 (file)
--- a/fs/file.c
+++ b/fs/file.c
@@ -642,6 +642,7 @@ static struct file *pick_file(struct files_struct *files, unsigned fd)
        if (fd >= fdt->max_fds)
                return NULL;
 
+       fd = array_index_nospec(fd, fdt->max_fds);
        file = fdt->fd[fd];
        if (file) {
                rcu_assign_pointer(fdt->fd[fd], NULL);
index e80c781731f82957b8ef0cea3ea3585915258200..8ae419152ff64f7b553c69ce7e8617a1d5d9fc24 100644 (file)
@@ -969,10 +969,13 @@ int jbd2_journal_bmap(journal_t *journal, unsigned long blocknr,
 {
        int err = 0;
        unsigned long long ret;
-       sector_t block = 0;
+       sector_t block = blocknr;
 
-       if (journal->j_inode) {
-               block = blocknr;
+       if (journal->j_bmap) {
+               err = journal->j_bmap(journal, &block);
+               if (err == 0)
+                       *retp = block;
+       } else if (journal->j_inode) {
                ret = bmap(journal->j_inode, &block);
 
                if (ret || !block) {
index 66b4eef09db57785b86c214e416660784081d1f7..df8b26a425248ac4aa87a4ef9772b9700b417209 100644 (file)
@@ -1863,9 +1863,10 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
                        void **priv)
 {
        struct inode *inode = file_inode(filp);
+       vfsuid_t vfsuid = i_uid_into_vfsuid(file_mnt_idmap(filp), inode);
        int error;
 
-       if ((!uid_eq(current_fsuid(), inode->i_uid)) && !capable(CAP_LEASE))
+       if ((!vfsuid_eq_kuid(vfsuid, current_fsuid())) && !capable(CAP_LEASE))
                return -EACCES;
        if (!S_ISREG(inode->i_mode))
                return -EINVAL;
@@ -2425,7 +2426,6 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 *flock)
                if (flock->l_pid != 0)
                        goto out;
 
-               cmd = F_GETLK64;
                fl->fl_flags |= FL_OFDLCK;
                fl->fl_owner = filp;
        }
index e7462b5e5f1e2bacd845896c9f7a5635ccf74be0..502e1b7742dbf604e8a30f502f34292fb38ed1cc 100644 (file)
@@ -1104,7 +1104,9 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
        since = READ_ONCE(file->f_wb_err);
        if (verf)
                nfsd_copy_write_verifier(verf, nn);
+       file_start_write(file);
        host_err = vfs_iter_write(file, &iter, &pos, flags);
+       file_end_write(file);
        if (host_err < 0) {
                nfsd_reset_write_verifier(nn);
                trace_nfsd_writeverf_reset(nn, rqstp, host_err);
index 2e76dbb81a8fc193a1d2124748fc652265e0a5e2..2c3dec2b6dfaf18477a0734bb08e6c0b79d5dcf2 100644 (file)
@@ -937,7 +937,6 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
        /*
         * Do the splice.
         */
-       ret = 0;
        bytes = 0;
        len = sd->total_len;
        flags = sd->flags;
index f7a9607c2b9578ce459dee3ebc87360ea834f327..2210e5eb1ea06e9b16b824c0662f976f919e8d05 100644 (file)
@@ -193,7 +193,7 @@ static int udf_adinicb_writepage(struct folio *folio,
        struct udf_inode_info *iinfo = UDF_I(inode);
 
        BUG_ON(!PageLocked(page));
-       memcpy_to_page(page, 0, iinfo->i_data + iinfo->i_lenEAttr,
+       memcpy_from_page(iinfo->i_data + iinfo->i_lenEAttr, page, 0,
                       i_size_read(inode));
        unlock_page(page);
        mark_inode_dirty(inode);
@@ -241,6 +241,15 @@ static int udf_read_folio(struct file *file, struct folio *folio)
 
 static void udf_readahead(struct readahead_control *rac)
 {
+       struct udf_inode_info *iinfo = UDF_I(rac->mapping->host);
+
+       /*
+        * No readahead needed for in-ICB files and udf_get_block() would get
+        * confused for such file anyway.
+        */
+       if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
+               return;
+
        mpage_readahead(rac, udf_get_block);
 }
 
@@ -407,6 +416,9 @@ static int udf_map_block(struct inode *inode, struct udf_map_rq *map)
        int err;
        struct udf_inode_info *iinfo = UDF_I(inode);
 
+       if (WARN_ON_ONCE(iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB))
+               return -EFSCORRUPTED;
+
        map->oflags = 0;
        if (!(map->iflags & UDF_MAP_CREATE)) {
                struct kernel_lb_addr eloc;
index 41734202796f4ccb1bbee62ce5ccef0991073a9d..2ef78aa1d3f608713d934a07055d8f93b9ed6fa7 100644 (file)
@@ -449,15 +449,17 @@ xfs_prepare_ioend(
 }
 
 /*
- * If the page has delalloc blocks on it, we need to punch them out before we
- * invalidate the page.  If we don't, we leave a stale delalloc mapping on the
- * inode that can trip up a later direct I/O read operation on the same region.
+ * If the folio has delalloc blocks on it, the caller is asking us to punch them
+ * out. If we don't, we can leave a stale delalloc mapping covered by a clean
+ * page that needs to be dirtied again before the delalloc mapping can be
+ * converted. This stale delalloc mapping can trip up a later direct I/O read
+ * operation on the same region.
  *
- * We prevent this by truncating away the delalloc regions on the page.  Because
+ * We prevent this by truncating away the delalloc regions on the folio. Because
  * they are delalloc, we can do this without needing a transaction. Indeed - if
  * we get ENOSPC errors, we have to be able to do this truncation without a
- * transaction as there is no space left for block reservation (typically why we
- * see a ENOSPC in writeback).
+ * transaction as there is no space left for block reservation (typically why
+ * we see a ENOSPC in writeback).
  */
 static void
 xfs_discard_folio(
@@ -475,8 +477,13 @@ xfs_discard_folio(
                "page discard on page "PTR_FMT", inode 0x%llx, pos %llu.",
                        folio, ip->i_ino, pos);
 
+       /*
+        * The end of the punch range is always the offset of the the first
+        * byte of the next folio. Hence the end offset is only dependent on the
+        * folio itself and not the start offset that is passed in.
+        */
        error = xfs_bmap_punch_delalloc_range(ip, pos,
-                       round_up(pos, folio_size(folio)));
+                               folio_pos(folio) + folio_size(folio));
 
        if (error && !xfs_is_shutdown(mp))
                xfs_alert(mp, "page discard unable to remove delalloc mapping.");
index 7dc0db7f5a761ca23bc7f99ccaed243482ea2918..6abcc34fafd8c2e807784908be3004c7e58ffda4 100644 (file)
@@ -1321,15 +1321,14 @@ xfs_qm_quotacheck(
 
        error = xfs_iwalk_threaded(mp, 0, 0, xfs_qm_dqusage_adjust, 0, true,
                        NULL);
-       if (error) {
-               /*
-                * The inode walk may have partially populated the dquot
-                * caches.  We must purge them before disabling quota and
-                * tearing down the quotainfo, or else the dquots will leak.
-                */
-               xfs_qm_dqpurge_all(mp);
-               goto error_return;
-       }
+
+       /*
+        * On error, the inode walk may have partially populated the dquot
+        * caches.  We must purge them before disabling quota and tearing down
+        * the quotainfo, or else the dquots will leak.
+        */
+       if (error)
+               goto error_purge;
 
        /*
         * We've made all the changes that we need to make incore.  Flush them
@@ -1363,10 +1362,8 @@ xfs_qm_quotacheck(
         * and turn quotaoff. The dquots won't be attached to any of the inodes
         * at this point (because we intentionally didn't in dqget_noattach).
         */
-       if (error) {
-               xfs_qm_dqpurge_all(mp);
-               goto error_return;
-       }
+       if (error)
+               goto error_purge;
 
        /*
         * If one type of quotas is off, then it will lose its
@@ -1376,7 +1373,7 @@ xfs_qm_quotacheck(
        mp->m_qflags &= ~XFS_ALL_QUOTA_CHKD;
        mp->m_qflags |= flags;
 
- error_return:
+error_return:
        xfs_buf_delwri_cancel(&buffer_list);
 
        if (error) {
@@ -1395,6 +1392,21 @@ xfs_qm_quotacheck(
        } else
                xfs_notice(mp, "Quotacheck: Done.");
        return error;
+
+error_purge:
+       /*
+        * On error, we may have inodes queued for inactivation. This may try
+        * to attach dquots to the inode before running cleanup operations on
+        * the inode and this can race with the xfs_qm_destroy_quotainfo() call
+        * below that frees mp->m_quotainfo. To avoid this race, flush all the
+        * pending inodegc operations before we purge the dquots from memory,
+        * ensuring that background inactivation is idle whilst we turn off
+        * quotas.
+        */
+       xfs_inodegc_flush(mp);
+       xfs_qm_dqpurge_all(mp);
+       goto error_return;
+
 }
 
 /*
index d8b0db2f7a7d1c2276388e0512b776afe1044618..e149eee6158815684990904a8ea518f44e6a62b4 100644 (file)
@@ -57,8 +57,6 @@
 #define ASPEED_CLK_GATE_I3C3CLK                40
 #define ASPEED_CLK_GATE_I3C4CLK                41
 #define ASPEED_CLK_GATE_I3C5CLK                42
-#define ASPEED_CLK_GATE_I3C6CLK                43
-#define ASPEED_CLK_GATE_I3C7CLK                44
 
 #define ASPEED_CLK_GATE_FSICLK         45
 
@@ -87,8 +85,9 @@
 #define ASPEED_CLK_MAC2RCLK            68
 #define ASPEED_CLK_MAC3RCLK            69
 #define ASPEED_CLK_MAC4RCLK            70
+#define ASPEED_CLK_I3C                 71
 
-/* Only list resets here that are not part of a gate */
+/* Only list resets here that are not part of a clock gate + reset pair */
 #define ASPEED_RESET_ADC               55
 #define ASPEED_RESET_JTAG_MASTER2      54
 #define ASPEED_RESET_I3C_DMA           39
index da23e691d359b7d433ea1c11ee96d69e97793d58..dea8adc8510e70051e9be11346df480c1a53850f 100644 (file)
 #define BCM63268_CLK_TBUS      27
 #define BCM63268_CLK_ROBOSW250 31
 
+#define BCM63268_TCLK_EPHY1            0
+#define BCM63268_TCLK_EPHY2            1
+#define BCM63268_TCLK_EPHY3            2
+#define BCM63268_TCLK_GPHY1            3
+#define BCM63268_TCLK_DSL              4
+#define BCM63268_TCLK_WAKEON_EPHY      6
+#define BCM63268_TCLK_WAKEON_DSL       7
+#define BCM63268_TCLK_FAP1             11
+#define BCM63268_TCLK_FAP2             15
+#define BCM63268_TCLK_UTO_50           16
+#define BCM63268_TCLK_UTO_EXTIN                17
+#define BCM63268_TCLK_USB_REF          18
+
 #endif /* __DT_BINDINGS_CLOCK_BCM63268_H */
index 88d5289883d38361a1250d0856e035705134a890..afacba338c9123b196c2f907f4f70d07abab9d3a 100644 (file)
 #define CLK_DOUT_MFCMSCL_M2M           73
 #define CLK_DOUT_MFCMSCL_MCSC          74
 #define CLK_DOUT_MFCMSCL_JPEG          75
-#define TOP_NR_CLK                     76
+#define CLK_MOUT_G3D_SWITCH            76
+#define CLK_GOUT_G3D_SWITCH            77
+#define CLK_DOUT_G3D_SWITCH            78
+#define TOP_NR_CLK                     79
 
 /* CMU_APM */
 #define CLK_RCO_I3C_PMIC               1
 #define IOCLK_AUDIOCDCLK5              58
 #define IOCLK_AUDIOCDCLK6              59
 #define TICK_USB                       60
-#define AUD_NR_CLK                     61
+#define CLK_GOUT_AUD_CMU_AUD_PCLK      61
+#define AUD_NR_CLK                     62
 
 /* CMU_CMGP */
 #define CLK_RCO_CMGP                   1
 #define CLK_GOUT_SYSREG_CMGP_PCLK      15
 #define CMGP_NR_CLK                    16
 
+/* CMU_G3D */
+#define CLK_FOUT_G3D_PLL               1
+#define CLK_MOUT_G3D_PLL               2
+#define CLK_MOUT_G3D_SWITCH_USER       3
+#define CLK_MOUT_G3D_BUSD              4
+#define CLK_DOUT_G3D_BUSP              5
+#define CLK_GOUT_G3D_CMU_G3D_PCLK      6
+#define CLK_GOUT_G3D_GPU_CLK           7
+#define CLK_GOUT_G3D_TZPC_PCLK         8
+#define CLK_GOUT_G3D_GRAY2BIN_CLK      9
+#define CLK_GOUT_G3D_BUSD_CLK          10
+#define CLK_GOUT_G3D_BUSP_CLK          11
+#define CLK_GOUT_G3D_SYSREG_PCLK       12
+#define G3D_NR_CLK                     13
+
 /* CMU_HSI */
 #define CLK_MOUT_HSI_BUS_USER          1
 #define CLK_MOUT_HSI_MMC_CARD_USER     2
 #define CLK_GOUT_MMC_CARD_ACLK         11
 #define CLK_GOUT_MMC_CARD_SDCLKIN      12
 #define CLK_GOUT_SYSREG_HSI_PCLK       13
-#define HSI_NR_CLK                     14
+#define CLK_GOUT_HSI_PPMU_ACLK         14
+#define CLK_GOUT_HSI_PPMU_PCLK         15
+#define CLK_GOUT_HSI_CMU_HSI_PCLK      16
+#define HSI_NR_CLK                     17
 
 /* CMU_IS */
 #define CLK_MOUT_IS_BUS_USER           1
diff --git a/include/dt-bindings/clock/loongson,ls1x-clk.h b/include/dt-bindings/clock/loongson,ls1x-clk.h
new file mode 100644 (file)
index 0000000..d400e9a
--- /dev/null
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Loongson-1 clock tree IDs
+ *
+ * Copyright (C) 2023 Keguang Zhang <keguang.zhang@gmail.com>
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_LS1X_CLK_H__
+#define __DT_BINDINGS_CLOCK_LS1X_CLK_H__
+
+#define LS1X_CLKID_PLL 0
+#define LS1X_CLKID_CPU 1
+#define LS1X_CLKID_DC  2
+#define LS1X_CLKID_AHB 3
+#define LS1X_CLKID_APB 4
+
+#define CLK_NR_CLKS    (LS1X_CLKID_APB + 1)
+
+#endif /* __DT_BINDINGS_CLOCK_LS1X_CLK_H__ */
index db1e27e792ff18301d19a6cb31208e96e6569fb4..3bc4dfc193c2dfad4d1822c42d300b84b4c669d7 100644 (file)
@@ -24,6 +24,7 @@
 #define LOONGSON2_SATA_CLK                             14
 #define LOONGSON2_PIX0_CLK                             15
 #define LOONGSON2_PIX1_CLK                             16
-#define LOONGSON2_CLK_END                              17
+#define LOONGSON2_BOOT_CLK                             17
+#define LOONGSON2_CLK_END                              18
 
 #endif
diff --git a/include/dt-bindings/clock/mediatek,mt8188-clk.h b/include/dt-bindings/clock/mediatek,mt8188-clk.h
new file mode 100644 (file)
index 0000000..bd5cd10
--- /dev/null
@@ -0,0 +1,726 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Garmin Chang <garmin.chang@mediatek.com>
+ */
+
+#ifndef _DT_BINDINGS_CLK_MT8188_H
+#define _DT_BINDINGS_CLK_MT8188_H
+
+/* TOPCKGEN */
+#define CLK_TOP_AXI                            0
+#define CLK_TOP_SPM                            1
+#define CLK_TOP_SCP                            2
+#define CLK_TOP_BUS_AXIMEM                     3
+#define CLK_TOP_VPP                            4
+#define CLK_TOP_ETHDR                          5
+#define CLK_TOP_IPE                            6
+#define CLK_TOP_CAM                            7
+#define CLK_TOP_CCU                            8
+#define CLK_TOP_CCU_AHB                                9
+#define CLK_TOP_IMG                            10
+#define CLK_TOP_CAMTM                          11
+#define CLK_TOP_DSP                            12
+#define CLK_TOP_DSP1                           13
+#define CLK_TOP_DSP2                           14
+#define CLK_TOP_DSP3                           15
+#define CLK_TOP_DSP4                           16
+#define CLK_TOP_DSP5                           17
+#define CLK_TOP_DSP6                           18
+#define CLK_TOP_DSP7                           19
+#define CLK_TOP_MFG_CORE_TMP                   20
+#define CLK_TOP_CAMTG                          21
+#define CLK_TOP_CAMTG2                         22
+#define CLK_TOP_CAMTG3                         23
+#define CLK_TOP_UART                           24
+#define CLK_TOP_SPI                            25
+#define CLK_TOP_MSDC50_0_HCLK                  26
+#define CLK_TOP_MSDC50_0                       27
+#define CLK_TOP_MSDC30_1                       28
+#define CLK_TOP_MSDC30_2                       29
+#define CLK_TOP_INTDIR                         30
+#define CLK_TOP_AUD_INTBUS                     31
+#define CLK_TOP_AUDIO_H                                32
+#define CLK_TOP_PWRAP_ULPOSC                   33
+#define CLK_TOP_ATB                            34
+#define CLK_TOP_SSPM                           35
+#define CLK_TOP_DP                             36
+#define CLK_TOP_EDP                            37
+#define CLK_TOP_DPI                            38
+#define CLK_TOP_DISP_PWM0                      39
+#define CLK_TOP_DISP_PWM1                      40
+#define CLK_TOP_USB_TOP                                41
+#define CLK_TOP_SSUSB_XHCI                     42
+#define CLK_TOP_USB_TOP_2P                     43
+#define CLK_TOP_SSUSB_XHCI_2P                  44
+#define CLK_TOP_USB_TOP_3P                     45
+#define CLK_TOP_SSUSB_XHCI_3P                  46
+#define CLK_TOP_I2C                            47
+#define CLK_TOP_SENINF                         48
+#define CLK_TOP_SENINF1                                49
+#define CLK_TOP_GCPU                           50
+#define CLK_TOP_VENC                           51
+#define CLK_TOP_VDEC                           52
+#define CLK_TOP_PWM                            53
+#define CLK_TOP_MCUPM                          54
+#define CLK_TOP_SPMI_P_MST                     55
+#define CLK_TOP_SPMI_M_MST                     56
+#define CLK_TOP_DVFSRC                         57
+#define CLK_TOP_TL                             58
+#define CLK_TOP_AES_MSDCFDE                    59
+#define CLK_TOP_DSI_OCC                                60
+#define CLK_TOP_WPE_VPP                                61
+#define CLK_TOP_HDCP                           62
+#define CLK_TOP_HDCP_24M                       63
+#define CLK_TOP_HDMI_APB                       64
+#define CLK_TOP_SNPS_ETH_250M                  65
+#define CLK_TOP_SNPS_ETH_62P4M_PTP             66
+#define CLK_TOP_SNPS_ETH_50M_RMII              67
+#define CLK_TOP_ADSP                           68
+#define CLK_TOP_AUDIO_LOCAL_BUS                        69
+#define CLK_TOP_ASM_H                          70
+#define CLK_TOP_ASM_L                          71
+#define CLK_TOP_APLL1                          72
+#define CLK_TOP_APLL2                          73
+#define CLK_TOP_APLL3                          74
+#define CLK_TOP_APLL4                          75
+#define CLK_TOP_APLL5                          76
+#define CLK_TOP_I2SO1                          77
+#define CLK_TOP_I2SO2                          78
+#define CLK_TOP_I2SI1                          79
+#define CLK_TOP_I2SI2                          80
+#define CLK_TOP_DPTX                           81
+#define CLK_TOP_AUD_IEC                                82
+#define CLK_TOP_A1SYS_HP                       83
+#define CLK_TOP_A2SYS                          84
+#define CLK_TOP_A3SYS                          85
+#define CLK_TOP_A4SYS                          86
+#define CLK_TOP_ECC                            87
+#define CLK_TOP_SPINOR                         88
+#define CLK_TOP_ULPOSC                         89
+#define CLK_TOP_SRCK                           90
+#define CLK_TOP_MFG_CK_FAST_REF                        91
+#define CLK_TOP_MAINPLL_D3                     92
+#define CLK_TOP_MAINPLL_D4                     93
+#define CLK_TOP_MAINPLL_D4_D2                  94
+#define CLK_TOP_MAINPLL_D4_D4                  95
+#define CLK_TOP_MAINPLL_D4_D8                  96
+#define CLK_TOP_MAINPLL_D5                     97
+#define CLK_TOP_MAINPLL_D5_D2                  98
+#define CLK_TOP_MAINPLL_D5_D4                  99
+#define CLK_TOP_MAINPLL_D5_D8                  100
+#define CLK_TOP_MAINPLL_D6                     101
+#define CLK_TOP_MAINPLL_D6_D2                  102
+#define CLK_TOP_MAINPLL_D6_D4                  103
+#define CLK_TOP_MAINPLL_D6_D8                  104
+#define CLK_TOP_MAINPLL_D7                     105
+#define CLK_TOP_MAINPLL_D7_D2                  106
+#define CLK_TOP_MAINPLL_D7_D4                  107
+#define CLK_TOP_MAINPLL_D7_D8                  108
+#define CLK_TOP_MAINPLL_D9                     109
+#define CLK_TOP_UNIVPLL_D2                     110
+#define CLK_TOP_UNIVPLL_D3                     111
+#define CLK_TOP_UNIVPLL_D4                     112
+#define CLK_TOP_UNIVPLL_D4_D2                  113
+#define CLK_TOP_UNIVPLL_D4_D4                  114
+#define CLK_TOP_UNIVPLL_D4_D8                  115
+#define CLK_TOP_UNIVPLL_D5                     116
+#define CLK_TOP_UNIVPLL_D5_D2                  117
+#define CLK_TOP_UNIVPLL_D5_D4                  118
+#define CLK_TOP_UNIVPLL_D5_D8                  119
+#define CLK_TOP_UNIVPLL_D6                     120
+#define CLK_TOP_UNIVPLL_D6_D2                  121
+#define CLK_TOP_UNIVPLL_D6_D4                  122
+#define CLK_TOP_UNIVPLL_D6_D8                  123
+#define CLK_TOP_UNIVPLL_D7                     124
+#define CLK_TOP_UNIVPLL_192M                   125
+#define CLK_TOP_UNIVPLL_192M_D4                        126
+#define CLK_TOP_UNIVPLL_192M_D8                        127
+#define CLK_TOP_UNIVPLL_192M_D10               128
+#define CLK_TOP_UNIVPLL_192M_D16               129
+#define CLK_TOP_UNIVPLL_192M_D32               130
+#define CLK_TOP_APLL1_D3                       131
+#define CLK_TOP_APLL1_D4                       132
+#define CLK_TOP_APLL2_D3                       133
+#define CLK_TOP_APLL2_D4                       134
+#define CLK_TOP_APLL3_D4                       135
+#define CLK_TOP_APLL4_D4                       136
+#define CLK_TOP_APLL5_D4                       137
+#define CLK_TOP_MMPLL_D4                       138
+#define CLK_TOP_MMPLL_D4_D2                    139
+#define CLK_TOP_MMPLL_D5                       140
+#define CLK_TOP_MMPLL_D5_D2                    141
+#define CLK_TOP_MMPLL_D5_D4                    142
+#define CLK_TOP_MMPLL_D6                       143
+#define CLK_TOP_MMPLL_D6_D2                    144
+#define CLK_TOP_MMPLL_D7                       145
+#define CLK_TOP_MMPLL_D9                       146
+#define CLK_TOP_TVDPLL1                                147
+#define CLK_TOP_TVDPLL1_D2                     148
+#define CLK_TOP_TVDPLL1_D4                     149
+#define CLK_TOP_TVDPLL1_D8                     150
+#define CLK_TOP_TVDPLL1_D16                    151
+#define CLK_TOP_TVDPLL2                                152
+#define CLK_TOP_TVDPLL2_D2                     153
+#define CLK_TOP_TVDPLL2_D4                     154
+#define CLK_TOP_TVDPLL2_D8                     155
+#define CLK_TOP_TVDPLL2_D16                    156
+#define CLK_TOP_MSDCPLL_D2                     157
+#define CLK_TOP_MSDCPLL_D16                    158
+#define CLK_TOP_ETHPLL                         159
+#define CLK_TOP_ETHPLL_D2                      160
+#define CLK_TOP_ETHPLL_D4                      161
+#define CLK_TOP_ETHPLL_D8                      162
+#define CLK_TOP_ETHPLL_D10                     163
+#define CLK_TOP_ADSPPLL_D2                     164
+#define CLK_TOP_ADSPPLL_D4                     165
+#define CLK_TOP_ADSPPLL_D8                     166
+#define CLK_TOP_ULPOSC1                                167
+#define CLK_TOP_ULPOSC1_D2                     168
+#define CLK_TOP_ULPOSC1_D4                     169
+#define CLK_TOP_ULPOSC1_D8                     170
+#define CLK_TOP_ULPOSC1_D7                     171
+#define CLK_TOP_ULPOSC1_D10                    172
+#define CLK_TOP_ULPOSC1_D16                    173
+#define CLK_TOP_MPHONE_SLAVE_BCK               174
+#define CLK_TOP_PAD_FPC                                175
+#define CLK_TOP_466M_FMEM                      176
+#define CLK_TOP_PEXTP_PIPE                     177
+#define CLK_TOP_DSI_PHY                                178
+#define CLK_TOP_APLL12_CK_DIV0                 179
+#define CLK_TOP_APLL12_CK_DIV1                 180
+#define CLK_TOP_APLL12_CK_DIV2                 181
+#define CLK_TOP_APLL12_CK_DIV3                 182
+#define CLK_TOP_APLL12_CK_DIV4                 183
+#define CLK_TOP_APLL12_CK_DIV9                 184
+#define CLK_TOP_CFGREG_CLOCK_EN_VPP0           185
+#define CLK_TOP_CFGREG_CLOCK_EN_VPP1           186
+#define CLK_TOP_CFGREG_CLOCK_EN_VDO0           187
+#define CLK_TOP_CFGREG_CLOCK_EN_VDO1           188
+#define CLK_TOP_CFGREG_CLOCK_ISP_AXI_GALS      189
+#define CLK_TOP_CFGREG_F26M_VPP0               190
+#define CLK_TOP_CFGREG_F26M_VPP1               191
+#define CLK_TOP_CFGREG_F26M_VDO0               192
+#define CLK_TOP_CFGREG_F26M_VDO1               193
+#define CLK_TOP_CFGREG_AUD_F26M_AUD            194
+#define CLK_TOP_CFGREG_UNIPLL_SES              195
+#define CLK_TOP_CFGREG_F_PCIE_PHY_REF          196
+#define CLK_TOP_SSUSB_TOP_REF                  197
+#define CLK_TOP_SSUSB_PHY_REF                  198
+#define CLK_TOP_SSUSB_TOP_P1_REF               199
+#define CLK_TOP_SSUSB_PHY_P1_REF               200
+#define CLK_TOP_SSUSB_TOP_P2_REF               201
+#define CLK_TOP_SSUSB_PHY_P2_REF               202
+#define CLK_TOP_SSUSB_TOP_P3_REF               203
+#define CLK_TOP_SSUSB_PHY_P3_REF               204
+#define CLK_TOP_NR_CLK                         205
+
+/* INFRACFG_AO */
+#define CLK_INFRA_AO_PMIC_TMR                  0
+#define CLK_INFRA_AO_PMIC_AP                   1
+#define CLK_INFRA_AO_PMIC_MD                   2
+#define CLK_INFRA_AO_PMIC_CONN                 3
+#define CLK_INFRA_AO_SEJ                       4
+#define CLK_INFRA_AO_APXGPT                    5
+#define CLK_INFRA_AO_GCE                       6
+#define CLK_INFRA_AO_GCE2                      7
+#define CLK_INFRA_AO_THERM                     8
+#define CLK_INFRA_AO_PWM_HCLK                  9
+#define CLK_INFRA_AO_PWM1                      10
+#define CLK_INFRA_AO_PWM2                      11
+#define CLK_INFRA_AO_PWM3                      12
+#define CLK_INFRA_AO_PWM4                      13
+#define CLK_INFRA_AO_PWM                       14
+#define CLK_INFRA_AO_UART0                     15
+#define CLK_INFRA_AO_UART1                     16
+#define CLK_INFRA_AO_UART2                     17
+#define CLK_INFRA_AO_UART3                     18
+#define CLK_INFRA_AO_UART4                     19
+#define CLK_INFRA_AO_GCE_26M                   20
+#define CLK_INFRA_AO_CQ_DMA_FPC                        21
+#define CLK_INFRA_AO_UART5                     22
+#define CLK_INFRA_AO_HDMI_26M                  23
+#define CLK_INFRA_AO_SPI0                      24
+#define CLK_INFRA_AO_MSDC0                     25
+#define CLK_INFRA_AO_MSDC1                     26
+#define CLK_INFRA_AO_MSDC2                     27
+#define CLK_INFRA_AO_MSDC0_SRC                 28
+#define CLK_INFRA_AO_DVFSRC                    29
+#define CLK_INFRA_AO_TRNG                      30
+#define CLK_INFRA_AO_AUXADC                    31
+#define CLK_INFRA_AO_CPUM                      32
+#define CLK_INFRA_AO_HDMI_32K                  33
+#define CLK_INFRA_AO_CEC_66M_HCLK              34
+#define CLK_INFRA_AO_PCIE_TL_26M               35
+#define CLK_INFRA_AO_MSDC1_SRC                 36
+#define CLK_INFRA_AO_CEC_66M_BCLK              37
+#define CLK_INFRA_AO_PCIE_TL_96M               38
+#define CLK_INFRA_AO_DEVICE_APC                        39
+#define CLK_INFRA_AO_ECC_66M_HCLK              40
+#define CLK_INFRA_AO_DEBUGSYS                  41
+#define CLK_INFRA_AO_AUDIO                     42
+#define CLK_INFRA_AO_PCIE_TL_32K               43
+#define CLK_INFRA_AO_DBG_TRACE                 44
+#define CLK_INFRA_AO_DRAMC_F26M                        45
+#define CLK_INFRA_AO_IRTX                      46
+#define CLK_INFRA_AO_DISP_PWM                  47
+#define CLK_INFRA_AO_CLDMA_BCLK                        48
+#define CLK_INFRA_AO_AUDIO_26M_BCLK            49
+#define CLK_INFRA_AO_SPI1                      50
+#define CLK_INFRA_AO_SPI2                      51
+#define CLK_INFRA_AO_SPI3                      52
+#define CLK_INFRA_AO_FSSPM                     53
+#define CLK_INFRA_AO_SSPM_BUS_HCLK             54
+#define CLK_INFRA_AO_APDMA_BCLK                        55
+#define CLK_INFRA_AO_SPI4                      56
+#define CLK_INFRA_AO_SPI5                      57
+#define CLK_INFRA_AO_CQ_DMA                    58
+#define CLK_INFRA_AO_MSDC0_SELF                        59
+#define CLK_INFRA_AO_MSDC1_SELF                        60
+#define CLK_INFRA_AO_MSDC2_SELF                        61
+#define CLK_INFRA_AO_I2S_DMA                   62
+#define CLK_INFRA_AO_AP_MSDC0                  63
+#define CLK_INFRA_AO_MD_MSDC0                  64
+#define CLK_INFRA_AO_MSDC30_2                  65
+#define CLK_INFRA_AO_GCPU                      66
+#define CLK_INFRA_AO_PCIE_PERI_26M             67
+#define CLK_INFRA_AO_GCPU_66M_BCLK             68
+#define CLK_INFRA_AO_GCPU_133M_BCLK            69
+#define CLK_INFRA_AO_DISP_PWM1                 70
+#define CLK_INFRA_AO_FBIST2FPC                 71
+#define CLK_INFRA_AO_DEVICE_APC_SYNC           72
+#define CLK_INFRA_AO_PCIE_P1_PERI_26M          73
+#define CLK_INFRA_AO_133M_MCLK_CK              74
+#define CLK_INFRA_AO_66M_MCLK_CK               75
+#define CLK_INFRA_AO_PCIE_PL_P_250M_P0         76
+#define CLK_INFRA_AO_RG_AES_MSDCFDE_CK_0P      77
+#define CLK_INFRA_AO_NR_CLK                    78
+
+/* APMIXEDSYS */
+#define CLK_APMIXED_ETHPLL                     0
+#define CLK_APMIXED_MSDCPLL                    1
+#define CLK_APMIXED_TVDPLL1                    2
+#define CLK_APMIXED_TVDPLL2                    3
+#define CLK_APMIXED_MMPLL                      4
+#define CLK_APMIXED_MAINPLL                    5
+#define CLK_APMIXED_IMGPLL                     6
+#define CLK_APMIXED_UNIVPLL                    7
+#define CLK_APMIXED_ADSPPLL                    8
+#define CLK_APMIXED_APLL1                      9
+#define CLK_APMIXED_APLL2                      10
+#define CLK_APMIXED_APLL3                      11
+#define CLK_APMIXED_APLL4                      12
+#define CLK_APMIXED_APLL5                      13
+#define CLK_APMIXED_MFGPLL                     14
+#define CLK_APMIXED_PLL_SSUSB26M_EN            15
+#define CLK_APMIXED_NR_CLK                     16
+
+/* AUDIODSP */
+#define CLK_AUDIODSP_AUDIO26M                  0
+#define CLK_AUDIODSP_NR_CLK                    1
+
+/* PERICFG_AO */
+#define CLK_PERI_AO_ETHERNET                   0
+#define CLK_PERI_AO_ETHERNET_BUS               1
+#define CLK_PERI_AO_FLASHIF_BUS                        2
+#define CLK_PERI_AO_FLASHIF_26M                        3
+#define CLK_PERI_AO_FLASHIFLASHCK              4
+#define CLK_PERI_AO_SSUSB_2P_BUS               5
+#define CLK_PERI_AO_SSUSB_2P_XHCI              6
+#define CLK_PERI_AO_SSUSB_3P_BUS               7
+#define CLK_PERI_AO_SSUSB_3P_XHCI              8
+#define CLK_PERI_AO_SSUSB_BUS                  9
+#define CLK_PERI_AO_SSUSB_XHCI                 10
+#define CLK_PERI_AO_ETHERNET_MAC               11
+#define CLK_PERI_AO_PCIE_P0_FMEM               12
+#define CLK_PERI_AO_NR_CLK                     13
+
+/* IMP_IIC_WRAP_C */
+#define CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C0       0
+#define CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C2       1
+#define CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C3       2
+#define CLK_IMP_IIC_WRAP_C_NR_CLK              3
+
+/* IMP_IIC_WRAP_W */
+#define CLK_IMP_IIC_WRAP_W_AP_CLOCK_I2C1       0
+#define CLK_IMP_IIC_WRAP_W_AP_CLOCK_I2C4       1
+#define CLK_IMP_IIC_WRAP_W_NR_CLK              2
+
+/* IMP_IIC_WRAP_EN */
+#define CLK_IMP_IIC_WRAP_EN_AP_CLOCK_I2C5      0
+#define CLK_IMP_IIC_WRAP_EN_AP_CLOCK_I2C6      1
+#define CLK_IMP_IIC_WRAP_EN_NR_CLK             2
+
+/* MFGCFG */
+#define CLK_MFGCFG_BG3D                                0
+#define CLK_MFGCFG_NR_CLK                      1
+
+/* VPPSYS0 */
+#define CLK_VPP0_MDP_FG                                0
+#define CLK_VPP0_STITCH                                1
+#define CLK_VPP0_PADDING                       2
+#define CLK_VPP0_MDP_TCC                       3
+#define CLK_VPP0_WARP0_ASYNC_TX                        4
+#define CLK_VPP0_WARP1_ASYNC_TX                        5
+#define CLK_VPP0_MUTEX                         6
+#define CLK_VPP02VPP1_RELAY                    7
+#define CLK_VPP0_VPP12VPP0_ASYNC               8
+#define CLK_VPP0_MMSYSRAM_TOP                  9
+#define CLK_VPP0_MDP_AAL                       10
+#define CLK_VPP0_MDP_RSZ                       11
+#define CLK_VPP0_SMI_COMMON_MMSRAM             12
+#define CLK_VPP0_GALS_VDO0_LARB0_MMSRAM                13
+#define CLK_VPP0_GALS_VDO0_LARB1_MMSRAM                14
+#define CLK_VPP0_GALS_VENCSYS_MMSRAM           15
+#define CLK_VPP0_GALS_VENCSYS_CORE1_MMSRAM     16
+#define CLK_VPP0_GALS_INFRA_MMSRAM             17
+#define CLK_VPP0_GALS_CAMSYS_MMSRAM            18
+#define CLK_VPP0_GALS_VPP1_LARB5_MMSRAM                19
+#define CLK_VPP0_GALS_VPP1_LARB6_MMSRAM                20
+#define CLK_VPP0_SMI_REORDER_MMSRAM            21
+#define CLK_VPP0_SMI_IOMMU                     22
+#define CLK_VPP0_GALS_IMGSYS_CAMSYS            23
+#define CLK_VPP0_MDP_RDMA                      24
+#define CLK_VPP0_MDP_WROT                      25
+#define CLK_VPP0_GALS_EMI0_EMI1                        26
+#define CLK_VPP0_SMI_SUB_COMMON_REORDER                27
+#define CLK_VPP0_SMI_RSI                       28
+#define CLK_VPP0_SMI_COMMON_LARB4              29
+#define CLK_VPP0_GALS_VDEC_VDEC_CORE1          30
+#define CLK_VPP0_GALS_VPP1_WPESYS              31
+#define CLK_VPP0_GALS_VDO0_VDO1_VENCSYS_CORE1  32
+#define CLK_VPP0_FAKE_ENG                      33
+#define CLK_VPP0_MDP_HDR                       34
+#define CLK_VPP0_MDP_TDSHP                     35
+#define CLK_VPP0_MDP_COLOR                     36
+#define CLK_VPP0_MDP_OVL                       37
+#define CLK_VPP0_DSIP_RDMA                     38
+#define CLK_VPP0_DISP_WDMA                     39
+#define CLK_VPP0_MDP_HMS                       40
+#define CLK_VPP0_WARP0_RELAY                   41
+#define CLK_VPP0_WARP0_ASYNC                   42
+#define CLK_VPP0_WARP1_RELAY                   43
+#define CLK_VPP0_WARP1_ASYNC                   44
+#define CLK_VPP0_NR_CLK                                45
+
+/* WPESYS */
+#define CLK_WPE_TOP_WPE_VPP0                   0
+#define CLK_WPE_TOP_SMI_LARB7                  1
+#define CLK_WPE_TOP_WPESYS_EVENT_TX            2
+#define CLK_WPE_TOP_SMI_LARB7_PCLK_EN          3
+#define CLK_WPE_TOP_NR_CLK                     4
+
+/* WPESYS_VPP0 */
+#define CLK_WPE_VPP0_VECI                      0
+#define CLK_WPE_VPP0_VEC2I                     1
+#define CLK_WPE_VPP0_VEC3I                     2
+#define CLK_WPE_VPP0_WPEO                      3
+#define CLK_WPE_VPP0_MSKO                      4
+#define CLK_WPE_VPP0_VGEN                      5
+#define CLK_WPE_VPP0_EXT                       6
+#define CLK_WPE_VPP0_VFC                       7
+#define CLK_WPE_VPP0_CACH0_TOP                 8
+#define CLK_WPE_VPP0_CACH0_DMA                 9
+#define CLK_WPE_VPP0_CACH1_TOP                 10
+#define CLK_WPE_VPP0_CACH1_DMA                 11
+#define CLK_WPE_VPP0_CACH2_TOP                 12
+#define CLK_WPE_VPP0_CACH2_DMA                 13
+#define CLK_WPE_VPP0_CACH3_TOP                 14
+#define CLK_WPE_VPP0_CACH3_DMA                 15
+#define CLK_WPE_VPP0_PSP                       16
+#define CLK_WPE_VPP0_PSP2                      17
+#define CLK_WPE_VPP0_SYNC                      18
+#define CLK_WPE_VPP0_C24                       19
+#define CLK_WPE_VPP0_MDP_CROP                  20
+#define CLK_WPE_VPP0_ISP_CROP                  21
+#define CLK_WPE_VPP0_TOP                       22
+#define CLK_WPE_VPP0_NR_CLK                    23
+
+/* VPPSYS1 */
+#define CLK_VPP1_SVPP1_MDP_OVL                 0
+#define CLK_VPP1_SVPP1_MDP_TCC                 1
+#define CLK_VPP1_SVPP1_MDP_WROT                        2
+#define CLK_VPP1_SVPP1_VPP_PAD                 3
+#define CLK_VPP1_SVPP2_MDP_WROT                        4
+#define CLK_VPP1_SVPP2_VPP_PAD                 5
+#define CLK_VPP1_SVPP3_MDP_WROT                        6
+#define CLK_VPP1_SVPP3_VPP_PAD                 7
+#define CLK_VPP1_SVPP1_MDP_RDMA                        8
+#define CLK_VPP1_SVPP1_MDP_FG                  9
+#define CLK_VPP1_SVPP2_MDP_RDMA                        10
+#define CLK_VPP1_SVPP2_MDP_FG                  11
+#define CLK_VPP1_SVPP3_MDP_RDMA                        12
+#define CLK_VPP1_SVPP3_MDP_FG                  13
+#define CLK_VPP1_VPP_SPLIT                     14
+#define CLK_VPP1_SVPP2_VDO0_DL_RELAY           15
+#define CLK_VPP1_SVPP1_MDP_RSZ                 16
+#define CLK_VPP1_SVPP1_MDP_TDSHP               17
+#define CLK_VPP1_SVPP1_MDP_COLOR               18
+#define CLK_VPP1_SVPP3_VDO1_DL_RELAY           19
+#define CLK_VPP1_SVPP2_MDP_RSZ                 20
+#define CLK_VPP1_SVPP2_VPP_MERGE               21
+#define CLK_VPP1_SVPP2_MDP_TDSHP               22
+#define CLK_VPP1_SVPP2_MDP_COLOR               23
+#define CLK_VPP1_SVPP3_MDP_RSZ                 24
+#define CLK_VPP1_SVPP3_VPP_MERGE               25
+#define CLK_VPP1_SVPP3_MDP_TDSHP               26
+#define CLK_VPP1_SVPP3_MDP_COLOR               27
+#define CLK_VPP1_GALS5                         28
+#define CLK_VPP1_GALS6                         29
+#define CLK_VPP1_LARB5                         30
+#define CLK_VPP1_LARB6                         31
+#define CLK_VPP1_SVPP1_MDP_HDR                 32
+#define CLK_VPP1_SVPP1_MDP_AAL                 33
+#define CLK_VPP1_SVPP2_MDP_HDR                 34
+#define CLK_VPP1_SVPP2_MDP_AAL                 35
+#define CLK_VPP1_SVPP3_MDP_HDR                 36
+#define CLK_VPP1_SVPP3_MDP_AAL                 37
+#define CLK_VPP1_DISP_MUTEX                    38
+#define CLK_VPP1_SVPP2_VDO1_DL_RELAY           39
+#define CLK_VPP1_SVPP3_VDO0_DL_RELAY           40
+#define CLK_VPP1_VPP0_DL_ASYNC                 41
+#define CLK_VPP1_VPP0_DL1_RELAY                        42
+#define CLK_VPP1_LARB5_FAKE_ENG                        43
+#define CLK_VPP1_LARB6_FAKE_ENG                        44
+#define CLK_VPP1_HDMI_META                     45
+#define CLK_VPP1_VPP_SPLIT_HDMI                        46
+#define CLK_VPP1_DGI_IN                                47
+#define CLK_VPP1_DGI_OUT                       48
+#define CLK_VPP1_VPP_SPLIT_DGI                 49
+#define CLK_VPP1_DL_CON_OCC                    50
+#define CLK_VPP1_VPP_SPLIT_26M                 51
+#define CLK_VPP1_NR_CLK                                52
+
+/* IMGSYS */
+#define CLK_IMGSYS_MAIN_LARB9                  0
+#define CLK_IMGSYS_MAIN_TRAW0                  1
+#define CLK_IMGSYS_MAIN_TRAW1                  2
+#define CLK_IMGSYS_MAIN_VCORE_GALS             3
+#define CLK_IMGSYS_MAIN_DIP0                   4
+#define CLK_IMGSYS_MAIN_WPE0                   5
+#define CLK_IMGSYS_MAIN_IPE                    6
+#define CLK_IMGSYS_MAIN_WPE1                   7
+#define CLK_IMGSYS_MAIN_WPE2                   8
+#define CLK_IMGSYS_MAIN_GALS                   9
+#define CLK_IMGSYS_MAIN_NR_CLK                 10
+
+/* IMGSYS1_DIP_TOP */
+#define CLK_IMGSYS1_DIP_TOP_LARB10             0
+#define CLK_IMGSYS1_DIP_TOP_DIP_TOP            1
+#define CLK_IMGSYS1_DIP_TOP_NR_CLK             2
+
+/* IMGSYS1_DIP_NR */
+#define CLK_IMGSYS1_DIP_NR_LARB15              0
+#define CLK_IMGSYS1_DIP_NR_DIP_NR              1
+#define CLK_IMGSYS1_DIP_NR_NR_CLK              2
+
+/* IMGSYS_WPE1 */
+#define CLK_IMGSYS_WPE1_LARB11                 0
+#define CLK_IMGSYS_WPE1                                1
+#define CLK_IMGSYS_WPE1_NR_CLK                 2
+
+/* IPESYS */
+#define CLK_IPE_DPE                            0
+#define CLK_IPE_FDVT                           1
+#define CLK_IPE_ME                             2
+#define CLK_IPESYS_TOP                         3
+#define CLK_IPE_SMI_LARB12                     4
+#define CLK_IPE_NR_CLK                         5
+
+/* IMGSYS_WPE2 */
+#define CLK_IMGSYS_WPE2_LARB11                 0
+#define CLK_IMGSYS_WPE2                                1
+#define CLK_IMGSYS_WPE2_NR_CLK                 2
+
+/* IMGSYS_WPE3 */
+#define CLK_IMGSYS_WPE3_LARB11                 0
+#define CLK_IMGSYS_WPE3                                1
+#define CLK_IMGSYS_WPE3_NR_CLK                 2
+
+/* CAMSYS */
+#define CLK_CAM_MAIN_LARB13                    0
+#define CLK_CAM_MAIN_LARB14                    1
+#define CLK_CAM_MAIN_CAM                       2
+#define CLK_CAM_MAIN_CAM_SUBA                  3
+#define CLK_CAM_MAIN_CAM_SUBB                  4
+#define CLK_CAM_MAIN_CAMTG                     5
+#define CLK_CAM_MAIN_SENINF                    6
+#define CLK_CAM_MAIN_GCAMSVA                   7
+#define CLK_CAM_MAIN_GCAMSVB                   8
+#define CLK_CAM_MAIN_GCAMSVC                   9
+#define CLK_CAM_MAIN_GCAMSVD                   10
+#define CLK_CAM_MAIN_GCAMSVE                   11
+#define CLK_CAM_MAIN_GCAMSVF                   12
+#define CLK_CAM_MAIN_GCAMSVG                   13
+#define CLK_CAM_MAIN_GCAMSVH                   14
+#define CLK_CAM_MAIN_GCAMSVI                   15
+#define CLK_CAM_MAIN_GCAMSVJ                   16
+#define CLK_CAM_MAIN_CAMSV_TOP                 17
+#define CLK_CAM_MAIN_CAMSV_CQ_A                        18
+#define CLK_CAM_MAIN_CAMSV_CQ_B                        19
+#define CLK_CAM_MAIN_CAMSV_CQ_C                        20
+#define CLK_CAM_MAIN_FAKE_ENG                  21
+#define CLK_CAM_MAIN_CAM2MM0_GALS              22
+#define CLK_CAM_MAIN_CAM2MM1_GALS              23
+#define CLK_CAM_MAIN_CAM2SYS_GALS              24
+#define CLK_CAM_MAIN_NR_CLK                    25
+
+/* CAMSYS_RAWA */
+#define CLK_CAM_RAWA_LARBX                     0
+#define CLK_CAM_RAWA_CAM                       1
+#define CLK_CAM_RAWA_CAMTG                     2
+#define CLK_CAM_RAWA_NR_CLK                    3
+
+/* CAMSYS_YUVA */
+#define CLK_CAM_YUVA_LARBX                     0
+#define CLK_CAM_YUVA_CAM                       1
+#define CLK_CAM_YUVA_CAMTG                     2
+#define CLK_CAM_YUVA_NR_CLK                    3
+
+/* CAMSYS_RAWB */
+#define CLK_CAM_RAWB_LARBX                     0
+#define CLK_CAM_RAWB_CAM                       1
+#define CLK_CAM_RAWB_CAMTG                     2
+#define CLK_CAM_RAWB_NR_CLK                    3
+
+/* CAMSYS_YUVB */
+#define CLK_CAM_YUVB_LARBX                     0
+#define CLK_CAM_YUVB_CAM                       1
+#define CLK_CAM_YUVB_CAMTG                     2
+#define CLK_CAM_YUVB_NR_CLK                    3
+
+/* CCUSYS */
+#define CLK_CCU_LARB27                         0
+#define CLK_CCU_AHB                            1
+#define CLK_CCU_CCU0                           2
+#define CLK_CCU_NR_CLK                         3
+
+/* VDECSYS_SOC */
+#define CLK_VDEC1_SOC_LARB1                    0
+#define CLK_VDEC1_SOC_LAT                      1
+#define CLK_VDEC1_SOC_LAT_ACTIVE                       2
+#define CLK_VDEC1_SOC_LAT_ENG                  3
+#define CLK_VDEC1_SOC_VDEC                     4
+#define CLK_VDEC1_SOC_VDEC_ACTIVE              5
+#define CLK_VDEC1_SOC_VDEC_ENG                 6
+#define CLK_VDEC1_NR_CLK                               7
+
+/* VDECSYS */
+#define CLK_VDEC2_LARB1                                0
+#define CLK_VDEC2_LAT                          1
+#define CLK_VDEC2_VDEC                         2
+#define CLK_VDEC2_VDEC_ACTIVE                  3
+#define CLK_VDEC2_VDEC_ENG                     4
+#define CLK_VDEC2_NR_CLK                               5
+
+/* VENCSYS */
+#define CLK_VENC1_LARB                 0
+#define CLK_VENC1_VENC                 1
+#define CLK_VENC1_JPGENC                       2
+#define CLK_VENC1_JPGDEC                       3
+#define CLK_VENC1_JPGDEC_C1                    4
+#define CLK_VENC1_GALS                 5
+#define CLK_VENC1_GALS_SRAM                    6
+#define CLK_VENC1_NR_CLK                               7
+
+/* VDOSYS0 */
+#define CLK_VDO0_DISP_OVL0                     0
+#define CLK_VDO0_FAKE_ENG0                     1
+#define CLK_VDO0_DISP_CCORR0                   2
+#define CLK_VDO0_DISP_MUTEX0                   3
+#define CLK_VDO0_DISP_GAMMA0                   4
+#define CLK_VDO0_DISP_DITHER0                  5
+#define CLK_VDO0_DISP_WDMA0                    6
+#define CLK_VDO0_DISP_RDMA0                    7
+#define CLK_VDO0_DSI0                          8
+#define CLK_VDO0_DSI1                          9
+#define CLK_VDO0_DSC_WRAP0                     10
+#define CLK_VDO0_VPP_MERGE0                    11
+#define CLK_VDO0_DP_INTF0                      12
+#define CLK_VDO0_DISP_AAL0                     13
+#define CLK_VDO0_INLINEROT0                    14
+#define CLK_VDO0_APB_BUS                       15
+#define CLK_VDO0_DISP_COLOR0                   16
+#define CLK_VDO0_MDP_WROT0                     17
+#define CLK_VDO0_DISP_RSZ0                     18
+#define CLK_VDO0_DISP_POSTMASK0                        19
+#define CLK_VDO0_FAKE_ENG1                     20
+#define CLK_VDO0_DL_ASYNC2                     21
+#define CLK_VDO0_DL_RELAY3                     22
+#define CLK_VDO0_DL_RELAY4                     23
+#define CLK_VDO0_SMI_GALS                      24
+#define CLK_VDO0_SMI_COMMON                    25
+#define CLK_VDO0_SMI_EMI                       26
+#define CLK_VDO0_SMI_IOMMU                     27
+#define CLK_VDO0_SMI_LARB                      28
+#define CLK_VDO0_SMI_RSI                       29
+#define CLK_VDO0_DSI0_DSI                      30
+#define CLK_VDO0_DSI1_DSI                      31
+#define CLK_VDO0_DP_INTF0_DP_INTF              32
+#define CLK_VDO0_NR_CLK                                33
+
+/* VDOSYS1 */
+#define CLK_VDO1_SMI_LARB2                     0
+#define CLK_VDO1_SMI_LARB3                     1
+#define CLK_VDO1_GALS                          2
+#define CLK_VDO1_FAKE_ENG0                     3
+#define CLK_VDO1_FAKE_ENG1                     4
+#define CLK_VDO1_MDP_RDMA0                     5
+#define CLK_VDO1_MDP_RDMA1                     6
+#define CLK_VDO1_MDP_RDMA2                     7
+#define CLK_VDO1_MDP_RDMA3                     8
+#define CLK_VDO1_VPP_MERGE0                    9
+#define CLK_VDO1_VPP_MERGE1                    10
+#define CLK_VDO1_VPP_MERGE2                    11
+#define CLK_VDO1_VPP_MERGE3                    12
+#define CLK_VDO1_VPP_MERGE4                    13
+#define CLK_VDO1_VPP2_TO_VDO1_DL_ASYNC         14
+#define CLK_VDO1_VPP3_TO_VDO1_DL_ASYNC         15
+#define CLK_VDO1_DISP_MUTEX                    16
+#define CLK_VDO1_MDP_RDMA4                     17
+#define CLK_VDO1_MDP_RDMA5                     18
+#define CLK_VDO1_MDP_RDMA6                     19
+#define CLK_VDO1_MDP_RDMA7                     20
+#define CLK_VDO1_DP_INTF0_MMCK                 21
+#define CLK_VDO1_DPI0_MM                       22
+#define CLK_VDO1_DPI1_MM                       23
+#define CLK_VDO1_MERGE0_DL_ASYNC               24
+#define CLK_VDO1_MERGE1_DL_ASYNC               25
+#define CLK_VDO1_MERGE2_DL_ASYNC               26
+#define CLK_VDO1_MERGE3_DL_ASYNC               27
+#define CLK_VDO1_MERGE4_DL_ASYNC               28
+#define CLK_VDO1_DSC_VDO1_DL_ASYNC             29
+#define CLK_VDO1_MERGE_VDO1_DL_ASYNC           30
+#define CLK_VDO1_PADDING0                      31
+#define CLK_VDO1_PADDING1                      32
+#define CLK_VDO1_PADDING2                      33
+#define CLK_VDO1_PADDING3                      34
+#define CLK_VDO1_PADDING4                      35
+#define CLK_VDO1_PADDING5                      36
+#define CLK_VDO1_PADDING6                      37
+#define CLK_VDO1_PADDING7                      38
+#define CLK_VDO1_DISP_RSZ0                     39
+#define CLK_VDO1_DISP_RSZ1                     40
+#define CLK_VDO1_DISP_RSZ2                     41
+#define CLK_VDO1_DISP_RSZ3                     42
+#define CLK_VDO1_HDR_VDO_FE0                   43
+#define CLK_VDO1_HDR_GFX_FE0                   44
+#define CLK_VDO1_HDR_VDO_BE                    45
+#define CLK_VDO1_HDR_VDO_FE1                   46
+#define CLK_VDO1_HDR_GFX_FE1                   47
+#define CLK_VDO1_DISP_MIXER                    48
+#define CLK_VDO1_HDR_VDO_FE0_DL_ASYNC          49
+#define CLK_VDO1_HDR_VDO_FE1_DL_ASYNC          50
+#define CLK_VDO1_HDR_GFX_FE0_DL_ASYNC          51
+#define CLK_VDO1_HDR_GFX_FE1_DL_ASYNC          52
+#define CLK_VDO1_HDR_VDO_BE_DL_ASYNC           53
+#define CLK_VDO1_DPI0                          54
+#define CLK_VDO1_DISP_MONITOR_DPI0             55
+#define CLK_VDO1_DPI1                          56
+#define CLK_VDO1_DISP_MONITOR_DPI1             57
+#define CLK_VDO1_DPINTF                                58
+#define CLK_VDO1_DISP_MONITOR_DPINTF           59
+#define CLK_VDO1_26M_SLOW                      60
+#define CLK_VDO1_NR_CLK                                61
+
+#endif /* _DT_BINDINGS_CLK_MT8188_H */
diff --git a/include/dt-bindings/clock/starfive,jh7110-crg.h b/include/dt-bindings/clock/starfive,jh7110-crg.h
new file mode 100644 (file)
index 0000000..06257bf
--- /dev/null
@@ -0,0 +1,221 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+/*
+ * Copyright 2022 Emil Renner Berthing <kernel@esmil.dk>
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__
+#define __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__
+
+/* SYSCRG clocks */
+#define JH7110_SYSCLK_CPU_ROOT                 0
+#define JH7110_SYSCLK_CPU_CORE                 1
+#define JH7110_SYSCLK_CPU_BUS                  2
+#define JH7110_SYSCLK_GPU_ROOT                 3
+#define JH7110_SYSCLK_PERH_ROOT                        4
+#define JH7110_SYSCLK_BUS_ROOT                 5
+#define JH7110_SYSCLK_NOCSTG_BUS               6
+#define JH7110_SYSCLK_AXI_CFG0                 7
+#define JH7110_SYSCLK_STG_AXIAHB               8
+#define JH7110_SYSCLK_AHB0                     9
+#define JH7110_SYSCLK_AHB1                     10
+#define JH7110_SYSCLK_APB_BUS                  11
+#define JH7110_SYSCLK_APB0                     12
+#define JH7110_SYSCLK_PLL0_DIV2                        13
+#define JH7110_SYSCLK_PLL1_DIV2                        14
+#define JH7110_SYSCLK_PLL2_DIV2                        15
+#define JH7110_SYSCLK_AUDIO_ROOT               16
+#define JH7110_SYSCLK_MCLK_INNER               17
+#define JH7110_SYSCLK_MCLK                     18
+#define JH7110_SYSCLK_MCLK_OUT                 19
+#define JH7110_SYSCLK_ISP_2X                   20
+#define JH7110_SYSCLK_ISP_AXI                  21
+#define JH7110_SYSCLK_GCLK0                    22
+#define JH7110_SYSCLK_GCLK1                    23
+#define JH7110_SYSCLK_GCLK2                    24
+#define JH7110_SYSCLK_CORE                     25
+#define JH7110_SYSCLK_CORE1                    26
+#define JH7110_SYSCLK_CORE2                    27
+#define JH7110_SYSCLK_CORE3                    28
+#define JH7110_SYSCLK_CORE4                    29
+#define JH7110_SYSCLK_DEBUG                    30
+#define JH7110_SYSCLK_RTC_TOGGLE               31
+#define JH7110_SYSCLK_TRACE0                   32
+#define JH7110_SYSCLK_TRACE1                   33
+#define JH7110_SYSCLK_TRACE2                   34
+#define JH7110_SYSCLK_TRACE3                   35
+#define JH7110_SYSCLK_TRACE4                   36
+#define JH7110_SYSCLK_TRACE_COM                        37
+#define JH7110_SYSCLK_NOC_BUS_CPU_AXI          38
+#define JH7110_SYSCLK_NOC_BUS_AXICFG0_AXI      39
+#define JH7110_SYSCLK_OSC_DIV2                 40
+#define JH7110_SYSCLK_PLL1_DIV4                        41
+#define JH7110_SYSCLK_PLL1_DIV8                        42
+#define JH7110_SYSCLK_DDR_BUS                  43
+#define JH7110_SYSCLK_DDR_AXI                  44
+#define JH7110_SYSCLK_GPU_CORE                 45
+#define JH7110_SYSCLK_GPU_CORE_CLK             46
+#define JH7110_SYSCLK_GPU_SYS_CLK              47
+#define JH7110_SYSCLK_GPU_APB                  48
+#define JH7110_SYSCLK_GPU_RTC_TOGGLE           49
+#define JH7110_SYSCLK_NOC_BUS_GPU_AXI          50
+#define JH7110_SYSCLK_ISP_TOP_CORE             51
+#define JH7110_SYSCLK_ISP_TOP_AXI              52
+#define JH7110_SYSCLK_NOC_BUS_ISP_AXI          53
+#define JH7110_SYSCLK_HIFI4_CORE               54
+#define JH7110_SYSCLK_HIFI4_AXI                        55
+#define JH7110_SYSCLK_AXI_CFG1_MAIN            56
+#define JH7110_SYSCLK_AXI_CFG1_AHB             57
+#define JH7110_SYSCLK_VOUT_SRC                 58
+#define JH7110_SYSCLK_VOUT_AXI                 59
+#define JH7110_SYSCLK_NOC_BUS_DISP_AXI         60
+#define JH7110_SYSCLK_VOUT_TOP_AHB             61
+#define JH7110_SYSCLK_VOUT_TOP_AXI             62
+#define JH7110_SYSCLK_VOUT_TOP_HDMITX0_MCLK    63
+#define JH7110_SYSCLK_VOUT_TOP_MIPIPHY_REF     64
+#define JH7110_SYSCLK_JPEGC_AXI                        65
+#define JH7110_SYSCLK_CODAJ12_AXI              66
+#define JH7110_SYSCLK_CODAJ12_CORE             67
+#define JH7110_SYSCLK_CODAJ12_APB              68
+#define JH7110_SYSCLK_VDEC_AXI                 69
+#define JH7110_SYSCLK_WAVE511_AXI              70
+#define JH7110_SYSCLK_WAVE511_BPU              71
+#define JH7110_SYSCLK_WAVE511_VCE              72
+#define JH7110_SYSCLK_WAVE511_APB              73
+#define JH7110_SYSCLK_VDEC_JPG                 74
+#define JH7110_SYSCLK_VDEC_MAIN                        75
+#define JH7110_SYSCLK_NOC_BUS_VDEC_AXI         76
+#define JH7110_SYSCLK_VENC_AXI                 77
+#define JH7110_SYSCLK_WAVE420L_AXI             78
+#define JH7110_SYSCLK_WAVE420L_BPU             79
+#define JH7110_SYSCLK_WAVE420L_VCE             80
+#define JH7110_SYSCLK_WAVE420L_APB             81
+#define JH7110_SYSCLK_NOC_BUS_VENC_AXI         82
+#define JH7110_SYSCLK_AXI_CFG0_MAIN_DIV                83
+#define JH7110_SYSCLK_AXI_CFG0_MAIN            84
+#define JH7110_SYSCLK_AXI_CFG0_HIFI4           85
+#define JH7110_SYSCLK_AXIMEM2_AXI              86
+#define JH7110_SYSCLK_QSPI_AHB                 87
+#define JH7110_SYSCLK_QSPI_APB                 88
+#define JH7110_SYSCLK_QSPI_REF_SRC             89
+#define JH7110_SYSCLK_QSPI_REF                 90
+#define JH7110_SYSCLK_SDIO0_AHB                        91
+#define JH7110_SYSCLK_SDIO1_AHB                        92
+#define JH7110_SYSCLK_SDIO0_SDCARD             93
+#define JH7110_SYSCLK_SDIO1_SDCARD             94
+#define JH7110_SYSCLK_USB_125M                 95
+#define JH7110_SYSCLK_NOC_BUS_STG_AXI          96
+#define JH7110_SYSCLK_GMAC1_AHB                        97
+#define JH7110_SYSCLK_GMAC1_AXI                        98
+#define JH7110_SYSCLK_GMAC_SRC                 99
+#define JH7110_SYSCLK_GMAC1_GTXCLK             100
+#define JH7110_SYSCLK_GMAC1_RMII_RTX           101
+#define JH7110_SYSCLK_GMAC1_PTP                        102
+#define JH7110_SYSCLK_GMAC1_RX                 103
+#define JH7110_SYSCLK_GMAC1_RX_INV             104
+#define JH7110_SYSCLK_GMAC1_TX                 105
+#define JH7110_SYSCLK_GMAC1_TX_INV             106
+#define JH7110_SYSCLK_GMAC1_GTXC               107
+#define JH7110_SYSCLK_GMAC0_GTXCLK             108
+#define JH7110_SYSCLK_GMAC0_PTP                        109
+#define JH7110_SYSCLK_GMAC_PHY                 110
+#define JH7110_SYSCLK_GMAC0_GTXC               111
+#define JH7110_SYSCLK_IOMUX_APB                        112
+#define JH7110_SYSCLK_MAILBOX_APB              113
+#define JH7110_SYSCLK_INT_CTRL_APB             114
+#define JH7110_SYSCLK_CAN0_APB                 115
+#define JH7110_SYSCLK_CAN0_TIMER               116
+#define JH7110_SYSCLK_CAN0_CAN                 117
+#define JH7110_SYSCLK_CAN1_APB                 118
+#define JH7110_SYSCLK_CAN1_TIMER               119
+#define JH7110_SYSCLK_CAN1_CAN                 120
+#define JH7110_SYSCLK_PWM_APB                  121
+#define JH7110_SYSCLK_WDT_APB                  122
+#define JH7110_SYSCLK_WDT_CORE                 123
+#define JH7110_SYSCLK_TIMER_APB                        124
+#define JH7110_SYSCLK_TIMER0                   125
+#define JH7110_SYSCLK_TIMER1                   126
+#define JH7110_SYSCLK_TIMER2                   127
+#define JH7110_SYSCLK_TIMER3                   128
+#define JH7110_SYSCLK_TEMP_APB                 129
+#define JH7110_SYSCLK_TEMP_CORE                        130
+#define JH7110_SYSCLK_SPI0_APB                 131
+#define JH7110_SYSCLK_SPI1_APB                 132
+#define JH7110_SYSCLK_SPI2_APB                 133
+#define JH7110_SYSCLK_SPI3_APB                 134
+#define JH7110_SYSCLK_SPI4_APB                 135
+#define JH7110_SYSCLK_SPI5_APB                 136
+#define JH7110_SYSCLK_SPI6_APB                 137
+#define JH7110_SYSCLK_I2C0_APB                 138
+#define JH7110_SYSCLK_I2C1_APB                 139
+#define JH7110_SYSCLK_I2C2_APB                 140
+#define JH7110_SYSCLK_I2C3_APB                 141
+#define JH7110_SYSCLK_I2C4_APB                 142
+#define JH7110_SYSCLK_I2C5_APB                 143
+#define JH7110_SYSCLK_I2C6_APB                 144
+#define JH7110_SYSCLK_UART0_APB                        145
+#define JH7110_SYSCLK_UART0_CORE               146
+#define JH7110_SYSCLK_UART1_APB                        147
+#define JH7110_SYSCLK_UART1_CORE               148
+#define JH7110_SYSCLK_UART2_APB                        149
+#define JH7110_SYSCLK_UART2_CORE               150
+#define JH7110_SYSCLK_UART3_APB                        151
+#define JH7110_SYSCLK_UART3_CORE               152
+#define JH7110_SYSCLK_UART4_APB                        153
+#define JH7110_SYSCLK_UART4_CORE               154
+#define JH7110_SYSCLK_UART5_APB                        155
+#define JH7110_SYSCLK_UART5_CORE               156
+#define JH7110_SYSCLK_PWMDAC_APB               157
+#define JH7110_SYSCLK_PWMDAC_CORE              158
+#define JH7110_SYSCLK_SPDIF_APB                        159
+#define JH7110_SYSCLK_SPDIF_CORE               160
+#define JH7110_SYSCLK_I2STX0_APB               161
+#define JH7110_SYSCLK_I2STX0_BCLK_MST          162
+#define JH7110_SYSCLK_I2STX0_BCLK_MST_INV      163
+#define JH7110_SYSCLK_I2STX0_LRCK_MST          164
+#define JH7110_SYSCLK_I2STX0_BCLK              165
+#define JH7110_SYSCLK_I2STX0_BCLK_INV          166
+#define JH7110_SYSCLK_I2STX0_LRCK              167
+#define JH7110_SYSCLK_I2STX1_APB               168
+#define JH7110_SYSCLK_I2STX1_BCLK_MST          169
+#define JH7110_SYSCLK_I2STX1_BCLK_MST_INV      170
+#define JH7110_SYSCLK_I2STX1_LRCK_MST          171
+#define JH7110_SYSCLK_I2STX1_BCLK              172
+#define JH7110_SYSCLK_I2STX1_BCLK_INV          173
+#define JH7110_SYSCLK_I2STX1_LRCK              174
+#define JH7110_SYSCLK_I2SRX_APB                        175
+#define JH7110_SYSCLK_I2SRX_BCLK_MST           176
+#define JH7110_SYSCLK_I2SRX_BCLK_MST_INV       177
+#define JH7110_SYSCLK_I2SRX_LRCK_MST           178
+#define JH7110_SYSCLK_I2SRX_BCLK               179
+#define JH7110_SYSCLK_I2SRX_BCLK_INV           180
+#define JH7110_SYSCLK_I2SRX_LRCK               181
+#define JH7110_SYSCLK_PDM_DMIC                 182
+#define JH7110_SYSCLK_PDM_APB                  183
+#define JH7110_SYSCLK_TDM_AHB                  184
+#define JH7110_SYSCLK_TDM_APB                  185
+#define JH7110_SYSCLK_TDM_INTERNAL             186
+#define JH7110_SYSCLK_TDM_TDM                  187
+#define JH7110_SYSCLK_TDM_TDM_INV              188
+#define JH7110_SYSCLK_JTAG_CERTIFICATION_TRNG  189
+
+#define JH7110_SYSCLK_END                      190
+
+/* AONCRG clocks */
+#define JH7110_AONCLK_OSC_DIV4                 0
+#define JH7110_AONCLK_APB_FUNC                 1
+#define JH7110_AONCLK_GMAC0_AHB                        2
+#define JH7110_AONCLK_GMAC0_AXI                        3
+#define JH7110_AONCLK_GMAC0_RMII_RTX           4
+#define JH7110_AONCLK_GMAC0_TX                 5
+#define JH7110_AONCLK_GMAC0_TX_INV             6
+#define JH7110_AONCLK_GMAC0_RX                 7
+#define JH7110_AONCLK_GMAC0_RX_INV             8
+#define JH7110_AONCLK_OTPC_APB                 9
+#define JH7110_AONCLK_RTC_APB                  10
+#define JH7110_AONCLK_RTC_INTERNAL             11
+#define JH7110_AONCLK_RTC_32K                  12
+#define JH7110_AONCLK_RTC_CAL                  13
+
+#define JH7110_AONCLK_END                      14
+
+#endif /* __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__ */
index 6a6403a4c2d588c76dee9810bbac3bfe048fd278..d87a7882782a6080facb870e8e9416b9d2913fe8 100644 (file)
@@ -23,4 +23,8 @@
 #define BCM63268_RST_PCIE_HARD 17
 #define BCM63268_RST_GPHY      18
 
+#define BCM63268_TRST_SW       29
+#define BCM63268_TRST_HW       30
+#define BCM63268_TRST_POR      31
+
 #endif /* __DT_BINDINGS_RESET_BCM63268_H */
diff --git a/include/dt-bindings/reset/starfive,jh7110-crg.h b/include/dt-bindings/reset/starfive,jh7110-crg.h
new file mode 100644 (file)
index 0000000..d78e386
--- /dev/null
@@ -0,0 +1,154 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+/*
+ * Copyright (C) 2022 Emil Renner Berthing <kernel@esmil.dk>
+ */
+
+#ifndef __DT_BINDINGS_RESET_STARFIVE_JH7110_CRG_H__
+#define __DT_BINDINGS_RESET_STARFIVE_JH7110_CRG_H__
+
+/* SYSCRG resets */
+#define JH7110_SYSRST_JTAG_APB                 0
+#define JH7110_SYSRST_SYSCON_APB               1
+#define JH7110_SYSRST_IOMUX_APB                        2
+#define JH7110_SYSRST_BUS                      3
+#define JH7110_SYSRST_DEBUG                    4
+#define JH7110_SYSRST_CORE0                    5
+#define JH7110_SYSRST_CORE1                    6
+#define JH7110_SYSRST_CORE2                    7
+#define JH7110_SYSRST_CORE3                    8
+#define JH7110_SYSRST_CORE4                    9
+#define JH7110_SYSRST_CORE0_ST                 10
+#define JH7110_SYSRST_CORE1_ST                 11
+#define JH7110_SYSRST_CORE2_ST                 12
+#define JH7110_SYSRST_CORE3_ST                 13
+#define JH7110_SYSRST_CORE4_ST                 14
+#define JH7110_SYSRST_TRACE0                   15
+#define JH7110_SYSRST_TRACE1                   16
+#define JH7110_SYSRST_TRACE2                   17
+#define JH7110_SYSRST_TRACE3                   18
+#define JH7110_SYSRST_TRACE4                   19
+#define JH7110_SYSRST_TRACE_COM                        20
+#define JH7110_SYSRST_GPU_APB                  21
+#define JH7110_SYSRST_GPU_DOMA                 22
+#define JH7110_SYSRST_NOC_BUS_APB              23
+#define JH7110_SYSRST_NOC_BUS_AXICFG0_AXI      24
+#define JH7110_SYSRST_NOC_BUS_CPU_AXI          25
+#define JH7110_SYSRST_NOC_BUS_DISP_AXI         26
+#define JH7110_SYSRST_NOC_BUS_GPU_AXI          27
+#define JH7110_SYSRST_NOC_BUS_ISP_AXI          28
+#define JH7110_SYSRST_NOC_BUS_DDRC             29
+#define JH7110_SYSRST_NOC_BUS_STG_AXI          30
+#define JH7110_SYSRST_NOC_BUS_VDEC_AXI         31
+
+#define JH7110_SYSRST_NOC_BUS_VENC_AXI         32
+#define JH7110_SYSRST_AXI_CFG1_AHB             33
+#define JH7110_SYSRST_AXI_CFG1_MAIN            34
+#define JH7110_SYSRST_AXI_CFG0_MAIN            35
+#define JH7110_SYSRST_AXI_CFG0_MAIN_DIV                36
+#define JH7110_SYSRST_AXI_CFG0_HIFI4           37
+#define JH7110_SYSRST_DDR_AXI                  38
+#define JH7110_SYSRST_DDR_OSC                  39
+#define JH7110_SYSRST_DDR_APB                  40
+#define JH7110_SYSRST_ISP_TOP                  41
+#define JH7110_SYSRST_ISP_TOP_AXI              42
+#define JH7110_SYSRST_VOUT_TOP_SRC             43
+#define JH7110_SYSRST_CODAJ12_AXI              44
+#define JH7110_SYSRST_CODAJ12_CORE             45
+#define JH7110_SYSRST_CODAJ12_APB              46
+#define JH7110_SYSRST_WAVE511_AXI              47
+#define JH7110_SYSRST_WAVE511_BPU              48
+#define JH7110_SYSRST_WAVE511_VCE              49
+#define JH7110_SYSRST_WAVE511_APB              50
+#define JH7110_SYSRST_VDEC_JPG                 51
+#define JH7110_SYSRST_VDEC_MAIN                        52
+#define JH7110_SYSRST_AXIMEM0_AXI              53
+#define JH7110_SYSRST_WAVE420L_AXI             54
+#define JH7110_SYSRST_WAVE420L_BPU             55
+#define JH7110_SYSRST_WAVE420L_VCE             56
+#define JH7110_SYSRST_WAVE420L_APB             57
+#define JH7110_SYSRST_AXIMEM1_AXI              58
+#define JH7110_SYSRST_AXIMEM2_AXI              59
+#define JH7110_SYSRST_INTMEM                   60
+#define JH7110_SYSRST_QSPI_AHB                 61
+#define JH7110_SYSRST_QSPI_APB                 62
+#define JH7110_SYSRST_QSPI_REF                 63
+
+#define JH7110_SYSRST_SDIO0_AHB                        64
+#define JH7110_SYSRST_SDIO1_AHB                        65
+#define JH7110_SYSRST_GMAC1_AXI                        66
+#define JH7110_SYSRST_GMAC1_AHB                        67
+#define JH7110_SYSRST_MAILBOX_APB              68
+#define JH7110_SYSRST_SPI0_APB                 69
+#define JH7110_SYSRST_SPI1_APB                 70
+#define JH7110_SYSRST_SPI2_APB                 71
+#define JH7110_SYSRST_SPI3_APB                 72
+#define JH7110_SYSRST_SPI4_APB                 73
+#define JH7110_SYSRST_SPI5_APB                 74
+#define JH7110_SYSRST_SPI6_APB                 75
+#define JH7110_SYSRST_I2C0_APB                 76
+#define JH7110_SYSRST_I2C1_APB                 77
+#define JH7110_SYSRST_I2C2_APB                 78
+#define JH7110_SYSRST_I2C3_APB                 79
+#define JH7110_SYSRST_I2C4_APB                 80
+#define JH7110_SYSRST_I2C5_APB                 81
+#define JH7110_SYSRST_I2C6_APB                 82
+#define JH7110_SYSRST_UART0_APB                        83
+#define JH7110_SYSRST_UART0_CORE               84
+#define JH7110_SYSRST_UART1_APB                        85
+#define JH7110_SYSRST_UART1_CORE               86
+#define JH7110_SYSRST_UART2_APB                        87
+#define JH7110_SYSRST_UART2_CORE               88
+#define JH7110_SYSRST_UART3_APB                        89
+#define JH7110_SYSRST_UART3_CORE               90
+#define JH7110_SYSRST_UART4_APB                        91
+#define JH7110_SYSRST_UART4_CORE               92
+#define JH7110_SYSRST_UART5_APB                        93
+#define JH7110_SYSRST_UART5_CORE               94
+#define JH7110_SYSRST_SPDIF_APB                        95
+
+#define JH7110_SYSRST_PWMDAC_APB               96
+#define JH7110_SYSRST_PDM_DMIC                 97
+#define JH7110_SYSRST_PDM_APB                  98
+#define JH7110_SYSRST_I2SRX_APB                        99
+#define JH7110_SYSRST_I2SRX_BCLK               100
+#define JH7110_SYSRST_I2STX0_APB               101
+#define JH7110_SYSRST_I2STX0_BCLK              102
+#define JH7110_SYSRST_I2STX1_APB               103
+#define JH7110_SYSRST_I2STX1_BCLK              104
+#define JH7110_SYSRST_TDM_AHB                  105
+#define JH7110_SYSRST_TDM_CORE                 106
+#define JH7110_SYSRST_TDM_APB                  107
+#define JH7110_SYSRST_PWM_APB                  108
+#define JH7110_SYSRST_WDT_APB                  109
+#define JH7110_SYSRST_WDT_CORE                 110
+#define JH7110_SYSRST_CAN0_APB                 111
+#define JH7110_SYSRST_CAN0_CORE                        112
+#define JH7110_SYSRST_CAN0_TIMER               113
+#define JH7110_SYSRST_CAN1_APB                 114
+#define JH7110_SYSRST_CAN1_CORE                        115
+#define JH7110_SYSRST_CAN1_TIMER               116
+#define JH7110_SYSRST_TIMER_APB                        117
+#define JH7110_SYSRST_TIMER0                   118
+#define JH7110_SYSRST_TIMER1                   119
+#define JH7110_SYSRST_TIMER2                   120
+#define JH7110_SYSRST_TIMER3                   121
+#define JH7110_SYSRST_INT_CTRL_APB             122
+#define JH7110_SYSRST_TEMP_APB                 123
+#define JH7110_SYSRST_TEMP_CORE                        124
+#define JH7110_SYSRST_JTAG_CERTIFICATION       125
+
+#define JH7110_SYSRST_END                      126
+
+/* AONCRG resets */
+#define JH7110_AONRST_GMAC0_AXI                        0
+#define JH7110_AONRST_GMAC0_AHB                        1
+#define JH7110_AONRST_IOMUX                    2
+#define JH7110_AONRST_PMU_APB                  3
+#define JH7110_AONRST_PMU_WKUP                 4
+#define JH7110_AONRST_RTC_APB                  5
+#define JH7110_AONRST_RTC_CAL                  6
+#define JH7110_AONRST_RTC_32K                  7
+
+#define JH7110_AONRST_END                      8
+
+#endif /* __DT_BINDINGS_RESET_STARFIVE_JH7110_CRG_H__ */
index 842e72a5348fa3f571a1f1669af3c6c617ffe905..3f2ee3706ddad00cba954a70aeac5e08d582702d 100644 (file)
@@ -608,6 +608,25 @@ struct clk *clk_register_gate(struct device *dev, const char *name,
        __devm_clk_hw_register_gate((dev), NULL, (name), (parent_name), NULL, \
                               NULL, (flags), (reg), (bit_idx),               \
                               (clk_gate_flags), (lock))
+/**
+ * devm_clk_hw_register_gate_parent_data - register a gate clock with the
+ * clock framework
+ * @dev: device that is registering this clock
+ * @name: name of this clock
+ * @parent_data: parent clk data
+ * @flags: framework-specific flags for this clock
+ * @reg: register address to control gating of this clock
+ * @bit_idx: which bit in the register controls gating of this clock
+ * @clk_gate_flags: gate-specific flags for this clock
+ * @lock: shared register lock for this clock
+ */
+#define devm_clk_hw_register_gate_parent_data(dev, name, parent_data, flags,  \
+                                             reg, bit_idx, clk_gate_flags,   \
+                                             lock)                           \
+       __devm_clk_hw_register_gate((dev), NULL, (name), NULL, NULL,          \
+                                   (parent_data), (flags), (reg), (bit_idx), \
+                                   (clk_gate_flags), (lock))
+
 void clk_unregister_gate(struct clk *clk);
 void clk_hw_unregister_gate(struct clk_hw *hw);
 int clk_gate_is_enabled(struct clk_hw *hw);
@@ -1135,10 +1154,8 @@ struct clk_fractional_divider {
        void __iomem    *reg;
        u8              mshift;
        u8              mwidth;
-       u32             mmask;
        u8              nshift;
        u8              nwidth;
-       u32             nmask;
        u8              flags;
        void            (*approximation)(struct clk_hw *hw,
                                unsigned long rate, unsigned long *parent_rate,
index 8fbe76607965e9e3de8e948c8b923a086bbce763..d4901ca8883c33ea27b14d51dcd1d44cda53156d 100644 (file)
@@ -66,7 +66,7 @@ static inline void set_nr_cpu_ids(unsigned int nr)
  *
  * Finally, some operations just want the exact limit, either because
  * they set bits or just don't have any faster fixed-sized versions. We
- * call this just 'nr_cpumask_size'.
+ * call this just 'nr_cpumask_bits'.
  *
  * Note that these optional constants are always guaranteed to be at
  * least as big as 'nr_cpu_ids' itself is, and all our cpumask
@@ -147,7 +147,7 @@ static __always_inline void cpu_max_bits_warn(unsigned int cpu, unsigned int bit
 /* verify cpu argument to cpumask_* operators */
 static __always_inline unsigned int cpumask_check(unsigned int cpu)
 {
-       cpu_max_bits_warn(cpu, nr_cpumask_bits);
+       cpu_max_bits_warn(cpu, small_cpumask_bits);
        return cpu;
 }
 
@@ -518,14 +518,14 @@ static __always_inline bool cpumask_test_and_clear_cpu(int cpu, struct cpumask *
 /**
  * cpumask_setall - set all cpus (< nr_cpu_ids) in a cpumask
  * @dstp: the cpumask pointer
- *
- * Note: since we set bits, we should use the tighter 'bitmap_set()' with
- * the eact number of bits, not 'bitmap_fill()' that will fill past the
- * end.
  */
 static inline void cpumask_setall(struct cpumask *dstp)
 {
-       bitmap_set(cpumask_bits(dstp), 0, nr_cpumask_bits);
+       if (small_const_nbits(small_cpumask_bits)) {
+               cpumask_bits(dstp)[0] = BITMAP_LAST_WORD_MASK(nr_cpumask_bits);
+               return;
+       }
+       bitmap_fill(cpumask_bits(dstp), nr_cpumask_bits);
 }
 
 /**
index eaf8ab1773033214f59d556e4ab686300a51e8d1..1ea8c7a3570b2880aeb353d9707ad4f9a7df1ca4 100644 (file)
@@ -834,6 +834,7 @@ struct hid_driver {
  * @output_report: send output report to device
  * @idle: send idle request to device
  * @may_wakeup: return if device may act as a wakeup source during system-suspend
+ * @max_buffer_size: over-ride maximum data buffer size (default: HID_MAX_BUFFER_SIZE)
  */
 struct hid_ll_driver {
        int (*start)(struct hid_device *hdev);
@@ -859,6 +860,8 @@ struct hid_ll_driver {
 
        int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype);
        bool (*may_wakeup)(struct hid_device *hdev);
+
+       unsigned int max_buffer_size;
 };
 
 extern bool hid_is_usb(const struct hid_device *hdev);
index b06254e76d99af8fa4dddf59247b3b965802fe8b..8fc10089e19e8eba985cc335d21e2c0975379acf 100644 (file)
@@ -481,4 +481,10 @@ static inline void folio_zero_range(struct folio *folio,
        zero_user_segments(&folio->page, start, start + length, 0, 0);
 }
 
+static inline void put_and_unmap_page(struct page *page, void *addr)
+{
+       kunmap_local(addr);
+       put_page(page);
+}
+
 #endif /* _LINUX_HIGHMEM_H */
index 500404d85141dd5a1fee2f956eb22e4636eb9722..5ba89663ea8656fab46473920229a7a67935d1f8 100644 (file)
@@ -236,8 +236,8 @@ enum i2c_driver_flags {
 /**
  * struct i2c_driver - represent an I2C device driver
  * @class: What kind of i2c device we instantiate (for detect)
- * @probe: Callback for device binding - soon to be deprecated
- * @probe_new: New callback for device binding
+ * @probe: Callback for device binding
+ * @probe_new: Transitional callback for device binding - do not use
  * @remove: Callback for device unbinding
  * @shutdown: Callback for device shutdown
  * @alert: Alert callback, for example for the SMBus alert protocol
@@ -272,14 +272,18 @@ enum i2c_driver_flags {
 struct i2c_driver {
        unsigned int class;
 
+       union {
        /* Standard driver model interfaces */
-       int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
+               int (*probe)(struct i2c_client *client);
+               /*
+                * Legacy callback that was part of a conversion of .probe().
+                * Today it has the same semantic as .probe(). Don't use for new
+                * code.
+                */
+               int (*probe_new)(struct i2c_client *client);
+       };
        void (*remove)(struct i2c_client *client);
 
-       /* New driver model interface to aid the seamless removal of the
-        * current probe()'s, more commonly unused than used second parameter.
-        */
-       int (*probe_new)(struct i2c_client *client);
 
        /* driver model interfaces that don't relate to enumeration  */
        void (*shutdown)(struct i2c_client *client);
index 5962072a4b19e6e92de7f568dd4e5b8d666aad09..f619bae1dcc5d3a0ded86964f862d4310a289054 100644 (file)
@@ -1308,6 +1308,14 @@ struct journal_s
                                    struct buffer_head *bh,
                                    enum passtype pass, int off,
                                    tid_t expected_commit_id);
+
+       /**
+        * @j_bmap:
+        *
+        * Bmap function that should be used instead of the generic
+        * VFS bmap function.
+        */
+       int (*j_bmap)(struct journal_s *journal, sector_t *block);
 };
 
 #define jbd2_might_wait_for_commit(j) \
index 82d0e41b76f224f02a5b8fb3fec6d4c64721066a..faa108b1ba675ba89724b16ba3c16df2776aeb6b 100644 (file)
@@ -17,6 +17,13 @@ static inline bool nf_tproxy_sk_is_transparent(struct sock *sk)
        return false;
 }
 
+static inline void nf_tproxy_twsk_deschedule_put(struct inet_timewait_sock *tw)
+{
+       local_bh_disable();
+       inet_twsk_deschedule_put(tw);
+       local_bh_enable();
+}
+
 /* assign a socket to the skb -- consumes sk */
 static inline void nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk)
 {
diff --git a/include/soc/starfive/reset-starfive-jh71x0.h b/include/soc/starfive/reset-starfive-jh71x0.h
new file mode 100644 (file)
index 0000000..47b486e
--- /dev/null
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __SOC_STARFIVE_RESET_JH71X0_H
+#define __SOC_STARFIVE_RESET_JH71X0_H
+
+#include <linux/auxiliary_bus.h>
+#include <linux/compiler_types.h>
+#include <linux/container_of.h>
+
+struct jh71x0_reset_adev {
+       void __iomem *base;
+       struct auxiliary_device adev;
+};
+
+#define to_jh71x0_reset_adev(_adev) \
+       container_of((_adev), struct jh71x0_reset_adev, adev)
+
+#endif
index b4f0f9531119f2df1b9eb4f84ce3e5e19485822a..ada0a489bf2b69287416321e7dcf43144de68a0b 100644 (file)
@@ -245,7 +245,17 @@ struct btrfs_ioctl_dev_info_args {
        __u8 uuid[BTRFS_UUID_SIZE];             /* in/out */
        __u64 bytes_used;                       /* out */
        __u64 total_bytes;                      /* out */
-       __u64 unused[379];                      /* pad to 4k */
+       /*
+        * Optional, out.
+        *
+        * Showing the fsid of the device, allowing user space to check if this
+        * device is a seeding one.
+        *
+        * Introduced in v6.3, thus user space still needs to check if kernel
+        * changed this value.  Older kernel will not touch the values here.
+        */
+       __u8 fsid[BTRFS_UUID_SIZE];
+       __u64 unused[377];                      /* pad to 4k */
        __u8 path[BTRFS_DEVICE_PATH_NAME_MAX];  /* out */
 };
 
index 19ebbef41a63cbf824dd0dd61586f0bf06c020f0..5041c3598493874ce15b554d03e04df4f3c518d3 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause */
 /* Do not edit directly, auto-generated from: */
 /*     Documentation/netlink/specs/fou.yaml */
 /* YNL-GEN uapi header */
index 588391447bfb09d260448c5c63f8bd3ba0521a52..8c4e3e536c04285e155617cde126f2c4fce10e08 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause */
 /* Do not edit directly, auto-generated from: */
 /*     Documentation/netlink/specs/netdev.yaml */
 /* YNL-GEN uapi header */
index 411bb2d1acd452f6bb1af070dd338fd57fb6d3f7..f81c0a7136a5867b10cec91be62e0801b706560c 100644 (file)
@@ -616,7 +616,7 @@ static int io_wqe_worker(void *data)
        struct io_wqe_acct *acct = io_wqe_get_acct(worker);
        struct io_wqe *wqe = worker->wqe;
        struct io_wq *wq = wqe->wq;
-       bool last_timeout = false;
+       bool exit_mask = false, last_timeout = false;
        char buf[TASK_COMM_LEN];
 
        worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING);
@@ -632,8 +632,11 @@ static int io_wqe_worker(void *data)
                        io_worker_handle_work(worker);
 
                raw_spin_lock(&wqe->lock);
-               /* timed out, exit unless we're the last worker */
-               if (last_timeout && acct->nr_workers > 1) {
+               /*
+                * Last sleep timed out. Exit if we're not the last worker,
+                * or if someone modified our affinity.
+                */
+               if (last_timeout && (exit_mask || acct->nr_workers > 1)) {
                        acct->nr_workers--;
                        raw_spin_unlock(&wqe->lock);
                        __set_current_state(TASK_RUNNING);
@@ -652,7 +655,11 @@ static int io_wqe_worker(void *data)
                                continue;
                        break;
                }
-               last_timeout = !ret;
+               if (!ret) {
+                       last_timeout = true;
+                       exit_mask = !cpumask_test_cpu(raw_smp_processor_id(),
+                                                       wqe->cpu_mask);
+               }
        }
 
        if (test_bit(IO_WQ_BIT_EXIT, &wq->state))
@@ -704,7 +711,6 @@ static void io_init_new_worker(struct io_wqe *wqe, struct io_worker *worker,
        tsk->worker_private = worker;
        worker->task = tsk;
        set_cpus_allowed_ptr(tsk, wqe->cpu_mask);
-       tsk->flags |= PF_NO_SETAFFINITY;
 
        raw_spin_lock(&wqe->lock);
        hlist_nulls_add_head_rcu(&worker->nulls_node, &wqe->free_list);
index fd1cc35a1c00b67cc02fb8cf1f4421f933c43419..722624b6d0dcae61b64c3966260ddc3cae814616 100644 (file)
@@ -1499,14 +1499,14 @@ void io_free_batch_list(struct io_ring_ctx *ctx, struct io_wq_work_node *node)
 static void __io_submit_flush_completions(struct io_ring_ctx *ctx)
        __must_hold(&ctx->uring_lock)
 {
-       struct io_wq_work_node *node, *prev;
        struct io_submit_state *state = &ctx->submit_state;
+       struct io_wq_work_node *node;
 
        __io_cq_lock(ctx);
        /* must come first to preserve CQE ordering in failure cases */
        if (state->cqes_count)
                __io_flush_post_cqes(ctx);
-       wq_list_for_each(node, prev, &state->compl_reqs) {
+       __wq_list_for_each(node, &state->compl_reqs) {
                struct io_kiocb *req = container_of(node, struct io_kiocb,
                                            comp_list);
 
index 7c198a40d5f11d799e49441aefc9034cc71169f5..0eb194817242e5eb98e83077a195209a053e4eab 100644 (file)
@@ -3,6 +3,9 @@
 
 #include <linux/io_uring_types.h>
 
+#define __wq_list_for_each(pos, head)                          \
+       for (pos = (head)->first; pos; pos = (pos)->next)
+
 #define wq_list_for_each(pos, prv, head)                       \
        for (pos = (head)->first, prv = NULL; pos; prv = pos, pos = (pos)->next)
 
@@ -113,4 +116,4 @@ static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
        return container_of(work->list.next, struct io_wq_work, list);
 }
 
-#endif // INTERNAL_IO_SLIST_H
\ No newline at end of file
+#endif // INTERNAL_IO_SLIST_H
index 446a189b78b037ceb4b272ff02180ec9a3539f17..2e4c483075d331f70b2dafa11797e8f7c3fac757 100644 (file)
@@ -108,7 +108,7 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
        struct file *file = req->file;
        int ret;
 
-       if (!req->file->f_op->uring_cmd)
+       if (!file->f_op->uring_cmd)
                return -EOPNOTSUPP;
 
        ret = security_uring_cmd(ioucmd);
@@ -120,6 +120,8 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
        if (ctx->flags & IORING_SETUP_CQE32)
                issue_flags |= IO_URING_F_CQE32;
        if (ctx->flags & IORING_SETUP_IOPOLL) {
+               if (!file->f_op->uring_cmd_iopoll)
+                       return -EOPNOTSUPP;
                issue_flags |= IO_URING_F_IOPOLL;
                req->iopoll_completed = 0;
                WRITE_ONCE(ioucmd->cookie, NULL);
index fa22ec79ac0e1cea56932e64fdb4150770c6968c..73780748404c29bfd6b4d2284b2aff615093497f 100644 (file)
@@ -4569,6 +4569,7 @@ static int btf_datasec_resolve(struct btf_verifier_env *env,
        struct btf *btf = env->btf;
        u16 i;
 
+       env->resolve_mode = RESOLVE_TBD;
        for_each_vsi_from(i, v->next_member, v->t, vsi) {
                u32 var_type_id = vsi->type, type_id, type_size = 0;
                const struct btf_type *var_type = btf_type_by_id(env->btf,
index f68954d05e89dce1f7d430610322fff0a3a379f1..d8cda4c6de6c705051ffa2c14aa83a68c989da2f 100644 (file)
@@ -2936,7 +2936,7 @@ static bool clone3_args_valid(struct kernel_clone_args *kargs)
         * - make the CLONE_DETACHED bit reusable for clone3
         * - make the CSIGNAL bits reusable for clone3
         */
-       if (kargs->flags & (CLONE_DETACHED | CSIGNAL))
+       if (kargs->flags & (CLONE_DETACHED | (CSIGNAL & (~CLONE_NEWTIME))))
                return false;
 
        if ((kargs->flags & (CLONE_SIGHAND | CLONE_CLEAR_SIGHAND)) ==
index a6f9bdd956c39d2fabbb5932441965672c747aa2..f10f403104e7dcccaf8d702ed73d71d1e5ac9a35 100644 (file)
@@ -273,6 +273,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
        if (ret < 0)
                goto error;
 
+       ret = -ENOMEM;
        pages = kcalloc(sizeof(struct page *), nr_pages, GFP_KERNEL);
        if (!pages)
                goto error;
index 6f3d654b3339c0841d109ce0f3db1c98bd9365aa..f81b24320a36e139f71689075e87d2413cd54a89 100644 (file)
@@ -97,8 +97,11 @@ reset:
 struct xdp_page_head {
        struct xdp_buff orig_ctx;
        struct xdp_buff ctx;
-       struct xdp_frame frm;
-       u8 data[];
+       union {
+               /* ::data_hard_start starts here */
+               DECLARE_FLEX_ARRAY(struct xdp_frame, frame);
+               DECLARE_FLEX_ARRAY(u8, data);
+       };
 };
 
 struct xdp_test_data {
@@ -113,6 +116,10 @@ struct xdp_test_data {
        u32 frame_cnt;
 };
 
+/* tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c:%MAX_PKT_SIZE
+ * must be updated accordingly this gets changed, otherwise BPF selftests
+ * will fail.
+ */
 #define TEST_XDP_FRAME_SIZE (PAGE_SIZE - sizeof(struct xdp_page_head))
 #define TEST_XDP_MAX_BATCH 256
 
@@ -132,8 +139,8 @@ static void xdp_test_run_init_page(struct page *page, void *arg)
        headroom -= meta_len;
 
        new_ctx = &head->ctx;
-       frm = &head->frm;
-       data = &head->data;
+       frm = head->frame;
+       data = head->data;
        memcpy(data + headroom, orig_ctx->data_meta, frm_len);
 
        xdp_init_buff(new_ctx, TEST_XDP_FRAME_SIZE, &xdp->rxq);
@@ -223,7 +230,7 @@ static void reset_ctx(struct xdp_page_head *head)
        head->ctx.data = head->orig_ctx.data;
        head->ctx.data_meta = head->orig_ctx.data_meta;
        head->ctx.data_end = head->orig_ctx.data_end;
-       xdp_update_frame_from_buff(&head->ctx, &head->frm);
+       xdp_update_frame_from_buff(&head->ctx, head->frame);
 }
 
 static int xdp_recv_frames(struct xdp_frame **frames, int nframes,
@@ -285,7 +292,7 @@ static int xdp_test_run_batch(struct xdp_test_data *xdp, struct bpf_prog *prog,
                head = phys_to_virt(page_to_phys(page));
                reset_ctx(head);
                ctx = &head->ctx;
-               frm = &head->frm;
+               frm = head->frame;
                xdp->frame_cnt++;
 
                act = bpf_prog_run_xdp(prog, ctx);
index ebc202ffdd8d8d8fbb14e1009a86cbcad48094b4..bf61ea4b8132d0c625290e751dd4a5d850922abf 100644 (file)
@@ -134,6 +134,9 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what,
        struct usb_device *usbdev;
        int res;
 
+       if (what == NETDEV_UNREGISTER && dev->reg_state >= NETREG_UNREGISTERED)
+               return 0;
+
        /* Check whether we have a NCM device, and find its VID/PID. */
        if (!(dev->dev.parent && dev->dev.parent->driver &&
              strcmp(dev->dev.parent->driver->name, "cdc_ncm") == 0))
index 48812ec843f5533eff8e211230752d537e0737d8..9e10802587fc3c3057eda5c1786ac3f6fef7b9bb 100644 (file)
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: BSD-3-Clause
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /* Do not edit directly, auto-generated from: */
 /*     Documentation/netlink/specs/netdev.yaml */
 /* YNL-GEN kernel source */
index b16dc7e026bb13425d94f7500868090403b59213..2c5fc7d1e8a741e3ba2e7c3332ec4f436225c6d4 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /* Do not edit directly, auto-generated from: */
 /*     Documentation/netlink/specs/netdev.yaml */
 /* YNL-GEN kernel header */
index eb7d33b41e7107b07e4d8af7abf474b22255a9cd..1a31815104d617a66fee5e981131ceeffaa67128 100644 (file)
@@ -517,18 +517,16 @@ static void *kmalloc_reserve(unsigned int *size, gfp_t flags, int node,
 #ifdef HAVE_SKB_SMALL_HEAD_CACHE
        if (obj_size <= SKB_SMALL_HEAD_CACHE_SIZE &&
            !(flags & KMALLOC_NOT_NORMAL_BITS)) {
-
-               /* skb_small_head_cache has non power of two size,
-                * likely forcing SLUB to use order-3 pages.
-                * We deliberately attempt a NOMEMALLOC allocation only.
-                */
                obj = kmem_cache_alloc_node(skb_small_head_cache,
                                flags | __GFP_NOMEMALLOC | __GFP_NOWARN,
                                node);
-               if (obj) {
-                       *size = SKB_SMALL_HEAD_CACHE_SIZE;
+               *size = SKB_SMALL_HEAD_CACHE_SIZE;
+               if (obj || !(gfp_pfmemalloc_allowed(flags)))
                        goto out;
-               }
+               /* Try again but now we are using pfmemalloc reserves */
+               ret_pfmemalloc = true;
+               obj = kmem_cache_alloc_node(skb_small_head_cache, flags, node);
+               goto out;
        }
 #endif
        *size = obj_size = kmalloc_size_roundup(obj_size);
@@ -2082,6 +2080,7 @@ struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, unsigned int headroom)
 }
 EXPORT_SYMBOL(skb_realloc_headroom);
 
+/* Note: We plan to rework this in linux-6.4 */
 int __skb_unclone_keeptruesize(struct sk_buff *skb, gfp_t pri)
 {
        unsigned int saved_end_offset, saved_truesize;
@@ -2100,6 +2099,22 @@ int __skb_unclone_keeptruesize(struct sk_buff *skb, gfp_t pri)
        if (likely(skb_end_offset(skb) == saved_end_offset))
                return 0;
 
+#ifdef HAVE_SKB_SMALL_HEAD_CACHE
+       /* We can not change skb->end if the original or new value
+        * is SKB_SMALL_HEAD_HEADROOM, as it might break skb_kfree_head().
+        */
+       if (saved_end_offset == SKB_SMALL_HEAD_HEADROOM ||
+           skb_end_offset(skb) == SKB_SMALL_HEAD_HEADROOM) {
+               /* We think this path should not be taken.
+                * Add a temporary trace to warn us just in case.
+                */
+               pr_err_once("__skb_unclone_keeptruesize() skb_end_offset() %u -> %u\n",
+                           saved_end_offset, skb_end_offset(skb));
+               WARN_ON_ONCE(1);
+               return 0;
+       }
+#endif
+
        shinfo = skb_shinfo(skb);
 
        /* We are about to change back skb->end,
index 341c565dbc262fcece1c5b410609d910a68edcb0..c258887953905c340ad6deab8b66cbf45ecbf178 100644 (file)
@@ -2818,7 +2818,8 @@ static void sk_enter_memory_pressure(struct sock *sk)
 static void sk_leave_memory_pressure(struct sock *sk)
 {
        if (sk->sk_prot->leave_memory_pressure) {
-               sk->sk_prot->leave_memory_pressure(sk);
+               INDIRECT_CALL_INET_1(sk->sk_prot->leave_memory_pressure,
+                                    tcp_leave_memory_pressure, sk);
        } else {
                unsigned long *memory_pressure = sk->sk_prot->memory_pressure;
 
index 2215f576ee3788f74ea175b046d05d285bac752d..d8f4379d4fa68b5b07bb2c45cd74d4b73213c107 100644 (file)
@@ -1412,7 +1412,7 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info)
                return -EOPNOTSUPP;
        }
 
-       if (!nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) {
+       if (!info->attrs[NL802154_ATTR_SCAN_TYPE]) {
                NL_SET_ERR_MSG(info->extack, "Malformed request, missing scan type");
                return -EINVAL;
        }
index 6c3820f41dd5de44bae5f2d59b69639167998c58..5c14fe030eda555ebfc25e2e073b550ad40495ef 100644 (file)
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: BSD-3-Clause
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /* Do not edit directly, auto-generated from: */
 /*     Documentation/netlink/specs/fou.yaml */
 /* YNL-GEN kernel source */
index b7a68121ce6f79061e73462e02f706195d78988b..58b1e1ed4b3bb3cb6855c74b4c87f8d5876b7b07 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /* Do not edit directly, auto-generated from: */
 /*     Documentation/netlink/specs/fou.yaml */
 /* YNL-GEN kernel header */
index b22b2c745c76c317dad4f4d65d6c5ac48624d24d..69e331799604304078367011040b0dea69fcacf0 100644 (file)
@@ -38,7 +38,7 @@ nf_tproxy_handle_time_wait4(struct net *net, struct sk_buff *skb,
                                            hp->source, lport ? lport : hp->dest,
                                            skb->dev, NF_TPROXY_LOOKUP_LISTENER);
                if (sk2) {
-                       inet_twsk_deschedule_put(inet_twsk(sk));
+                       nf_tproxy_twsk_deschedule_put(inet_twsk(sk));
                        sk = sk2;
                }
        }
index cf26d65ca3893d5fc1b9c4fdc7d4e85316c1fc76..ebf91751193706ccec1bb9cfac48be28b5e28337 100644 (file)
@@ -186,6 +186,9 @@ static int tcp_bpf_recvmsg_parser(struct sock *sk,
        if (unlikely(flags & MSG_ERRQUEUE))
                return inet_recv_error(sk, msg, len, addr_len);
 
+       if (!len)
+               return 0;
+
        psock = sk_psock_get(sk);
        if (unlikely(!psock))
                return tcp_recvmsg(sk, msg, len, flags, addr_len);
@@ -244,6 +247,9 @@ static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
        if (unlikely(flags & MSG_ERRQUEUE))
                return inet_recv_error(sk, msg, len, addr_len);
 
+       if (!len)
+               return 0;
+
        psock = sk_psock_get(sk);
        if (unlikely(!psock))
                return tcp_recvmsg(sk, msg, len, flags, addr_len);
index e5dc91d0e0793ce6b203e0a6e4e0ffbd617b6820..0735d820e413f3002bb83fb011d998a9cad1b05c 100644 (file)
@@ -68,6 +68,9 @@ static int udp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
        if (unlikely(flags & MSG_ERRQUEUE))
                return inet_recv_error(sk, msg, len, addr_len);
 
+       if (!len)
+               return 0;
+
        psock = sk_psock_get(sk);
        if (unlikely(!psock))
                return sk_udp_recvmsg(sk, msg, len, flags, addr_len);
index 47447f0241df604bc657acbd9ce37008b49bacf0..bee45dfeb18741106fa517ef634fa09d25f0cea3 100644 (file)
@@ -477,6 +477,7 @@ int ila_xlat_nl_cmd_get_mapping(struct sk_buff *skb, struct genl_info *info)
 
        rcu_read_lock();
 
+       ret = -ESRCH;
        ila = ila_lookup_by_params(&xp, ilan);
        if (ila) {
                ret = ila_dump_info(ila,
index 929502e51203bc39232ab0e43f768fe5f72b7641..52f828bb5a83daee7b74674fb56b58d430eccff2 100644 (file)
@@ -63,7 +63,7 @@ nf_tproxy_handle_time_wait6(struct sk_buff *skb, int tproto, int thoff,
                                            lport ? lport : hp->dest,
                                            skb->dev, NF_TPROXY_LOOKUP_LISTENER);
                if (sk2) {
-                       inet_twsk_deschedule_put(inet_twsk(sk));
+                       nf_tproxy_twsk_deschedule_put(inet_twsk(sk));
                        sk = sk2;
                }
        }
index 7250082e7de56c77298b0d3b62c4f0dff95b77cc..c6a6a6099b4e2200951367ccd90c12c0ac800a6a 100644 (file)
@@ -96,8 +96,8 @@ static DEFINE_MUTEX(nf_conntrack_mutex);
 #define GC_SCAN_MAX_DURATION   msecs_to_jiffies(10)
 #define GC_SCAN_EXPIRED_MAX    (64000u / HZ)
 
-#define MIN_CHAINLEN   8u
-#define MAX_CHAINLEN   (32u - MIN_CHAINLEN)
+#define MIN_CHAINLEN   50u
+#define MAX_CHAINLEN   (80u - MIN_CHAINLEN)
 
 static struct conntrack_gc_work conntrack_gc_work;
 
index c11dff91d52d2795f72dbc628259275489b1b1a2..bfc3aaa2c872bda90476820c4e62366d9c4f2157 100644 (file)
@@ -328,11 +328,12 @@ nla_put_failure:
 }
 
 #ifdef CONFIG_NF_CONNTRACK_MARK
-static int ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct)
+static int ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct,
+                              bool dump)
 {
        u32 mark = READ_ONCE(ct->mark);
 
-       if (!mark)
+       if (!mark && !dump)
                return 0;
 
        if (nla_put_be32(skb, CTA_MARK, htonl(mark)))
@@ -343,7 +344,7 @@ nla_put_failure:
        return -1;
 }
 #else
-#define ctnetlink_dump_mark(a, b) (0)
+#define ctnetlink_dump_mark(a, b, c) (0)
 #endif
 
 #ifdef CONFIG_NF_CONNTRACK_SECMARK
@@ -548,7 +549,7 @@ static int ctnetlink_dump_extinfo(struct sk_buff *skb,
 static int ctnetlink_dump_info(struct sk_buff *skb, struct nf_conn *ct)
 {
        if (ctnetlink_dump_status(skb, ct) < 0 ||
-           ctnetlink_dump_mark(skb, ct) < 0 ||
+           ctnetlink_dump_mark(skb, ct, true) < 0 ||
            ctnetlink_dump_secctx(skb, ct) < 0 ||
            ctnetlink_dump_id(skb, ct) < 0 ||
            ctnetlink_dump_use(skb, ct) < 0 ||
@@ -831,8 +832,7 @@ ctnetlink_conntrack_event(unsigned int events, const struct nf_ct_event *item)
        }
 
 #ifdef CONFIG_NF_CONNTRACK_MARK
-       if (events & (1 << IPCT_MARK) &&
-           ctnetlink_dump_mark(skb, ct) < 0)
+       if (ctnetlink_dump_mark(skb, ct, events & (1 << IPCT_MARK)))
                goto nla_put_failure;
 #endif
        nlmsg_end(skb, nlh);
@@ -2735,7 +2735,7 @@ static int __ctnetlink_glue_build(struct sk_buff *skb, struct nf_conn *ct)
                goto nla_put_failure;
 
 #ifdef CONFIG_NF_CONNTRACK_MARK
-       if (ctnetlink_dump_mark(skb, ct) < 0)
+       if (ctnetlink_dump_mark(skb, ct, true) < 0)
                goto nla_put_failure;
 #endif
        if (ctnetlink_dump_labels(skb, ct) < 0)
index 7f2bda6641bd8a22566b7f2e910e87324cbecace..8e6d7eaf9dc8b5c783b1a7591ff21608e41dcdaf 100644 (file)
@@ -105,11 +105,15 @@ static void nft_last_destroy(const struct nft_ctx *ctx,
 static int nft_last_clone(struct nft_expr *dst, const struct nft_expr *src)
 {
        struct nft_last_priv *priv_dst = nft_expr_priv(dst);
+       struct nft_last_priv *priv_src = nft_expr_priv(src);
 
        priv_dst->last = kzalloc(sizeof(*priv_dst->last), GFP_ATOMIC);
        if (!priv_dst->last)
                return -ENOMEM;
 
+       priv_dst->last->set = priv_src->last->set;
+       priv_dst->last->jiffies = priv_src->last->jiffies;
+
        return 0;
 }
 
index 123578e289179cd053bc48e02fbd83a07c8dcf13..3ba12a7471b0f6210947cd09db9f582012f3d8c5 100644 (file)
@@ -236,12 +236,16 @@ static void nft_quota_destroy(const struct nft_ctx *ctx,
 static int nft_quota_clone(struct nft_expr *dst, const struct nft_expr *src)
 {
        struct nft_quota *priv_dst = nft_expr_priv(dst);
+       struct nft_quota *priv_src = nft_expr_priv(src);
+
+       priv_dst->quota = priv_src->quota;
+       priv_dst->flags = priv_src->flags;
 
        priv_dst->consumed = kmalloc(sizeof(*priv_dst->consumed), GFP_ATOMIC);
        if (!priv_dst->consumed)
                return -ENOMEM;
 
-       atomic64_set(priv_dst->consumed, 0);
+       *priv_dst->consumed = *priv_src->consumed;
 
        return 0;
 }
index 348bf561bc9fb0502dcfc340fd7079d469a6a449..b9264e730fd931f4b3861ae88a2aabe52061e94e 100644 (file)
@@ -1446,8 +1446,8 @@ static int nfc_se_io(struct nfc_dev *dev, u32 se_idx,
        return rc;
 
 error:
-       kfree(cb_context);
        device_unlock(&dev->dev);
+       kfree(cb_context);
        return rc;
 }
 
index 8dabfb52ea3db383e5172ab07e18792fa3d91341..0d7aee8933c5ffdc5acdb78138a9725ef63824f5 100644 (file)
@@ -158,6 +158,9 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla,
                nparms->zone = parm->zone;
 
                ret = 0;
+       } else {
+               err = ret;
+               goto out_free;
        }
 
        err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack);
index e960a46b05205bb0bca7dc0d21531e4d6a3853e3..475fe222a85566639bac75fc4a95bf649a10357d 100644 (file)
@@ -2200,8 +2200,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
                fnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]);
 
                if (!tc_flags_valid(fnew->flags)) {
+                       kfree(fnew);
                        err = -EINVAL;
-                       goto errout;
+                       goto errout_tb;
                }
        }
 
@@ -2226,8 +2227,10 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
                }
                spin_unlock(&tp->lock);
 
-               if (err)
-                       goto errout;
+               if (err) {
+                       kfree(fnew);
+                       goto errout_tb;
+               }
        }
        fnew->handle = handle;
 
@@ -2337,7 +2340,6 @@ errout_mask:
        fl_mask_put(head, fnew->mask);
 errout_idr:
        idr_remove(&head->handle_idr, fnew->handle);
-errout:
        __fl_put(fnew);
 errout_tb:
        kfree(tb);
index a4cccdfdc00a242ba2334f06404e6cd663bd91de..ff6dd86bdc9f3f504426f0d3f91424f14d77b689 100644 (file)
@@ -2657,16 +2657,14 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 {
        struct sock *sk = sock->sk;
        struct smc_sock *smc;
-       int rc = -EPIPE;
+       int rc;
 
        smc = smc_sk(sk);
        lock_sock(sk);
-       if ((sk->sk_state != SMC_ACTIVE) &&
-           (sk->sk_state != SMC_APPCLOSEWAIT1) &&
-           (sk->sk_state != SMC_INIT))
-               goto out;
 
+       /* SMC does not support connect with fastopen */
        if (msg->msg_flags & MSG_FASTOPEN) {
+               /* not connected yet, fallback */
                if (sk->sk_state == SMC_INIT && !smc->connect_nonblock) {
                        rc = smc_switch_to_fallback(smc, SMC_CLC_DECL_OPTUNSUPP);
                        if (rc)
@@ -2675,6 +2673,11 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
                        rc = -EINVAL;
                        goto out;
                }
+       } else if ((sk->sk_state != SMC_ACTIVE) &&
+                  (sk->sk_state != SMC_APPCLOSEWAIT1) &&
+                  (sk->sk_state != SMC_INIT)) {
+               rc = -EPIPE;
+               goto out;
        }
 
        if (smc->use_fallback) {
index 6bae8ce7059ee97a8e8cee3fa5726bf6ae0b6e86..9c92c0e6c4da8c54f4878172f17f1d1be757f706 100644 (file)
@@ -450,7 +450,9 @@ static struct file_system_type sock_fs_type = {
  *
  *     Returns the &file bound with @sock, implicitly storing it
  *     in sock->file. If dname is %NULL, sets to "".
- *     On failure the return is a ERR pointer (see linux/err.h).
+ *
+ *     On failure @sock is released, and an ERR pointer is returned.
+ *
  *     This function uses GFP_KERNEL internally.
  */
 
@@ -1638,7 +1640,6 @@ static struct socket *__sys_socket_create(int family, int type, int protocol)
 struct file *__sys_socket_file(int family, int type, int protocol)
 {
        struct socket *sock;
-       struct file *file;
        int flags;
 
        sock = __sys_socket_create(family, type, protocol);
@@ -1649,11 +1650,7 @@ struct file *__sys_socket_file(int family, int type, int protocol)
        if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
                flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
 
-       file = sock_alloc_file(sock, flags, NULL);
-       if (IS_ERR(file))
-               sock_release(sock);
-
-       return file;
+       return sock_alloc_file(sock, flags, NULL);
 }
 
 int __sys_socket(int family, int type, int protocol)
index 1fd3f5e572854750575fc0ee0a714b5b3ecca33b..fea7ce8fba14e4a54e2d49fcbd163da110b0ec26 100644 (file)
@@ -798,6 +798,7 @@ svc_start_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
 static int
 svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
 {
+       struct svc_rqst *rqstp;
        struct task_struct *task;
        unsigned int state = serv->sv_nrthreads-1;
 
@@ -806,7 +807,10 @@ svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
                task = choose_victim(serv, pool, &state);
                if (task == NULL)
                        break;
-               kthread_stop(task);
+               rqstp = kthread_data(task);
+               /* Did we lose a race to svo_function threadfn? */
+               if (kthread_stop(task) == -EINTR)
+                       svc_exit_thread(rqstp);
                nrservs++;
        } while (nrservs < 0);
        return 0;
index 6c593788dc250682cabedcf37332e75ee3b6ce66..a7cc4f9faac28ce10d3088570d2a44f5bef9a8e1 100644 (file)
@@ -508,6 +508,8 @@ handle_error:
                        zc_pfrag.offset = iter_offset.offset;
                        zc_pfrag.size = copy;
                        tls_append_frag(record, &zc_pfrag, copy);
+
+                       iter_offset.offset += copy;
                } else if (copy) {
                        copy = min_t(size_t, copy, pfrag->size - pfrag->offset);
 
index 3735cb00905dfc7b0a12343308c4fae72f1bb839..b32c112984dd9567fd9d07cc6850f234c1914a43 100644 (file)
@@ -405,13 +405,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
                        rc = -EINVAL;
                        goto out;
                }
-               lock_sock(sk);
                memcpy(crypto_info_aes_gcm_128->iv,
                       cctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE,
                       TLS_CIPHER_AES_GCM_128_IV_SIZE);
                memcpy(crypto_info_aes_gcm_128->rec_seq, cctx->rec_seq,
                       TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE);
-               release_sock(sk);
                if (copy_to_user(optval,
                                 crypto_info_aes_gcm_128,
                                 sizeof(*crypto_info_aes_gcm_128)))
@@ -429,13 +427,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
                        rc = -EINVAL;
                        goto out;
                }
-               lock_sock(sk);
                memcpy(crypto_info_aes_gcm_256->iv,
                       cctx->iv + TLS_CIPHER_AES_GCM_256_SALT_SIZE,
                       TLS_CIPHER_AES_GCM_256_IV_SIZE);
                memcpy(crypto_info_aes_gcm_256->rec_seq, cctx->rec_seq,
                       TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE);
-               release_sock(sk);
                if (copy_to_user(optval,
                                 crypto_info_aes_gcm_256,
                                 sizeof(*crypto_info_aes_gcm_256)))
@@ -451,13 +447,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
                        rc = -EINVAL;
                        goto out;
                }
-               lock_sock(sk);
                memcpy(aes_ccm_128->iv,
                       cctx->iv + TLS_CIPHER_AES_CCM_128_SALT_SIZE,
                       TLS_CIPHER_AES_CCM_128_IV_SIZE);
                memcpy(aes_ccm_128->rec_seq, cctx->rec_seq,
                       TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE);
-               release_sock(sk);
                if (copy_to_user(optval, aes_ccm_128, sizeof(*aes_ccm_128)))
                        rc = -EFAULT;
                break;
@@ -472,13 +466,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
                        rc = -EINVAL;
                        goto out;
                }
-               lock_sock(sk);
                memcpy(chacha20_poly1305->iv,
                       cctx->iv + TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE,
                       TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE);
                memcpy(chacha20_poly1305->rec_seq, cctx->rec_seq,
                       TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE);
-               release_sock(sk);
                if (copy_to_user(optval, chacha20_poly1305,
                                sizeof(*chacha20_poly1305)))
                        rc = -EFAULT;
@@ -493,13 +485,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
                        rc = -EINVAL;
                        goto out;
                }
-               lock_sock(sk);
                memcpy(sm4_gcm_info->iv,
                       cctx->iv + TLS_CIPHER_SM4_GCM_SALT_SIZE,
                       TLS_CIPHER_SM4_GCM_IV_SIZE);
                memcpy(sm4_gcm_info->rec_seq, cctx->rec_seq,
                       TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE);
-               release_sock(sk);
                if (copy_to_user(optval, sm4_gcm_info, sizeof(*sm4_gcm_info)))
                        rc = -EFAULT;
                break;
@@ -513,13 +503,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
                        rc = -EINVAL;
                        goto out;
                }
-               lock_sock(sk);
                memcpy(sm4_ccm_info->iv,
                       cctx->iv + TLS_CIPHER_SM4_CCM_SALT_SIZE,
                       TLS_CIPHER_SM4_CCM_IV_SIZE);
                memcpy(sm4_ccm_info->rec_seq, cctx->rec_seq,
                       TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE);
-               release_sock(sk);
                if (copy_to_user(optval, sm4_ccm_info, sizeof(*sm4_ccm_info)))
                        rc = -EFAULT;
                break;
@@ -535,13 +523,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
                        rc = -EINVAL;
                        goto out;
                }
-               lock_sock(sk);
                memcpy(crypto_info_aria_gcm_128->iv,
                       cctx->iv + TLS_CIPHER_ARIA_GCM_128_SALT_SIZE,
                       TLS_CIPHER_ARIA_GCM_128_IV_SIZE);
                memcpy(crypto_info_aria_gcm_128->rec_seq, cctx->rec_seq,
                       TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE);
-               release_sock(sk);
                if (copy_to_user(optval,
                                 crypto_info_aria_gcm_128,
                                 sizeof(*crypto_info_aria_gcm_128)))
@@ -559,13 +545,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
                        rc = -EINVAL;
                        goto out;
                }
-               lock_sock(sk);
                memcpy(crypto_info_aria_gcm_256->iv,
                       cctx->iv + TLS_CIPHER_ARIA_GCM_256_SALT_SIZE,
                       TLS_CIPHER_ARIA_GCM_256_IV_SIZE);
                memcpy(crypto_info_aria_gcm_256->rec_seq, cctx->rec_seq,
                       TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE);
-               release_sock(sk);
                if (copy_to_user(optval,
                                 crypto_info_aria_gcm_256,
                                 sizeof(*crypto_info_aria_gcm_256)))
@@ -614,11 +598,9 @@ static int do_tls_getsockopt_no_pad(struct sock *sk, char __user *optval,
        if (len < sizeof(value))
                return -EINVAL;
 
-       lock_sock(sk);
        value = -EINVAL;
        if (ctx->rx_conf == TLS_SW || ctx->rx_conf == TLS_HW)
                value = ctx->rx_no_pad;
-       release_sock(sk);
        if (value < 0)
                return value;
 
@@ -635,6 +617,8 @@ static int do_tls_getsockopt(struct sock *sk, int optname,
 {
        int rc = 0;
 
+       lock_sock(sk);
+
        switch (optname) {
        case TLS_TX:
        case TLS_RX:
@@ -651,6 +635,9 @@ static int do_tls_getsockopt(struct sock *sk, int optname,
                rc = -ENOPROTOOPT;
                break;
        }
+
+       release_sock(sk);
+
        return rc;
 }
 
index 782d3701b86f45802d564a91a47e2aaeed5396ba..635b8bf6b937c1d362c62a527d9656c11e97df6b 100644 (file)
@@ -956,7 +956,9 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
                               MSG_CMSG_COMPAT))
                return -EOPNOTSUPP;
 
-       mutex_lock(&tls_ctx->tx_lock);
+       ret = mutex_lock_interruptible(&tls_ctx->tx_lock);
+       if (ret)
+               return ret;
        lock_sock(sk);
 
        if (unlikely(msg->msg_controllen)) {
@@ -1290,7 +1292,9 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
                      MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY))
                return -EOPNOTSUPP;
 
-       mutex_lock(&tls_ctx->tx_lock);
+       ret = mutex_lock_interruptible(&tls_ctx->tx_lock);
+       if (ret)
+               return ret;
        lock_sock(sk);
        ret = tls_sw_do_sendpage(sk, page, offset, size, flags);
        release_sock(sk);
@@ -2127,7 +2131,7 @@ recv_end:
                else
                        err = process_rx_list(ctx, msg, &control, 0,
                                              async_copy_bytes, is_peek);
-               decrypted = max(err, 0);
+               decrypted += max(err, 0);
        }
 
        copied += decrypted;
@@ -2435,11 +2439,19 @@ static void tx_work_handler(struct work_struct *work)
 
        if (!test_and_clear_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask))
                return;
-       mutex_lock(&tls_ctx->tx_lock);
-       lock_sock(sk);
-       tls_tx_records(sk, -1);
-       release_sock(sk);
-       mutex_unlock(&tls_ctx->tx_lock);
+
+       if (mutex_trylock(&tls_ctx->tx_lock)) {
+               lock_sock(sk);
+               tls_tx_records(sk, -1);
+               release_sock(sk);
+               mutex_unlock(&tls_ctx->tx_lock);
+       } else if (!test_and_set_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask)) {
+               /* Someone is holding the tx_lock, they will likely run Tx
+                * and cancel the work on their way out of the lock section.
+                * Schedule a long delay just in case.
+                */
+               schedule_delayed_work(&ctx->tx_work.work, msecs_to_jiffies(10));
+       }
 }
 
 static bool tls_is_tx_ready(struct tls_sw_context_tx *ctx)
index 347122c3575eaae597405369e2e9d8324d6ad240..0b0f18ecce4470d6fd21c084a3ea49e04dcbb9bd 100644 (file)
@@ -2105,7 +2105,8 @@ out:
 #define UNIX_SKB_FRAGS_SZ (PAGE_SIZE << get_order(32768))
 
 #if IS_ENABLED(CONFIG_AF_UNIX_OOB)
-static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other)
+static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other,
+                    struct scm_cookie *scm, bool fds_sent)
 {
        struct unix_sock *ousk = unix_sk(other);
        struct sk_buff *skb;
@@ -2116,6 +2117,11 @@ static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other
        if (!skb)
                return err;
 
+       err = unix_scm_to_skb(scm, skb, !fds_sent);
+       if (err < 0) {
+               kfree_skb(skb);
+               return err;
+       }
        skb_put(skb, 1);
        err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, 1);
 
@@ -2243,7 +2249,7 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
 
 #if IS_ENABLED(CONFIG_AF_UNIX_OOB)
        if (msg->msg_flags & MSG_OOB) {
-               err = queue_oob(sock, msg, other);
+               err = queue_oob(sock, msg, other, &scm, fds_sent);
                if (err)
                        goto out_err;
                sent++;
index e9bf155139612d84b0f52de487210ff916ea9b22..2f9d8271c6ec7df2007267d3905703c6c9686d10 100644 (file)
@@ -54,6 +54,9 @@ static int unix_bpf_recvmsg(struct sock *sk, struct msghdr *msg,
        struct sk_psock *psock;
        int copied;
 
+       if (!len)
+               return 0;
+
        psock = sk_psock_get(sk);
        if (unlikely(!psock))
                return __unix_recvmsg(sk, msg, len, flags);
index 28ce13840a8891397d8a42988edb5e64a6eecf4f..7bdeb8eea92dcf7cbbe0c35a8501e9627ddc3256 100644 (file)
@@ -1500,8 +1500,6 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev,
                connect->key = NULL;
                connect->key_len = 0;
                connect->key_idx = 0;
-               connect->crypto.cipher_group = 0;
-               connect->crypto.n_ciphers_pairwise = 0;
        }
 
        wdev->connect_keys = connkeys;
index a7a857f1784d80d6264eeebecbeb371c7d13ba5b..f8129c624b0709815cbd266d569bb12fb70e6047 100644 (file)
@@ -109,6 +109,7 @@ struct kvm_regs {
 #define KVM_ARM_VCPU_SVE               4 /* enable SVE for this CPU */
 #define KVM_ARM_VCPU_PTRAUTH_ADDRESS   5 /* VCPU uses address authentication */
 #define KVM_ARM_VCPU_PTRAUTH_GENERIC   6 /* VCPU uses generic authentication */
+#define KVM_ARM_VCPU_HAS_EL2           7 /* Support nested virtualization */
 
 struct kvm_vcpu_init {
        __u32 target;
index b70111a75688a794586e12ac3db3deeeb4a948b4..b89005819cd551a9cc983fde516a9a060137ad84 100644 (file)
@@ -13,7 +13,7 @@
 /*
  * Defines x86 CPU feature bits
  */
-#define NCAPINTS                       20         /* N 32-bit words worth of info */
+#define NCAPINTS                       21         /* N 32-bit words worth of info */
 #define NBUGINTS                       1          /* N 32-bit bug flags */
 
 /*
index c44b56f7ffba0d0e4bf881c035a3a3668be9929e..5dfa4fb76f4b2ba025b4c4e45b9e4846b75128c6 100644 (file)
 #define DISABLED_MASK17        0
 #define DISABLED_MASK18        0
 #define DISABLED_MASK19        0
-#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)
+#define DISABLED_MASK20        0
+#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)
 
 #endif /* _ASM_X86_DISABLED_FEATURES_H */
index 37ff47552bcb7b57fdc75bc0246f2bb3876add4a..ad35355ee43ead14e638ac5c853fd5a82b8ee774 100644 (file)
@@ -25,6 +25,7 @@
 #define _EFER_SVME             12 /* Enable virtualization */
 #define _EFER_LMSLE            13 /* Long Mode Segment Limit Enable */
 #define _EFER_FFXSR            14 /* Enable Fast FXSAVE/FXRSTOR */
+#define _EFER_AUTOIBRS         21 /* Enable Automatic IBRS */
 
 #define EFER_SCE               (1<<_EFER_SCE)
 #define EFER_LME               (1<<_EFER_LME)
@@ -33,6 +34,7 @@
 #define EFER_SVME              (1<<_EFER_SVME)
 #define EFER_LMSLE             (1<<_EFER_LMSLE)
 #define EFER_FFXSR             (1<<_EFER_FFXSR)
+#define EFER_AUTOIBRS          (1<<_EFER_AUTOIBRS)
 
 /* Intel MSRs. Some also available on other CPUs */
 
 #define SPEC_CTRL_RRSBA_DIS_S_SHIFT    6          /* Disable RRSBA behavior */
 #define SPEC_CTRL_RRSBA_DIS_S          BIT(SPEC_CTRL_RRSBA_DIS_S_SHIFT)
 
+/* A mask for bits which the kernel toggles when controlling mitigations */
+#define SPEC_CTRL_MITIGATIONS_MASK     (SPEC_CTRL_IBRS | SPEC_CTRL_STIBP | SPEC_CTRL_SSBD \
+                                                       | SPEC_CTRL_RRSBA_DIS_S)
+
 #define MSR_IA32_PRED_CMD              0x00000049 /* Prediction Command */
 #define PRED_CMD_IBPB                  BIT(0)     /* Indirect Branch Prediction Barrier */
 
 #define MSR_TURBO_RATIO_LIMIT1         0x000001ae
 #define MSR_TURBO_RATIO_LIMIT2         0x000001af
 
+#define MSR_SNOOP_RSP_0                        0x00001328
+#define MSR_SNOOP_RSP_1                        0x00001329
+
 #define MSR_LBR_SELECT                 0x000001c8
 #define MSR_LBR_TOS                    0x000001c9
 
 #define MSR_AMD64_SEV_ES_ENABLED       BIT_ULL(MSR_AMD64_SEV_ES_ENABLED_BIT)
 #define MSR_AMD64_SEV_SNP_ENABLED      BIT_ULL(MSR_AMD64_SEV_SNP_ENABLED_BIT)
 
+/* SNP feature bits enabled by the hypervisor */
+#define MSR_AMD64_SNP_VTOM                     BIT_ULL(3)
+#define MSR_AMD64_SNP_REFLECT_VC               BIT_ULL(4)
+#define MSR_AMD64_SNP_RESTRICTED_INJ           BIT_ULL(5)
+#define MSR_AMD64_SNP_ALT_INJ                  BIT_ULL(6)
+#define MSR_AMD64_SNP_DEBUG_SWAP               BIT_ULL(7)
+#define MSR_AMD64_SNP_PREVENT_HOST_IBS         BIT_ULL(8)
+#define MSR_AMD64_SNP_BTB_ISOLATION            BIT_ULL(9)
+#define MSR_AMD64_SNP_VMPL_SSS                 BIT_ULL(10)
+#define MSR_AMD64_SNP_SECURE_TSC               BIT_ULL(11)
+#define MSR_AMD64_SNP_VMGEXIT_PARAM            BIT_ULL(12)
+#define MSR_AMD64_SNP_IBS_VIRT                 BIT_ULL(14)
+#define MSR_AMD64_SNP_VMSA_REG_PROTECTION      BIT_ULL(16)
+#define MSR_AMD64_SNP_SMT_PROTECTION           BIT_ULL(17)
+
+/* SNP feature bits reserved for future use. */
+#define MSR_AMD64_SNP_RESERVED_BIT13           BIT_ULL(13)
+#define MSR_AMD64_SNP_RESERVED_BIT15           BIT_ULL(15)
+#define MSR_AMD64_SNP_RESERVED_MASK            GENMASK_ULL(63, 18)
+
 #define MSR_AMD64_VIRT_SPEC_CTRL       0xc001011f
 
 /* AMD Collaborative Processor Performance Control MSRs */
 
 /* - AMD: */
 #define MSR_IA32_MBA_BW_BASE           0xc0000200
+#define MSR_IA32_SMBA_BW_BASE          0xc0000280
+#define MSR_IA32_EVT_CFG_BASE          0xc0000400
 
 /* MSR_IA32_VMX_MISC bits */
 #define MSR_IA32_VMX_MISC_INTEL_PT                 (1ULL << 14)
index aff774775c678434e2b20218d0873676f5b4a39b..7ba1726b71c7b8bfc95888dc78508998bba263fe 100644 (file)
@@ -98,6 +98,7 @@
 #define REQUIRED_MASK17        0
 #define REQUIRED_MASK18        0
 #define REQUIRED_MASK19        0
-#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)
+#define REQUIRED_MASK20        0
+#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)
 
 #endif /* _ASM_X86_REQUIRED_FEATURES_H */
index e48deab8901d4ecb9fddaaf334247e27fb6c1762..7f467fe05d42ea702d45679bc8ce27d18656b124 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/types.h>
 #include <linux/ioctl.h>
+#include <linux/stddef.h>
 
 #define KVM_PIO_PAGE_OFFSET 1
 #define KVM_COALESCED_MMIO_PAGE_OFFSET 2
@@ -507,8 +508,8 @@ struct kvm_nested_state {
         * KVM_{GET,PUT}_NESTED_STATE ioctl values.
         */
        union {
-               struct kvm_vmx_nested_state_data vmx[0];
-               struct kvm_svm_nested_state_data svm[0];
+               __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx);
+               __DECLARE_FLEX_ARRAY(struct kvm_svm_nested_state_data, svm);
        } data;
 };
 
@@ -525,6 +526,35 @@ struct kvm_pmu_event_filter {
 #define KVM_PMU_EVENT_ALLOW 0
 #define KVM_PMU_EVENT_DENY 1
 
+#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0)
+#define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS)
+
+/*
+ * Masked event layout.
+ * Bits   Description
+ * ----   -----------
+ * 7:0    event select (low bits)
+ * 15:8   umask match
+ * 31:16  unused
+ * 35:32  event select (high bits)
+ * 36:54  unused
+ * 55     exclude bit
+ * 63:56  umask mask
+ */
+
+#define KVM_PMU_ENCODE_MASKED_ENTRY(event_select, mask, match, exclude) \
+       (((event_select) & 0xFFULL) | (((event_select) & 0XF00ULL) << 24) | \
+       (((mask) & 0xFFULL) << 56) | \
+       (((match) & 0xFFULL) << 8) | \
+       ((__u64)(!!(exclude)) << 55))
+
+#define KVM_PMU_MASKED_ENTRY_EVENT_SELECT \
+       (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32))
+#define KVM_PMU_MASKED_ENTRY_UMASK_MASK                (GENMASK_ULL(63, 56))
+#define KVM_PMU_MASKED_ENTRY_UMASK_MATCH       (GENMASK_ULL(15, 8))
+#define KVM_PMU_MASKED_ENTRY_EXCLUDE           (BIT_ULL(55))
+#define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT  (56)
+
 /* for KVM_{GET,SET,HAS}_DEVICE_ATTR */
 #define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp counter (TSC) */
 #define   KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */
index f69c168391aa58cf280ba6fb5aca6630e3593d1a..80e1df482337dfe064d809966a309cecd0930070 100644 (file)
 #define SVM_VMGEXIT_AP_CREATE                  1
 #define SVM_VMGEXIT_AP_DESTROY                 2
 #define SVM_VMGEXIT_HV_FEATURES                        0x8000fffd
+#define SVM_VMGEXIT_TERM_REQUEST               0x8000fffe
+#define SVM_VMGEXIT_TERM_REASON(reason_set, reason_code)       \
+       /* SW_EXITINFO1[3:0] */                                 \
+       (((((u64)reason_set) & 0xf)) |                          \
+       /* SW_EXITINFO1[11:4] */                                \
+       ((((u64)reason_code) & 0xff) << 4))
 #define SVM_VMGEXIT_UNSUPPORTED_EVENT          0x8000ffff
 
 /* Exit code reserved for hypervisor/software use */
index 5418e2f99834e5dec0bd2f12d801da4d7b10d77a..a91ac666f758274c3f1ebf411cdf3469d69b93d2 100644 (file)
@@ -7,7 +7,7 @@
 #include <asm/alternative.h>
 #include <asm/export.h>
 
-.pushsection .noinstr.text, "ax"
+.section .noinstr.text, "ax"
 
 /*
  * We build a jump to memcpy_orig by default which gets NOPped out on
@@ -42,7 +42,7 @@ SYM_TYPED_FUNC_START(__memcpy)
 SYM_FUNC_END(__memcpy)
 EXPORT_SYMBOL(__memcpy)
 
-SYM_FUNC_ALIAS_WEAK(memcpy, __memcpy)
+SYM_FUNC_ALIAS(memcpy, __memcpy)
 EXPORT_SYMBOL(memcpy)
 
 /*
@@ -183,4 +183,3 @@ SYM_FUNC_START_LOCAL(memcpy_orig)
        RET
 SYM_FUNC_END(memcpy_orig)
 
-.popsection
index fc9ffd3ff3b213a38448d5fbff5493989e21a158..6143b1a6fa2caa0d5977d22c3f1c23456ff6d3bf 100644 (file)
@@ -6,6 +6,8 @@
 #include <asm/alternative.h>
 #include <asm/export.h>
 
+.section .noinstr.text, "ax"
+
 /*
  * ISO C memset - set a memory block to a byte value. This function uses fast
  * string to get better performance than the original function. The code is
@@ -43,7 +45,7 @@ SYM_FUNC_START(__memset)
 SYM_FUNC_END(__memset)
 EXPORT_SYMBOL(__memset)
 
-SYM_FUNC_ALIAS_WEAK(memset, __memset)
+SYM_FUNC_ALIAS(memset, __memset)
 EXPORT_SYMBOL(memset)
 
 /*
index 87d112650dfbb0ec9ac6825ae2746c61b2659960..7c0cf5031abe8796fc40c7307ddfde4832f2655d 100644 (file)
@@ -6,7 +6,6 @@
 #include <vdso/bits.h>
 #include <asm/bitsperlong.h>
 
-#define BIT_ULL(nr)            (ULL(1) << (nr))
 #define BIT_MASK(nr)           (UL(1) << ((nr) % BITS_PER_LONG))
 #define BIT_WORD(nr)           ((nr) / BITS_PER_LONG)
 #define BIT_ULL_MASK(nr)       (ULL(1) << ((nr) % BITS_PER_LONG_LONG))
index 2f86b2ad6d7e9d6bd7478c369dc301899a37a791..e8c07da58c9f20ed3b7b4aa886f964d335fa41d2 100644 (file)
@@ -43,6 +43,7 @@
 #define F_SEAL_GROW    0x0004  /* prevent file from growing */
 #define F_SEAL_WRITE   0x0008  /* prevent writes */
 #define F_SEAL_FUTURE_WRITE    0x0010  /* prevent future writes while mapped */
+#define F_SEAL_EXEC    0x0020  /* prevent chmod modifying exec bits */
 /* (1U << 31) is reserved for signed error codes */
 
 /*
index 55155e262646e5fc48b6317054b07b1c15aad02a..d77aef872a0a07e767b2bddad095a250a9da1e65 100644 (file)
@@ -583,6 +583,8 @@ struct kvm_s390_mem_op {
                struct {
                        __u8 ar;        /* the access register number */
                        __u8 key;       /* access key, ignored if flag unset */
+                       __u8 pad1[6];   /* ignored */
+                       __u64 old_addr; /* ignored if cmpxchg flag unset */
                };
                __u32 sida_offset; /* offset into the sida */
                __u8 reserved[32]; /* ignored */
@@ -595,11 +597,17 @@ struct kvm_s390_mem_op {
 #define KVM_S390_MEMOP_SIDA_WRITE      3
 #define KVM_S390_MEMOP_ABSOLUTE_READ   4
 #define KVM_S390_MEMOP_ABSOLUTE_WRITE  5
+#define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG        6
+
 /* flags for kvm_s390_mem_op->flags */
 #define KVM_S390_MEMOP_F_CHECK_ONLY            (1ULL << 0)
 #define KVM_S390_MEMOP_F_INJECT_EXCEPTION      (1ULL << 1)
 #define KVM_S390_MEMOP_F_SKEY_PROTECTION       (1ULL << 2)
 
+/* flags specifying extension support via KVM_CAP_S390_MEM_OP_EXTENSION */
+#define KVM_S390_MEMOP_EXTENSION_CAP_BASE      (1 << 0)
+#define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG   (1 << 1)
+
 /* for KVM_INTERRUPT */
 struct kvm_interrupt {
        /* in */
@@ -1175,6 +1183,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223
 #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224
 #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225
+#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
index 588391447bfb09d260448c5c63f8bd3ba0521a52..8c4e3e536c04285e155617cde126f2c4fce10e08 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause */
 /* Do not edit directly, auto-generated from: */
 /*     Documentation/netlink/specs/netdev.yaml */
 /* YNL-GEN uapi header */
index ccb7f5dad59be96b2cba0011717759ff8e67c640..37675437b76860ae4c3bef6a35e0eded9c25d55b 100644 (file)
@@ -374,6 +374,7 @@ enum perf_event_read_format {
 #define PERF_ATTR_SIZE_VER5    112     /* add: aux_watermark */
 #define PERF_ATTR_SIZE_VER6    120     /* add: aux_sample_size */
 #define PERF_ATTR_SIZE_VER7    128     /* add: sig_data */
+#define PERF_ATTR_SIZE_VER8    136     /* add: config3 */
 
 /*
  * Hardware event_id to monitor via a performance monitoring event:
@@ -515,6 +516,8 @@ struct perf_event_attr {
         * truncated accordingly on 32 bit architectures.
         */
        __u64   sig_data;
+
+       __u64   config3; /* extension of config2 */
 };
 
 /*
index a5e06dcbba136d618c6dcf61f0cbb6e3bfe9ea2c..1312a137f7fb85e1b042139f7762b3bb9775fa8e 100644 (file)
@@ -281,6 +281,12 @@ struct prctl_mm_map {
 # define PR_SME_VL_LEN_MASK            0xffff
 # define PR_SME_VL_INHERIT             (1 << 17) /* inherit across exec */
 
+/* Memory deny write / execute */
+#define PR_SET_MDWE                    65
+# define PR_MDWE_REFUSE_EXEC_GAIN      1
+
+#define PR_GET_MDWE                    66
+
 #define PR_SET_VMA             0x53564d41
 # define PR_SET_VMA_ANON_NAME          0
 
index f9f115a7c75b8a3060f0678599e7662d0015b878..92e1b700b51cbdf66aed6b3d17bc32688cd4706b 100644 (file)
  */
 #define VHOST_VDPA_SUSPEND             _IO(VHOST_VIRTIO, 0x7D)
 
+/* Resume a device so it can resume processing virtqueue requests
+ *
+ * After the return of this ioctl the device will have restored all the
+ * necessary states and it is fully operational to continue processing the
+ * virtqueue descriptors.
+ */
+#define VHOST_VDPA_RESUME              _IO(VHOST_VIRTIO, 0x7E)
+
 #endif
index 6d005a1f5d9425d5a2cf2199271f55bb32bcc87c..388b212088ea6a38383918d9d46b82321b11c3d3 100644 (file)
@@ -5,5 +5,6 @@
 #include <vdso/const.h>
 
 #define BIT(nr)                        (UL(1) << (nr))
+#define BIT_ULL(nr)            (ULL(1) << (nr))
 
 #endif /* __VDSO_BITS_H */
index db410b74d5395cb63e5094eafdaffc54552912cb..ffaa8038aa8c66d18af3933ece7f7ad695a0632a 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 
 import argparse
 import json
index 3c73f59eabab987ac0a72f004aad354866645db8..4b3797fe784bad06c42d21cfedcb5428ac2e61ae 100644 (file)
@@ -1,7 +1,8 @@
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 
-from .nlspec import SpecAttr, SpecAttrSet, SpecFamily, SpecOperation
+from .nlspec import SpecAttr, SpecAttrSet, SpecEnumEntry, SpecEnumSet, \
+    SpecFamily, SpecOperation
 from .ynl import YnlFamily
 
-__all__ = ["SpecAttr", "SpecAttrSet", "SpecFamily", "SpecOperation",
-           "YnlFamily"]
+__all__ = ["SpecAttr", "SpecAttrSet", "SpecEnumEntry", "SpecEnumSet",
+           "SpecFamily", "SpecOperation", "YnlFamily"]
index 71da568e2c28f7b8b0497b3993541370b1f2467e..a34d088f67432187c0d5b0e457788081d1ba5f95 100644 (file)
@@ -1,4 +1,4 @@
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 
 import collections
 import importlib
@@ -57,6 +57,94 @@ class SpecElement:
         pass
 
 
+class SpecEnumEntry(SpecElement):
+    """ Entry within an enum declared in the Netlink spec.
+
+    Attributes:
+        doc         documentation string
+        enum_set    back reference to the enum
+        value       numerical value of this enum (use accessors in most situations!)
+
+    Methods:
+        raw_value   raw value, i.e. the id in the enum, unlike user value which is a mask for flags
+        user_value   user value, same as raw value for enums, for flags it's the mask
+    """
+    def __init__(self, enum_set, yaml, prev, value_start):
+        if isinstance(yaml, str):
+            yaml = {'name': yaml}
+        super().__init__(enum_set.family, yaml)
+
+        self.doc = yaml.get('doc', '')
+        self.enum_set = enum_set
+
+        if 'value' in yaml:
+            self.value = yaml['value']
+        elif prev:
+            self.value = prev.value + 1
+        else:
+            self.value = value_start
+
+    def has_doc(self):
+        return bool(self.doc)
+
+    def raw_value(self):
+        return self.value
+
+    def user_value(self):
+        if self.enum_set['type'] == 'flags':
+            return 1 << self.value
+        else:
+            return self.value
+
+
+class SpecEnumSet(SpecElement):
+    """ Enum type
+
+    Represents an enumeration (list of numerical constants)
+    as declared in the "definitions" section of the spec.
+
+    Attributes:
+        type            enum or flags
+        entries         entries by name
+        entries_by_val  entries by value
+    Methods:
+        get_mask      for flags compute the mask of all defined values
+    """
+    def __init__(self, family, yaml):
+        super().__init__(family, yaml)
+
+        self.type = yaml['type']
+
+        prev_entry = None
+        value_start = self.yaml.get('value-start', 0)
+        self.entries = dict()
+        self.entries_by_val = dict()
+        for entry in self.yaml['entries']:
+            e = self.new_entry(entry, prev_entry, value_start)
+            self.entries[e.name] = e
+            self.entries_by_val[e.raw_value()] = e
+            prev_entry = e
+
+    def new_entry(self, entry, prev_entry, value_start):
+        return SpecEnumEntry(self, entry, prev_entry, value_start)
+
+    def has_doc(self):
+        if 'doc' in self.yaml:
+            return True
+        for entry in self.entries.values():
+            if entry.has_doc():
+                return True
+        return False
+
+    def get_mask(self):
+        mask = 0
+        idx = self.yaml.get('value-start', 0)
+        for _ in self.entries.values():
+            mask |= 1 << idx
+            idx += 1
+        return mask
+
+
 class SpecAttr(SpecElement):
     """ Single Netlink atttribute type
 
@@ -95,15 +183,22 @@ class SpecAttrSet(SpecElement):
         self.attrs = collections.OrderedDict()
         self.attrs_by_val = collections.OrderedDict()
 
-        val = 0
-        for elem in self.yaml['attributes']:
-            if 'value' in elem:
-                val = elem['value']
+        if self.subset_of is None:
+            val = 1
+            for elem in self.yaml['attributes']:
+                if 'value' in elem:
+                    val = elem['value']
 
-            attr = self.new_attr(elem, val)
-            self.attrs[attr.name] = attr
-            self.attrs_by_val[attr.value] = attr
-            val += 1
+                attr = self.new_attr(elem, val)
+                self.attrs[attr.name] = attr
+                self.attrs_by_val[attr.value] = attr
+                val += 1
+        else:
+            real_set = family.attr_sets[self.subset_of]
+            for elem in self.yaml['attributes']:
+                attr = real_set[elem['name']]
+                self.attrs[attr.name] = attr
+                self.attrs_by_val[attr.value] = attr
 
     def new_attr(self, elem, value):
         return SpecAttr(self.family, self, elem, value)
@@ -186,6 +281,7 @@ class SpecFamily(SpecElement):
         msgs       dict of all messages (index by name)
         msgs_by_value  dict of all messages (indexed by name)
         ops        dict of all valid requests / responses
+        consts     dict of all constants/enums
     """
     def __init__(self, spec_path, schema_path=None):
         with open(spec_path, "r") as stream:
@@ -215,6 +311,7 @@ class SpecFamily(SpecElement):
         self.req_by_value = collections.OrderedDict()
         self.rsp_by_value = collections.OrderedDict()
         self.ops = collections.OrderedDict()
+        self.consts = collections.OrderedDict()
 
         last_exception = None
         while len(self._resolution_list) > 0:
@@ -235,6 +332,9 @@ class SpecFamily(SpecElement):
             if len(resolved) == 0:
                 raise last_exception
 
+    def new_enum(self, elem):
+        return SpecEnumSet(self, elem)
+
     def new_attr_set(self, elem):
         return SpecAttrSet(self, elem)
 
@@ -245,7 +345,7 @@ class SpecFamily(SpecElement):
         self._resolution_list.append(elem)
 
     def _dictify_ops_unified(self):
-        val = 0
+        val = 1
         for elem in self.yaml['operations']['list']:
             if 'value' in elem:
                 val = elem['value']
@@ -256,7 +356,7 @@ class SpecFamily(SpecElement):
             self.msgs[op.name] = op
 
     def _dictify_ops_directional(self):
-        req_val = rsp_val = 0
+        req_val = rsp_val = 1
         for elem in self.yaml['operations']['list']:
             if 'notify' in elem:
                 if 'value' in elem:
@@ -289,6 +389,12 @@ class SpecFamily(SpecElement):
     def resolve(self):
         self.resolve_up(super())
 
+        for elem in self.yaml['definitions']:
+            if elem['type'] == 'enum' or elem['type'] == 'flags':
+                self.consts[elem['name']] = self.new_enum(elem)
+            else:
+                self.consts[elem['name']] = elem
+
         for elem in self.yaml['attribute-sets']:
             attr_set = self.new_attr_set(elem)
             self.attr_sets[elem['name']] = attr_set
index 1c7411ee04dc875c7924fa83bba784239b62ff97..90764a83c6461118d6dd9aeff19d16224bf87f9a 100644 (file)
@@ -1,4 +1,4 @@
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 
 import functools
 import os
@@ -303,11 +303,6 @@ class YnlFamily(SpecFamily):
         self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_CAP_ACK, 1)
         self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_EXT_ACK, 1)
 
-        self._types = dict()
-
-        for elem in self.yaml.get('definitions', []):
-            self._types[elem['name']] = elem
-
         self.async_msg_ids = set()
         self.async_msg_queue = []
 
@@ -353,13 +348,13 @@ class YnlFamily(SpecFamily):
 
     def _decode_enum(self, rsp, attr_spec):
         raw = rsp[attr_spec['name']]
-        enum = self._types[attr_spec['enum']]
+        enum = self.consts[attr_spec['enum']]
         i = attr_spec.get('value-start', 0)
         if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']:
             value = set()
             while raw:
                 if raw & 1:
-                    value.add(enum['entries'][i])
+                    value.add(enum.entries_by_val[i].name)
                 raw >>= 1
                 i += 1
         else:
index 274e9c566f61b09d093958d1d4fd89b8c9b17905..1bcc5354d8000725b52eeea7d77c8710afcf08c6 100755 (executable)
@@ -1,11 +1,12 @@
 #!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 
 import argparse
 import collections
 import os
 import yaml
 
-from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation
+from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, SpecEnumEntry
 
 
 def c_upper(name):
@@ -566,97 +567,37 @@ class Struct:
         self.inherited = [c_lower(x) for x in sorted(self._inherited)]
 
 
-class EnumEntry:
+class EnumEntry(SpecEnumEntry):
     def __init__(self, enum_set, yaml, prev, value_start):
-        if isinstance(yaml, str):
-            self.name = yaml
-            yaml = {}
-            self.doc = ''
-        else:
-            self.name = yaml['name']
-            self.doc = yaml.get('doc', '')
-
-        self.yaml = yaml
-        self.enum_set = enum_set
-        self.c_name = c_upper(enum_set.value_pfx + self.name)
-
-        if 'value' in yaml:
-            self.value = yaml['value']
-            if prev:
-                self.value_change = (self.value != prev.value + 1)
-        elif prev:
-            self.value_change = False
-            self.value = prev.value + 1
+        super().__init__(enum_set, yaml, prev, value_start)
+
+        if prev:
+            self.value_change = (self.value != prev.value + 1)
         else:
-            self.value = value_start
             self.value_change = (self.value != 0)
-
         self.value_change = self.value_change or self.enum_set['type'] == 'flags'
 
-    def __getitem__(self, key):
-        return self.yaml[key]
-
-    def __contains__(self, key):
-        return key in self.yaml
-
-    def has_doc(self):
-        return bool(self.doc)
+        # Added by resolve:
+        self.c_name = None
+        delattr(self, "c_name")
 
-    # raw value, i.e. the id in the enum, unlike user value which is a mask for flags
-    def raw_value(self):
-        return self.value
+    def resolve(self):
+        self.resolve_up(super())
 
-    # user value, same as raw value for enums, for flags it's the mask
-    def user_value(self):
-        if self.enum_set['type'] == 'flags':
-            return 1 << self.value
-        else:
-            return self.value
+        self.c_name = c_upper(self.enum_set.value_pfx + self.name)
 
 
-class EnumSet:
+class EnumSet(SpecEnumSet):
     def __init__(self, family, yaml):
-        self.yaml = yaml
-        self.family = family
-
         self.render_name = c_lower(family.name + '-' + yaml['name'])
         self.enum_name = 'enum ' + self.render_name
 
         self.value_pfx = yaml.get('name-prefix', f"{family.name}-{yaml['name']}-")
 
-        self.type = yaml['type']
-
-        prev_entry = None
-        value_start = self.yaml.get('value-start', 0)
-        self.entries = {}
-        self.entry_list = []
-        for entry in self.yaml['entries']:
-            e = EnumEntry(self, entry, prev_entry, value_start)
-            self.entries[e.name] = e
-            self.entry_list.append(e)
-            prev_entry = e
-
-    def __getitem__(self, key):
-        return self.yaml[key]
-
-    def __contains__(self, key):
-        return key in self.yaml
-
-    def has_doc(self):
-        if 'doc' in self.yaml:
-            return True
-        for entry in self.entry_list:
-            if entry.has_doc():
-                return True
-        return False
+        super().__init__(family, yaml)
 
-    def get_mask(self):
-        mask = 0
-        idx = self.yaml.get('value-start', 0)
-        for _ in self.entry_list:
-            mask |= 1 << idx
-            idx += 1
-        return mask
+    def new_entry(self, entry, prev_entry, value_start):
+        return EnumEntry(self, entry, prev_entry, value_start)
 
 
 class AttrSet(SpecAttrSet):
@@ -791,8 +732,6 @@ class Family(SpecFamily):
 
         self.mcgrps = self.yaml.get('mcast-groups', {'list': []})
 
-        self.consts = dict()
-
         self.hooks = dict()
         for when in ['pre', 'post']:
             self.hooks[when] = dict()
@@ -819,6 +758,9 @@ class Family(SpecFamily):
         if self.kernel_policy == 'global':
             self._load_global_policy()
 
+    def new_enum(self, elem):
+        return EnumSet(self, elem)
+
     def new_attr_set(self, elem):
         return AttrSet(self, elem)
 
@@ -836,12 +778,6 @@ class Family(SpecFamily):
                 }
 
     def _dictify(self):
-        for elem in self.yaml['definitions']:
-            if elem['type'] == 'enum' or elem['type'] == 'flags':
-                self.consts[elem['name']] = EnumSet(self, elem)
-            else:
-                self.consts[elem['name']] = elem
-
         ntf = []
         for msg in self.msgs.values():
             if 'notify' in msg:
@@ -1979,7 +1915,7 @@ def render_uapi(family, cw):
                 if 'doc' in enum:
                     doc = ' - ' + enum['doc']
                 cw.write_doc_line(enum.enum_name + doc)
-                for entry in enum.entry_list:
+                for entry in enum.entries.values():
                     if entry.has_doc():
                         doc = '@' + entry.c_name + ': ' + entry['doc']
                         cw.write_doc_line(doc)
@@ -1987,7 +1923,7 @@ def render_uapi(family, cw):
 
             uapi_enum_start(family, cw, const, 'name')
             name_pfx = const.get('name-prefix', f"{family.name}-{const['name']}-")
-            for entry in enum.entry_list:
+            for entry in enum.entries.values():
                 suffix = ','
                 if entry.value_change:
                     suffix = f" = {entry.user_value()}" + suffix
@@ -2044,14 +1980,17 @@ def render_uapi(family, cw):
     max_value = f"({cnt_name} - 1)"
 
     uapi_enum_start(family, cw, family['operations'], 'enum-name')
+    val = 0
     for op in family.msgs.values():
         if separate_ntf and ('notify' in op or 'event' in op):
             continue
 
         suffix = ','
-        if 'value' in op:
-            suffix = f" = {op['value']},"
+        if op.value != val:
+            suffix = f" = {op.value},"
+            val = op.value
         cw.p(op.enum_name + suffix)
+        val += 1
     cw.nl()
     cw.p(cnt_name + ('' if max_by_define else ','))
     if not max_by_define:
@@ -2124,12 +2063,12 @@ def main():
 
     _, spec_kernel = find_kernel_root(args.spec)
     if args.mode == 'uapi':
-        cw.p('/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */')
+        cw.p('/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause */')
     else:
         if args.header:
-            cw.p('/* SPDX-License-Identifier: BSD-3-Clause */')
+            cw.p('/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */')
         else:
-            cw.p('// SPDX-License-Identifier: BSD-3-Clause')
+            cw.p('// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause')
     cw.p("/* Do not edit directly, auto-generated from: */")
     cw.p(f"/*\t{spec_kernel} */")
     cw.p(f"/* YNL-GEN {args.mode} {'header' if args.header else 'source'} */")
index 43989ae48ed05634aa63480c94ad9967c182c36a..74f5de1c239944020e1a76555da542d20a11c2bc 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 
 TOOL=$(dirname $(realpath $0))/ynl-gen-c.py
 
index f8182417b7341d2c4eb99ca618bffe338cb717d7..10bb1d494258dcbc5b95de71f86ad4bf814c8e47 100644 (file)
@@ -538,6 +538,7 @@ static int perf_event__repipe_buildid_mmap2(struct perf_tool *tool,
                        dso->hit = 1;
                }
                dso__put(dso);
+               perf_event__repipe(tool, event, sample, machine);
                return 0;
        }
 
index 5d18a5a6f662481a40697aceae9e47de5f4477b3..fa7c40956d0fa957c95b8755db61d83e0ee1cc4b 100644 (file)
@@ -539,12 +539,7 @@ static int enable_counters(void)
                        return err;
        }
 
-       /*
-        * We need to enable counters only if:
-        * - we don't have tracee (attaching to task or cpu)
-        * - we have initial delay configured
-        */
-       if (!target__none(&target)) {
+       if (!target__enable_on_exec(&target)) {
                if (!all_counters_use_bpf)
                        evlist__enable(evsel_list);
        }
@@ -914,7 +909,7 @@ try_again_reset:
                        return err;
        }
 
-       if (stat_config.initial_delay) {
+       if (target.initial_delay) {
                pr_info(EVLIST_DISABLED_MSG);
        } else {
                err = enable_counters();
@@ -926,8 +921,8 @@ try_again_reset:
        if (forks)
                evlist__start_workload(evsel_list);
 
-       if (stat_config.initial_delay > 0) {
-               usleep(stat_config.initial_delay * USEC_PER_MSEC);
+       if (target.initial_delay > 0) {
+               usleep(target.initial_delay * USEC_PER_MSEC);
                err = enable_counters();
                if (err)
                        return -1;
@@ -1248,7 +1243,7 @@ static struct option stat_options[] = {
                     "aggregate counts per thread", AGGR_THREAD),
        OPT_SET_UINT(0, "per-node", &stat_config.aggr_mode,
                     "aggregate counts per numa node", AGGR_NODE),
-       OPT_INTEGER('D', "delay", &stat_config.initial_delay,
+       OPT_INTEGER('D', "delay", &target.initial_delay,
                    "ms to wait before starting measurement after program start (-1: start with events disabled)"),
        OPT_CALLBACK_NOOPT(0, "metric-only", &stat_config.metric_only, NULL,
                        "Only print computed metrics. No raw values", enable_metric_only),
index d90f8d102eb99eeb2a8a8ce8af3269a35907e889..97598d14e532354826c37186e5f55a3f4ef35ffa 100644 (file)
@@ -40,19 +40,6 @@ def is_counter_value(num):
   return isfloat(num) or num == '<not counted>' or num == '<not supported>'
 
 def check_json_output(expected_items):
-  if expected_items != -1:
-    for line in Lines:
-      if 'failed' not in line:
-        count = 0
-        count = line.count(',')
-        if count != expected_items and count >= 1 and count <= 3 and 'metric-value' in line:
-          # Events that generate >1 metric may have isolated metric
-          # values and possibly other prefixes like interval, core and
-          # aggregate-number.
-          continue
-        if count != expected_items:
-          raise RuntimeError(f'wrong number of fields. counted {count} expected {expected_items}'
-                             f' in \'{line}\'')
   checks = {
       'aggregate-number': lambda x: isfloat(x),
       'core': lambda x: True,
@@ -73,6 +60,16 @@ def check_json_output(expected_items):
   }
   input = '[\n' + ','.join(Lines) + '\n]'
   for item in json.loads(input):
+    if expected_items != -1:
+      count = len(item)
+      if count != expected_items and count >= 1 and count <= 4 and 'metric-value' in item:
+        # Events that generate >1 metric may have isolated metric
+        # values and possibly other prefixes like interval, core and
+        # aggregate-number.
+        pass
+      elif count != expected_items:
+        raise RuntimeError(f'wrong number of fields. counted {count} expected {expected_items}'
+                           f' in \'{item}\'')
     for key, value in item.items():
       if key not in checks:
         raise RuntimeError(f'Unexpected key: key={key} value={value}')
@@ -82,11 +79,11 @@ def check_json_output(expected_items):
 
 try:
   if args.no_args or args.system_wide or args.event:
-    expected_items = 6
-  elif args.interval or args.per_thread or args.system_wide_no_aggr:
     expected_items = 7
-  elif args.per_core or args.per_socket or args.per_node or args.per_die:
+  elif args.interval or args.per_thread or args.system_wide_no_aggr:
     expected_items = 8
+  elif args.per_core or args.per_socket or args.per_node or args.per_die:
+    expected_items = 9
   else:
     # If no option is specified, don't check the number of items.
     expected_items = -1
index b7f050aa6210c92177c7a80a9b2bbf3e08fd2f4f..324fc9e6edd79c91c5a5f4e71ac52b90f475fcd2 100755 (executable)
@@ -7,6 +7,7 @@
 set -e
 
 skip_test=0
+csv_sep=@
 
 function commachecker()
 {
@@ -34,7 +35,7 @@ function commachecker()
                [ "$x" = "Failed" ] && continue
 
                # Count the number of commas
-               x=$(echo $line | tr -d -c ',')
+               x=$(echo $line | tr -d -c $csv_sep)
                cnt="${#x}"
                # echo $line $cnt
                [[ ! "$cnt" =~ $exp ]] && {
@@ -54,7 +55,7 @@ function ParanoidAndNotRoot()
 check_no_args()
 {
        echo -n "Checking CSV output: no args "
-       perf stat -x, true 2>&1 | commachecker --no-args
+       perf stat -x$csv_sep true 2>&1 | commachecker --no-args
        echo "[Success]"
 }
 
@@ -66,7 +67,7 @@ check_system_wide()
                echo "[Skip] paranoid and not root"
                return
        fi
-       perf stat -x, -a true 2>&1 | commachecker --system-wide
+       perf stat -x$csv_sep -a true 2>&1 | commachecker --system-wide
        echo "[Success]"
 }
 
@@ -79,14 +80,14 @@ check_system_wide_no_aggr()
                return
        fi
        echo -n "Checking CSV output: system wide no aggregation "
-       perf stat -x, -A -a --no-merge true 2>&1 | commachecker --system-wide-no-aggr
+       perf stat -x$csv_sep -A -a --no-merge true 2>&1 | commachecker --system-wide-no-aggr
        echo "[Success]"
 }
 
 check_interval()
 {
        echo -n "Checking CSV output: interval "
-       perf stat -x, -I 1000 true 2>&1 | commachecker --interval
+       perf stat -x$csv_sep -I 1000 true 2>&1 | commachecker --interval
        echo "[Success]"
 }
 
@@ -94,7 +95,7 @@ check_interval()
 check_event()
 {
        echo -n "Checking CSV output: event "
-       perf stat -x, -e cpu-clock true 2>&1 | commachecker --event
+       perf stat -x$csv_sep -e cpu-clock true 2>&1 | commachecker --event
        echo "[Success]"
 }
 
@@ -106,7 +107,7 @@ check_per_core()
                echo "[Skip] paranoid and not root"
                return
        fi
-       perf stat -x, --per-core -a true 2>&1 | commachecker --per-core
+       perf stat -x$csv_sep --per-core -a true 2>&1 | commachecker --per-core
        echo "[Success]"
 }
 
@@ -118,7 +119,7 @@ check_per_thread()
                echo "[Skip] paranoid and not root"
                return
        fi
-       perf stat -x, --per-thread -a true 2>&1 | commachecker --per-thread
+       perf stat -x$csv_sep --per-thread -a true 2>&1 | commachecker --per-thread
        echo "[Success]"
 }
 
@@ -130,7 +131,7 @@ check_per_die()
                echo "[Skip] paranoid and not root"
                return
        fi
-       perf stat -x, --per-die -a true 2>&1 | commachecker --per-die
+       perf stat -x$csv_sep --per-die -a true 2>&1 | commachecker --per-die
        echo "[Success]"
 }
 
@@ -142,7 +143,7 @@ check_per_node()
                echo "[Skip] paranoid and not root"
                return
        fi
-       perf stat -x, --per-node -a true 2>&1 | commachecker --per-node
+       perf stat -x$csv_sep --per-node -a true 2>&1 | commachecker --per-node
        echo "[Success]"
 }
 
@@ -154,7 +155,7 @@ check_per_socket()
                echo "[Skip] paranoid and not root"
                return
        fi
-       perf stat -x, --per-socket -a true 2>&1 | commachecker --per-socket
+       perf stat -x$csv_sep --per-socket -a true 2>&1 | commachecker --per-socket
        echo "[Success]"
 }
 
index 38e3b287dbb225885f24d31acebff75d24e5dab1..d877a0a9731f9f2fd6295cc3ef75c6320c697af0 100644 (file)
@@ -277,7 +277,7 @@ int on_switch(u64 *ctx)
        else
                prev_state = get_task_state(prev);
 
-       return off_cpu_stat(ctx, prev, next, prev_state);
+       return off_cpu_stat(ctx, prev, next, prev_state & 0xff);
 }
 
 char LICENSE[] SEC("license") = "Dual BSD/GPL";
index 534d36d26fc38a5ae9c94ce917e581eb6fd6e856..a07473703c6dd65fe2f8ba1295704aa45d6dd4ae 100644 (file)
@@ -842,11 +842,7 @@ int create_perf_stat_counter(struct evsel *evsel,
        if (evsel__is_group_leader(evsel)) {
                attr->disabled = 1;
 
-               /*
-                * In case of initial_delay we enable tracee
-                * events manually.
-                */
-               if (target__none(target) && !config->initial_delay)
+               if (target__enable_on_exec(target))
                        attr->enable_on_exec = 1;
        }
 
index b1c29156c560f83304d75e947df441235519d701..bf1794ebc916d56d25de420d811cd33e01141545 100644 (file)
@@ -166,7 +166,6 @@ struct perf_stat_config {
        FILE                    *output;
        unsigned int             interval;
        unsigned int             timeout;
-       int                      initial_delay;
        unsigned int             unit_width;
        unsigned int             metric_only_len;
        int                      times;
index daec6cba500d4ecb1ee5e3dc739f612df055e60f..880f1af7f6ad6ac220077c5157035f3f918b4205 100644 (file)
@@ -18,6 +18,7 @@ struct target {
        bool         per_thread;
        bool         use_bpf;
        bool         hybrid;
+       int          initial_delay;
        const char   *attr_map;
 };
 
@@ -72,6 +73,17 @@ static inline bool target__none(struct target *target)
        return !target__has_task(target) && !target__has_cpu(target);
 }
 
+static inline bool target__enable_on_exec(struct target *target)
+{
+       /*
+        * Normally enable_on_exec should be set if:
+        *  1) The tracee process is forked (not attaching to existed task or cpu).
+        *  2) And initial_delay is not configured.
+        * Otherwise, we enable tracee events manually.
+        */
+       return target__none(target) && !target->initial_delay;
+}
+
 static inline bool target__has_per_thread(struct target *target)
 {
        return target->system_wide && target->per_thread;
index cbb600be943d338a3c36f699d4698ee8f8b30222..210d643fda6c7b6d4eadc02e64fed0498dc0b5ee 100644 (file)
@@ -879,6 +879,34 @@ static struct btf_raw_test raw_tests[] = {
        .btf_load_err = true,
        .err_str = "Invalid elem",
 },
+{
+       .descr = "var after datasec, ptr followed by modifier",
+       .raw_types = {
+               /* .bss section */                              /* [1] */
+               BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 2),
+                       sizeof(void*)+4),
+               BTF_VAR_SECINFO_ENC(4, 0, sizeof(void*)),
+               BTF_VAR_SECINFO_ENC(6, sizeof(void*), 4),
+               /* int */                                       /* [2] */
+               BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
+               /* int* */                                      /* [3] */
+               BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 2),
+               BTF_VAR_ENC(NAME_TBD, 3, 0),                    /* [4] */
+               /* const int */                                 /* [5] */
+               BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 2),
+               BTF_VAR_ENC(NAME_TBD, 5, 0),                    /* [6] */
+               BTF_END_RAW,
+       },
+       .str_sec = "\0a\0b\0c\0",
+       .str_sec_size = sizeof("\0a\0b\0c\0"),
+       .map_type = BPF_MAP_TYPE_ARRAY,
+       .map_name = ".bss",
+       .key_size = sizeof(int),
+       .value_size = sizeof(void*)+4,
+       .key_type_id = 0,
+       .value_type_id = 1,
+       .max_entries = 1,
+},
 /* Test member exceeds the size of struct.
  *
  * struct A {
index 2666c84dbd014a4576366ea7338ccf51e10e1f05..7271a18ab3e22d0d637ef0e00518a9afdee6539c 100644 (file)
@@ -65,12 +65,13 @@ static int attach_tc_prog(struct bpf_tc_hook *hook, int fd)
 }
 
 /* The maximum permissible size is: PAGE_SIZE - sizeof(struct xdp_page_head) -
- * sizeof(struct skb_shared_info) - XDP_PACKET_HEADROOM = 3368 bytes
+ * SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) - XDP_PACKET_HEADROOM =
+ * 3408 bytes for 64-byte cacheline and 3216 for 256-byte one.
  */
 #if defined(__s390x__)
-#define MAX_PKT_SIZE 3176
+#define MAX_PKT_SIZE 3216
 #else
-#define MAX_PKT_SIZE 3368
+#define MAX_PKT_SIZE 3408
 #endif
 static void test_max_pkt_size(int fd)
 {
index cd4582129c7d69c1e45b6a3acbd7a5f2c6c07e67..4fce46afe6db812fee6544caea897565994d28e0 100644 (file)
@@ -195,5 +195,8 @@ int main(int argc, char *argv[])
        test_clone3(CLONE_NEWPID, getpagesize() + 8, -E2BIG,
                        CLONE3_ARGS_NO_TEST);
 
+       /* Do a clone3() in a new time namespace */
+       test_clone3(CLONE_NEWTIME, 0, 0, CLONE3_ARGS_NO_TEST);
+
        return !ksft_get_fail_cnt() ? ksft_exit_pass() : ksft_exit_fail();
 }
index 9c5a55abca6b688a29375afda91d5c6937783fb4..5b5cef445b5490350b9a7da03496f209a1fb02b8 100644 (file)
@@ -17,5 +17,6 @@ CONFIG_FTRACE_SYSCALLS=y
 CONFIG_FUNCTION_TRACER=y
 CONFIG_HIDRAW=y
 CONFIG_HID=y
+CONFIG_HID_BPF=y
 CONFIG_INPUT_EVDEV=y
 CONFIG_UHID=y
index 924ecb3f1f737ded0e608478c27a6737090f5c26..dd40d9f6f25998b845049de06ef4b47210f8f85a 100755 (executable)
@@ -404,6 +404,8 @@ EOF
        echo SERVER-$family | ip netns exec "$ns1" timeout 5 socat -u STDIN TCP-LISTEN:2000 &
        sc_s=$!
 
+       sleep 1
+
        result=$(ip netns exec "$ns0" timeout 1 socat TCP:$daddr:2000 STDOUT)
 
        if [ "$result" = "SERVER-inet" ];then