1/*
2 * Broadcom chipcommon sflash interface
3 *
4 * Copyright (C) 2015, Broadcom Corporation. All Rights Reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 * $Id: $
19 */
20
21#ifndef _hndsflash_h_
22#define _hndsflash_h_
23
24#include <typedefs.h>
25#include <sbchipc.h>
26
27struct hndsflash;
28typedef struct hndsflash hndsflash_t;
29
30struct hndsflash {
31	uint blocksize;		/* Block size */
32	uint numblocks;		/* Number of blocks */
33	uint32 type;		/* Type */
34	uint size;		/* Total size in bytes */
35	uint32 base;
36	uint32 phybase;
37	uint8 vendor_id;
38	uint16 device_id;
39
40	si_t *sih;
41	void *core;
42	int (*read)(hndsflash_t *sfl, uint offset, uint len, const uchar *buf);
43	int (*write)(hndsflash_t *sfl, uint offset, uint len, const uchar *buf);
44	int (*erase)(hndsflash_t *sfl, uint offset);
45	int (*commit)(hndsflash_t *sfl, uint offset, uint len, const uchar *buf);
46	int (*poll)(hndsflash_t *sfl, uint offset);
47};
48
49hndsflash_t *hndsflash_init(si_t *sih);
50int hndsflash_read(hndsflash_t *sfl, uint offset, uint len, const uchar *buf);
51int hndsflash_write(hndsflash_t *sfl, uint offset, uint len, const uchar *buf);
52int hndsflash_erase(hndsflash_t *sfl, uint offset);
53int hndsflash_commit(hndsflash_t *sfl, uint offset, uint len, const uchar *buf);
54int hndsflash_poll(hndsflash_t *sfl, uint offset);
55
56#endif /* _hndsflash_h_ */
57