1210284Sjmallett/***********************license start***************
2232812Sjmallett * Copyright (c) 2003-2010  Cavium Inc. (support@cavium.com). All rights
3215990Sjmallett * reserved.
4210284Sjmallett *
5210284Sjmallett *
6215990Sjmallett * Redistribution and use in source and binary forms, with or without
7215990Sjmallett * modification, are permitted provided that the following conditions are
8215990Sjmallett * met:
9210284Sjmallett *
10215990Sjmallett *   * Redistributions of source code must retain the above copyright
11215990Sjmallett *     notice, this list of conditions and the following disclaimer.
12210284Sjmallett *
13215990Sjmallett *   * Redistributions in binary form must reproduce the above
14215990Sjmallett *     copyright notice, this list of conditions and the following
15215990Sjmallett *     disclaimer in the documentation and/or other materials provided
16215990Sjmallett *     with the distribution.
17215990Sjmallett
18232812Sjmallett *   * Neither the name of Cavium Inc. nor the names of
19215990Sjmallett *     its contributors may be used to endorse or promote products
20215990Sjmallett *     derived from this software without specific prior written
21215990Sjmallett *     permission.
22215990Sjmallett
23215990Sjmallett * This Software, including technical data, may be subject to U.S. export  control
24215990Sjmallett * laws, including the U.S. Export Administration Act and its  associated
25215990Sjmallett * regulations, and may be subject to export or import  regulations in other
26215990Sjmallett * countries.
27215990Sjmallett
28215990Sjmallett * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29232812Sjmallett * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30215990Sjmallett * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31215990Sjmallett * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32215990Sjmallett * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33215990Sjmallett * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34215990Sjmallett * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35215990Sjmallett * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36215990Sjmallett * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37215990Sjmallett * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38210284Sjmallett ***********************license end**************************************/
39210284Sjmallett
40210284Sjmallett
41210284Sjmallett
42210284Sjmallett
43210284Sjmallett
44210284Sjmallett
45215990Sjmallett
46210284Sjmallett/**
47210284Sjmallett * @file
48210284Sjmallett *
49210284Sjmallett * This file provides bootbus flash operations
50210284Sjmallett *
51232812Sjmallett * <hr>$Revision: 70030 $<hr>
52210284Sjmallett *
53210284Sjmallett *
54210284Sjmallett */
55210284Sjmallett
56210284Sjmallett
57210284Sjmallett#ifndef __CVMX_FLASH_H__
58210284Sjmallett#define __CVMX_FLASH_H__
59210284Sjmallett
60210284Sjmallett#ifdef	__cplusplus
61210284Sjmallettextern "C" {
62210284Sjmallett#endif
63210284Sjmallett
64210284Sjmalletttypedef struct
65210284Sjmallett{
66210284Sjmallett    int start_offset;
67210284Sjmallett    int block_size;
68210284Sjmallett    int num_blocks;
69210284Sjmallett} cvmx_flash_region_t;
70210284Sjmallett
71210284Sjmallett/**
72210284Sjmallett * Initialize the flash access library
73210284Sjmallett */
74210284Sjmallettvoid cvmx_flash_initialize(void);
75210284Sjmallett
76210284Sjmallett/**
77210284Sjmallett * Return a pointer to the flash chip
78210284Sjmallett *
79210284Sjmallett * @param chip_id Chip ID to return
80210284Sjmallett * @return NULL if the chip doesn't exist
81210284Sjmallett */
82210284Sjmallettvoid *cvmx_flash_get_base(int chip_id);
83210284Sjmallett
84210284Sjmallett/**
85210284Sjmallett * Return the number of erasable regions on the chip
86210284Sjmallett *
87210284Sjmallett * @param chip_id Chip to return info for
88210284Sjmallett * @return Number of regions
89210284Sjmallett */
90210284Sjmallettint cvmx_flash_get_num_regions(int chip_id);
91210284Sjmallett
92210284Sjmallett/**
93210284Sjmallett * Return information about a flash chips region
94210284Sjmallett *
95210284Sjmallett * @param chip_id Chip to get info for
96210284Sjmallett * @param region  Region to get info for
97210284Sjmallett * @return Region information
98210284Sjmallett */
99210284Sjmallettconst cvmx_flash_region_t *cvmx_flash_get_region_info(int chip_id, int region);
100210284Sjmallett
101210284Sjmallett/**
102210284Sjmallett * Erase a block on the flash chip
103210284Sjmallett *
104210284Sjmallett * @param chip_id Chip to erase a block on
105210284Sjmallett * @param region  Region to erase a block in
106210284Sjmallett * @param block   Block number to erase
107210284Sjmallett * @return Zero on success. Negative on failure
108210284Sjmallett */
109210284Sjmallettint cvmx_flash_erase_block(int chip_id, int region, int block);
110210284Sjmallett
111210284Sjmallett/**
112210284Sjmallett * Write a block on the flash chip
113210284Sjmallett *
114210284Sjmallett * @param chip_id Chip to write a block on
115210284Sjmallett * @param region  Region to write a block in
116210284Sjmallett * @param block   Block number to write
117210284Sjmallett * @param data    Data to write
118210284Sjmallett * @return Zero on success. Negative on failure
119210284Sjmallett */
120210284Sjmallettint cvmx_flash_write_block(int chip_id, int region, int block, const void *data);
121210284Sjmallett
122210284Sjmallett/**
123210284Sjmallett * Erase and write data to a flash
124210284Sjmallett *
125210284Sjmallett * @param address Memory address to write to
126210284Sjmallett * @param data    Data to write
127210284Sjmallett * @param len     Length of the data
128210284Sjmallett * @return Zero on success. Negative on failure
129210284Sjmallett */
130210284Sjmallettint cvmx_flash_write(void *address, const void *data, int len);
131210284Sjmallett
132210284Sjmallett#ifdef	__cplusplus
133210284Sjmallett}
134210284Sjmallett#endif
135210284Sjmallett
136210284Sjmallett#endif /* __CVMX_FLASH_H__ */
137