extern int bcm_mailbox_property(void *data, int size) { uint32_t success; dma_addr_t mem_bus; /* the memory address accessed from videocore */ void *mem_kern; /* the memory address accessed from driver */ int s = 0; /* allocate some memory for the messages communicating with GPU */ mem_kern = dma_alloc_coherent(NULL, PAGE_ALIGN(size), &mem_bus, GFP_ATOMIC); if (mem_kern) { /* create the message */ memcpy(mem_kern, data, size); /* send the message */ wmb(); s = bcm_mailbox_write(MBOX_CHAN_PROPERTY, (uint32_t)mem_bus); if (s == 0) { s = bcm_mailbox_read(MBOX_CHAN_PROPERTY, &success); } if (s == 0) { /* copy the response */ rmb(); memcpy(data, mem_kern, size); } dma_free_coherent(NULL, PAGE_ALIGN(size), mem_kern, mem_bus); } else { s = -ENOMEM; } if (s != 0) printk(KERN_ERR DRIVER_NAME ": %s failed (%d)\n", __func__, s); return s; }
int bcm_power_request(BCM_POWER_HANDLE_T handle, uint32_t request) { int rc = 0; DPRINTK("bcm_power_request(%d, %x)\n", handle, request); if ((handle < BCM_POWER_MAXCLIENTS) && (g_state.client_request[handle] != BCM_POWER_NOCLIENT)) { if (down_interruptible(&g_state.mutex) != 0) { DPRINTK("bcm_power_request -> interrupted\n"); return -EINTR; } if (request != g_state.client_request[handle]) { uint32_t others_request = 0; uint32_t global_request; BCM_POWER_HANDLE_T i; for (i = 0; i < BCM_POWER_MAXCLIENTS; i++) { if (i != handle) others_request |= g_state.client_request[i]; } others_request &= ~BCM_POWER_NOCLIENT; global_request = request | others_request; if (global_request != g_state.global_request) { uint32_t actual; /* Send a request to VideoCore */ bcm_mailbox_write(MBOX_CHAN_POWER, global_request << 4); /* Wait for a response during power-up */ if (global_request & ~g_state.global_request) { rc = bcm_mailbox_read(MBOX_CHAN_POWER, &actual); DPRINTK ("bcm_mailbox_read -> %08x, %d\n", actual, rc); actual >>= 4; } else {