summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 33b46d7)
raw | patch | inline | side by side (parent: 33b46d7)
author | Anand Mahadevan SS <a0230421@ti.com> | |
Thu, 4 Jul 2019 15:22:08 +0000 (20:52 +0530) | ||
committer | Anand Mahadevan SS <a0230421@ti.com> | |
Thu, 4 Jul 2019 15:25:47 +0000 (20:55 +0530) |
- The newly added APIs can be replaced by a small fix in the
original function.
- We can avoid code duplication
- It's not required to take user input on freq limits
Signed-off-by: Anand Mahadevan SS <a0230421@ti.com>
original function.
- We can avoid code duplication
- It's not required to take user input on freq limits
Signed-off-by: Anand Mahadevan SS <a0230421@ti.com>
src/sciclient_pm.c | patch | blob | history |
diff --git a/src/sciclient_pm.c b/src/sciclient_pm.c
index 3438b78c61222633b441a42891a1ac4d9d0eb763..c9eeb6cf93d2041e4285f7cae12d658a78cf9ab2 100755 (executable)
--- a/src/sciclient_pm.c
+++ b/src/sciclient_pm.c
request.min_freq_hz = (uint64_t) freqHz;
request.target_freq_hz = (uint64_t) freqHz;
request.max_freq_hz = (uint64_t) freqHz;
-
- /* If clockId is larger than 8-bit max, we use clk32 to specify the
- * extended clock id for the device */
- if (clockId >= 255U)
- {
- request.clk32 = clockId;
- request.clk = (uint8_t) 255U;
- }
- else
- {
- request.clk = (uint8_t) clockId;
- }
-
- struct tisci_msg_set_freq_resp response;
- Sciclient_ReqPrm_t reqParam ;
- reqParam.messageType = (uint16_t) TISCI_MSG_SET_FREQ;
- reqParam.flags = (uint32_t)(TISCI_MSG_FLAG_AOP | additionalFlag);
- reqParam.pReqPayload = (const uint8_t *) &request;
- reqParam.reqPayloadSize = (uint32_t) sizeof (request);
- reqParam.timeout = (uint32_t) timeout;
-
- Sciclient_RespPrm_t respParam ;
- respParam.flags = (uint32_t) 0; /* Populated by the API */
- respParam.pRespPayload = (uint8_t *) &response;
- respParam.respPayloadSize = (uint32_t) sizeof (response);
-
- retVal = Sciclient_service(&reqParam, &respParam);
- if((retVal != CSL_PASS) ||
- ((respParam.flags & TISCI_MSG_FLAG_ACK) != TISCI_MSG_FLAG_ACK))
+ /* This is required in cases of fractional clocks with a recurring decimal */
+ if(freqHz%10!=0)
{
- retVal = CSL_EFAIL;
+ request.min_freq_hz = (uint64_t)(freqHz-(freqHz%10));
+ request.max_freq_hz = (uint64_t)(request.min_freq_hz + 10UL);
}
- return retVal;
-}
-
-int32_t Sciclient_pmSetModuleClkFreqRange(uint32_t moduleId,
- uint32_t clockId,
- uint64_t freqHz,
- uint64_t minFreqHz,
- uint64_t maxFreqHz,
- uint32_t additionalFlag,
- uint32_t timeout)
-{
- int32_t retVal = CSL_PASS;
-
- struct tisci_msg_set_freq_req request ;
- request.device = (uint32_t) moduleId;
- request.min_freq_hz = (uint64_t) minFreqHz;
- request.target_freq_hz = (uint64_t) freqHz;
- request.max_freq_hz = (uint64_t) maxFreqHz;
/* If clockId is larger than 8-bit max, we use clk32 to specify the
* extended clock id for the device */
request.min_freq_hz = (uint64_t) reqFreqHz;
request.target_freq_hz = (uint64_t) reqFreqHz;
request.max_freq_hz = (uint64_t) reqFreqHz;
-
- /* If clockId is larger than 8-bit max, we use clk32 to specify the
- * extended clock id for the device */
- if (clockId >= 255U)
+ /* This is required in cases of fractional clocks with a recurring decimal */
+ if(reqFreqHz%10!=0)
{
- request.clk32 = clockId;
- request.clk = (uint8_t) 255U;
+ request.min_freq_hz = (uint64_t)(reqFreqHz-(reqFreqHz%10));
+ request.max_freq_hz = (uint64_t)(request.min_freq_hz + 10UL);
}
- else
- {
- request.clk = (uint8_t) clockId;
- }
-
- struct tisci_msg_query_freq_resp response = {0};
- Sciclient_ReqPrm_t reqParam ;
- reqParam.messageType = (uint16_t) TISCI_MSG_QUERY_FREQ;
- reqParam.flags = (uint32_t) TISCI_MSG_FLAG_AOP;
- reqParam.pReqPayload = (const uint8_t *) &request;
- reqParam.reqPayloadSize = (uint32_t) sizeof (request);
- reqParam.timeout = (uint32_t) timeout;
-
- Sciclient_RespPrm_t respParam ;
- respParam.flags = (uint32_t) 0; /* Populated by the API */
- respParam.pRespPayload = (uint8_t *) &response;
- respParam.respPayloadSize = (uint32_t) sizeof (response);
-
-
- retVal = Sciclient_service(&reqParam, &respParam);
- if((retVal != CSL_PASS) ||
- ((respParam.flags & TISCI_MSG_FLAG_ACK) != TISCI_MSG_FLAG_ACK))
- {
- retVal = CSL_EFAIL;
- }
- if (retVal == CSL_PASS)
- {
- *respFreqHz = (uint64_t) response.freq_hz;
- }
- return retVal;
-}
-
-int32_t Sciclient_pmQueryModuleClkFreqRange(uint32_t moduleId,
- uint32_t clockId,
- uint64_t reqFreqHz,
- uint64_t minFreqHz,
- uint64_t maxFreqHz,
- uint64_t *respFreqHz,
- uint32_t timeout)
-{
- int32_t retVal = CSL_PASS;
-
- struct tisci_msg_query_freq_req request ;
- request.device = (uint32_t) moduleId;
- request.min_freq_hz = (uint64_t) minFreqHz;
- request.target_freq_hz = (uint64_t) reqFreqHz;
- request.max_freq_hz = (uint64_t) maxFreqHz;
/* If clockId is larger than 8-bit max, we use clk32 to specify the
* extended clock id for the device */