Lines Matching +full:console +full:- +full:size
1 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
3 * Freescale DPAA2 Platforms Console Driver
5 * Copyright 2015-2016 Freescale Semiconductor Inc.
9 #define pr_fmt(fmt) "dpaa2-console: " fmt
65 u32 last_byte = readl(&cd->hdr->last_byte); in adjust_end()
67 cd->end_of_data = cd->start_addr + LAST_BYTE(last_byte); in adjust_end()
93 ssize_t size; in dpaa2_console_size() local
95 if (cd->cur_ptr <= cd->end_of_data) in dpaa2_console_size()
96 size = cd->end_of_data - cd->cur_ptr; in dpaa2_console_size()
98 size = (cd->end_addr - cd->cur_ptr) + in dpaa2_console_size()
99 (cd->end_of_data - cd->start_addr); in dpaa2_console_size()
101 return size; in dpaa2_console_size()
105 u64 offset, u64 size, in dpaa2_generic_console_open() argument
116 return -ENOMEM; in dpaa2_generic_console_open()
120 err = -EIO; in dpaa2_generic_console_open()
124 cd->map_addr = ioremap(base_addr + offset, size); in dpaa2_generic_console_open()
125 if (!cd->map_addr) { in dpaa2_generic_console_open()
126 pr_err("cannot map console log memory\n"); in dpaa2_generic_console_open()
127 err = -EIO; in dpaa2_generic_console_open()
131 cd->hdr = (struct log_header __iomem *)cd->map_addr; in dpaa2_generic_console_open()
132 read_magic = readl(&cd->hdr->magic_word); in dpaa2_generic_console_open()
133 last_byte = readl(&cd->hdr->last_byte); in dpaa2_generic_console_open()
134 buf_start = readl(&cd->hdr->buf_start); in dpaa2_generic_console_open()
135 buf_length = readl(&cd->hdr->buf_length); in dpaa2_generic_console_open()
140 err = -EIO; in dpaa2_generic_console_open()
144 cd->start_addr = cd->map_addr + buf_start - offset_delta; in dpaa2_generic_console_open()
145 cd->end_addr = cd->start_addr + buf_length; in dpaa2_generic_console_open()
150 if (wrapped && cd->end_of_data != cd->end_addr) in dpaa2_generic_console_open()
151 cd->cur_ptr = cd->end_of_data + 1; in dpaa2_generic_console_open()
153 cd->cur_ptr = cd->start_addr; in dpaa2_generic_console_open()
155 fp->private_data = cd; in dpaa2_generic_console_open()
160 iounmap(cd->map_addr); in dpaa2_generic_console_open()
185 struct console_data *cd = fp->private_data; in dpaa2_console_close()
187 iounmap(cd->map_addr); in dpaa2_console_close()
195 struct console_data *cd = fp->private_data; in dpaa2_console_read()
197 size_t bytes_end = cd->end_addr - cd->cur_ptr; in dpaa2_console_read()
205 if (cd->end_of_data == cd->cur_ptr) in dpaa2_console_read()
213 return -ENOMEM; in dpaa2_console_read()
216 memcpy_fromio(kbuf, cd->cur_ptr, bytes_end); in dpaa2_console_read()
218 err = -EFAULT; in dpaa2_console_read()
222 cd->cur_ptr = cd->start_addr; in dpaa2_console_read()
223 bytes -= bytes_end; in dpaa2_console_read()
227 memcpy_fromio(kbuf, cd->cur_ptr, bytes); in dpaa2_console_read()
229 err = -EFAULT; in dpaa2_console_read()
232 cd->cur_ptr += bytes; in dpaa2_console_read()
274 error = of_address_to_resource(pdev->dev.of_node, 0, &mc_base_addr); in dpaa2_console_probe()
277 pdev->dev.of_node, error); in dpaa2_console_probe()
312 { .compatible = "fsl,dpaa2-console",},
320 .name = "dpaa2-console",
331 MODULE_DESCRIPTION("DPAA2 console driver");