diff options
author | James Buren <braewoods+rb@braewoods.net> | 2020-10-27 16:00:52 +0000 |
---|---|---|
committer | James Buren <braewoods+rb@braewoods.net> | 2020-10-27 16:01:16 +0000 |
commit | bee736f3ea8be2a200925499ba4440922c9dbb66 (patch) | |
tree | a215a7156cab8644f48c677c667e1388567939ab | |
parent | e5b963b8e12fc7edbc00f607131e4a6d603fba7b (diff) | |
download | rockbox-bee736f3ea8be2a200925499ba4440922c9dbb66.tar.gz rockbox-bee736f3ea8be2a200925499ba4440922c9dbb66.zip |
iriver_flash: make cfi_read_id use FB directly
Change-Id: Id747b0846515443871a0df10d83e3b1fc4731e7c
-rw-r--r-- | apps/plugins/iriver_flash.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/apps/plugins/iriver_flash.c b/apps/plugins/iriver_flash.c index f5d209268f..2921ca0501 100644 --- a/apps/plugins/iriver_flash.c +++ b/apps/plugins/iriver_flash.c | |||
@@ -67,26 +67,24 @@ static volatile uint16_t* FB = (uint16_t*)0x00000000; /* Flash base address */ | |||
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | /* read the manufacturer and device ID */ | 69 | /* read the manufacturer and device ID */ |
70 | bool cfi_read_id(volatile uint16_t* pBase, uint8_t* pManufacturerID, uint8_t* pDeviceID) | 70 | bool cfi_read_id(uint8_t* pManufacturerID, uint8_t* pDeviceID) |
71 | { | 71 | { |
72 | uint8_t not_manu, not_id; /* read values before switching to ID mode */ | 72 | uint8_t not_manu, not_id; /* read values before switching to ID mode */ |
73 | uint8_t manu, id; /* read values when in ID mode */ | 73 | uint8_t manu, id; /* read values when in ID mode */ |
74 | 74 | ||
75 | pBase = (uint16_t*)((uint32_t)pBase & 0xFFF80000); /* down to 512k align */ | ||
76 | |||
77 | /* read the normal content */ | 75 | /* read the normal content */ |
78 | not_manu = pBase[0]; /* should be 'A' (0x41) and 'R' (0x52) */ | 76 | not_manu = FB[0]; /* should be 'A' (0x41) and 'R' (0x52) */ |
79 | not_id = pBase[1]; /* from the "ARCH" marker */ | 77 | not_id = FB[1]; /* from the "ARCH" marker */ |
80 | 78 | ||
81 | pBase[0x5555] = 0xAA; /* enter command mode */ | 79 | FB[0x5555] = 0xAA; /* enter command mode */ |
82 | pBase[0x2AAA] = 0x55; | 80 | FB[0x2AAA] = 0x55; |
83 | pBase[0x5555] = 0x90; /* ID command */ | 81 | FB[0x5555] = 0x90; /* ID command */ |
84 | rb->sleep(HZ/50); /* Atmel wants 20ms pause here */ | 82 | rb->sleep(HZ/50); /* Atmel wants 20ms pause here */ |
85 | 83 | ||
86 | manu = pBase[0]; | 84 | manu = FB[0]; |
87 | id = pBase[1]; | 85 | id = FB[1]; |
88 | 86 | ||
89 | pBase[0] = 0xF0; /* reset flash (back to normal read mode) */ | 87 | FB[0] = 0xF0; /* reset flash (back to normal read mode) */ |
90 | rb->sleep(HZ/50); /* Atmel wants 20ms pause here */ | 88 | rb->sleep(HZ/50); /* Atmel wants 20ms pause here */ |
91 | 89 | ||
92 | /* I assume success if the obtained values are different from | 90 | /* I assume success if the obtained values are different from |
@@ -149,7 +147,7 @@ bool cfi_get_flash_info(struct flash_info* pInfo) | |||
149 | { | 147 | { |
150 | rb->memset(pInfo, 0, sizeof(struct flash_info)); | 148 | rb->memset(pInfo, 0, sizeof(struct flash_info)); |
151 | 149 | ||
152 | if (!cfi_read_id(FB, &pInfo->manufacturer, &pInfo->id)) | 150 | if (!cfi_read_id(&pInfo->manufacturer, &pInfo->id)) |
153 | return false; | 151 | return false; |
154 | 152 | ||
155 | if (pInfo->manufacturer == 0xBF) /* SST */ | 153 | if (pInfo->manufacturer == 0xBF) /* SST */ |