diff --git a/sys/arm64/conf/std.arm b/sys/arm64/conf/std.arm index af1958cef073..d17c80b78fff 100644 --- a/sys/arm64/conf/std.arm +++ b/sys/arm64/conf/std.arm @@ -1,15 +1,17 @@ # # ARM SoC support # # Bus drivers device pci_n1sdp # ARM Neoverse N1 SDP PCI # GPIO / PINCTRL device pl061 # Arm PL061 GPIO controller # Serial (COM) ports device pl011 +device arm_doorbell # ARM Message Handling Unit (MHU) + options FDT device acpi diff --git a/sys/arm64/conf/std.dev b/sys/arm64/conf/std.dev index 6ef7358e5e85..affe3d3014a3 100644 --- a/sys/arm64/conf/std.dev +++ b/sys/arm64/conf/std.dev @@ -1,109 +1,114 @@ # Bus drivers device pci options PCI_HP # PCI-Express native HotPlug options PCI_IOV # PCI SR-IOV support # CPU frequency control device cpufreq # Block devices device ahci device scbus device da # ATA/SCSI peripherals device cd # CD device pass # Passthrough device (direct ATA/SCSI access) # NVM Express (NVMe) support device nvme # base NVMe driver options NVME_USE_NVD=0 # prefer the cam(4) based nda(4) driver device nvd # expose NVMe namespaces as disks, depends on nvme # GPIO / PINCTRL device gpio device gpioled device fdt_pinctrl device gpioregulator # I2C device iicbus device iicmux device iic device icee # Generic IIC eeprom # Crypto accelerators device armv8crypto # ARMv8 OpenCrypto module # SPI device spibus # PWM device pwm # Serial (COM) ports device uart # Generic UART driver # Console device vt device kbdmux device vt_efifb # Pseudo devices. device crypto # core crypto support device loop # Network loopback device ether # Ethernet support device vlan # 802.1Q VLAN support device tuntap # Packet tunnel. device md # Memory "disks" device gif # IPv6 and IPv4 tunneling device firmware # firmware assist module device clk device phy device hwreset device nvmem device regulator device syscon # EVDEV support device evdev # input event device support options EVDEV_SUPPORT # evdev support in legacy drivers device uinput # install /dev/uinput cdev # PCI/PCI-X/PCIe Ethernet NICs that use iflib infrastructure device iflib device em # Intel PRO/1000 Gigabit Ethernet Family device ix # Intel 10Gb Ethernet Family # Ethernet NICs device mdio device mii device miibus # MII bus support # The `bpf' device enables the Berkeley Packet Filter. # Be aware of the administrative consequences of enabling this! # Note that 'bpf' is required for DHCP. device bpf # Berkeley packet filter # USB support options USB_DEBUG # enable debug msgs options USB_HOST_ALIGN=64 # Align usb buffers to cache line size. device ohci # OHCI USB interface device uhci # UHCI USB interface device ehci # EHCI USB interface (USB 2.0) device xhci # XHCI USB interface (USB 3.0) device usb # USB Bus (required) device ukbd # Keyboard device umass # Disks/Mass storage - Requires scbus and da # Sound support device sound # MMC/SD/SDIO Card slot support device mmc # mmc/sd bus device mmcsd # mmc/sd flash cards # HID support options HID_DEBUG # enable debug msgs device hid # Generic HID support + +# Firmware +device scmi # System Control Management Interface + +device mmio_sram # Generic on-chip SRAM diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index a009a19b1359..455018bc70b3 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -1,649 +1,657 @@ # $FreeBSD$ ## ## Kernel ## kern/msi_if.m optional intrng kern/pic_if.m optional intrng kern/subr_devmap.c standard kern/subr_intr.c optional intrng kern/subr_physmem.c standard libkern/strlen.c standard libkern/arm64/crc32c_armv8.S standard arm/arm/generic_timer.c standard arm/arm/gic.c standard arm/arm/gic_acpi.c optional acpi arm/arm/gic_fdt.c optional fdt arm/arm/gic_if.m standard arm/arm/pmu.c standard arm/arm/pmu_acpi.c optional acpi arm/arm/pmu_fdt.c optional fdt arm64/acpica/acpi_iort.c optional acpi arm64/acpica/acpi_machdep.c optional acpi arm64/acpica/OsdEnvironment.c optional acpi arm64/acpica/acpi_wakeup.c optional acpi arm64/acpica/pci_cfgreg.c optional acpi pci arm64/arm64/autoconf.c standard arm64/arm64/bus_machdep.c standard arm64/arm64/bus_space_asm.S standard arm64/arm64/busdma_bounce.c standard arm64/arm64/busdma_machdep.c standard arm64/arm64/clock.c standard arm64/arm64/copyinout.S standard arm64/arm64/cpu_errata.c standard arm64/arm64/cpufunc_asm.S standard arm64/arm64/db_disasm.c optional ddb arm64/arm64/db_interface.c optional ddb arm64/arm64/db_trace.c optional ddb arm64/arm64/debug_monitor.c standard arm64/arm64/disassem.c optional ddb arm64/arm64/dump_machdep.c standard arm64/arm64/efirt_machdep.c optional efirt arm64/arm64/elf32_machdep.c optional compat_freebsd32 arm64/arm64/elf_machdep.c standard arm64/arm64/exception.S standard arm64/arm64/exec_machdep.c standard arm64/arm64/freebsd32_machdep.c optional compat_freebsd32 arm64/arm64/gdb_machdep.c optional gdb arm64/arm64/gicv3_its.c optional intrng fdt arm64/arm64/gic_v3.c standard arm64/arm64/gic_v3_acpi.c optional acpi arm64/arm64/gic_v3_fdt.c optional fdt arm64/arm64/hyp_stub.S standard arm64/arm64/identcpu.c standard arm64/arm64/locore.S standard no-obj arm64/arm64/machdep.c standard arm64/arm64/machdep_boot.c standard arm64/arm64/mem.c standard arm64/arm64/memcmp.S standard arm64/arm64/memcpy.S standard arm64/arm64/memset.S standard arm64/arm64/minidump_machdep.c standard arm64/arm64/mp_machdep.c optional smp arm64/arm64/nexus.c standard arm64/arm64/ofw_machdep.c optional fdt arm64/arm64/ptrauth.c standard \ compile-with "${NORMAL_C:N-mbranch-protection*}" arm64/arm64/pmap.c standard arm64/arm64/ptrace_machdep.c standard arm64/arm64/sigtramp.S standard arm64/arm64/stack_machdep.c optional ddb | stack arm64/arm64/strcmp.S standard arm64/arm64/strncmp.S standard arm64/arm64/support_ifunc.c standard arm64/arm64/support.S standard arm64/arm64/swtch.S standard arm64/arm64/sys_machdep.c standard arm64/arm64/trap.c standard arm64/arm64/uio_machdep.c standard arm64/arm64/uma_machdep.c standard arm64/arm64/undefined.c standard arm64/arm64/unwind.c optional ddb | kdtrace_hooks | stack arm64/arm64/vfp.c standard arm64/arm64/vm_machdep.c standard arm64/coresight/coresight.c standard arm64/coresight/coresight_acpi.c optional acpi arm64/coresight/coresight_fdt.c optional fdt arm64/coresight/coresight_if.m standard arm64/coresight/coresight_cmd.c standard arm64/coresight/coresight_cpu_debug.c optional fdt arm64/coresight/coresight_etm4x.c standard arm64/coresight/coresight_etm4x_acpi.c optional acpi arm64/coresight/coresight_etm4x_fdt.c optional fdt arm64/coresight/coresight_funnel.c standard arm64/coresight/coresight_funnel_acpi.c optional acpi arm64/coresight/coresight_funnel_fdt.c optional fdt arm64/coresight/coresight_replicator.c standard arm64/coresight/coresight_replicator_acpi.c optional acpi arm64/coresight/coresight_replicator_fdt.c optional fdt arm64/coresight/coresight_tmc.c standard arm64/coresight/coresight_tmc_acpi.c optional acpi arm64/coresight/coresight_tmc_fdt.c optional fdt arm64/iommu/iommu.c optional iommu arm64/iommu/iommu_if.m optional iommu arm64/iommu/iommu_pmap.c optional iommu arm64/iommu/smmu.c optional iommu arm64/iommu/smmu_acpi.c optional iommu acpi arm64/iommu/smmu_fdt.c optional iommu fdt arm64/iommu/smmu_quirks.c optional iommu dev/iommu/busdma_iommu.c optional iommu dev/iommu/iommu_gas.c optional iommu crypto/armv8/armv8_crypto.c optional armv8crypto armv8_crypto_wrap.o optional armv8crypto \ dependency "$S/crypto/armv8/armv8_crypto_wrap.c" \ compile-with "${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc:N-mgeneral-regs-only} -I$S/crypto/armv8/ ${WERROR} ${NO_WCAST_QUAL} -march=armv8-a+crypto ${.IMPSRC}" \ no-implicit-rule \ clean "armv8_crypto_wrap.o" aesv8-armx.o optional armv8crypto | ossl \ dependency "$S/crypto/openssl/aarch64/aesv8-armx.S" \ compile-with "${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc:N-mgeneral-regs-only} -I$S/crypto/armv8/ ${WERROR} ${NO_WCAST_QUAL} -march=armv8-a+crypto ${.IMPSRC}" \ no-implicit-rule \ clean "aesv8-armx.o" ghashv8-armx.o optional armv8crypto \ dependency "$S/crypto/openssl/aarch64/ghashv8-armx.S" \ compile-with "${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc:N-mgeneral-regs-only} -I$S/crypto/armv8/ ${WERROR} ${NO_WCAST_QUAL} -march=armv8-a+crypto ${.IMPSRC}" \ no-implicit-rule \ clean "ghashv8-armx.o" crypto/des/des_enc.c optional netsmb crypto/openssl/ossl_aarch64.c optional ossl crypto/openssl/aarch64/chacha-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" crypto/openssl/aarch64/poly1305-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" crypto/openssl/aarch64/sha1-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" crypto/openssl/aarch64/sha256-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" crypto/openssl/aarch64/sha512-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" crypto/openssl/aarch64/vpaes-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" dev/acpica/acpi_bus_if.m optional acpi dev/acpica/acpi_if.m optional acpi dev/acpica/acpi_pci_link.c optional acpi pci dev/acpica/acpi_pcib.c optional acpi pci dev/acpica/acpi_pxm.c optional acpi dev/ahci/ahci_generic.c optional ahci cddl/dev/dtrace/aarch64/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/aarch64/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" cddl/dev/fbt/aarch64/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}" contrib/openzfs/module/icp/asm-aarch64/blake3/b3_aarch64_sse2.S optional zfs compile-with "${ZFS_S:N-mgeneral-regs-only}" contrib/openzfs/module/icp/asm-aarch64/blake3/b3_aarch64_sse41.S optional zfs compile-with "${ZFS_S:N-mgeneral-regs-only}" ## ## ASoC support ## dev/sound/fdt/audio_dai_if.m optional sound fdt dev/sound/fdt/audio_soc.c optional sound fdt dev/sound/fdt/dummy_codec.c optional sound fdt dev/sound/fdt/simple_amplifier.c optional sound fdt ## ## Device drivers ## dev/axgbe/if_axgbe.c optional axa fdt dev/axgbe/xgbe-desc.c optional axa fdt dev/axgbe/xgbe-dev.c optional axa fdt dev/axgbe/xgbe-drv.c optional axa fdt dev/axgbe/xgbe-mdio.c optional axa fdt dev/axgbe/xgbe-sysctl.c optional axa fdt dev/axgbe/xgbe-txrx.c optional axa fdt dev/axgbe/xgbe_osdep.c optional axa fdt dev/axgbe/xgbe-phy-v1.c optional axa fdt dev/cpufreq/cpufreq_dt.c optional cpufreq fdt dev/dpaa2/dpaa2_bp.c optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_cmd_if.m optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_con.c optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_io.c optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_mac.c optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_mc.c optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_mc_acpi.c optional soc_nxp_ls dpaa2 acpi dev/dpaa2/dpaa2_mc_fdt.c optional soc_nxp_ls dpaa2 fdt dev/dpaa2/dpaa2_mc_if.m optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_mcp.c optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_ni.c optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_rc.c optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_swp.c optional soc_nxp_ls dpaa2 dev/dpaa2/dpaa2_swp_if.m optional soc_nxp_ls dpaa2 dev/dpaa2/memac_mdio_acpi.c optional soc_nxp_ls dpaa2 acpi dev/dpaa2/memac_mdio_common.c optional soc_nxp_ls dpaa2 acpi | soc_nxp_ls dpaa2 fdt dev/dpaa2/memac_mdio_fdt.c optional soc_nxp_ls dpaa2 fdt dev/dpaa2/memac_mdio_if.m optional soc_nxp_ls dpaa2 acpi | soc_nxp_ls dpaa2 fdt dev/dwc/if_dwc.c optional fdt dwc_rk soc_rockchip_rk3328 | fdt dwc_rk soc_rockchip_rk3399 | fdt dwc_socfpga soc_intel_stratix10 dev/dwc/if_dwc_if.m optional fdt dwc_rk soc_rockchip_rk3328 | fdt dwc_rk soc_rockchip_rk3399 | fdt dwc_socfpga soc_intel_stratix10 dev/enetc/enetc_mdio.c optional enetc soc_nxp_ls dev/enetc/if_enetc.c optional enetc iflib pci fdt soc_nxp_ls dev/etherswitch/felix/felix.c optional enetc etherswitch fdt felix pci soc_nxp_ls +dev/firmware/arm/scmi.c optional fdt scmi +dev/firmware/arm/scmi_clk.c optional fdt scmi +dev/firmware/arm/scmi_shmem.c optional fdt scmi + dev/gpio/pl061.c optional pl061 gpio dev/gpio/pl061_acpi.c optional pl061 gpio acpi dev/gpio/pl061_fdt.c optional pl061 gpio fdt dev/gpio/qoriq_gpio.c optional soc_nxp_ls gpio fdt dev/hwpmc/hwpmc_arm64.c optional hwpmc dev/hwpmc/hwpmc_arm64_md.c optional hwpmc dev/hwpmc/hwpmc_cmn600.c optional hwpmc acpi arm64/arm64/cmn600.c optional hwpmc acpi dev/hwpmc/hwpmc_dmc620.c optional hwpmc acpi dev/hwpmc/pmu_dmc620.c optional hwpmc acpi # Microsoft Hyper-V dev/hyperv/vmbus/hyperv.c optional hyperv acpi dev/hyperv/vmbus/aarch64/hyperv_aarch64.c optional hyperv acpi dev/hyperv/vmbus/vmbus.c optional hyperv acpi pci dev/hyperv/vmbus/aarch64/vmbus_aarch64.c optional hyperv acpi dev/hyperv/vmbus/vmbus_if.m optional hyperv acpi dev/hyperv/vmbus/vmbus_res.c optional hyperv acpi dev/hyperv/vmbus/vmbus_xact.c optional hyperv acpi dev/hyperv/vmbus/aarch64/hyperv_machdep.c optional hyperv acpi dev/hyperv/vmbus/vmbus_chan.c optional hyperv acpi dev/hyperv/vmbus/hyperv_busdma.c optional hyperv acpi dev/hyperv/vmbus/vmbus_br.c optional hyperv acpi dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv acpi dev/hyperv/utilities/vmbus_timesync.c optional hyperv acpi dev/hyperv/utilities/vmbus_heartbeat.c optional hyperv acpi dev/hyperv/utilities/vmbus_ic.c optional hyperv acpi dev/hyperv/utilities/vmbus_shutdown.c optional hyperv acpi dev/hyperv/utilities/hv_kvp.c optional hyperv acpi dev/hyperv/netvsc/hn_nvs.c optional hyperv acpi dev/hyperv/netvsc/hn_rndis.c optional hyperv acpi dev/hyperv/netvsc/if_hn.c optional hyperv acpi dev/ice/if_ice_iflib.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_lib.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_osdep.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_resmgr.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_strings.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_iflib_recovery_txrx.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_iflib_txrx.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_common.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_controlq.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_dcb.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_flex_pipe.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_flow.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_nvm.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_sched.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_switch.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_vlan_mode.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_fw_logging.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_fwlog.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/ice_rdma.c optional ice pci \ compile-with "${NORMAL_C} -I$S/dev/ice" dev/ice/irdma_if.m optional ice pci \ compile-with "${NORMAL_M} -I$S/dev/ice" dev/ice/irdma_di_if.m optional ice pci \ compile-with "${NORMAL_M} -I$S/dev/ice" ice_ddp.c optional ice_ddp \ compile-with "${AWK} -f $S/tools/fw_stub.awk ice_ddp.fw:ice_ddp:0x01031b00 -mice_ddp -c${.TARGET}" \ no-ctfconvert no-implicit-rule before-depend local \ clean "ice_ddp.c" ice_ddp.fwo optional ice_ddp \ dependency "ice_ddp.fw" \ compile-with "${NORMAL_FWO}" \ no-implicit-rule \ clean "ice_ddp.fwo" ice_ddp.fw optional ice_ddp \ dependency "$S/contrib/dev/ice/ice-1.3.27.0.pkg" \ compile-with "${CP} $S/contrib/dev/ice/ice-1.3.27.0.pkg ice_ddp.fw" \ no-obj no-implicit-rule \ clean "ice_ddp.fw" dev/iicbus/sy8106a.c optional sy8106a fdt dev/iicbus/twsi/mv_twsi.c optional twsi fdt dev/iicbus/twsi/a10_twsi.c optional twsi fdt dev/iicbus/twsi/twsi.c optional twsi fdt dev/ipmi/ipmi.c optional ipmi dev/ipmi/ipmi_acpi.c optional ipmi acpi dev/ipmi/ipmi_kcs.c optional ipmi dev/ipmi/ipmi_smic.c optional ipmi +dev/mailbox/arm/arm_doorbell.c optional fdt arm_doorbell dev/mbox/mbox_if.m optional soc_brcm_bcm2837 dev/mmc/host/dwmmc.c optional dwmmc fdt dev/mmc/host/dwmmc_altera.c optional dwmmc dwmmc_altera fdt dev/mmc/host/dwmmc_hisi.c optional dwmmc dwmmc_hisi fdt dev/mmc/host/dwmmc_rockchip.c optional dwmmc rk_dwmmc fdt dev/neta/if_mvneta_fdt.c optional neta fdt dev/neta/if_mvneta.c optional neta mdio mii fdt dev/ofw/ofw_cpu.c optional fdt dev/ofw/ofw_pci.c optional fdt pci dev/ofw/ofw_pcib.c optional fdt pci dev/pci/controller/pci_n1sdp.c optional pci_n1sdp acpi dev/pci/pci_host_generic.c optional pci dev/pci/pci_host_generic_acpi.c optional pci acpi dev/pci/pci_host_generic_fdt.c optional pci fdt dev/pci/pci_dw_mv.c optional pci fdt dev/pci/pci_dw.c optional pci fdt dev/pci/pci_dw_if.m optional pci fdt dev/psci/psci.c standard dev/psci/smccc_arm64.S standard dev/psci/smccc.c standard dev/safexcel/safexcel.c optional safexcel fdt dev/sdhci/sdhci_xenon.c optional sdhci_xenon sdhci dev/sdhci/sdhci_xenon_acpi.c optional sdhci_xenon sdhci acpi dev/sdhci/sdhci_xenon_fdt.c optional sdhci_xenon sdhci fdt +dev/sram/mmio_sram.c optional fdt mmio_sram +dev/sram/mmio_sram_if.m optional fdt mmio_sram + dev/uart/uart_cpu_arm64.c optional uart dev/uart/uart_dev_mu.c optional uart uart_mu fdt dev/uart/uart_dev_pl011.c optional uart pl011 dev/usb/controller/dwc_otg_hisi.c optional dwcotg fdt soc_hisi_hi6220 dev/usb/controller/dwc3.c optional xhci acpi dwc3 | xhci fdt dwc3 dev/usb/controller/ehci_mv.c optional ehci_mv fdt dev/usb/controller/generic_ehci.c optional ehci dev/usb/controller/generic_ehci_acpi.c optional ehci acpi dev/usb/controller/generic_ehci_fdt.c optional ehci fdt dev/usb/controller/generic_ohci.c optional ohci fdt dev/usb/controller/generic_usb_if.m optional ohci fdt dev/usb/controller/musb_otg_allwinner.c optional musb fdt soc_allwinner_a64 dev/usb/controller/usb_nop_xceiv.c optional fdt dev/usb/controller/generic_xhci.c optional xhci dev/usb/controller/generic_xhci_acpi.c optional xhci acpi dev/usb/controller/generic_xhci_fdt.c optional xhci fdt dev/vnic/mrml_bridge.c optional vnic fdt dev/vnic/nic_main.c optional vnic pci dev/vnic/nicvf_main.c optional vnic pci pci_iov dev/vnic/nicvf_queues.c optional vnic pci pci_iov dev/vnic/thunder_bgx_fdt.c optional soc_cavm_thunderx pci vnic fdt dev/vnic/thunder_bgx.c optional soc_cavm_thunderx pci vnic pci dev/vnic/thunder_mdio_fdt.c optional soc_cavm_thunderx pci vnic fdt dev/vnic/thunder_mdio.c optional soc_cavm_thunderx pci vnic dev/vnic/lmac_if.m optional inet | inet6 | vnic ## ## SoC Support ## # Allwinner common files arm/allwinner/a10_timer.c optional a10_timer fdt arm/allwinner/a10_codec.c optional sound a10_codec fdt arm/allwinner/a31_dmac.c optional a31_dmac fdt arm/allwinner/a33_codec.c optional fdt sound a33_codec arm/allwinner/a64/sun50i_a64_acodec.c optional fdt sound a64_codec arm/allwinner/sunxi_dma_if.m optional a31_dmac arm/allwinner/aw_cir.c optional evdev aw_cir fdt arm/allwinner/aw_dwc3.c optional aw_dwc3 fdt arm/allwinner/aw_gpio.c optional gpio aw_gpio fdt arm/allwinner/aw_i2s.c optional fdt sound aw_i2s arm/allwinner/aw_mmc.c optional mmc aw_mmc fdt | mmccam aw_mmc fdt arm/allwinner/aw_nmi.c optional aw_nmi fdt \ compile-with "${NORMAL_C} -I$S/contrib/device-tree/include" arm/allwinner/aw_pwm.c optional aw_pwm fdt arm/allwinner/aw_r_intc.c optional aw_r_intc fdt arm/allwinner/aw_rsb.c optional aw_rsb fdt arm/allwinner/aw_rtc.c optional aw_rtc fdt arm/allwinner/aw_sid.c optional aw_sid nvmem fdt arm/allwinner/aw_spi.c optional aw_spi fdt arm/allwinner/aw_syscon.c optional aw_syscon syscon fdt arm/allwinner/aw_thermal.c optional aw_thermal nvmem fdt arm/allwinner/aw_usbphy.c optional ehci aw_usbphy fdt arm/allwinner/aw_usb3phy.c optional xhci aw_usbphy fdt arm/allwinner/aw_wdog.c optional aw_wdog fdt arm/allwinner/axp81x.c optional axp81x fdt arm/allwinner/if_awg.c optional awg syscon aw_sid nvmem fdt # Allwinner clock driver arm/allwinner/clkng/aw_ccung.c optional aw_ccu fdt arm/allwinner/clkng/aw_clk_frac.c optional aw_ccu fdt arm/allwinner/clkng/aw_clk_m.c optional aw_ccu fdt arm/allwinner/clkng/aw_clk_mipi.c optional aw_ccu fdt arm/allwinner/clkng/aw_clk_nkmp.c optional aw_ccu fdt arm/allwinner/clkng/aw_clk_nm.c optional aw_ccu fdt arm/allwinner/clkng/aw_clk_nmm.c optional aw_ccu fdt arm/allwinner/clkng/aw_clk_np.c optional aw_ccu fdt arm/allwinner/clkng/aw_clk_prediv_mux.c optional aw_ccu fdt arm/allwinner/clkng/ccu_a64.c optional soc_allwinner_a64 aw_ccu fdt arm/allwinner/clkng/ccu_h3.c optional soc_allwinner_h5 aw_ccu fdt arm/allwinner/clkng/ccu_h6.c optional soc_allwinner_h6 aw_ccu fdt arm/allwinner/clkng/ccu_h6_r.c optional soc_allwinner_h6 aw_ccu fdt arm/allwinner/clkng/ccu_sun8i_r.c optional aw_ccu fdt arm/allwinner/clkng/ccu_de2.c optional aw_ccu fdt # Allwinner padconf files arm/allwinner/a64/a64_padconf.c optional soc_allwinner_a64 fdt arm/allwinner/a64/a64_r_padconf.c optional soc_allwinner_a64 fdt arm/allwinner/h3/h3_padconf.c optional soc_allwinner_h5 fdt arm/allwinner/h3/h3_r_padconf.c optional soc_allwinner_h5 fdt arm/allwinner/h6/h6_padconf.c optional soc_allwinner_h6 fdt arm/allwinner/h6/h6_r_padconf.c optional soc_allwinner_h6 fdt # Altera/Intel dev/altera/dwc/if_dwc_socfpga.c optional fdt dwc_socfpga arm64/intel/firmware.c optional soc_intel_stratix10 fdt arm64/intel/stratix10-soc-fpga-mgr.c optional soc_intel_stratix10 fdt arm64/intel/stratix10-svc.c optional soc_intel_stratix10 fdt # Annapurna arm/annapurna/alpine/alpine_ccu.c optional al_ccu fdt arm/annapurna/alpine/alpine_nb_service.c optional al_nb_service fdt arm/annapurna/alpine/alpine_pci.c optional al_pci fdt arm/annapurna/alpine/alpine_pci_msix.c optional al_pci fdt arm/annapurna/alpine/alpine_serdes.c optional al_serdes fdt \ no-depend \ compile-with "${CC} -c -o ${.TARGET} ${CFLAGS} -I$S/contrib/alpine-hal -I$S/contrib/alpine-hal/eth ${.IMPSRC}" # Broadcom arm64/broadcom/brcmmdio/mdio_mux_iproc.c optional soc_brcm_ns2 fdt arm64/broadcom/brcmmdio/mdio_nexus_iproc.c optional soc_brcm_ns2 fdt arm64/broadcom/brcmmdio/mdio_ns2_pcie_phy.c optional soc_brcm_ns2 fdt pci arm64/broadcom/genet/if_genet.c optional soc_brcm_bcm2838 fdt genet arm/broadcom/bcm2835/bcm2835_audio.c optional sound vchiq fdt \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" arm/broadcom/bcm2835/bcm2835_bsc.c optional bcm2835_bsc fdt arm/broadcom/bcm2835/bcm2835_clkman.c optional soc_brcm_bcm2837 fdt | soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_cpufreq.c optional soc_brcm_bcm2837 fdt | soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_dma.c optional soc_brcm_bcm2837 fdt | soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_fbd.c optional vt soc_brcm_bcm2837 fdt | vt soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_firmware.c optional soc_brcm_bcm2837 fdt | soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_ft5406.c optional evdev bcm2835_ft5406 fdt arm/broadcom/bcm2835/bcm2835_gpio.c optional gpio soc_brcm_bcm2837 fdt | gpio soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_intr.c optional soc_brcm_bcm2837 fdt | soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_mbox.c optional soc_brcm_bcm2837 fdt | soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_rng.c optional !random_loadable soc_brcm_bcm2837 fdt | !random_loadable soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_sdhci.c optional sdhci soc_brcm_bcm2837 fdt | sdhci soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_sdhost.c optional sdhci soc_brcm_bcm2837 fdt | sdhci soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_spi.c optional bcm2835_spi fdt arm/broadcom/bcm2835/bcm2835_vcbus.c optional soc_brcm_bcm2837 fdt | soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_vcio.c optional soc_brcm_bcm2837 fdt | soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2835_wdog.c optional soc_brcm_bcm2837 fdt | soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm2836.c optional soc_brcm_bcm2837 fdt | soc_brcm_bcm2838 fdt arm/broadcom/bcm2835/bcm283x_dwc_fdt.c optional dwcotg fdt soc_brcm_bcm2837 | dwcotg fdt soc_brcm_bcm2838 arm/broadcom/bcm2835/bcm2838_pci.c optional soc_brcm_bcm2838 fdt pci arm/broadcom/bcm2835/bcm2838_xhci.c optional soc_brcm_bcm2838 fdt pci xhci arm/broadcom/bcm2835/raspberrypi_gpio.c optional soc_brcm_bcm2837 gpio fdt | soc_brcm_bcm2838 gpio fdt contrib/vchiq/interface/compat/vchi_bsd.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -Wno-unused -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" contrib/vchiq/interface/vchiq_arm/vchiq_arm.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -Wno-unused -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" contrib/vchiq/interface/vchiq_arm/vchiq_connected.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" contrib/vchiq/interface/vchiq_arm/vchiq_core.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" contrib/vchiq/interface/vchiq_arm/vchiq_kern_lib.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" contrib/vchiq/interface/vchiq_arm/vchiq_shim.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" contrib/vchiq/interface/vchiq_arm/vchiq_util.c optional vchiq soc_brcm_bcm2837 \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" # Cavium arm64/cavium/thunder_pcie_fdt.c optional soc_cavm_thunderx pci fdt arm64/cavium/thunder_pcie_pem.c optional soc_cavm_thunderx pci arm64/cavium/thunder_pcie_pem_fdt.c optional soc_cavm_thunderx pci fdt arm64/cavium/thunder_pcie_common.c optional soc_cavm_thunderx pci # i.MX8 Clock support arm64/freescale/imx/imx8mq_ccm.c optional fdt soc_freescale_imx8 arm64/freescale/imx/clk/imx_clk_gate.c optional fdt soc_freescale_imx8 arm64/freescale/imx/clk/imx_clk_mux.c optional fdt soc_freescale_imx8 arm64/freescale/imx/clk/imx_clk_composite.c optional fdt soc_freescale_imx8 arm64/freescale/imx/clk/imx_clk_sscg_pll.c optional fdt soc_freescale_imx8 arm64/freescale/imx/clk/imx_clk_frac_pll.c optional fdt soc_freescale_imx8 # iMX drivers arm/freescale/imx/imx_gpio.c optional gpio soc_freescale_imx8 fdt arm/freescale/imx/imx_i2c.c optional fsliic arm/freescale/imx/imx_machdep.c optional fdt soc_freescale_imx8 arm64/freescale/imx/imx7gpc.c optional fdt soc_freescale_imx8 dev/ffec/if_ffec.c optional ffec # Marvell arm/mv/a37x0_gpio.c optional a37x0_gpio gpio fdt arm/mv/a37x0_iic.c optional a37x0_iic iicbus fdt arm/mv/a37x0_spi.c optional a37x0_spi spibus fdt arm/mv/clk/a37x0_tbg.c optional a37x0_tbg clk fdt syscon arm/mv/clk/a37x0_xtal.c optional a37x0_xtal clk fdt syscon arm/mv/armada38x/armada38x_rtc.c optional mv_rtc fdt arm/mv/gpio.c optional mv_gpio fdt arm/mv/mvebu_gpio.c optional mv_gpio fdt arm/mv/mvebu_pinctrl.c optional mvebu_pinctrl fdt arm/mv/mv_ap806_clock.c optional soc_marvell_8k fdt arm/mv/mv_ap806_gicp.c optional mv_ap806_gicp fdt arm/mv/mv_ap806_sei.c optional mv_ap806_sei fdt arm/mv/mv_cp110_clock.c optional soc_marvell_8k fdt arm/mv/mv_cp110_icu.c optional mv_cp110_icu fdt arm/mv/mv_cp110_icu_bus.c optional mv_cp110_icu fdt arm/mv/mv_thermal.c optional soc_marvell_8k mv_thermal fdt arm/mv/clk/a37x0_tbg_pll.c optional a37x0_tbg clk fdt syscon arm/mv/clk/a37x0_periph_clk_driver.c optional a37x0_nb_periph a37x0_sb_periph clk fdt syscon arm/mv/clk/a37x0_nb_periph_clk_driver.c optional a37x0_nb_periph clk fdt syscon arm/mv/clk/a37x0_sb_periph_clk_driver.c optional a37x0_sb_periph clk fdt syscon arm/mv/clk/periph.c optional a37x0_nb_periph a37x0_sb_periph clk fdt syscon arm/mv/clk/periph_clk_d.c optional a37x0_nb_periph a37x0_sb_periph clk fdt syscon arm/mv/clk/periph_clk_fixed.c optional a37x0_nb_periph a37x0_sb_periph clk fdt syscon arm/mv/clk/periph_clk_gate.c optional a37x0_nb_periph a37x0_sb_periph clk fdt syscon arm/mv/clk/periph_clk_mux_gate.c optional a37x0_nb_periph a37x0_sb_periph clk fdt syscon # NVidia arm/nvidia/tegra_abpmisc.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_ahci.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_efuse.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_ehci.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_gpio.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_i2c.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_lic.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_mc.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_pcie.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_sdhci.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_soctherm_if.m optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_soctherm.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_uart.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_usbphy.c optional fdt soc_nvidia_tegra210 arm/nvidia/tegra_xhci.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/max77620.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/max77620_gpio.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/max77620_regulators.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/max77620_rtc.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/tegra210_car.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/tegra210_clk_per.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/tegra210_clk_pll.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/tegra210_clk_super.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/tegra210_coretemp.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/tegra210_cpufreq.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/tegra210_pinmux.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/tegra210_pmc.c optional fdt soc_nvidia_tegra210 arm64/nvidia/tegra210/tegra210_xusbpadctl.c optional fdt soc_nvidia_tegra210 # Nvidia firmware for Tegra tegra210_xusb_fw.c optional tegra210_xusb_fw \ dependency "$S/conf/files.arm64" \ compile-with "${AWK} -f $S/tools/fw_stub.awk tegra210_xusb.fw:tegra210_xusb_fw -mtegra210_xusb_fw -c${.TARGET}" \ no-ctfconvert no-implicit-rule before-depend local \ clean "tegra210_xusb_fw.c" tegra210_xusb.fwo optional tegra210_xusb_fw \ dependency "tegra210_xusb.fw" \ compile-with "${NORMAL_FWO}" \ no-implicit-rule \ clean "tegra210_xusb.fwo" tegra210_xusb.fw optional tegra210_xusb_fw \ dependency "$S/contrib/dev/nvidia/tegra210_xusb.bin.uu" \ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ clean "tegra210_xusb.fw" # NXP arm/freescale/vybrid/vf_i2c.c optional vf_i2c iicbus soc_nxp_ls arm64/qoriq/qoriq_dw_pci.c optional pci fdt soc_nxp_ls arm64/qoriq/qoriq_gpio_pic.c optional gpio fdt soc_nxp_ls arm64/qoriq/qoriq_therm.c optional pci fdt soc_nxp_ls arm64/qoriq/qoriq_therm_if.m optional pci fdt soc_nxp_ls arm64/qoriq/clk/ls1028a_clkgen.c optional clk soc_nxp_ls fdt arm64/qoriq/clk/ls1028a_flexspi_clk.c optional clk soc_nxp_ls fdt arm64/qoriq/clk/ls1046a_clkgen.c optional clk soc_nxp_ls fdt arm64/qoriq/clk/ls1088a_clkgen.c optional clk soc_nxp_ls fdt arm64/qoriq/clk/lx2160a_clkgen.c optional clk soc_nxp_ls fdt arm64/qoriq/clk/qoriq_clk_pll.c optional clk soc_nxp_ls arm64/qoriq/clk/qoriq_clkgen.c optional clk soc_nxp_ls fdt dev/ahci/ahci_fsl_fdt.c optional soc_nxp_ls ahci fdt dev/flash/flexspi/flex_spi.c optional clk flex_spi soc_nxp_ls fdt # Qualcomm arm64/qualcomm/qcom_gcc.c optional qcom_gcc fdt # RockChip Drivers arm64/rockchip/rk3328_codec.c optional fdt rk3328codec soc_rockchip_rk3328 arm64/rockchip/rk3399_emmcphy.c optional fdt rk_emmcphy soc_rockchip_rk3399 arm64/rockchip/rk_dwc3.c optional fdt rk_dwc3 soc_rockchip_rk3399 arm64/rockchip/rk_i2c.c optional fdt rk_i2c soc_rockchip_rk3328 | fdt rk_i2c soc_rockchip_rk3399 arm64/rockchip/rk_i2s.c optional fdt sound soc_rockchip_rk3328 | fdt sound soc_rockchip_rk3399 dev/iicbus/pmic/rockchip/rk8xx.c optional fdt rk805 soc_rockchip_rk3328 | fdt rk805 soc_rockchip_rk3399 dev/iicbus/pmic/rockchip/rk805.c optional fdt rk805 soc_rockchip_rk3328 dev/iicbus/pmic/rockchip/rk808.c optional fdt rk805 soc_rockchip_rk3399 dev/iicbus/pmic/rockchip/rk8xx_clocks.c optional fdt rk805 soc_rockchip_rk3328 | fdt rk805 soc_rockchip_rk3399 dev/iicbus/pmic/rockchip/rk8xx_regulators.c optional fdt rk805 soc_rockchip_rk3328 | fdt rk805 soc_rockchip_rk3399 dev/iicbus/pmic/rockchip/rk8xx_rtc.c optional fdt rk805 soc_rockchip_rk3328 | fdt rk805 soc_rockchip_rk3399 arm64/rockchip/rk_grf.c optional fdt soc_rockchip_rk3328 | fdt soc_rockchip_rk3399 arm64/rockchip/rk_pinctrl.c optional fdt rk_pinctrl soc_rockchip_rk3328 | fdt rk_pinctrl soc_rockchip_rk3399 arm64/rockchip/rk_gpio.c optional fdt rk_gpio soc_rockchip_rk3328 | fdt rk_gpio soc_rockchip_rk3399 arm64/rockchip/rk_iodomain.c optional fdt rk_iodomain arm64/rockchip/rk_spi.c optional fdt rk_spi arm64/rockchip/rk_usb2phy.c optional fdt rk_usb2phy soc_rockchip_rk3328 | fdt rk_usb2phy soc_rockchip_rk3399 arm64/rockchip/rk_typec_phy.c optional fdt rk_typec_phy soc_rockchip_rk3399 arm64/rockchip/if_dwc_rk.c optional fdt dwc_rk soc_rockchip_rk3328 | fdt dwc_rk soc_rockchip_rk3399 arm64/rockchip/rk_tsadc_if.m optional fdt soc_rockchip_rk3399 arm64/rockchip/rk_tsadc.c optional fdt soc_rockchip_rk3399 arm64/rockchip/rk_pwm.c optional fdt rk_pwm arm64/rockchip/rk_pcie.c optional fdt pci soc_rockchip_rk3399 arm64/rockchip/rk_pcie_phy.c optional fdt pci soc_rockchip_rk3399 # RockChip Clock support arm64/rockchip/clk/rk_cru.c optional fdt soc_rockchip_rk3328 | fdt soc_rockchip_rk3399 arm64/rockchip/clk/rk_clk_armclk.c optional fdt soc_rockchip_rk3328 | fdt soc_rockchip_rk3399 arm64/rockchip/clk/rk_clk_composite.c optional fdt soc_rockchip_rk3328 | fdt soc_rockchip_rk3399 arm64/rockchip/clk/rk_clk_fract.c optional fdt soc_rockchip_rk3328 | fdt soc_rockchip_rk3399 arm64/rockchip/clk/rk_clk_gate.c optional fdt soc_rockchip_rk3328 | fdt soc_rockchip_rk3399 arm64/rockchip/clk/rk_clk_mux.c optional fdt soc_rockchip_rk3328 | fdt soc_rockchip_rk3399 arm64/rockchip/clk/rk_clk_pll.c optional fdt soc_rockchip_rk3328 | fdt soc_rockchip_rk3399 arm64/rockchip/clk/rk3328_cru.c optional fdt soc_rockchip_rk3328 arm64/rockchip/clk/rk3399_cru.c optional fdt soc_rockchip_rk3399 arm64/rockchip/clk/rk3399_pmucru.c optional fdt soc_rockchip_rk3399 # Xilinx arm/xilinx/uart_dev_cdnc.c optional uart soc_xilinx_zynq fdt diff --git a/sys/dev/firmware/arm/scmi.c b/sys/dev/firmware/arm/scmi.c new file mode 100644 index 000000000000..deb334ecfb68 --- /dev/null +++ b/sys/dev/firmware/arm/scmi.c @@ -0,0 +1,273 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "dev/mailbox/arm/arm_doorbell.h" + +#include "scmi.h" +#include "scmi_protocols.h" + +struct scmi_softc { + struct simplebus_softc simplebus_sc; + device_t dev; + device_t tx_shmem; + struct arm_doorbell *db; + struct mtx mtx; + int req_done; +}; + +static device_t +scmi_get_shmem(struct scmi_softc *sc, int index) +{ + phandle_t *shmems; + phandle_t node; + device_t dev; + size_t len; + + node = ofw_bus_get_node(sc->dev); + if (node <= 0) + return (NULL); + + len = OF_getencprop_alloc_multi(node, "shmem", sizeof(*shmems), + (void **)&shmems); + if (len <= 0) { + device_printf(sc->dev, "%s: Can't get shmem node.\n", __func__); + return (NULL); + } + + if (index >= len) { + OF_prop_free(shmems); + return (NULL); + } + + dev = OF_device_from_xref(shmems[index]); + if (dev == NULL) + device_printf(sc->dev, "%s: Can't get shmem device.\n", + __func__); + + OF_prop_free(shmems); + + return (dev); +} + +static void +scmi_callback(void *arg) +{ + struct scmi_softc *sc; + + sc = arg; + + dprintf("%s sc %p\n", __func__, sc); + + SCMI_LOCK(sc); + sc->req_done = 1; + wakeup(sc); + SCMI_UNLOCK(sc); +} + +static int +scmi_request_locked(struct scmi_softc *sc, struct scmi_req *req) +{ + struct scmi_smt_header hdr; + int timeout; + + bzero(&hdr, sizeof(struct scmi_smt_header)); + + SCMI_ASSERT_LOCKED(sc); + + /* Read header */ + scmi_shmem_read(sc->tx_shmem, 0, &hdr, SMT_HEADER_SIZE); + + if ((hdr.channel_status & SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE) == 0) + return (1); + + /* Update header */ + hdr.channel_status &= ~SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE; + hdr.msg_header = req->protocol_id << SMT_HEADER_PROTOCOL_ID_S; + hdr.msg_header |= req->message_id << SMT_HEADER_MESSAGE_ID_S; + hdr.length = sizeof(hdr.msg_header) + req->in_size; + hdr.flags |= SCMI_SHMEM_FLAG_INTR_ENABLED; + + /* Write header */ + scmi_shmem_write(sc->tx_shmem, 0, &hdr, SMT_HEADER_SIZE); + + /* Write request */ + scmi_shmem_write(sc->tx_shmem, SMT_HEADER_SIZE, req->in_buf, + req->in_size); + + sc->req_done = 0; + + /* Interrupt SCP firmware. */ + arm_doorbell_set(sc->db); + + timeout = 200; + + dprintf("%s: request\n", __func__); + + do { + if (cold) { + if (arm_doorbell_get(sc->db)) + break; + DELAY(10000); + } else { + msleep(sc, &sc->mtx, 0, "scmi", hz / 10); + if (sc->req_done) + break; + } + } while (timeout--); + + if (timeout <= 0) + return (-1); + + dprintf("%s: got reply, timeout %d\n", __func__, timeout); + + /* Read header. */ + scmi_shmem_read(sc->tx_shmem, 0, &hdr, SMT_HEADER_SIZE); + + /* Read response */ + scmi_shmem_read(sc->tx_shmem, SMT_HEADER_SIZE, req->out_buf, + req->out_size); + + return (0); +} + +int +scmi_request(device_t dev, struct scmi_req *req) +{ + struct scmi_softc *sc; + int error; + + sc = device_get_softc(dev); + + SCMI_LOCK(sc); + error = scmi_request_locked(sc, req); + SCMI_UNLOCK(sc); + + return (error); +} + +static int +scmi_probe(device_t dev) +{ + + if (!ofw_bus_is_compatible(dev, "arm,scmi")) + return (ENXIO); + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + device_set_desc(dev, "ARM SCMI interface driver"); + + return (BUS_PROBE_DEFAULT); +} + +static int +scmi_attach(device_t dev) +{ + struct scmi_softc *sc; + phandle_t node; + int error; + + sc = device_get_softc(dev); + sc->dev = dev; + + node = ofw_bus_get_node(dev); + if (node == -1) + return (ENXIO); + + sc->tx_shmem = scmi_get_shmem(sc, 0); + if (sc->tx_shmem == NULL) { + device_printf(dev, "TX shmem dev not found.\n"); + return (ENXIO); + } + + sc->db = arm_doorbell_ofw_get(sc->dev, "tx"); + if (sc->db == NULL) { + device_printf(dev, "Doorbell device not found.\n"); + return (ENXIO); + } + + mtx_init(&sc->mtx, device_get_nameunit(dev), "SCMI", MTX_DEF); + + arm_doorbell_set_handler(sc->db, scmi_callback, sc); + + simplebus_init(dev, node); + + /* + * Allow devices to identify. + */ + bus_generic_probe(dev); + + /* + * Now walk the OFW tree and attach top-level devices. + */ + for (node = OF_child(node); node > 0; node = OF_peer(node)) + simplebus_add_device(dev, node, 0, NULL, -1, NULL); + + error = bus_generic_attach(dev); + + return (error); +} + +static int +scmi_detach(device_t dev) +{ + + return (0); +} + +static device_method_t scmi_methods[] = { + DEVMETHOD(device_probe, scmi_probe), + DEVMETHOD(device_attach, scmi_attach), + DEVMETHOD(device_detach, scmi_detach), + DEVMETHOD_END +}; + +DEFINE_CLASS_1(scmi, scmi_driver, scmi_methods, sizeof(struct scmi_softc), + simplebus_driver); + +DRIVER_MODULE(scmi, simplebus, scmi_driver, 0, 0); +MODULE_VERSION(scmi, 1); diff --git a/sys/dev/firmware/arm/scmi.h b/sys/dev/firmware/arm/scmi.h new file mode 100644 index 000000000000..d2ced74840f7 --- /dev/null +++ b/sys/dev/firmware/arm/scmi.h @@ -0,0 +1,82 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _ARM64_SCMI_SCMI_H_ +#define _ARM64_SCMI_SCMI_H_ + +#define SCMI_LOCK(sc) mtx_lock(&(sc)->mtx) +#define SCMI_UNLOCK(sc) mtx_unlock(&(sc)->mtx) +#define SCMI_ASSERT_LOCKED(sc) mtx_assert(&(sc)->mtx, MA_OWNED) + +#define dprintf(fmt, ...) + +/* Shared Memory Transfer. */ +struct scmi_smt_header { + uint32_t reserved; + uint32_t channel_status; +#define SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR (1 << 1) +#define SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE (1 << 0) + uint32_t reserved1[2]; + uint32_t flags; +#define SCMI_SHMEM_FLAG_INTR_ENABLED (1 << 0) + uint32_t length; + uint32_t msg_header; + uint8_t msg_payload[0]; +}; + +#define SMT_HEADER_SIZE sizeof(struct scmi_smt_header) + +#define SMT_HEADER_TOKEN_S 18 +#define SMT_HEADER_TOKEN_M (0x3fff << SMT_HEADER_TOKEN_S) +#define SMT_HEADER_PROTOCOL_ID_S 10 +#define SMT_HEADER_PROTOCOL_ID_M (0xff << SMT_HEADER_PROTOCOL_ID_S) +#define SMT_HEADER_MESSAGE_TYPE_S 8 +#define SMT_HEADER_MESSAGE_TYPE_M (0x3 << SMT_HEADER_MESSAGE_TYPE_S) +#define SMT_HEADER_MESSAGE_ID_S 0 +#define SMT_HEADER_MESSAGE_ID_M (0xff << SMT_HEADER_MESSAGE_ID_S) + +struct scmi_req { + int protocol_id; + int message_id; + const void *in_buf; + uint32_t in_size; + void *out_buf; + uint32_t out_size; +}; + +int scmi_request(device_t dev, struct scmi_req *req); +void scmi_shmem_read(device_t dev, bus_size_t offset, void *buf, + bus_size_t len); +void scmi_shmem_write(device_t dev, bus_size_t offset, const void *buf, + bus_size_t len); + +#endif /* !_ARM64_SCMI_SCMI_H_ */ diff --git a/sys/dev/firmware/arm/scmi_clk.c b/sys/dev/firmware/arm/scmi_clk.c new file mode 100644 index 000000000000..a42f0ed2c0ba --- /dev/null +++ b/sys/dev/firmware/arm/scmi_clk.c @@ -0,0 +1,434 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "scmi.h" +#include "scmi_protocols.h" +#include "scmi_clk.h" + +struct scmi_clk_softc { + device_t dev; + device_t scmi; + struct clkdom *clkdom; +}; + +struct scmi_clknode_softc { + device_t dev; + int clock_id; +}; + +static int +scmi_clk_get_rate(struct scmi_clk_softc *sc, int clk_id, uint64_t *rate) +{ + struct scmi_clk_rate_get_out out; + struct scmi_clk_rate_get_in in; + struct scmi_req req; + int error; + + req.protocol_id = SCMI_PROTOCOL_ID_CLOCK; + req.message_id = SCMI_CLOCK_RATE_GET; + req.in_buf = ∈ + req.in_size = sizeof(struct scmi_clk_rate_get_in); + req.out_buf = &out; + req.out_size = sizeof(struct scmi_clk_rate_get_out); + + in.clock_id = clk_id; + + error = scmi_request(sc->scmi, &req); + if (error != 0) + return (error); + + if (out.status != 0) + return (ENXIO); + + *rate = out.rate_lsb | ((uint64_t)out.rate_msb << 32); + + return (0); +} + +static int +scmi_clk_set_rate(struct scmi_clk_softc *sc, int clk_id, uint64_t rate) +{ + struct scmi_clk_rate_set_out out; + struct scmi_clk_rate_set_in in; + struct scmi_req req; + int error; + + req.protocol_id = SCMI_PROTOCOL_ID_CLOCK; + req.message_id = SCMI_CLOCK_RATE_SET; + req.in_buf = ∈ + req.in_size = sizeof(struct scmi_clk_rate_set_in); + req.out_buf = &out; + req.out_size = sizeof(struct scmi_clk_rate_set_out); + + in.clock_id = clk_id; + in.flags = SCMI_CLK_RATE_ROUND_CLOSEST; + in.rate_lsb = (uint32_t)rate; + in.rate_msb = (uint32_t)(rate >> 32); + + error = scmi_request(sc->scmi, &req); + if (error != 0) + return (error); + + if (out.status != 0) + return (ENXIO); + + return (0); +} + +static int +scmi_clk_gate(struct scmi_clk_softc *sc, int clk_id, int enable) +{ + struct scmi_clk_state_out out; + struct scmi_clk_state_in in; + struct scmi_req req; + int error; + + req.protocol_id = SCMI_PROTOCOL_ID_CLOCK; + req.message_id = SCMI_CLOCK_CONFIG_SET; + req.in_buf = ∈ + req.in_size = sizeof(struct scmi_clk_state_in); + req.out_buf = &out; + req.out_size = sizeof(struct scmi_clk_state_out); + + in.clock_id = clk_id; + in.attributes = enable; + + error = scmi_request(sc->scmi, &req); + if (error != 0) + return (error); + + if (out.status != 0) + return (ENXIO); + + return (0); +} + +static int +scmi_clknode_init(struct clknode *clk, device_t dev) +{ + + clknode_init_parent_idx(clk, 0); + + return (0); +} + +static int +scmi_clknode_recalc_freq(struct clknode *clk, uint64_t *freq) +{ + + return (0); +} + +static int +scmi_clknode_set_freq(struct clknode *clk, uint64_t fin, uint64_t *fout, + int flags, int *stop) +{ + struct scmi_clknode_softc *clk_sc; + struct scmi_clk_softc *sc; + + clk_sc = clknode_get_softc(clk); + sc = device_get_softc(clk_sc->dev); + + dprintf("%s: %ld\n", __func__, *fout); + + scmi_clk_set_rate(sc, clk_sc->clock_id, *fout); + + *stop = 1; + + return (0); +} + +static clknode_method_t scmi_clknode_methods[] = { + /* Device interface */ + CLKNODEMETHOD(clknode_init, scmi_clknode_init), + CLKNODEMETHOD(clknode_recalc_freq, scmi_clknode_recalc_freq), + CLKNODEMETHOD(clknode_set_freq, scmi_clknode_set_freq), + CLKNODEMETHOD_END +}; + +DEFINE_CLASS_1(scmi_clknode, scmi_clknode_class, scmi_clknode_methods, + sizeof(struct scmi_clknode_softc), clknode_class); + +static int +scmi_clk_add_node(struct scmi_clk_softc *sc, int index, char *clock_name) +{ + struct scmi_clknode_softc *clk_sc; + struct clknode_init_def def; + struct clknode *clk; + + memset(&def, 0, sizeof(def)); + def.id = index; + def.name = clock_name; + def.parent_names = NULL; + def.parent_cnt = 0; + + clk = clknode_create(sc->clkdom, &scmi_clknode_class, &def); + if (clk == NULL) { + device_printf(sc->dev, "Cannot create clknode.\n"); + return (ENXIO); + } + + clk_sc = clknode_get_softc(clk); + clk_sc->dev = sc->dev; + clk_sc->clock_id = index; + + if (clknode_register(sc->clkdom, clk) == NULL) { + device_printf(sc->dev, "Could not register clock '%s'.\n", + def.name); + return (ENXIO); + } + + device_printf(sc->dev, "Clock '%s' registered.\n", def.name); + + return (0); +} + +static int +scmi_clk_get_name(struct scmi_clk_softc *sc, int index, char **result) +{ + struct scmi_clk_name_get_out out; + struct scmi_clk_name_get_in in; + struct scmi_req req; + char *clock_name; + int error; + + req.protocol_id = SCMI_PROTOCOL_ID_CLOCK; + req.message_id = SCMI_CLOCK_NAME_GET; + req.in_buf = ∈ + req.in_size = sizeof(struct scmi_clk_name_get_in); + req.out_buf = &out; + req.out_size = sizeof(struct scmi_clk_name_get_out); + + in.clock_id = index; + + error = scmi_request(sc->scmi, &req); + if (error != 0) + return (error); + + if (out.status != 0) + return (ENXIO); + + clock_name = malloc(sizeof(out.name), M_DEVBUF, M_WAITOK); + strncpy(clock_name, out.name, sizeof(out.name)); + + *result = clock_name; + + return (0); +} + +static int +scmi_clk_attrs(struct scmi_clk_softc *sc, int index) +{ + struct scmi_clk_attrs_out out; + struct scmi_clk_attrs_in in; + struct scmi_req req; + int error; + char *clock_name; + + req.protocol_id = SCMI_PROTOCOL_ID_CLOCK; + req.message_id = SCMI_CLOCK_ATTRIBUTES; + req.in_buf = ∈ + req.in_size = sizeof(struct scmi_clk_attrs_in); + req.out_buf = &out; + req.out_size = sizeof(struct scmi_clk_attrs_out); + + in.clock_id = index; + + error = scmi_request(sc->scmi, &req); + if (error != 0) + return (error); + + if (out.status != 0) + return (ENXIO); + + if (out.attributes & CLK_ATTRS_EXT_CLK_NAME) { + error = scmi_clk_get_name(sc, index, &clock_name); + if (error) + return (error); + } else { + clock_name = malloc(sizeof(out.clock_name), M_DEVBUF, M_WAITOK); + strncpy(clock_name, out.clock_name, sizeof(out.clock_name)); + } + + error = scmi_clk_add_node(sc, index, clock_name); + + return (error); +} + +static int +scmi_clk_discover(struct scmi_clk_softc *sc) +{ + struct scmi_clk_protocol_attrs_out out; + struct scmi_req req; + int nclocks; + int failing; + int error; + int i; + + req.protocol_id = SCMI_PROTOCOL_ID_CLOCK; + req.message_id = SCMI_PROTOCOL_ATTRIBUTES; + req.in_buf = NULL; + req.in_size = 0; + req.out_buf = &out; + req.out_size = sizeof(struct scmi_clk_protocol_attrs_out); + + error = scmi_request(sc->scmi, &req); + if (error != 0) + return (error); + + if (out.status != 0) + return (ENXIO); + + nclocks = (out.attributes & CLK_ATTRS_NCLOCKS_M) >> + CLK_ATTRS_NCLOCKS_S; + + device_printf(sc->dev, "Found %d clocks.\n", nclocks); + + failing = 0; + + for (i = 0; i < nclocks; i++) { + error = scmi_clk_attrs(sc, i); + if (error) { + device_printf(sc->dev, + "Could not process clock index %d.\n", i); + failing++; + } + } + + if (failing == nclocks) + return (ENXIO); + + return (0); +} + +static int +scmi_clk_init(struct scmi_clk_softc *sc) +{ + int error; + + /* Create clock domain */ + sc->clkdom = clkdom_create(sc->dev); + if (sc->clkdom == NULL) + return (ENXIO); + + error = scmi_clk_discover(sc); + if (error) { + device_printf(sc->dev, "Could not discover clocks.\n"); + return (ENXIO); + } + + error = clkdom_finit(sc->clkdom); + if (error) { + device_printf(sc->dev, "Failed to init clock domain.\n"); + return (ENXIO); + } + + return (0); +} + +static int +scmi_clk_probe(device_t dev) +{ + phandle_t node; + uint32_t reg; + int error; + + node = ofw_bus_get_node(dev); + + error = OF_getencprop(node, "reg", ®, sizeof(uint32_t)); + if (error < 0) + return (ENXIO); + + if (reg != SCMI_PROTOCOL_ID_CLOCK) + return (ENXIO); + + device_set_desc(dev, "SCMI Clock Management Unit"); + + return (BUS_PROBE_DEFAULT); +} + +static int +scmi_clk_attach(device_t dev) +{ + struct scmi_clk_softc *sc; + phandle_t node; + + sc = device_get_softc(dev); + sc->dev = dev; + sc->scmi = device_get_parent(dev); + + node = ofw_bus_get_node(sc->dev); + + OF_device_register_xref(OF_xref_from_node(node), sc->dev); + + scmi_clk_init(sc); + + return (0); +} + +static int +scmi_clk_detach(device_t dev) +{ + + return (0); +} + +static device_method_t scmi_clk_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, scmi_clk_probe), + DEVMETHOD(device_attach, scmi_clk_attach), + DEVMETHOD(device_detach, scmi_clk_detach), + DEVMETHOD_END +}; + +static driver_t scmi_clk_driver = { + "scmi_clk", + scmi_clk_methods, + sizeof(struct scmi_clk_softc), +}; + +EARLY_DRIVER_MODULE(scmi_clk, scmi, scmi_clk_driver, 0, 0, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); +MODULE_VERSION(scmi_clk, 1); diff --git a/sys/dev/firmware/arm/scmi_clk.h b/sys/dev/firmware/arm/scmi_clk.h new file mode 100644 index 000000000000..41e347cc8906 --- /dev/null +++ b/sys/dev/firmware/arm/scmi_clk.h @@ -0,0 +1,116 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _ARM64_SCMI_SCMI_CLK_H_ +#define _ARM64_SCMI_SCMI_CLK_H_ + +/* + * SCMI Clock Protocol + */ + +struct scmi_clk_protocol_attrs_out { + int32_t status; + uint32_t attributes; +#define CLK_ATTRS_NCLOCKS_S 0 +#define CLK_ATTRS_NCLOCKS_M (0xffff << CLK_ATTRS_NCLOCKS_S) +}; + +struct scmi_clk_attrs_in { + uint32_t clock_id; +}; + +struct scmi_clk_attrs_out { + int32_t status; + uint32_t attributes; +#define CLK_ATTRS_RATE_CHANGE_NOTIFY_SUPP (1 << 31) +#define CLK_ATTRS_RATE_REQ_CHANGE_NOTIFY_SUPP (1 << 30) +#define CLK_ATTRS_EXT_CLK_NAME (1 << 29) +#define CLK_ATTRS_ENABLED (1 << 0) + uint8_t clock_name[16]; /* only if attrs bit 29 unset */ + uint32_t clock_enable_delay; /* worst case */ +}; + +struct scmi_clk_name_get_in { + uint32_t clock_id; +}; + +struct scmi_clk_name_get_out { + int32_t status; + uint32_t flags; + uint8_t name[64]; +}; + +enum scmi_clock_message_id { + SCMI_CLOCK_ATTRIBUTES = 0x3, + SCMI_CLOCK_RATE_SET = 0x5, + SCMI_CLOCK_RATE_GET = 0x6, + SCMI_CLOCK_CONFIG_SET = 0x7, + SCMI_CLOCK_NAME_GET = 0x8, +}; + +#define SCMI_CLK_RATE_ASYNC_NOTIFY (1 << 0) +#define SCMI_CLK_RATE_ASYNC_NORESP (1 << 0 | 1 << 1) +#define SCMI_CLK_RATE_ROUND_DOWN 0 +#define SCMI_CLK_RATE_ROUND_UP (1 << 2) +#define SCMI_CLK_RATE_ROUND_CLOSEST (1 << 3) + +struct scmi_clk_state_in { + uint32_t clock_id; + uint32_t attributes; +}; + +struct scmi_clk_state_out { + int32_t status; +}; + +struct scmi_clk_rate_get_in { + uint32_t clock_id; +}; + +struct scmi_clk_rate_get_out { + int32_t status; + uint32_t rate_lsb; + uint32_t rate_msb; +}; + +struct scmi_clk_rate_set_in { + uint32_t flags; + uint32_t clock_id; + uint32_t rate_lsb; + uint32_t rate_msb; +}; + +struct scmi_clk_rate_set_out { + int32_t status; +}; + +#endif /* !_ARM64_SCMI_SCMI_CLK_H_ */ diff --git a/sys/dev/firmware/arm/scmi_protocols.h b/sys/dev/firmware/arm/scmi_protocols.h new file mode 100644 index 000000000000..aa2eceb15660 --- /dev/null +++ b/sys/dev/firmware/arm/scmi_protocols.h @@ -0,0 +1,63 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _ARM64_SCMI_SCMI_PROTOCOLS_H_ +#define _ARM64_SCMI_SCMI_PROTOCOLS_H_ + +enum scmi_std_protocol { + SCMI_PROTOCOL_ID_BASE = 0x10, + SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11, + SCMI_PROTOCOL_ID_SYSTEM = 0x12, + SCMI_PROTOCOL_ID_PERF = 0x13, + SCMI_PROTOCOL_ID_CLOCK = 0x14, + SCMI_PROTOCOL_ID_SENSOR = 0x15, + SCMI_PROTOCOL_ID_RESET_DOMAIN = 0x16, + SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN = 0x17, +}; + +enum scmi_status_code { + SCMI_SUCCESS = 0, + SCMI_NOT_SUPPORTED = -1, + SCMI_INVALID_PARAMETERS = -2, + SCMI_DENIED = -3, + SCMI_NOT_FOUND = -4, + SCMI_OUT_OF_RANGE = -5, + SCMI_BUSY = -6, + SCMI_COMMS_ERROR = -7, + SCMI_GENERIC_ERROR = -8, + SCMI_HARDWARE_ERROR = -9, + SCMI_PROTOCOL_ERROR = -10, +}; + +#define SCMI_PROTOCOL_ATTRIBUTES 0x1 + +#endif /* !_ARM64_SCMI_SCMI_PROTOCOLS_H_ */ diff --git a/sys/dev/firmware/arm/scmi_shmem.c b/sys/dev/firmware/arm/scmi_shmem.c new file mode 100644 index 000000000000..892dc5aee20e --- /dev/null +++ b/sys/dev/firmware/arm/scmi_shmem.c @@ -0,0 +1,146 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "mmio_sram_if.h" + +#include "scmi.h" + +struct shmem_softc { + device_t dev; + device_t parent; + int reg; +}; + +static int +shmem_probe(device_t dev) +{ + + if (!ofw_bus_is_compatible(dev, "arm,scmi-shmem")) + return (ENXIO); + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + device_set_desc(dev, "ARM SCMI Shared Memory driver"); + + return (BUS_PROBE_DEFAULT); +} + +static int +shmem_attach(device_t dev) +{ + struct shmem_softc *sc; + phandle_t node; + int reg; + + sc = device_get_softc(dev); + sc->dev = dev; + sc->parent = device_get_parent(dev); + + node = ofw_bus_get_node(dev); + if (node == -1) + return (ENXIO); + + OF_getencprop(node, "reg", ®, sizeof(reg)); + + dprintf("%s: reg %x\n", __func__, reg); + + sc->reg = reg; + + OF_device_register_xref(OF_xref_from_node(node), dev); + + return (0); +} + +static int +shmem_detach(device_t dev) +{ + + return (0); +} + +void +scmi_shmem_read(device_t dev, bus_size_t offset, void *buf, bus_size_t len) +{ + struct shmem_softc *sc; + uint8_t *addr; + int i; + + sc = device_get_softc(dev); + + addr = (uint8_t *)buf; + + for (i = 0; i < len; i++) + addr[i] = MMIO_SRAM_READ_1(sc->parent, sc->reg + offset + i); +} + +void +scmi_shmem_write(device_t dev, bus_size_t offset, const void *buf, + bus_size_t len) +{ + struct shmem_softc *sc; + const uint8_t *addr; + int i; + + sc = device_get_softc(dev); + + addr = (const uint8_t *)buf; + + for (i = 0; i < len; i++) + MMIO_SRAM_WRITE_1(sc->parent, sc->reg + offset + i, addr[i]); +} + +static device_method_t shmem_methods[] = { + DEVMETHOD(device_probe, shmem_probe), + DEVMETHOD(device_attach, shmem_attach), + DEVMETHOD(device_detach, shmem_detach), + DEVMETHOD_END +}; + +DEFINE_CLASS_1(shmem, shmem_driver, shmem_methods, sizeof(struct shmem_softc), + simplebus_driver); + +EARLY_DRIVER_MODULE(shmem, mmio_sram, shmem_driver, 0, 0, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); +MODULE_VERSION(scmi, 1); diff --git a/sys/dev/mailbox/arm/arm_doorbell.c b/sys/dev/mailbox/arm/arm_doorbell.c new file mode 100644 index 000000000000..dcf88c711140 --- /dev/null +++ b/sys/dev/mailbox/arm/arm_doorbell.c @@ -0,0 +1,347 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "arm_doorbell.h" + +#define MHU_CHAN_RX_LP 0x000 /* Low priority channel */ +#define MHU_CHAN_RX_HP 0x020 /* High priority channel */ +#define MHU_CHAN_RX_SEC 0x200 /* Secure channel */ +#define MHU_INTR_STAT 0x00 +#define MHU_INTR_SET 0x08 +#define MHU_INTR_CLEAR 0x10 + +#define MHU_TX_REG_OFFSET 0x100 + +#define DOORBELL_N_CHANNELS 3 +#define DOORBELL_N_DOORBELLS (DOORBELL_N_CHANNELS * 32) + +struct arm_doorbell dbells[DOORBELL_N_DOORBELLS]; + +static struct resource_spec arm_doorbell_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 1, RF_ACTIVE }, + { -1, 0 } +}; + +struct arm_doorbell_softc { + struct resource *res[3]; + void *lp_intr_cookie; + void *hp_intr_cookie; + device_t dev; +}; + +static void +arm_doorbell_lp_intr(void *arg) +{ + struct arm_doorbell_softc *sc; + struct arm_doorbell *db; + uint32_t reg; + int i; + + sc = arg; + + reg = bus_read_4(sc->res[0], MHU_CHAN_RX_LP + MHU_INTR_STAT); + for (i = 0; i < 32; i++) { + if (reg & (1 << i)) { + db = &dbells[i]; + bus_write_4(sc->res[0], MHU_CHAN_RX_LP + MHU_INTR_CLEAR, + (1 << i)); + if (db->func != NULL) + db->func(db->arg); + } + } +} + +static void +arm_doorbell_hp_intr(void *arg) +{ + struct arm_doorbell_softc *sc; + struct arm_doorbell *db; + uint32_t reg; + int i; + + sc = arg; + + reg = bus_read_4(sc->res[0], MHU_CHAN_RX_HP + MHU_INTR_STAT); + for (i = 0; i < 32; i++) { + if (reg & (1 << i)) { + db = &dbells[i]; + bus_write_4(sc->res[0], MHU_CHAN_RX_HP + MHU_INTR_CLEAR, + (1 << i)); + if (db->func != NULL) + db->func(db->arg); + } + } +} + +static int +arm_doorbell_probe(device_t dev) +{ + + if (!ofw_bus_is_compatible(dev, "arm,mhu-doorbell")) + return (ENXIO); + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + device_set_desc(dev, "ARM MHU Doorbell"); + + return (BUS_PROBE_DEFAULT); +} + +static int +arm_doorbell_attach(device_t dev) +{ + struct arm_doorbell_softc *sc; + phandle_t node; + int error; + + sc = device_get_softc(dev); + sc->dev = dev; + + node = ofw_bus_get_node(dev); + if (node == -1) + return (ENXIO); + + if (bus_alloc_resources(dev, arm_doorbell_spec, sc->res) != 0) { + device_printf(dev, "Can't allocate resources for device.\n"); + return (ENXIO); + } + + /* Setup interrupt handlers. */ + error = bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | INTR_MPSAFE, + NULL, arm_doorbell_lp_intr, sc, &sc->lp_intr_cookie); + if (error != 0) { + device_printf(dev, "Can't setup LP interrupt handler.\n"); + bus_release_resources(dev, arm_doorbell_spec, sc->res); + return (ENXIO); + } + + error = bus_setup_intr(dev, sc->res[2], INTR_TYPE_MISC | INTR_MPSAFE, + NULL, arm_doorbell_hp_intr, sc, &sc->hp_intr_cookie); + if (error != 0) { + device_printf(dev, "Can't setup HP interrupt handler.\n"); + bus_release_resources(dev, arm_doorbell_spec, sc->res); + return (ENXIO); + } + + OF_device_register_xref(OF_xref_from_node(node), dev); + + return (0); +} + +static int +arm_doorbell_detach(device_t dev) +{ + + return (EBUSY); +} + +struct arm_doorbell * +arm_doorbell_ofw_get(device_t dev, const char *name) +{ + phandle_t node, parent; + struct arm_doorbell *db; + device_t db_dev; + pcell_t *cells; + int nmboxes; + int ncells; + int idx; + int db_id; + int error; + int chan; + + node = ofw_bus_get_node(dev); + + error = ofw_bus_parse_xref_list_get_length(node, "mboxes", + "#mbox-cells", &nmboxes); + if (error) { + device_printf(dev, "%s can't get mboxes list.\n", __func__); + return (NULL); + } + + if (nmboxes == 0) { + device_printf(dev, "%s mbox list is empty.\n", __func__); + return (NULL); + } + + error = ofw_bus_find_string_index(node, "mbox-names", name, &idx); + if (error != 0) { + device_printf(dev, "%s can't find string index.\n", + __func__); + return (NULL); + } + + error = ofw_bus_parse_xref_list_alloc(node, "mboxes", "#mbox-cells", + idx, &parent, &ncells, &cells); + if (error != 0) { + device_printf(dev, "%s can't get mbox device xref\n", + __func__); + return (NULL); + } + + if (ncells != 2) { + device_printf(dev, "Unexpected data size.\n"); + OF_prop_free(cells); + return (NULL); + } + + db_dev = OF_device_from_xref(parent); + if (db_dev == NULL) { + device_printf(dev, "%s: Can't get arm_doorbell device\n", + __func__); + OF_prop_free(cells); + return (NULL); + } + + chan = cells[0]; + if (chan >= DOORBELL_N_CHANNELS) { + device_printf(dev, "Unexpected channel number.\n"); + OF_prop_free(cells); + return (NULL); + } + + db_id = cells[1]; + if (db_id >= 32) { + device_printf(dev, "Unexpected channel bit.\n"); + OF_prop_free(cells); + return (NULL); + } + + db = &dbells[chan * db_id]; + db->dev = dev; + db->db_dev = db_dev; + db->chan = chan; + db->db = db_id; + + OF_prop_free(cells); + + return (db); +} + +void +arm_doorbell_set(struct arm_doorbell *db) +{ + struct arm_doorbell_softc *sc; + uint32_t offset; + + sc = device_get_softc(db->db_dev); + + switch (db->chan) { + case 0: + offset = MHU_CHAN_RX_LP; + break; + case 1: + offset = MHU_CHAN_RX_HP; + break; + case 2: + offset = MHU_CHAN_RX_SEC; + break; + default: + panic("not reached"); + }; + + offset |= MHU_TX_REG_OFFSET; + + bus_write_4(sc->res[0], offset + MHU_INTR_SET, (1 << db->db)); +} + +int +arm_doorbell_get(struct arm_doorbell *db) +{ + struct arm_doorbell_softc *sc; + uint32_t offset; + uint32_t reg; + + sc = device_get_softc(db->db_dev); + + switch (db->chan) { + case 0: + offset = MHU_CHAN_RX_LP; + break; + case 1: + offset = MHU_CHAN_RX_HP; + break; + case 2: + offset = MHU_CHAN_RX_SEC; + break; + default: + panic("not reached"); + }; + + reg = bus_read_4(sc->res[0], offset + MHU_INTR_STAT); + if (reg & (1 << db->db)) { + bus_write_4(sc->res[0], offset + MHU_INTR_CLEAR, + (1 << db->db)); + return (1); + } + + return (0); +} + +void +arm_doorbell_set_handler(struct arm_doorbell *db, void (*func)(void *), + void *arg) +{ + + db->func = func; + db->arg = arg; +} + +static device_method_t arm_doorbell_methods[] = { + DEVMETHOD(device_probe, arm_doorbell_probe), + DEVMETHOD(device_attach, arm_doorbell_attach), + DEVMETHOD(device_detach, arm_doorbell_detach), + DEVMETHOD_END +}; + +DEFINE_CLASS_1(arm_doorbell, arm_doorbell_driver, arm_doorbell_methods, + sizeof(struct arm_doorbell_softc), simplebus_driver); + +EARLY_DRIVER_MODULE(arm_doorbell, simplebus, arm_doorbell_driver, 0, 0, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); +MODULE_VERSION(arm_doorbell, 1); diff --git a/sys/dev/mailbox/arm/arm_doorbell.h b/sys/dev/mailbox/arm/arm_doorbell.h new file mode 100644 index 000000000000..7f109704ccd6 --- /dev/null +++ b/sys/dev/mailbox/arm/arm_doorbell.h @@ -0,0 +1,51 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _ARM64_SCMI_ARM_DOORBELL_H_ +#define _ARM64_SCMI_ARM_DOORBELL_H_ + +struct arm_doorbell { + device_t dev; + device_t db_dev; + int chan; + int db; + void (*func)(void *); + void *arg; +}; + +void arm_doorbell_set(struct arm_doorbell *db); +int arm_doorbell_get(struct arm_doorbell *db); +struct arm_doorbell * arm_doorbell_ofw_get(device_t dev, const char *name); +void arm_doorbell_set_handler(struct arm_doorbell *db, void (*func)(void *), + void *arg); + +#endif /* !_ARM64_SCMI_ARM_DOORBELL_H_ */ diff --git a/sys/dev/sram/mmio_sram.c b/sys/dev/sram/mmio_sram.c new file mode 100644 index 000000000000..0425723450a0 --- /dev/null +++ b/sys/dev/sram/mmio_sram.c @@ -0,0 +1,164 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "mmio_sram_if.h" + +#define dprintf(fmt, ...) + +static struct resource_spec mmio_sram_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { -1, 0 } +}; + +struct mmio_sram_softc { + struct simplebus_softc simplebus_sc; + struct resource *res[1]; + device_t dev; +}; + +static int +mmio_sram_probe(device_t dev) +{ + + if (!ofw_bus_is_compatible(dev, "mmio-sram")) + return (ENXIO); + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + device_set_desc(dev, "MMIO SRAM"); + + return (BUS_PROBE_DEFAULT); +} + +static int +mmio_sram_attach(device_t dev) +{ + struct mmio_sram_softc *sc; + phandle_t node; + + sc = device_get_softc(dev); + sc->dev = dev; + + if (bus_alloc_resources(dev, mmio_sram_spec, sc->res) != 0) { + device_printf(dev, "Can't allocate resources for device.\n"); + return (ENXIO); + } + + node = ofw_bus_get_node(dev); + if (node == -1) + return (ENXIO); + + simplebus_init(dev, node); + + /* + * Allow devices to identify. + */ + bus_generic_probe(dev); + + /* + * Now walk the OFW tree and attach top-level devices. + */ + for (node = OF_child(node); node > 0; node = OF_peer(node)) + simplebus_add_device(dev, node, 0, NULL, -1, NULL); + + return (bus_generic_attach(dev)); +} + +static int +mmio_sram_detach(device_t dev) +{ + struct mmio_sram_softc *sc; + + sc = device_get_softc(dev); + + bus_release_resources(dev, mmio_sram_spec, sc->res); + + return (0); +} + +static uint8_t +mmio_sram_read_1(device_t dev, bus_size_t offset) +{ + struct mmio_sram_softc *sc; + + sc = device_get_softc(dev); + + dprintf("%s: reading from %lx\n", __func__, offset); + + return (bus_read_1(sc->res[0], offset)); +} + +static void +mmio_sram_write_1(device_t dev, bus_size_t offset, uint8_t val) +{ + struct mmio_sram_softc *sc; + + sc = device_get_softc(dev); + + dprintf("%s: writing to %lx val %x\n", __func__, offset, val); + + bus_write_1(sc->res[0], offset, val); +} + +static device_method_t mmio_sram_methods[] = { + /* Device Interface */ + DEVMETHOD(device_probe, mmio_sram_probe), + DEVMETHOD(device_attach, mmio_sram_attach), + DEVMETHOD(device_detach, mmio_sram_detach), + + /* MMIO interface */ + DEVMETHOD(mmio_sram_read_1, mmio_sram_read_1), + DEVMETHOD(mmio_sram_write_1, mmio_sram_write_1), + DEVMETHOD_END +}; + +DEFINE_CLASS_1(mmio_sram, mmio_sram_driver, mmio_sram_methods, + sizeof(struct mmio_sram_softc), simplebus_driver); + +EARLY_DRIVER_MODULE(mmio_sram, simplebus, mmio_sram_driver, 0, 0, + BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE); +MODULE_VERSION(mmio_sram, 1); diff --git a/sys/dev/sram/mmio_sram_if.m b/sys/dev/sram/mmio_sram_if.m new file mode 100644 index 000000000000..02994175c069 --- /dev/null +++ b/sys/dev/sram/mmio_sram_if.m @@ -0,0 +1,44 @@ +#- +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2022 Ruslan Bukin +# +# This work was supported by Innovate UK project 105694, "Digital Security by +# Design (DSbD) Technology Platform Prototype". +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# $FreeBSD$ +# + +#include + +INTERFACE mmio_sram; + +METHOD uint8_t read_1 { + device_t dev; + bus_size_t offset; +}; + +METHOD void write_1 { + device_t dev; + bus_size_t offset; + uint8_t value; +};