Skip to content

Commit

Permalink
rpg: refactor chip ID handling, rename Initialize -> SDInitialize
Browse files Browse the repository at this point in the history
  • Loading branch information
lifehackerhansol committed Nov 23, 2024
1 parent 40ce2d4 commit e389231
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion blocksds/include/common/rpg/iorpg.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ static inline u64 IORPG_CMD_SD_WRITE_DATA(const u32* buffer) {
}

// user API
bool ioRPG_Initialize(void);
u32 ioRPG_CardReadChipID(void);
bool ioRPG_SDInitialize(void);
void ioRPG_SDReadSingleSector(u32 sector, void* buffer);
void ioRPG_SDReadMultiSector(u32 sector, u32 num_sectors, void* buffer);
void ioRPG_SDWriteSingleSector(u32 sector, const void* buffer);
Expand Down
7 changes: 6 additions & 1 deletion blocksds/source/common/rpg/iorpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,13 @@ static void ioRPG_SDWaitForState(uint8_t state) {
} while (data != state);
}

u32 ioRPG_CardReadChipID(void) {
return cardExt_ReadData4Byte(((u64)CARD_CMD_DATA_CHIPID << 56),
IORPG_CTRL_READ_4B | MCCNT1_LATENCY1(4));
}

// SDIO initialization
bool ioRPG_Initialize(void) {
bool ioRPG_SDInitialize(void) {
int isSD20 = 0;
u32 responseR1 = 0;

Expand Down
5 changes: 2 additions & 3 deletions blocksds/source/platform/ak2/iointerface.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@

// Initialize the driver. Returns true on success.
bool AK2_Startup(void) {
return ioRPG_Initialize();
return ioRPG_SDInitialize();
}

// Returns true if a card is present and initialized.
bool AK2_IsInserted(void) {
return cardExt_ReadData4Byte(((u64)CARD_CMD_DATA_CHIPID << 56),
IORPG_CTRL_READ_4B | MCCNT1_LATENCY1(4)) == 0xFC2;
return ioRPG_CardReadChipID() == 0xFC2;
}

// Reads 512 byte sectors into a buffer that may be unaligned. Returns true on
Expand Down
5 changes: 2 additions & 3 deletions blocksds/source/platform/ak2_cmd24/iointerface.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@

// Initialize the driver. Returns true on success.
bool AK2Q_Startup(void) {
return ioRPG_Initialize();
return ioRPG_SDInitialize();
}

// Returns true if a card is present and initialized.
bool AK2Q_IsInserted(void) {
return cardExt_ReadData4Byte(((u64)CARD_CMD_DATA_CHIPID << 56),
IORPG_CTRL_READ_4B | MCCNT1_LATENCY1(4)) == 0xFC2;
return ioRPG_CardReadChipID() == 0xFC2;
}

// Reads 512 byte sectors into a buffer that may be unaligned. Returns true on
Expand Down
5 changes: 2 additions & 3 deletions blocksds/source/platform/r4idsn/iointerface.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@

// Initialize the driver. Returns true on success.
bool R4iDSN_Startup(void) {
return ioRPG_Initialize();
return ioRPG_SDInitialize();
}

// Returns true if a card is present and initialized.
bool R4iDSN_IsInserted(void) {
return cardExt_ReadData4Byte(((u64)CARD_CMD_DATA_CHIPID << 56),
IORPG_CTRL_READ_4B | MCCNT1_LATENCY1(4)) == 0xFC2;
return ioRPG_CardReadChipID() == 0xFC2;
}

// Reads 512 byte sectors into a buffer that may be unaligned. Returns true on
Expand Down
5 changes: 2 additions & 3 deletions blocksds/source/platform/rpgs/iointerface.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@

// Initialize the driver. Returns true on success.
bool RPGS_Startup(void) {
return ioRPG_Initialize();
return ioRPG_SDInitialize();
}

// Returns true if a card is present and initialized.
bool RPGS_IsInserted(void) {
return cardExt_ReadData4Byte(((u64)CARD_CMD_DATA_CHIPID << 56),
IORPG_CTRL_READ_4B | MCCNT1_LATENCY1(4)) == 0xFC2;
return ioRPG_CardReadChipID() == 0xFC2;
}

// Reads 512 byte sectors into a buffer that may be unaligned. Returns true on
Expand Down

0 comments on commit e389231

Please sign in to comment.