1*6cb10275Sriastradh.\" $NetBSD: flash.9,v 1.5 2014/03/18 18:20:40 riastradh Exp $ 22b6ee221Sahoka.\" 32b6ee221Sahoka.\" Copyright (c) 2010 Department of Software Engineering, 42b6ee221Sahoka.\" University of Szeged, Hungary 52b6ee221Sahoka.\" Copyright (c) 2010 Adam Hoka <ahoka@NetBSD.org> 62b6ee221Sahoka.\" All rights reserved. 72b6ee221Sahoka.\" 82b6ee221Sahoka.\" This code is derived from software contributed to The NetBSD Foundation 92b6ee221Sahoka.\" by the Department of Software Engineering, University of Szeged, Hungary 102b6ee221Sahoka.\" 112b6ee221Sahoka.\" Redistribution and use in source and binary forms, with or without 122b6ee221Sahoka.\" modification, are permitted provided that the following conditions 132b6ee221Sahoka.\" are met: 142b6ee221Sahoka.\" 1. Redistributions of source code must retain the above copyright 152b6ee221Sahoka.\" notice, this list of conditions and the following disclaimer. 162b6ee221Sahoka.\" 2. Redistributions in binary form must reproduce the above copyright 172b6ee221Sahoka.\" notice, this list of conditions and the following disclaimer in the 182b6ee221Sahoka.\" documentation and/or other materials provided with the distribution. 192b6ee221Sahoka.\" 202b6ee221Sahoka.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 212b6ee221Sahoka.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 222b6ee221Sahoka.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 232b6ee221Sahoka.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 242b6ee221Sahoka.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 252b6ee221Sahoka.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 262b6ee221Sahoka.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 272b6ee221Sahoka.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 282b6ee221Sahoka.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 292b6ee221Sahoka.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 302b6ee221Sahoka.\" SUCH DAMAGE. 312b6ee221Sahoka.\" 32bb2c5893Sjruoho.Dd March 31, 2011 332b6ee221Sahoka.Dt FLASH 9 342b6ee221Sahoka.Os 352b6ee221Sahoka.Sh NAME 362b6ee221Sahoka.Nm flash 372b6ee221Sahoka.Nd subsystem for flash-like memory devices 382b6ee221Sahoka.Sh SYNOPSIS 392b6ee221Sahoka.In dev/flash/flash.h 402b6ee221Sahoka.Ft device_t 412b6ee221Sahoka.Fn flash_attach_mi "const struct flash_interface *fl" "device_t dev" 422b6ee221Sahoka.Sh DESCRIPTION 432b6ee221SahokaFlash-like devices can register themselves to the 442b6ee221Sahoka.Nm 452b6ee221Sahokalayer with the 462b6ee221Sahoka.Fa flash_hw_if 472b6ee221Sahokastructure. 48bb2c5893SjruohoThis structure has function pointers and other fields. 492b6ee221Sahoka.Pp 502b6ee221SahokaThe attachment can be done by calling 51bb2c5893Sjruoho.Fn flash_attach_mi 52bb2c5893Sjruohowith this structure and the device's 53bb2c5893Sjruoho.Vt device_t 54bb2c5893Sjruohoas an argument. 552b6ee221SahokaReturn value is the flash layer device. 562b6ee221SahokaThe 572b6ee221Sahoka.Fa flash_interface 58bb2c5893Sjruohostructure is shown below. 592b6ee221Sahoka.Bd -literal 602b6ee221Sahokastruct flash_interface { 612b6ee221Sahoka int (*erase) (device_t, struct flash_erase_instruction *); 622b6ee221Sahoka int (*read) (device_t, off_t, size_t, size_t *, uint8_t *); 632b6ee221Sahoka int (*write) (device_t, off_t, size_t, size_t *, const uint8_t *); 642b6ee221Sahoka int (*block_markbad)(device_t, uint64_t); 652b6ee221Sahoka int (*block_isbad)(device_t, uint64_t); 662b6ee221Sahoka int (*sync) (device_t); 672b6ee221Sahoka 682b6ee221Sahoka int (*submit)(device_t, struct buf *); 692b6ee221Sahoka 702b6ee221Sahoka /* storage for partition info */ 712b6ee221Sahoka struct flash_partition partition; 722b6ee221Sahoka 732b6ee221Sahoka /* total size of mtd */ 742b6ee221Sahoka flash_addr_t size; 752b6ee221Sahoka uint32_t page_size; 762b6ee221Sahoka uint32_t erasesize; 772b6ee221Sahoka uint32_t writesize; 782b6ee221Sahoka uint32_t minor; 792b6ee221Sahoka uint8_t type; 802b6ee221Sahoka}; 812b6ee221Sahoka.Ed 822b6ee221Sahoka.Sh SEE ALSO 83839b4739Swiz.Xr flash 4 , 842b6ee221Sahoka.Xr nand 9 852b6ee221Sahoka.Sh AUTHORS 86a5684d07Swiz.An Adam Hoka Aq Mt ahoka@NetBSD.org 87