| .. | .. |
|---|
| 24 | 24 | #include <linux/kthread.h> |
|---|
| 25 | 25 | #include <linux/delay.h> |
|---|
| 26 | 26 | #include <misc/rkflash_vendor_storage.h> |
|---|
| 27 | +#include "../../mmc/host/rk_sdmmc_ops.h" |
|---|
| 27 | 28 | |
|---|
| 28 | 29 | #define EMMC_IDB_PART_OFFSET 64 |
|---|
| 29 | 30 | #define EMMC_SYS_PART_OFFSET 8064 |
|---|
| .. | .. |
|---|
| 45 | 46 | static u8 *g_idb_buffer; |
|---|
| 46 | 47 | static struct vendor_info *g_vendor; |
|---|
| 47 | 48 | static DEFINE_MUTEX(vendor_ops_mutex); |
|---|
| 48 | | -extern int rk_emmc_transfer(u8 *buffer, unsigned addr, unsigned blksz, |
|---|
| 49 | | - int write); |
|---|
| 50 | 49 | |
|---|
| 51 | 50 | static int emmc_vendor_ops(u8 *buffer, u32 addr, u32 n_sec, int write) |
|---|
| 52 | 51 | { |
|---|
| 53 | | - u32 i, ret = 0; |
|---|
| 54 | | - |
|---|
| 55 | | - for (i = 0; i < n_sec; i++) |
|---|
| 56 | | - ret = rk_emmc_transfer(buffer + i * 512, addr + i, 512, write); |
|---|
| 57 | | - |
|---|
| 58 | | - return ret; |
|---|
| 52 | + return rk_emmc_transfer(buffer, addr, n_sec << 9, write); |
|---|
| 59 | 53 | } |
|---|
| 60 | 54 | |
|---|
| 61 | 55 | static int emmc_vendor_storage_init(void) |
|---|
| .. | .. |
|---|
| 211 | 205 | #ifdef CONFIG_ROCKCHIP_VENDOR_STORAGE_UPDATE_LOADER |
|---|
| 212 | 206 | static int id_blk_read_data(u32 index, u32 n_sec, u8 *buf) |
|---|
| 213 | 207 | { |
|---|
| 214 | | - u32 i; |
|---|
| 215 | | - u32 ret = 0; |
|---|
| 216 | | - |
|---|
| 217 | 208 | if (index + n_sec >= 1024 * 5) |
|---|
| 218 | 209 | return 0; |
|---|
| 219 | 210 | index = index + EMMC_IDB_PART_OFFSET; |
|---|
| 220 | | - for (i = 0; i < n_sec; i++) { |
|---|
| 221 | | - ret = rk_emmc_transfer(buf + i * 512, index + i, 512, 0); |
|---|
| 222 | | - if (ret) |
|---|
| 223 | | - return ret; |
|---|
| 224 | | - } |
|---|
| 225 | | - return ret; |
|---|
| 211 | + |
|---|
| 212 | + return rk_emmc_transfer(buf, index, n_sec << 9, 0); |
|---|
| 226 | 213 | } |
|---|
| 227 | 214 | |
|---|
| 228 | 215 | static int id_blk_write_data(u32 index, u32 n_sec, u8 *buf) |
|---|
| 229 | 216 | { |
|---|
| 230 | | - u32 i; |
|---|
| 231 | | - u32 ret = 0; |
|---|
| 232 | | - |
|---|
| 233 | 217 | if (index + n_sec >= 1024 * 5) |
|---|
| 234 | 218 | return 0; |
|---|
| 235 | 219 | index = index + EMMC_IDB_PART_OFFSET; |
|---|
| 236 | | - for (i = 0; i < n_sec; i++) { |
|---|
| 237 | | - ret = rk_emmc_transfer(buf + i * 512, index + i, 512, 1); |
|---|
| 238 | | - if (ret) |
|---|
| 239 | | - return ret; |
|---|
| 240 | | - } |
|---|
| 241 | | - return ret; |
|---|
| 220 | + |
|---|
| 221 | + return rk_emmc_transfer(buf, index, n_sec << 9, 1); |
|---|
| 242 | 222 | } |
|---|
| 243 | 223 | |
|---|
| 244 | 224 | static int emmc_write_idblock(u32 size, u8 *buf, u32 *id_blk_tbl) |
|---|