Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\hpet.c Create Date:2022-07-28 08:43:06
Last Modify:2020-03-16 21:38:50 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:hpet_enable - Try to setup the HPET timer. Returns 1 on success.

Proto:int __init hpet_enable(void)

Type:int

Parameter:Nothing

819  If Not is_hpet_capable() Then Return 0
822  hpet_set_mapping()
823  If Not hpet_virt_address Then Return 0
827  If Not AMD SB700 based systems with spread spectrum enabled use a SMM based* HPET emulation to provide proper frequency setting.* On such systems the SMM code is initialized with the first HPET register* access and takes some time to complete Then Go to out_nohpet
833  hpet_period = hpet_readl(HPET_PERIOD)
834  If hpet_period < HPET_MIN_PERIOD || hpet_period > HPET_MAX_PERIOD Then Go to out_nohpet
838  freq = FSEC_PER_SEC
839  do_div() is NOT a C function(freq, hpet_period)
840  hpet_freq = freq
846  id = hpet_readl(HPET_ID)
847  hpet_print_config()
850  channels = ((id & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT) + 1
856  If IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_HPET_EMULATE_RTC) && channels < 2 Then Go to out_nohpet
859  hc = kcalloc - allocate memory for an array. The memory is set to zero.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
860  If Not hc Then
861  pr_warn("Disabling HPET.\n")
862  Go to out_nohpet
864  channels = hc
865  nr_channels = channels
868  cfg = hpet_readl(HPET_CFG)
869  boot_cfg = cfg
870  cfg &= ~(HPET_CFG_ENABLE | HPET_CFG_LEGACY)
871  hpet_writel(cfg, HPET_CFG)
872  If cfg Then pr_warn("Global config: Unknown bits %#x\n", cfg)
876  When i < channels cycle
877  num = i
879  cfg = hpet_readl(HPET_Tn_CFG(i))
880  boot_cfg = cfg
881  irq = (cfg & Tn_INT_ROUTE_CNF_MASK) >> Tn_INT_ROUTE_CNF_SHIFT
882  irq = irq
884  cfg &= ~( HPET_TN_ENABLE | HPET_TN_LEVEL | HPET_TN_FSB)
885  hpet_writel(cfg, HPET_Tn_CFG(i))
887  cfg &= ~( HPET_TN_PERIODIC | HPET_TN_PERIODIC_CAP | HPET_TN_64BIT_CAP | HPET_TN_32BIT | HPET_TN_ROUTE | HPET_TN_FSB | HPET_TN_FSB_CAP)
890  If cfg Then pr_warn("Channel #%u config: Unknown bits %#x\n", i, cfg)
893  hpet_print_config()
900  If Not hpet_counting() Then Go to out_nohpet
903  clocksource_register_hz( & clocksource_hpet, (u32)hpet_freq)
905  If id & HPET_ID_LEGSUP Then
906  hpet_legacy_clockevent_register( & channels[0])
907  mode = HPET_MODE_LEGACY
908  If IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_HPET_EMULATE_RTC) Then mode = HPET_MODE_LEGACY
910  Return 1
912  Return 0
914  out_nohpet :
915  free previously allocated memory
916  channels = NULL
917  nr_channels = 0
918  hpet_clear_mapping()
919  HPET address is set in acpi/boot.c, when an ACPI entry exists = 0
920  Return 0
Caller
NameDescribe
hpet_late_initThe late initialization runs after the PCI quirks have been invoked* which might have detected a system on which the HPET can be enforced