Lines Matching refs:rtt_dev

50         struct spi_flash_device *rtt_dev = (struct spi_flash_device *) (dev->user_data);  in rt_sfud_control()  local
52 if (rtt_dev == RT_NULL || geometry == RT_NULL) { in rt_sfud_control()
56 geometry->bytes_per_sector = rtt_dev->geometry.bytes_per_sector; in rt_sfud_control()
57 geometry->sector_count = rtt_dev->geometry.sector_count; in rt_sfud_control()
58 geometry->block_size = rtt_dev->geometry.block_size; in rt_sfud_control()
63 struct spi_flash_device *rtt_dev = (struct spi_flash_device *) (dev->user_data); in rt_sfud_control() local
64 sfud_flash *sfud_dev = (sfud_flash *) (rtt_dev->user_data); in rt_sfud_control()
67 … if (addrs == RT_NULL || start_addr > end_addr || rtt_dev == RT_NULL || sfud_dev == RT_NULL) { in rt_sfud_control()
75 phy_start_addr = start_addr * rtt_dev->geometry.bytes_per_sector; in rt_sfud_control()
76 phy_size = (end_addr - start_addr) * rtt_dev->geometry.bytes_per_sector; in rt_sfud_control()
90 struct spi_flash_device *rtt_dev = (struct spi_flash_device *) (dev->user_data); in rt_sfud_read() local
91 sfud_flash *sfud_dev = (sfud_flash *) (rtt_dev->user_data); in rt_sfud_read()
94 RT_ASSERT(rtt_dev); in rt_sfud_read()
97 rt_off_t phy_pos = pos * rtt_dev->geometry.bytes_per_sector; in rt_sfud_read()
98 rt_size_t phy_size = size * rtt_dev->geometry.bytes_per_sector; in rt_sfud_read()
108 struct spi_flash_device *rtt_dev = (struct spi_flash_device *) (dev->user_data); in rt_sfud_write() local
109 sfud_flash *sfud_dev = (sfud_flash *) (rtt_dev->user_data); in rt_sfud_write()
112 RT_ASSERT(rtt_dev); in rt_sfud_write()
115 rt_off_t phy_pos = pos * rtt_dev->geometry.bytes_per_sector; in rt_sfud_write()
116 rt_size_t phy_size = size * rtt_dev->geometry.bytes_per_sector; in rt_sfud_write()
132 struct spi_flash_device *rtt_dev = (struct spi_flash_device *) (sfud_dev->user_data); in spi_write_read() local
136 RT_ASSERT(rtt_dev); in spi_write_read()
147 if(rtt_dev->rt_spi_device->bus->mode & RT_SPI_BUS_MODE_QSPI) { in spi_write_read()
148 qspi_dev = (struct rt_qspi_device *) (rtt_dev->rt_spi_device); in spi_write_read()
163 …if (rt_spi_send_then_recv(rtt_dev->rt_spi_device, write_buf, write_size, read_buf, read_size) != R… in spi_write_read()
167 if (rt_spi_send(rtt_dev->rt_spi_device, write_buf, write_size) <= 0) { in spi_write_read()
171 if (rt_spi_recv(rtt_dev->rt_spi_device, read_buf, read_size) <= 0) { in spi_write_read()
189 struct spi_flash_device *rtt_dev = (struct spi_flash_device *) (sfud_dev->user_data); in qspi_read() local
190 struct rt_qspi_device *qspi_dev = (struct rt_qspi_device *) (rtt_dev->rt_spi_device); in qspi_read()
194 RT_ASSERT(rtt_dev); in qspi_read()
230 struct spi_flash_device *rtt_dev = (struct spi_flash_device *) (sfud_dev->user_data); in spi_lock() local
234 RT_ASSERT(rtt_dev); in spi_lock()
236 rt_mutex_take(&(rtt_dev->lock), RT_WAITING_FOREVER); in spi_lock()
241 struct spi_flash_device *rtt_dev = (struct spi_flash_device *) (sfud_dev->user_data); in spi_unlock() local
245 RT_ASSERT(rtt_dev); in spi_unlock()
247 rt_mutex_release(&(rtt_dev->lock)); in spi_unlock()
304 rt_spi_flash_device_t rtt_dev = RT_NULL; in rt_sfud_flash_probe_ex() local
315 rtt_dev = (rt_spi_flash_device_t) rt_malloc(sizeof(struct spi_flash_device)); in rt_sfud_flash_probe_ex()
320 if (rtt_dev) { in rt_sfud_flash_probe_ex()
321 rt_memset(rtt_dev, 0, sizeof(struct spi_flash_device)); in rt_sfud_flash_probe_ex()
323 rt_mutex_init(&(rtt_dev->lock), spi_flash_dev_name, RT_IPC_FLAG_PRIO); in rt_sfud_flash_probe_ex()
326 if (rtt_dev && sfud_dev && spi_flash_dev_name_bak && spi_dev_name_bak) { in rt_sfud_flash_probe_ex()
336 rtt_dev->rt_spi_device = (struct rt_spi_device *) rt_device_find(spi_dev_name); in rt_sfud_flash_probe_ex()
337 …if (rtt_dev->rt_spi_device == RT_NULL || rtt_dev->rt_spi_device->parent.type != RT_Device_Class_SP… in rt_sfud_flash_probe_ex()
345 if(rtt_dev->rt_spi_device->bus->mode &RT_SPI_BUS_MODE_QSPI) { in rt_sfud_flash_probe_ex()
346 qspi_dev = (struct rt_qspi_device *)rtt_dev->rt_spi_device; in rt_sfud_flash_probe_ex()
352 rt_spi_configure(rtt_dev->rt_spi_device, spi_cfg); in rt_sfud_flash_probe_ex()
358 rtt_dev->user_data = sfud_dev; in rt_sfud_flash_probe_ex()
359 rtt_dev->rt_spi_device->user_data = rtt_dev; in rt_sfud_flash_probe_ex()
360 rtt_dev->flash_device.user_data = rtt_dev; in rt_sfud_flash_probe_ex()
361 sfud_dev->user_data = rtt_dev; in rt_sfud_flash_probe_ex()
368 rtt_dev->geometry.sector_count = sfud_dev->chip.capacity / sfud_dev->chip.erase_gran; in rt_sfud_flash_probe_ex()
369 rtt_dev->geometry.bytes_per_sector = sfud_dev->chip.erase_gran; in rt_sfud_flash_probe_ex()
370 rtt_dev->geometry.block_size = sfud_dev->chip.erase_gran; in rt_sfud_flash_probe_ex()
373 if(rtt_dev->rt_spi_device->bus->mode &RT_SPI_BUS_MODE_QSPI) { in rt_sfud_flash_probe_ex()
386 rtt_dev->flash_device.type = RT_Device_Class_Block; in rt_sfud_flash_probe_ex()
388 rtt_dev->flash_device.ops = &flash_device_ops; in rt_sfud_flash_probe_ex()
390 rtt_dev->flash_device.init = RT_NULL; in rt_sfud_flash_probe_ex()
391 rtt_dev->flash_device.open = RT_NULL; in rt_sfud_flash_probe_ex()
392 rtt_dev->flash_device.close = RT_NULL; in rt_sfud_flash_probe_ex()
393 rtt_dev->flash_device.read = rt_sfud_read; in rt_sfud_flash_probe_ex()
394 rtt_dev->flash_device.write = rt_sfud_write; in rt_sfud_flash_probe_ex()
395 rtt_dev->flash_device.control = rt_sfud_control; in rt_sfud_flash_probe_ex()
398 …rt_device_register(&(rtt_dev->flash_device), spi_flash_dev_name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_F… in rt_sfud_flash_probe_ex()
401 return rtt_dev; in rt_sfud_flash_probe_ex()
409 if (rtt_dev) { in rt_sfud_flash_probe_ex()
410 rt_mutex_detach(&(rtt_dev->lock)); in rt_sfud_flash_probe_ex()
413 rt_free(rtt_dev); in rt_sfud_flash_probe_ex()
468 rt_spi_flash_device_t rtt_dev = RT_NULL; in rt_sfud_flash_find() local
478 rtt_dev = (rt_spi_flash_device_t) (rt_spi_device->user_data); in rt_sfud_flash_find()
479 if (rtt_dev && rtt_dev->user_data) { in rt_sfud_flash_find()
480 sfud_dev = (sfud_flash_t) (rtt_dev->user_data); in rt_sfud_flash_find()
493 rt_spi_flash_device_t rtt_dev = RT_NULL; in rt_sfud_flash_find_by_dev_name() local
496 rtt_dev = (rt_spi_flash_device_t) rt_device_find(flash_dev_name); in rt_sfud_flash_find_by_dev_name()
497 if (rtt_dev == RT_NULL || rtt_dev->flash_device.type != RT_Device_Class_Block) { in rt_sfud_flash_find_by_dev_name()
502 if (rtt_dev->user_data) { in rt_sfud_flash_find_by_dev_name()
503 sfud_dev = (sfud_flash_t) (rtt_dev->user_data); in rt_sfud_flash_find_by_dev_name()
531 static rt_spi_flash_device_t rtt_dev = NULL, rtt_dev_bak = NULL; in sf() local
558 rtt_dev_bak = rtt_dev; in sf()
565 rtt_dev = rt_sfud_flash_probe("sf_cmd", spi_dev_name); in sf()
566 if (!rtt_dev) { in sf()
570 sfud_dev = (sfud_flash_t)rtt_dev->user_data; in sf()