Lines Matching +full:page +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0+
6 * Copyright (C) 2005-2009 Samsung Electronics
17 * - 2048b page, 128k erase block.
18 * - 4096b page, 256k erase block.
28 #define onenand_sector_address(page) (page << 2) argument
73 density_mask = 1 << (18 + density - ffs(size)); in onenand_spl_get_geometry()
81 static int onenand_spl_read_page(uint32_t block, uint32_t page, uint32_t *buf, in onenand_spl_read_page() argument
85 uint32_t offset; in onenand_spl_read_page() local
93 onenand_writew(onenand_sector_address(page), in onenand_spl_read_page()
107 if (page < 2 && (onenand_readw(ONENAND_SPARERAM) != 0xffff)) in onenand_spl_read_page()
110 for (offset = 0; offset < pagesize; offset += 4) in onenand_spl_read_page()
111 buf[offset / 4] = readl(addr + offset); in onenand_spl_read_page()
117 /* Temporary storage for non page aligned and non page sized reads. */
121 * onenand_spl_read_block - Read data from physical eraseblock into a buffer
123 * @offset: Data offset from the start of @peb
128 * @offset + @len are not allowed to be larger than a physical
131 int onenand_spl_read_block(int block, int offset, int len, void *dst) in onenand_spl_read_block() argument
133 int page, read; in onenand_spl_read_block() local
139 /* Calculate the page number */ in onenand_spl_read_block()
140 page = offset / psize; in onenand_spl_read_block()
141 /* Offset to the start of a flash page */ in onenand_spl_read_block()
142 offset = offset % psize; in onenand_spl_read_block()
146 * Non page aligned reads go to the scratch buffer. in onenand_spl_read_block()
147 * Page aligned reads go directly to the destination. in onenand_spl_read_block()
149 if (offset || len < psize) { in onenand_spl_read_block()
150 onenand_spl_read_page(block, page, in onenand_spl_read_block()
152 read = min(len, psize - offset); in onenand_spl_read_block()
153 memcpy(dst, scratch_buf + offset, read); in onenand_spl_read_block()
154 offset = 0; in onenand_spl_read_block()
156 onenand_spl_read_page(block, page, dst, psize); in onenand_spl_read_block()
159 page++; in onenand_spl_read_block()
160 len -= read; in onenand_spl_read_block()
172 uint32_t page, rpage; in onenand_spl_load_image() local
179 * The page can be either 2k or 4k, avoid using DIV_ROUND_UP to avoid in onenand_spl_load_image()
183 page = offs / 2048; in onenand_spl_load_image()
184 to_page = page + DIV_ROUND_UP(size, 2048); in onenand_spl_load_image()
186 page = offs / 4096; in onenand_spl_load_image()
187 to_page = page + DIV_ROUND_UP(size, 4096); in onenand_spl_load_image()
190 for (; page <= to_page; page++) { in onenand_spl_load_image()
191 block = page / ONENAND_PAGES_PER_BLOCK; in onenand_spl_load_image()
192 rpage = page & (ONENAND_PAGES_PER_BLOCK - 1); in onenand_spl_load_image()
195 page += ONENAND_PAGES_PER_BLOCK - 1; in onenand_spl_load_image()