Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup I2C / GPIO / DMA / I2S drivers #16

Merged
merged 8 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions drivers/audio/csaudiork3x/Source/Utilities/hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ CCsAudioRk3xHW::~CCsAudioRk3xHW() {

#if USERKHW
static UINT32 read32(PVOID addr) {
UINT32 ret = *(UINT32*)addr;
UINT32 ret = READ_REGISTER_ULONG((ULONG *)addr);
//DbgPrint("Read from %p: 0x%x\n", addr, ret);
return ret;
}

static void write32(PVOID addr, UINT32 data) {
*(UINT32*)addr = data;
WRITE_REGISTER_ULONG((ULONG *)addr, data);
//DbgPrint("Write to %p: 0x%x\n", addr, data);
}

Expand Down
1 change: 0 additions & 1 deletion drivers/audio/rk3xi2sbus/rk3xi2sbus.inx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Signature = "$WINDOWS NT$"
Class = System
ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318}
Provider = CoolStar
DriverVer = 8/15/2022,1.0.0
CatalogFile = rk3xi2sbus.cat
PnpLockdown = 1

Expand Down
File renamed without changes.
File renamed without changes.
36 changes: 0 additions & 36 deletions drivers/dma/pl330dma/bitops.h

This file was deleted.

16 changes: 9 additions & 7 deletions drivers/dma/pl330dma/dmacontroller.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ static ULONG Pl330DmaDebugLevel = 100;
static ULONG Pl330DmaDebugCatagories = DBG_INIT || DBG_PNP || DBG_IOCTL;

void ReadDmacConfiguration(PPL330DMA_CONTEXT pDevice) {
const UINT32 crd = read32(pDevice, CRD);
const UINT32 cr0 = read32(pDevice, CR0);
UINT32 val;

val = read32(pDevice, CRD) >> CRD_DATA_WIDTH_SHIFT;
val = crd >> CRD_DATA_WIDTH_SHIFT;
val &= CRD_DATA_WIDTH_MASK;
pDevice->Config.DataBusWidth = 8 * (1 << val);

val = read32(pDevice, CRD) >> CRD_DATA_BUFF_SHIFT;
val = crd >> CRD_DATA_BUFF_SHIFT;
val &= CRD_DATA_BUFF_MASK;
pDevice->Config.DataBufDepth = val + 1;

val = read32(pDevice, CRD) >> CR0_NUM_CHANS_SHIFT;
val = crd >> CR0_NUM_CHANS_SHIFT;
val &= CR0_NUM_CHANS_MASK;
val += 1;
pDevice->Config.NumChan = val;

val = read32(pDevice, CR0);
val = cr0;
if (val & CR0_PERIPH_REQ_SET) {
val = (val >> CR0_NUM_PERIPH_SHIFT) & CR0_NUM_PERIPH_MASK;
val += 1;
Expand All @@ -30,13 +32,13 @@ void ReadDmacConfiguration(PPL330DMA_CONTEXT pDevice) {
pDevice->Config.NumPeripherals = 0;
}

val = read32(pDevice, CR0);
val = cr0;
if (val & CR0_BOOT_MAN_NS)
pDevice->Config.Mode |= DMAC_MODE_NS;
else
pDevice->Config.Mode &= ~DMAC_MODE_NS;

val = read32(pDevice, CR0) >> CR0_NUM_EVENTS_SHIFT;
val = cr0 >> CR0_NUM_EVENTS_SHIFT;
val &= CR0_NUM_EVENTS_MASK;
val += 1;
pDevice->Config.NumEvents = val;
Expand Down Expand Up @@ -118,7 +120,7 @@ static NTSTATUS UntilDmacIdle(PPL330DMA_THREAD Thread)
if (!(read32(pDevice, DBGSTATUS) & DBG_BUSY))
return STATUS_SUCCESS;

__yield();
YieldProcessor();

LARGE_INTEGER CurrentTime;
KeQuerySystemTimePrecise(&CurrentTime);
Expand Down
1 change: 0 additions & 1 deletion drivers/dma/pl330dma/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <wdf.h>
#include <acpiioct.h>

#include "bitops.h"
#include "pl330.h"
#include <pl330dma.h>

Expand Down
3 changes: 2 additions & 1 deletion drivers/dma/pl330dma/insn.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ NTSTATUS SubmitAudioDMA(
ccr |= ((maxBurst - 1) << CC_SRCBRSTLEN_SHFT);
ccr |= ((maxBurst - 1) << CC_DSTBRSTLEN_SHFT);

UINT32 burstSz = __ffs(addrWidth); //bus width = 4 bytes
ULONG burstSz = 0;
_BitScanForward(&burstSz, addrWidth);
ccr |= (burstSz << CC_SRCBRSTSIZE_SHFT);
ccr |= (burstSz << CC_DSTBRSTSIZE_SHFT);
ccr |= (CCTRL0 << CC_SRCCCTRL_SHFT);
Expand Down
4 changes: 2 additions & 2 deletions drivers/dma/pl330dma/pl330.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ void udelay(ULONG usec) {

UINT32 read32(PPL330DMA_CONTEXT pDevice, UINT32 reg)
{
return *(UINT32 *)((CHAR *)pDevice->MMIOAddress + reg);
return READ_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pDevice->MMIOAddress + reg));
}

void write32(PPL330DMA_CONTEXT pDevice, UINT32 reg, UINT32 val) {
*(UINT32 *)((CHAR *)pDevice->MMIOAddress + reg) = val;
WRITE_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pDevice->MMIOAddress + reg), val);
}

NTSTATUS
Expand Down
2 changes: 1 addition & 1 deletion drivers/dma/pl330dma/pl330.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ enum pl330_byteswap {
#define MCODE_BUFF_PER_REQ 256

/* Use this _only_ to wait on transient states */
#define UNTIL(t, s) while (!(_state(t) & (s))) __yield();
#define UNTIL(t, s) while (!(_state(t) & (s))) YieldProcessor();

/* The number of default descriptors */

Expand Down
6 changes: 2 additions & 4 deletions drivers/dma/pl330dma/pl330.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<WppEnabled>true</WppEnabled>
<WppScanConfigurationData Condition="'%(ClCompile. ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
<WppKernelMode>true</WppKernelMode>
<TreatWarningAsError>false</TreatWarningAsError>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WppEnabled>false</WppEnabled>
</ClCompile>
<Inf>
<TimeStamp>1.0.0</TimeStamp>
Expand All @@ -71,11 +71,11 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<WppEnabled>true</WppEnabled>
<WppScanConfigurationData Condition="'%(ClCompile. ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
<WppKernelMode>true</WppKernelMode>
<TreatWarningAsError>false</TreatWarningAsError>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WppEnabled>false</WppEnabled>
</ClCompile>
<Inf>
<TimeStamp>1.0.0</TimeStamp>
Expand All @@ -95,11 +95,9 @@
<FilesToPackage Include="@(Inf->'%(CopyOutput)')" Condition="'@(Inf)'!=''" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="bitops.h" />
<ClInclude Include="driver.h" />
<ClInclude Include="opcodes.h" />
<ClInclude Include="pl330.h" />
<ClInclude Include="trace.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dmacontroller.c" />
Expand Down
6 changes: 0 additions & 6 deletions drivers/dma/pl330dma/pl330.vcxproj.Filters
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,9 @@
<ClInclude Include="driver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="trace.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pl330.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bitops.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="opcodes.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
1 change: 0 additions & 1 deletion drivers/dma/pl330dma/pl330dma.inx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Signature = "$WINDOWS NT$"
Class = System
ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318}
Provider = CoolStar
DriverVer = 6/30/2023,1.0.0
CatalogFile = pl330dma.cat
PnpLockdown = 1

Expand Down
43 changes: 0 additions & 43 deletions drivers/dma/pl330dma/trace.h

This file was deleted.

File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions drivers/gpio/rk3xgpio/rk3xgpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ typedef struct _SIM_GPIO_CONTEXT {

UINT32 read32(PROCKCHIP_GPIO_BANK pBank, UINT32 reg)
{
return *(UINT32*)((CHAR*)pBank->VirtualBaseAddress + reg);
return READ_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pBank->VirtualBaseAddress + reg));
}

void write32(PROCKCHIP_GPIO_BANK pBank, UINT32 reg, UINT32 val) {
*(UINT32*)((CHAR*)pBank->VirtualBaseAddress + reg) = val;
WRITE_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pBank->VirtualBaseAddress + reg), val);
}

void gpio_write32_v2(PROCKCHIP_GPIO_BANK pBank, UINT32 reg, UINT32 val) {
Expand Down
1 change: 0 additions & 1 deletion drivers/gpio/rk3xgpio/rk3xgpio.inx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Signature = "$WINDOWS NT$"
Class = System
ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318}
Provider = CoolStar
DriverVer = 6/30/2023,1.0.0
CatalogFile = rk3xgpio.cat
PnpLockdown = 1

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions drivers/i2c/rk3xi2c/rk3xi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ static ULONG Rk3xI2CDebugCatagories = DBG_INIT || DBG_PNP || DBG_IOCTL;

UINT32 read32(PRK3XI2C_CONTEXT pDevice, UINT32 reg)
{
return *(UINT32 *)((CHAR *)pDevice->MMIOAddress + reg);
return READ_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pDevice->MMIOAddress + reg));
}

void write32(PRK3XI2C_CONTEXT pDevice, UINT32 reg, UINT32 val) {
*(UINT32 *)((CHAR *)pDevice->MMIOAddress + reg) = val;
WRITE_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pDevice->MMIOAddress + reg), val);
}

NTSTATUS
Expand Down
1 change: 0 additions & 1 deletion drivers/i2c/rk3xi2c/rk3xi2c.inx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Signature = "$WINDOWS NT$"
Class = System
ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318}
Provider = CoolStar
DriverVer = 6/30/2023,1.0.0
CatalogFile = rk3xi2c.cat
PnpLockdown = 1

Expand Down
5 changes: 2 additions & 3 deletions drivers/i2c/rk3xi2c/rk3xi2c.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<WppEnabled>true</WppEnabled>
<WppEnabled>false</WppEnabled>
<WppScanConfigurationData Condition="'%(ClCompile. ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
<WppKernelMode>true</WppKernelMode>
<TreatWarningAsError>false</TreatWarningAsError>
Expand All @@ -71,7 +71,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<WppEnabled>true</WppEnabled>
<WppEnabled>false</WppEnabled>
<WppScanConfigurationData Condition="'%(ClCompile. ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
<WppKernelMode>true</WppKernelMode>
<TreatWarningAsError>false</TreatWarningAsError>
Expand All @@ -97,7 +97,6 @@
<ItemGroup>
<ClInclude Include="driver.h" />
<ClInclude Include="rk3xi2c.h" />
<ClInclude Include="trace.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="clocks.c" />
Expand Down
3 changes: 0 additions & 3 deletions drivers/i2c/rk3xi2c/rk3xi2c.vcxproj.Filters
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,5 @@
<ClInclude Include="rk3xi2c.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="trace.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
43 changes: 0 additions & 43 deletions drivers/i2c/rk3xi2c/trace.h

This file was deleted.