Lines Matching +full:data +full:- +full:shift
1 // SPDX-License-Identifier: GPL-2.0-only
8 * Baikal-T1 Physically Mapped Internal ROM driver
22 #include "physmap-bt1-rom.h"
25 * Baikal-T1 SoC ROMs are only accessible by the dword-aligned instructions.
26 * We have to take this into account when implementing the data read-methods.
27 * Note there is no need in bothering with endianness, since both Baikal-T1
33 void __iomem *src = map->virt + ofs; in bt1_rom_map_read()
34 unsigned int shift; in bt1_rom_map_read() local
36 u32 data; in bt1_rom_map_read() local
38 /* Read data within offset dword. */ in bt1_rom_map_read()
39 shift = (uintptr_t)src & 0x3; in bt1_rom_map_read()
40 data = readl_relaxed(src - shift); in bt1_rom_map_read()
41 if (!shift) { in bt1_rom_map_read()
42 ret.x[0] = data; in bt1_rom_map_read()
45 ret.x[0] = data >> (shift * BITS_PER_BYTE); in bt1_rom_map_read()
47 /* Read data from the next dword. */ in bt1_rom_map_read()
48 shift = 4 - shift; in bt1_rom_map_read()
49 if (ofs + shift >= map->size) in bt1_rom_map_read()
52 data = readl_relaxed(src + shift); in bt1_rom_map_read()
53 ret.x[0] |= data << (shift * BITS_PER_BYTE); in bt1_rom_map_read()
62 void __iomem *src = map->virt + from; in bt1_rom_map_copy_from()
63 unsigned int shift, chunk; in bt1_rom_map_copy_from() local
64 u32 data; in bt1_rom_map_copy_from() local
66 if (len <= 0 || from >= map->size) in bt1_rom_map_copy_from()
70 len = min_t(ssize_t, map->size - from, len); in bt1_rom_map_copy_from()
73 * Since requested data size can be pretty big we have to implement in bt1_rom_map_copy_from()
78 shift = (uintptr_t)src & 0x3; in bt1_rom_map_copy_from()
79 if (shift) { in bt1_rom_map_copy_from()
80 chunk = min_t(ssize_t, 4 - shift, len); in bt1_rom_map_copy_from()
81 data = readl_relaxed(src - shift); in bt1_rom_map_copy_from()
82 memcpy(to, (char *)&data + shift, chunk); in bt1_rom_map_copy_from()
85 len -= chunk; in bt1_rom_map_copy_from()
89 data = readl_relaxed(src); in bt1_rom_map_copy_from()
90 memcpy(to, &data, 4); in bt1_rom_map_copy_from()
93 len -= 4; in bt1_rom_map_copy_from()
97 data = readl_relaxed(src); in bt1_rom_map_copy_from()
98 memcpy(to, &data, len); in bt1_rom_map_copy_from()
106 struct device *dev = &pdev->dev; in of_flash_probe_bt1_rom()
108 /* It's supposed to be read-only MTD. */ in of_flash_probe_bt1_rom()
109 if (!of_device_is_compatible(np, "mtd-rom")) { in of_flash_probe_bt1_rom()
110 dev_info(dev, "No mtd-rom compatible string\n"); in of_flash_probe_bt1_rom()
115 if (!of_device_is_compatible(np, "baikal,bt1-int-rom")) in of_flash_probe_bt1_rom()
119 if (map->bankwidth != 4) in of_flash_probe_bt1_rom()
122 map->read = bt1_rom_map_read; in of_flash_probe_bt1_rom()
123 map->copy_from = bt1_rom_map_copy_from; in of_flash_probe_bt1_rom()