2020-10-03 17:22:44 +02:00
|
|
|
#include "global.h"
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-03-22 22:19:43 +01:00
|
|
|
s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data) {
|
2020-03-17 00:31:30 -04:00
|
|
|
s32 status;
|
|
|
|
OSPiHandle* curHandle;
|
|
|
|
|
2020-03-22 22:19:43 +01:00
|
|
|
while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) {
|
2020-03-17 00:31:30 -04:00
|
|
|
;
|
2020-03-22 22:19:43 +01:00
|
|
|
}
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-03-22 22:19:43 +01:00
|
|
|
if (__osCurrentHandle[handle->domain]->type != handle->type) {
|
2020-03-17 00:31:30 -04:00
|
|
|
curHandle = __osCurrentHandle[handle->domain];
|
|
|
|
|
2020-03-22 22:19:43 +01:00
|
|
|
if (handle->domain == 0) {
|
|
|
|
if (curHandle->latency != handle->latency) {
|
2020-03-17 00:31:30 -04:00
|
|
|
HW_REG(PI_BSD_DOM1_LAT_REG, u32) = handle->latency;
|
2020-03-22 22:19:43 +01:00
|
|
|
}
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-03-22 22:19:43 +01:00
|
|
|
if (curHandle->pageSize != handle->pageSize) {
|
2020-03-17 00:31:30 -04:00
|
|
|
HW_REG(PI_BSD_DOM1_PGS_REG, u32) = handle->pageSize;
|
2020-03-22 22:19:43 +01:00
|
|
|
}
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-03-22 22:19:43 +01:00
|
|
|
if (curHandle->relDuration != handle->relDuration) {
|
2020-03-17 00:31:30 -04:00
|
|
|
HW_REG(PI_BSD_DOM1_RLS_REG, u32) = handle->relDuration;
|
2020-03-22 22:19:43 +01:00
|
|
|
}
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-03-22 22:19:43 +01:00
|
|
|
if (curHandle->pulse != handle->pulse) {
|
2020-03-17 00:31:30 -04:00
|
|
|
HW_REG(PI_BSD_DOM1_PWD_REG, u32) = handle->pulse;
|
2020-03-22 22:19:43 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (curHandle->latency != handle->latency) {
|
2020-03-17 00:31:30 -04:00
|
|
|
HW_REG(PI_BSD_DOM2_LAT_REG, u32) = handle->latency;
|
2020-03-22 22:19:43 +01:00
|
|
|
}
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-03-22 22:19:43 +01:00
|
|
|
if (curHandle->pageSize != handle->pageSize) {
|
2020-03-17 00:31:30 -04:00
|
|
|
HW_REG(PI_BSD_DOM2_PGS_REG, u32) = handle->pageSize;
|
2020-03-22 22:19:43 +01:00
|
|
|
}
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-03-22 22:19:43 +01:00
|
|
|
if (curHandle->relDuration != handle->relDuration) {
|
2020-03-17 00:31:30 -04:00
|
|
|
HW_REG(PI_BSD_DOM2_RLS_REG, u32) = handle->relDuration;
|
2020-03-22 22:19:43 +01:00
|
|
|
}
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-03-22 22:19:43 +01:00
|
|
|
if (curHandle->pulse != handle->pulse) {
|
2020-03-17 00:31:30 -04:00
|
|
|
HW_REG(PI_BSD_DOM2_PWD_REG, u32) = handle->pulse;
|
2020-03-22 22:19:43 +01:00
|
|
|
}
|
2020-03-17 00:31:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
curHandle->type = handle->type;
|
|
|
|
curHandle->latency = handle->latency;
|
|
|
|
curHandle->pageSize = handle->pageSize;
|
|
|
|
curHandle->relDuration = handle->relDuration;
|
|
|
|
curHandle->pulse = handle->pulse;
|
|
|
|
}
|
|
|
|
|
|
|
|
HW_REG(handle->baseAddress | devAddr, u32) = data;
|
|
|
|
return 0;
|
|
|
|
}
|