Skip to content

Commit e4161d9

Browse files
committed
partially fix aarch64 BE on the zero2w
1 parent 777eaee commit e4161d9

File tree

6 files changed

+72
-41
lines changed

6 files changed

+72
-41
lines changed

drivers/clk/bcm/clk-raspberrypi.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ static int raspberrypi_fw_is_prepared(struct clk_hw *hw)
198198
if (ret)
199199
return 0;
200200

201+
val = le32_to_cpu(val);
202+
201203
return !!(val & RPI_FIRMWARE_STATE_ENABLE_BIT);
202204
}
203205

@@ -215,6 +217,8 @@ static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw,
215217
if (ret)
216218
return 0;
217219

220+
val = le32_to_cpu(val);
221+
218222
return val;
219223
}
220224

@@ -310,6 +314,9 @@ static struct clk_hw *raspberrypi_clk_register(struct raspberrypi_clk *rpi,
310314
return ERR_PTR(ret);
311315
}
312316

317+
min_rate = le32_to_cpu(min_rate);
318+
max_rate = le32_to_cpu(max_rate);
319+
313320
ret = devm_clk_hw_register(rpi->dev, &data->hw);
314321
if (ret)
315322
return ERR_PTR(ret);
@@ -370,6 +377,9 @@ static int raspberrypi_discover_clocks(struct raspberrypi_clk *rpi,
370377
return ret;
371378

372379
while (clks->id) {
380+
clks->id = le32_to_cpu(clks->id);
381+
clks->parent = le32_to_cpu(clks->parent);
382+
373383
struct raspberrypi_clk_variant *variant;
374384

375385
if (clks->id >= RPI_FIRMWARE_NUM_CLK_ID) {

drivers/firmware/raspberrypi.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,27 @@ int rpi_firmware_property_list(struct rpi_firmware *fw,
109109
/* The firmware will error out without parsing in this case. */
110110
WARN_ON(size >= 1024 * 1024);
111111

112-
buf[0] = size;
113-
buf[1] = RPI_FIRMWARE_STATUS_REQUEST;
112+
buf[0] = cpu_to_le32(size);
113+
buf[1] = cpu_to_le32(RPI_FIRMWARE_STATUS_REQUEST);
114114
memcpy(&buf[2], data, tag_size);
115-
buf[size / 4 - 1] = RPI_FIRMWARE_PROPERTY_END;
115+
buf[size / 4 - 1] = cpu_to_le32(RPI_FIRMWARE_PROPERTY_END);
116+
117+
//for (int i=0; i < (size/4); i++) printk(" 0x%x ", buf[i]);
118+
116119
wmb();
117120

118121
ret = rpi_firmware_transaction(fw, MBOX_CHAN_PROPERTY, bus_addr);
119122

120123
rmb();
121124
memcpy(data, &buf[2], tag_size);
122-
if (ret == 0 && buf[1] != RPI_FIRMWARE_STATUS_SUCCESS) {
125+
if (ret == 0 && le32_to_cpu(buf[1]) != RPI_FIRMWARE_STATUS_SUCCESS) {
123126
/*
124127
* The tag name here might not be the one causing the
125128
* error, if there were multiple tags in the request.
126129
* But single-tag is the most common, so go with it.
127130
*/
128131
dev_err(fw->cl.dev, "Request 0x%08x returned status 0x%08x\n",
129-
buf[2], buf[1]);
132+
le32_to_cpu(buf[2]), le32_to_cpu(buf[1]));
130133
ret = -EINVAL;
131134
}
132135

@@ -167,8 +170,8 @@ int rpi_firmware_property(struct rpi_firmware *fw,
167170
return -ENOMEM;
168171

169172
header = data;
170-
header->tag = tag;
171-
header->buf_size = buf_size;
173+
header->tag = cpu_to_le32(tag);
174+
header->buf_size = cpu_to_le32(buf_size);
172175
header->req_resp_size = 0;
173176
memcpy(data + sizeof(*header), tag_data, buf_size);
174177

@@ -272,10 +275,11 @@ rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
272275
return;
273276

274277
/* This is not compatible with y2038 */
275-
date_and_time = packet;
278+
date_and_time = le32_to_cpu(packet);
276279

277280
ret = rpi_firmware_property(fw, RPI_FIRMWARE_GET_FIRMWARE_VARIANT,
278281
&variant, sizeof(variant));
282+
variant = le32_to_cpu(variant);
279283

280284
if (!ret) {
281285
if (variant >= ARRAY_SIZE(variant_strs))
@@ -299,6 +303,8 @@ rpi_firmware_print_firmware_hash(struct rpi_firmware *fw)
299303
if (ret)
300304
return;
301305

306+
for (int i=0; i<5; i++) hash[i] = le32_to_cpu(hash[i]);
307+
302308
dev_info(fw->cl.dev,
303309
"Firmware hash is %08x%08x%08x%08x%08x\n",
304310
hash[0], hash[1], hash[2], hash[3], hash[4]);

drivers/hwmon/raspberrypi-hwmon.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static void rpi_firmware_get_throttled(struct rpi_hwmon_data *data)
3131
int ret;
3232

3333
/* Request firmware to clear sticky bits */
34-
value = 0xffff;
34+
value = cpu_to_le32(0xffff);
3535

3636
ret = rpi_firmware_property(data->fw, RPI_FIRMWARE_GET_THROTTLED,
3737
&value, sizeof(value));
@@ -40,6 +40,7 @@ static void rpi_firmware_get_throttled(struct rpi_hwmon_data *data)
4040
ret);
4141
return;
4242
}
43+
value = le32_to_cpu(value);
4344

4445
new_uv = value & UNDERVOLTAGE_STICKY_BIT;
4546
old_uv = data->last_throttled & UNDERVOLTAGE_STICKY_BIT;

drivers/mmc/host/bcm2835-sdhost.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,13 +1568,13 @@ void bcm2835_sdhost_set_clock(struct bcm2835_host *host, unsigned int clock)
15681568
host->mmc->actual_clock = 0;
15691569

15701570
if (host->firmware_sets_cdiv) {
1571-
u32 msg[3] = { clock, 0, 0 };
1571+
u32 msg[3] = { cpu_to_le32(clock), 0, 0 };
15721572

15731573
rpi_firmware_property(host->fw,
15741574
RPI_FIRMWARE_SET_SDHOST_CLOCK,
15751575
&msg, sizeof(msg));
15761576

1577-
clock = max(msg[1], msg[2]);
1577+
clock = max(le32_to_cpu(msg[1]), le32_to_cpu(msg[2]));
15781578
spin_lock_irqsave(&host->lock, flags);
15791579
} else {
15801580
spin_lock_irqsave(&host->lock, flags);
@@ -2142,14 +2142,14 @@ static int bcm2835_sdhost_probe(struct platform_device *pdev)
21422142
mmc->caps |= MMC_CAP_4_BIT_DATA;
21432143

21442144
msg[0] = 0;
2145-
msg[1] = ~0;
2146-
msg[2] = ~0;
2145+
msg[1] = cpu_to_le32(~0);
2146+
msg[2] = cpu_to_le32(~0);
21472147

21482148
rpi_firmware_property(host->fw,
21492149
RPI_FIRMWARE_SET_SDHOST_CLOCK,
21502150
&msg, sizeof(msg));
21512151

2152-
host->firmware_sets_cdiv = (msg[1] != ~0);
2152+
host->firmware_sets_cdiv = (le32_to_cpu(msg[1]) != ~0);
21532153

21542154
platform_set_drvdata(pdev, host);
21552155

drivers/pmdomain/bcm/raspberrypi-power.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ rpi_has_new_domain_support(struct rpi_power_domains *rpi_domains)
141141
struct rpi_power_domain_packet packet;
142142
int ret;
143143

144-
packet.domain = RPI_POWER_DOMAIN_ARM;
145-
packet.on = ~0;
144+
packet.domain = cpu_to_le32(RPI_POWER_DOMAIN_ARM);
145+
packet.on = cpu_to_le32(~0);
146146

147147
ret = rpi_firmware_property(rpi_domains->fw,
148148
RPI_FIRMWARE_GET_DOMAIN_STATE,
149149
&packet, sizeof(packet));
150150

151-
return ret == 0 && packet.on != ~0;
151+
return ret == 0 && le32_to_cpu(packet.on) != ~0;
152152
}
153153

154154
static int rpi_power_probe(struct platform_device *pdev)

drivers/video/fbdev/bcm2708_fb.c

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int bcm2708_fb_debugfs_init(struct bcm2708_fb *fb)
215215
static void set_display_num(struct bcm2708_fb *fb)
216216
{
217217
if (fb && fb->fbdev && fb->fbdev->firmware_supports_multifb) {
218-
u32 tmp = fb->display_settings.display_num;
218+
u32 tmp = cpu_to_le32(fb->display_settings.display_num);
219219

220220
if (rpi_firmware_property(fb->fbdev->fw,
221221
RPI_FIRMWARE_FRAMEBUFFER_SET_DISPLAY_NUM,
@@ -350,22 +350,22 @@ static int bcm2708_fb_set_par(struct fb_info *info)
350350
{
351351
struct bcm2708_fb *fb = to_bcm2708(info);
352352
struct fb_alloc_tags fbinfo = {
353-
.tag1 = { RPI_FIRMWARE_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT,
354-
8, 0, },
355-
.xres = info->var.xres,
356-
.yres = info->var.yres,
357-
.tag2 = { RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT,
358-
8, 0, },
359-
.xres_virtual = info->var.xres_virtual,
360-
.yres_virtual = info->var.yres_virtual,
361-
.tag3 = { RPI_FIRMWARE_FRAMEBUFFER_SET_DEPTH, 4, 0 },
362-
.bpp = info->var.bits_per_pixel,
363-
.tag4 = { RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_OFFSET, 8, 0 },
364-
.xoffset = info->var.xoffset,
365-
.yoffset = info->var.yoffset,
366-
.tag5 = { RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE, 8, 0 },
353+
.tag1 = { cpu_to_le32(RPI_FIRMWARE_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT),
354+
cpu_to_le32(8), 0, },
355+
.xres = cpu_to_le32(info->var.xres),
356+
.yres = cpu_to_le32(info->var.yres),
357+
.tag2 = { cpu_to_le32(RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT),
358+
cpu_to_le32(8), 0, },
359+
.xres_virtual = cpu_to_le32(info->var.xres_virtual),
360+
.yres_virtual = cpu_to_le32(info->var.yres_virtual),
361+
.tag3 = { cpu_to_le32(RPI_FIRMWARE_FRAMEBUFFER_SET_DEPTH), cpu_to_le32(4), 0 },
362+
.bpp = cpu_to_le32(info->var.bits_per_pixel),
363+
.tag4 = { cpu_to_le32(RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_OFFSET), cpu_to_le32(8), 0 },
364+
.xoffset = cpu_to_le32(info->var.xoffset),
365+
.yoffset = cpu_to_le32(info->var.yoffset),
366+
.tag5 = { cpu_to_le32(RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE), cpu_to_le32(8), 0 },
367367
/* base and screen_size will be initialised later */
368-
.tag6 = { RPI_FIRMWARE_FRAMEBUFFER_SET_PITCH, 4, 0 },
368+
.tag6 = { cpu_to_le32(RPI_FIRMWARE_FRAMEBUFFER_SET_PITCH), cpu_to_le32(4), 0 },
369369
/* pitch will be initialised later */
370370
};
371371
int ret, image_size;
@@ -397,6 +397,7 @@ static int bcm2708_fb_set_par(struct fb_info *info)
397397
fb->dma_addr = 0;
398398
}
399399

400+
printk(KERN_ERR"allocating %d bytes\n", image_size);
400401
fb->cpuaddr = dma_alloc_coherent(info->device, image_size,
401402
&fb->dma_addr, GFP_KERNEL);
402403

@@ -409,13 +410,13 @@ static int bcm2708_fb_set_par(struct fb_info *info)
409410
}
410411

411412
if (fb->cpuaddr) {
412-
fbinfo.base = fb->dma_addr;
413-
fbinfo.screen_size = image_size;
414-
fbinfo.pitch = (info->var.xres * info->var.bits_per_pixel) >> 3;
413+
fbinfo.base = cpu_to_le32(fb->dma_addr);
414+
fbinfo.screen_size = cpu_to_le32(image_size);
415+
fbinfo.pitch = cpu_to_le32((info->var.xres * info->var.bits_per_pixel) >> 3);
415416

416417
ret = rpi_firmware_property_list(fb->fbdev->fw, &fbinfo,
417418
sizeof(fbinfo));
418-
if (ret || fbinfo.base != fb->dma_addr) {
419+
if (ret || le32_to_cpu(fbinfo.base) != fb->dma_addr) {
419420
/* Firmware either failed, or assigned a different base
420421
* address (ie it doesn't support being passed an FB
421422
* allocation).
@@ -442,7 +443,7 @@ static int bcm2708_fb_set_par(struct fb_info *info)
442443
*/
443444
fbinfo.base = 0;
444445
fbinfo.screen_size = 0;
445-
fbinfo.tag6.tag = RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH;
446+
fbinfo.tag6.tag = cpu_to_le32(RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH);
446447
fbinfo.pitch = 0;
447448

448449
ret = rpi_firmware_property_list(fb->fbdev->fw, &fbinfo,
@@ -460,6 +461,14 @@ static int bcm2708_fb_set_par(struct fb_info *info)
460461
else
461462
fb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
462463

464+
fbinfo.base = le32_to_cpu(fbinfo.base);
465+
fbinfo.bpp = le32_to_cpu(fbinfo.bpp);
466+
fbinfo.pitch = le32_to_cpu(fbinfo.pitch);
467+
fbinfo.screen_size = le32_to_cpu(fbinfo.screen_size);
468+
fbinfo.xres = le32_to_cpu(fbinfo.xres);
469+
fbinfo.yres = le32_to_cpu(fbinfo.yres);
470+
fbinfo.yres_virtual = le32_to_cpu(fbinfo.yres_virtual);
471+
463472
fb->fb.fix.line_length = fbinfo.pitch;
464473
fbinfo.base |= 0x40000000;
465474
fb->fb_bus_address = fbinfo.base;
@@ -1087,6 +1096,7 @@ static int bcm2708_fb_probe(struct platform_device *dev)
10871096
ret = rpi_firmware_property(fw,
10881097
RPI_FIRMWARE_FRAMEBUFFER_GET_NUM_DISPLAYS,
10891098
&num_displays, sizeof(u32));
1099+
num_displays = le32_to_cpu(num_displays);
10901100

10911101
/* If we fail to get the number of displays, or it returns 0, then
10921102
* assume old firmware that doesn't have the mailbox call, so just
@@ -1149,19 +1159,23 @@ static int bcm2708_fb_probe(struct platform_device *dev)
11491159
for (i = 0; i < num_displays; i++) {
11501160
struct bcm2708_fb *fb = &fbdev->displays[i];
11511161

1152-
fb->display_settings.display_num = i;
1162+
fb->display_settings.display_num = cpu_to_le32(i);
11531163
fb->dev = dev;
11541164
fb->fb.device = &dev->dev;
11551165
fb->fbdev = fbdev;
11561166

1157-
fb->gpu.base = gpu_mem.base;
1158-
fb->gpu.length = gpu_mem.length;
1167+
fb->gpu.base = le32_to_cpu(gpu_mem.base);
1168+
fb->gpu.length = le32_to_cpu(gpu_mem.length);
11591169

11601170
if (fbdev->firmware_supports_multifb) {
11611171
ret = rpi_firmware_property(fw,
11621172
RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_SETTINGS,
11631173
&fb->display_settings,
11641174
GET_DISPLAY_SETTINGS_PAYLOAD_SIZE);
1175+
fb->display_settings.display_num = le32_to_cpu(fb->display_settings.display_num);
1176+
fb->display_settings.width = le32_to_cpu(fb->display_settings.width);
1177+
fb->display_settings.height = le32_to_cpu(fb->display_settings.height);
1178+
fb->display_settings.depth = le32_to_cpu(fb->display_settings.depth);
11651179
} else {
11661180
memset(&fb->display_settings, 0,
11671181
sizeof(fb->display_settings));

0 commit comments

Comments
 (0)