sandbox.c (19d051a2b78b626ea3f8103a9a08e73508ba9fa6) | sandbox.c (f790ca7c7dfd6b96d418a29d4a8654cdfebbdfc3) |
---|---|
1/* 2 * Simulate a SPI flash 3 * 4 * Copyright (c) 2011-2013 The Chromium OS Authors. 5 * See file CREDITS for list of people who contributed to this 6 * project. 7 * 8 * Licensed under the GPL-2 or later. --- 74 unchanged lines hidden (view full) --- 83 uint erase_size; 84 /* Current position in the flash; used when reading/writing/etc... */ 85 uint off; 86 /* How many address bytes we've consumed */ 87 uint addr_bytes, pad_addr_bytes; 88 /* The current flash status (see STAT_XXX defines above) */ 89 u16 status; 90 /* Data describing the flash we're emulating */ | 1/* 2 * Simulate a SPI flash 3 * 4 * Copyright (c) 2011-2013 The Chromium OS Authors. 5 * See file CREDITS for list of people who contributed to this 6 * project. 7 * 8 * Licensed under the GPL-2 or later. --- 74 unchanged lines hidden (view full) --- 83 uint erase_size; 84 /* Current position in the flash; used when reading/writing/etc... */ 85 uint off; 86 /* How many address bytes we've consumed */ 87 uint addr_bytes, pad_addr_bytes; 88 /* The current flash status (see STAT_XXX defines above) */ 89 u16 status; 90 /* Data describing the flash we're emulating */ |
91 const struct spi_flash_params *data; | 91 const struct spi_flash_info *data; |
92 /* The file on disk to serv up data from */ 93 int fd; 94}; 95 96struct sandbox_spi_flash_plat_data { 97 const char *filename; 98 const char *device_name; 99 int bus; --- 7 unchanged lines hidden (view full) --- 107 * parameter. 108 */ 109static int sandbox_sf_probe(struct udevice *dev) 110{ 111 /* spec = idcode:file */ 112 struct sandbox_spi_flash *sbsf = dev_get_priv(dev); 113 const char *file; 114 size_t len, idname_len; | 92 /* The file on disk to serv up data from */ 93 int fd; 94}; 95 96struct sandbox_spi_flash_plat_data { 97 const char *filename; 98 const char *device_name; 99 int bus; --- 7 unchanged lines hidden (view full) --- 107 * parameter. 108 */ 109static int sandbox_sf_probe(struct udevice *dev) 110{ 111 /* spec = idcode:file */ 112 struct sandbox_spi_flash *sbsf = dev_get_priv(dev); 113 const char *file; 114 size_t len, idname_len; |
115 const struct spi_flash_params *data; | 115 const struct spi_flash_info *data; |
116 struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev); 117 struct sandbox_state *state = state_get_current(); 118 struct udevice *bus = dev->parent; 119 const char *spec = NULL; 120 int ret = 0; 121 int cs = -1; 122 int i; 123 --- 39 unchanged lines hidden (view full) --- 163 if (spec) 164 spec++; 165 else 166 spec = pdata->device_name; 167 idname_len = strlen(spec); 168 } 169 debug("%s: device='%s'\n", __func__, spec); 170 | 116 struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev); 117 struct sandbox_state *state = state_get_current(); 118 struct udevice *bus = dev->parent; 119 const char *spec = NULL; 120 int ret = 0; 121 int cs = -1; 122 int i; 123 --- 39 unchanged lines hidden (view full) --- 163 if (spec) 164 spec++; 165 else 166 spec = pdata->device_name; 167 idname_len = strlen(spec); 168 } 169 debug("%s: device='%s'\n", __func__, spec); 170 |
171 for (data = spi_flash_params_table; data->name; data++) { | 171 for (data = spi_flash_ids; data->name; data++) { |
172 len = strlen(data->name); 173 if (idname_len != len) 174 continue; 175 if (!strncasecmp(spec, data->name, len)) 176 break; 177 } 178 if (!data->name) { 179 printf("%s: unknown flash '%*s'\n", __func__, (int)idname_len, --- 174 unchanged lines hidden (view full) --- 354 while (pos < bytes) { 355 switch (sbsf->state) { 356 case SF_ID: { 357 u8 id; 358 359 debug(" id: off:%u tx:", sbsf->off); 360 if (sbsf->off < IDCODE_LEN) { 361 /* Extract correct byte from ID 0x00aabbcc */ | 172 len = strlen(data->name); 173 if (idname_len != len) 174 continue; 175 if (!strncasecmp(spec, data->name, len)) 176 break; 177 } 178 if (!data->name) { 179 printf("%s: unknown flash '%*s'\n", __func__, (int)idname_len, --- 174 unchanged lines hidden (view full) --- 354 while (pos < bytes) { 355 switch (sbsf->state) { 356 case SF_ID: { 357 u8 id; 358 359 debug(" id: off:%u tx:", sbsf->off); 360 if (sbsf->off < IDCODE_LEN) { 361 /* Extract correct byte from ID 0x00aabbcc */ |
362 id = sbsf->data->jedec >> | 362 id = ((((sbsf->data)->id[0]) << 16) | 363 (((sbsf->data)->id[1]) << 8 | 364 ((sbsf->data)->id[2]))) >> |
363 (8 * (IDCODE_LEN - 1 - sbsf->off)); 364 } else { 365 id = 0; 366 } 367 debug("%d %02x\n", sbsf->off, id); 368 tx[pos++] = id; 369 ++sbsf->off; 370 break; --- 330 unchanged lines hidden --- | 365 (8 * (IDCODE_LEN - 1 - sbsf->off)); 366 } else { 367 id = 0; 368 } 369 debug("%d %02x\n", sbsf->off, id); 370 tx[pos++] = id; 371 ++sbsf->off; 372 break; --- 330 unchanged lines hidden --- |