Lines Matching +full:bcm2835 +full:- +full:firmware
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
43 #include <arm/broadcom/bcm2835/bcm2835_firmware.h>
44 #include <arm/broadcom/bcm2835/bcm2835_mbox.h>
45 #include <arm/broadcom/bcm2835/bcm2835_mbox_prop.h>
46 #include <arm/broadcom/bcm2835/bcm2835_vcbus.h>
65 mtx_lock(&(sc)->lock); \
69 mtx_unlock(&(sc)->lock); \
91 bus_space_read_4((sc)->bst, (sc)->bsh, reg)
93 bus_space_write_4((sc)->bst, (sc)->bsh, reg, val)
96 {"broadcom,bcm2835-mbox", 1},
97 {"brcm,bcm2835-mbox", 1},
116 if (sc->msg[chan]) { in bcm_mbox_read_msg()
121 sc->msg[chan] = msg; in bcm_mbox_read_msg()
138 sc->have_message[chan] = 1; in bcm_mbox_intr()
139 wakeup(&sc->have_message[chan]); in bcm_mbox_intr()
151 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in bcm_mbox_probe()
154 device_set_desc(dev, "BCM2835 VideoCore Mailbox"); in bcm_mbox_probe()
166 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); in bcm_mbox_attach()
167 if (sc->mem_res == NULL) { in bcm_mbox_attach()
172 sc->bst = rman_get_bustag(sc->mem_res); in bcm_mbox_attach()
173 sc->bsh = rman_get_bushandle(sc->mem_res); in bcm_mbox_attach()
176 sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); in bcm_mbox_attach()
177 if (sc->irq_res == NULL) { in bcm_mbox_attach()
183 if (bus_setup_intr(dev, sc->irq_res, INTR_MPSAFE | INTR_TYPE_MISC, in bcm_mbox_attach()
184 NULL, bcm_mbox_intr, sc, &sc->intr_hl) != 0) { in bcm_mbox_attach()
185 bus_release_resource(dev, SYS_RES_IRQ, rid, sc->irq_res); in bcm_mbox_attach()
190 mtx_init(&sc->lock, "vcio mbox", NULL, MTX_DEF); in bcm_mbox_attach()
192 sc->msg[i] = 0; in bcm_mbox_attach()
193 sc->have_message[i] = 0; in bcm_mbox_attach()
196 sx_init(&sc->property_chan_lock, "mboxprop"); in bcm_mbox_attach()
218 sc->have_message[chan] = 0; in bcm_mbox_write()
219 while ((mbox_read_4(sc, REG_STATUS) & STATUS_FULL) && --limit) in bcm_mbox_write()
243 if (sc->have_message[chan] == 0) { in bcm_mbox_read()
244 if (mtx_sleep(&sc->have_message[chan], &sc->lock, 0, in bcm_mbox_read()
266 *data = MBOX_DATA(sc->msg[chan]); in bcm_mbox_read()
267 sc->msg[chan] = 0; in bcm_mbox_read()
268 sc->have_message[chan] = 0; in bcm_mbox_read()
352 if (msg->code != BCM2835_MBOX_CODE_RESP_SUCCESS) { in bcm2835_mbox_err()
360 for (idx = 0; tag->tag != 0; idx++) { in bcm2835_mbox_err()
362 * When setting the GPIO config or state the firmware doesn't in bcm2835_mbox_err()
363 * set tag->val_len correctly. in bcm2835_mbox_err()
365 if ((tag->tag == BCM2835_FIRMWARE_TAG_SET_GPIO_CONFIG || in bcm2835_mbox_err()
366 tag->tag == BCM2835_FIRMWARE_TAG_SET_GPIO_STATE) && in bcm2835_mbox_err()
367 tag->val_len == 0) { in bcm2835_mbox_err()
368 tag->val_len = BCM2835_MBOX_TAG_VAL_LEN_RESPONSE | in bcm2835_mbox_err()
369 tag->val_buf_size; in bcm2835_mbox_err()
371 if ((tag->val_len & BCM2835_MBOX_TAG_VAL_LEN_RESPONSE) == 0) { in bcm2835_mbox_err()
376 tag->val_len &= ~BCM2835_MBOX_TAG_VAL_LEN_RESPONSE; in bcm2835_mbox_err()
380 sizeof(*tag) + tag->val_buf_size); in bcm2835_mbox_err()
409 sx_xlock(&sc->property_chan_lock); in bcm2835_mbox_property()
439 sx_xunlock(&sc->property_chan_lock); in bcm2835_mbox_property()
521 fb->xres = msg.physical_w_h.body.resp.width; in bcm2835_mbox_fb_get_w_h()
522 fb->yres = msg.physical_w_h.body.resp.height; in bcm2835_mbox_fb_get_w_h()
543 fb->bpp = msg.bpp.body.resp.bpp; in bcm2835_mbox_fb_get_bpp()
558 msg.physical_w_h.body.req.width = fb->xres; in bcm2835_mbox_fb_init()
559 msg.physical_w_h.body.req.height = fb->yres; in bcm2835_mbox_fb_init()
561 msg.virtual_w_h.body.req.width = fb->vxres; in bcm2835_mbox_fb_init()
562 msg.virtual_w_h.body.req.height = fb->vyres; in bcm2835_mbox_fb_init()
564 msg.offset.body.req.x = fb->xoffset; in bcm2835_mbox_fb_init()
565 msg.offset.body.req.y = fb->yoffset; in bcm2835_mbox_fb_init()
567 msg.depth.body.req.bpp = fb->bpp; in bcm2835_mbox_fb_init()
577 fb->xres = msg.physical_w_h.body.resp.width; in bcm2835_mbox_fb_init()
578 fb->yres = msg.physical_w_h.body.resp.height; in bcm2835_mbox_fb_init()
579 fb->vxres = msg.virtual_w_h.body.resp.width; in bcm2835_mbox_fb_init()
580 fb->vyres = msg.virtual_w_h.body.resp.height; in bcm2835_mbox_fb_init()
581 fb->xoffset = msg.offset.body.resp.x; in bcm2835_mbox_fb_init()
582 fb->yoffset = msg.offset.body.resp.y; in bcm2835_mbox_fb_init()
583 fb->pitch = msg.pitch.body.resp.pitch; in bcm2835_mbox_fb_init()
584 fb->base = VCBUS_TO_ARMC(msg.buffer.body.resp.fb_address); in bcm2835_mbox_fb_init()
585 fb->size = msg.buffer.body.resp.fb_size; in bcm2835_mbox_fb_init()