Lines Matching +full:data +full:- +full:shift

1 // SPDX-License-Identifier: GPL-2.0-only
8 * Baikal-T1 Physically Mapped Internal ROM driver
21 #include "physmap-bt1-rom.h"
24 * Baikal-T1 SoC ROMs are only accessible by the dword-aligned instructions.
25 * We have to take this into account when implementing the data read-methods.
26 * Note there is no need in bothering with endianness, since both Baikal-T1
32 void __iomem *src = map->virt + ofs; in bt1_rom_map_read()
33 unsigned int shift; in bt1_rom_map_read() local
35 u32 data; in bt1_rom_map_read() local
37 /* Read data within offset dword. */ in bt1_rom_map_read()
38 shift = (uintptr_t)src & 0x3; in bt1_rom_map_read()
39 data = readl_relaxed(src - shift); in bt1_rom_map_read()
40 if (!shift) { in bt1_rom_map_read()
41 ret.x[0] = data; in bt1_rom_map_read()
44 ret.x[0] = data >> (shift * BITS_PER_BYTE); in bt1_rom_map_read()
46 /* Read data from the next dword. */ in bt1_rom_map_read()
47 shift = 4 - shift; in bt1_rom_map_read()
48 if (ofs + shift >= map->size) in bt1_rom_map_read()
51 data = readl_relaxed(src + shift); in bt1_rom_map_read()
52 ret.x[0] |= data << (shift * BITS_PER_BYTE); in bt1_rom_map_read()
61 void __iomem *src = map->virt + from; in bt1_rom_map_copy_from()
62 unsigned int shift, chunk; in bt1_rom_map_copy_from() local
63 u32 data; in bt1_rom_map_copy_from() local
65 if (len <= 0 || from >= map->size) in bt1_rom_map_copy_from()
69 len = min_t(ssize_t, map->size - from, len); in bt1_rom_map_copy_from()
72 * Since requested data size can be pretty big we have to implement in bt1_rom_map_copy_from()
77 shift = (uintptr_t)src & 0x3; in bt1_rom_map_copy_from()
78 if (shift) { in bt1_rom_map_copy_from()
79 chunk = min_t(ssize_t, 4 - shift, len); in bt1_rom_map_copy_from()
80 data = readl_relaxed(src - shift); in bt1_rom_map_copy_from()
81 memcpy(to, (char *)&data + shift, chunk); in bt1_rom_map_copy_from()
84 len -= chunk; in bt1_rom_map_copy_from()
88 data = readl_relaxed(src); in bt1_rom_map_copy_from()
89 memcpy(to, &data, 4); in bt1_rom_map_copy_from()
92 len -= 4; in bt1_rom_map_copy_from()
96 data = readl_relaxed(src); in bt1_rom_map_copy_from()
97 memcpy(to, &data, len); in bt1_rom_map_copy_from()
105 struct device *dev = &pdev->dev; in of_flash_probe_bt1_rom()
107 /* It's supposed to be read-only MTD. */ in of_flash_probe_bt1_rom()
108 if (!of_device_is_compatible(np, "mtd-rom")) { in of_flash_probe_bt1_rom()
109 dev_info(dev, "No mtd-rom compatible string\n"); in of_flash_probe_bt1_rom()
114 if (!of_device_is_compatible(np, "baikal,bt1-int-rom")) in of_flash_probe_bt1_rom()
118 if (map->bankwidth != 4) in of_flash_probe_bt1_rom()
121 map->read = bt1_rom_map_read; in of_flash_probe_bt1_rom()
122 map->copy_from = bt1_rom_map_copy_from; in of_flash_probe_bt1_rom()