h6. [[Hardware Abstraction Layer]] h6(. » [[HAL Device API]] h6((. » [[List of HAL devices]] h6(((. » CPU clock generator h5. (HALDeviceSysPeri_CPUClk) h4. Device API API versions 0 and 0.1 are currently defined. h5. API version 0 API version 0 only allows the CPU clock rate to be set to one of a limited number of values, and the main entry points (_numspeeds_, _info_, _get_ and _set_) to be re-entrant. <pre> struct cpuclkdevice { struct device dev; uint32_t (*numspeeds)(struct cpuclkdevice *cpuclk); uint32_t (*info)(struct cpuclkdevice *cpuclk, uint32_t idx); uint32_t (*get)(struct cpuclkdevice *cpuclk); int (*set)(struct cpuclkdevice *cpuclk, uint32_t idx); int (*override)(struct cpuclkdevice *cpuclk, const void *table, uint32_t numentries, int format); }; </pre> h5. API version 0.1 API version 0.1 adds a _getoverride_ entry point as the opposite of _override_ defined in API version 0. <pre> struct cpuclkdevice_0_1 { /* Version 0 interface */ struct cpuclkdevice dev; /* 0.1 extension */ int (*getoverride)(struct cpuclkdevice *cpuclk, void *table, uint32_t numentries, int format); }; </pre> h5. API version 0.2 API version 0.2 adds a _getdietemperature_ entry point to allow more complex regulation of speed versus temperature. <pre> struct cpuclkdevice_0_2 { /* Version 0.1 interface */ struct cpuclkdevice_0_1 dev; /* 0.2 extension */ unsigned int (*getdietemperature)(struct cpuclkdevice *cpuclk); }; </pre> h5. Reading the available CPU speeds The _numspeeds_ and _info_ entry points are used to read the number of available CPU speeds, and the corresponding clock rate (in MHz) for each speed index. These calls are equivalent to [[Portable_Speed2]] reason codes 4 and 5. Clock rates returned by _info_ must be increasing order. h5. Getting the current CPU speed The _get_ entry point should return the current CPU speed, as an index. If the call was made while in the middle of changing speed, the call must act to complete the change request before returning with the new clock speed. This call is equivalent to [[Portable_Speed2]] reason code 7. h5. Setting the current CPU speed The _set_ entry point is used to set the CPU speed to the given index. If the call was made while in the middle of changing speed, the previous change request must be cancelled and the CPU should instead switch to the new speed. A return value of 0 indicates success, and -1 indicates failure. If a change request is cancelled due to _set_ being re-entered, 0 is returned. h5. Overriding the list of available speeds The _override_ entry point can be used to override the list of CPU speeds that the device supports. This can be used for purposes such as overclocking. On entry, _table_ must point to a device-specific table of data describing the available speeds, and _numentries_ must be the number of entries in the table. _format_ must be a device-specific identifier specifying the table format. If the call is successful, the contents of _table_ will be copied into the device and the value of _format_ will be returned. If the call fails due to the table format being incorrect, the expected table format value will be returned. If the call fails for any other reason (e.g. because the system is in the middle of changing speed), -1 will be returned. For details about the supported table formats, see the source code/documentation accompanying the relevant device implementation. h5. Reading the table of override data Copies _numentries_ entries from the override table into the _table_ pointer in the given _format_. Return values as for _override_ entry point. h5. Reading the temperature It may be necessary to regulate the CPU clock to keep within the safe operating area of the silicon, or to speed up the case fan in a thermally constrained case. The temperature is returned in kelvin with 0.1K granularity. h4. Support in RISC OS The PortableHAL version of the [[Portable]] module will search for a HALDeviceSysPeri_CPUClk device upon initialisation. If it finds such a device, and the device initialises successfully, it will use that device to provide implementations of the [[Portable_Speed]] and [[Portable_Speed2]] SWIs. h4. Known implementations |_<. Device ID |_<. Description |_<. Implemented in | |HALDeviceID_CPUClk_OMAP3 |OMAP3 CPU clock generator |HAL.OMAP3.s.CPUClk | |HALDeviceID_CPUClk_OMAP4 |OMAP4 CPU clock generator |HAL.OMAP4.s.SR44x | |HALDeviceID_CPUClk_OMAP5 |OMAP5 CPU clock generator |HAL.OMAP5.s.SR54x | h6. Information sources: Kernel.Hdr.HALDevice, HWSupport.PortableHAL.Hdr.CPUClkDevice in CVS