Deleted Added
full compact
bcm2835_fbd.c (259517) bcm2835_fbd.c (266022)
1/*-
2 * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
1/*-
2 * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
3 * Copyright (c) 2012, 2013 The FreeBSD Foundation
3 * All rights reserved.
4 *
4 * All rights reserved.
5 *
6 * Portions of this software were developed by Oleksandr Rybalko
7 * under sponsorship from the FreeBSD Foundation.
8 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.

--- 7 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27#include <sys/cdefs.h>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.

--- 7 unchanged lines hidden (view full) ---

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c 259517 2013-12-17 15:23:47Z ray $");
32__FBSDID("$FreeBSD: stable/10/sys/arm/broadcom/bcm2835/bcm2835_fbd.c 266022 2014-05-14 14:37:27Z ian $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bio.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/endian.h>
36#include <sys/kernel.h>

--- 57 unchanged lines hidden (view full) ---

94 struct bcm_fb_config* fb_config;
95 bus_addr_t fb_config_phys;
96 struct intr_config_hook init_hook;
97
98};
99
100static int bcm_fb_probe(device_t);
101static int bcm_fb_attach(device_t);
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/bio.h>
37#include <sys/bus.h>
38#include <sys/conf.h>
39#include <sys/endian.h>
40#include <sys/kernel.h>

--- 57 unchanged lines hidden (view full) ---

98 struct bcm_fb_config* fb_config;
99 bus_addr_t fb_config_phys;
100 struct intr_config_hook init_hook;
101
102};
103
104static int bcm_fb_probe(device_t);
105static int bcm_fb_attach(device_t);
102static void bcm_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err);
106static void bcm_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg,
107 int err);
103
104static void
105bcm_fb_init(void *arg)
106{
108
109static void
110bcm_fb_init(void *arg)
111{
107 struct bcmsc_softc *sc = arg;
108 volatile struct bcm_fb_config* fb_config = sc->fb_config;
112 volatile struct bcm_fb_config *fb_config;
113 struct bcmsc_softc *sc;
109 struct fb_info *info;
110 phandle_t node;
111 pcell_t cell;
112 device_t mbox;
113 device_t fbd;
114 int err = 0;
115
114 struct fb_info *info;
115 phandle_t node;
116 pcell_t cell;
117 device_t mbox;
118 device_t fbd;
119 int err = 0;
120
121 sc = arg;
122 fb_config = sc->fb_config;
116 node = ofw_bus_get_node(sc->dev);
117
118 fb_config->xres = 0;
119 fb_config->yres = 0;
120 fb_config->bpp = 0;
121 fb_config->vxres = 0;
122 fb_config->vyres = 0;
123 fb_config->xoffset = 0;

--- 24 unchanged lines hidden (view full) ---

148 if (mbox) {
149 MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_FB, sc->fb_config_phys);
150 MBOX_READ(mbox, BCM2835_MBOX_CHAN_FB, &err);
151 }
152 bus_dmamap_sync(sc->dma_tag, sc->dma_map,
153 BUS_DMASYNC_POSTREAD);
154
155 if (fb_config->base != 0) {
123 node = ofw_bus_get_node(sc->dev);
124
125 fb_config->xres = 0;
126 fb_config->yres = 0;
127 fb_config->bpp = 0;
128 fb_config->vxres = 0;
129 fb_config->vyres = 0;
130 fb_config->xoffset = 0;

--- 24 unchanged lines hidden (view full) ---

155 if (mbox) {
156 MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_FB, sc->fb_config_phys);
157 MBOX_READ(mbox, BCM2835_MBOX_CHAN_FB, &err);
158 }
159 bus_dmamap_sync(sc->dma_tag, sc->dma_map,
160 BUS_DMASYNC_POSTREAD);
161
162 if (fb_config->base != 0) {
156 device_printf(sc->dev, "%dx%d(%dx%d@%d,%d) %dbpp\n",
163 device_printf(sc->dev, "%dx%d(%dx%d@%d,%d) %dbpp\n",
157 fb_config->xres, fb_config->yres,
158 fb_config->vxres, fb_config->vyres,
159 fb_config->xoffset, fb_config->yoffset,
160 fb_config->bpp);
161
162
164 fb_config->xres, fb_config->yres,
165 fb_config->vxres, fb_config->vyres,
166 fb_config->xoffset, fb_config->yoffset,
167 fb_config->bpp);
168
169
163 device_printf(sc->dev, "pitch %d, base 0x%08x, screen_size %d\n",
170 device_printf(sc->dev, "pitch %d, base 0x%08x, screen_size %d\n",
164 fb_config->pitch, fb_config->base,
165 fb_config->screen_size);
166
167
168
169
171 fb_config->pitch, fb_config->base,
172 fb_config->screen_size);
173
174
175
176
170 info = malloc(sizeof(struct fb_info), M_DEVBUF, M_WAITOK | M_ZERO);
177 info = malloc(sizeof(struct fb_info), M_DEVBUF,
178 M_WAITOK | M_ZERO);
171 info->fb_name = device_get_nameunit(sc->dev);
179 info->fb_name = device_get_nameunit(sc->dev);
172 info->fb_vbase = (intptr_t)pmap_mapdev(fb_config->base, fb_config->screen_size);
180 info->fb_vbase = (intptr_t)pmap_mapdev(fb_config->base,
181 fb_config->screen_size);
173 info->fb_pbase = fb_config->base;
174 info->fb_size = fb_config->screen_size;
175 info->fb_bpp = info->fb_depth = fb_config->bpp;
176 info->fb_stride = fb_config->pitch;
177 info->fb_width = fb_config->xres;
178 info->fb_height = fb_config->yres;
179
180 sc->info = info;
181
182 info->fb_pbase = fb_config->base;
183 info->fb_size = fb_config->screen_size;
184 info->fb_bpp = info->fb_depth = fb_config->bpp;
185 info->fb_stride = fb_config->pitch;
186 info->fb_width = fb_config->xres;
187 info->fb_height = fb_config->yres;
188
189 sc->info = info;
190
182 fbd = device_add_child(sc->dev, "fbd", device_get_unit(sc->dev));
191 fbd = device_add_child(sc->dev, "fbd",
192 device_get_unit(sc->dev));
183 if (fbd == NULL) {
184 device_printf(sc->dev, "Failed to add fbd child\n");
185 return;
186 }
187 if (device_probe_and_attach(fbd) != 0) {
188 device_printf(sc->dev, "Failed to attach fbd device\n");
189 return;
190 }

--- 48 unchanged lines hidden (view full) ---

239 err = bus_dmamap_load(sc->dma_tag, sc->dma_map, sc->fb_config,
240 dma_size, bcm_fb_dmamap_cb, &sc->fb_config_phys, BUS_DMA_NOWAIT);
241
242 if (err) {
243 device_printf(dev, "cannot load DMA map\n");
244 goto fail;
245 }
246
193 if (fbd == NULL) {
194 device_printf(sc->dev, "Failed to add fbd child\n");
195 return;
196 }
197 if (device_probe_and_attach(fbd) != 0) {
198 device_printf(sc->dev, "Failed to attach fbd device\n");
199 return;
200 }

--- 48 unchanged lines hidden (view full) ---

249 err = bus_dmamap_load(sc->dma_tag, sc->dma_map, sc->fb_config,
250 dma_size, bcm_fb_dmamap_cb, &sc->fb_config_phys, BUS_DMA_NOWAIT);
251
252 if (err) {
253 device_printf(dev, "cannot load DMA map\n");
254 goto fail;
255 }
256
247 /*
248 * We have to wait until interrupts are enabled.
257 /*
258 * We have to wait until interrupts are enabled.
249 * Mailbox relies on it to get data from VideoCore
250 */
251 sc->init_hook.ich_func = bcm_fb_init;
252 sc->init_hook.ich_arg = sc;
253
254 if (config_intrhook_establish(&sc->init_hook) != 0) {
255 device_printf(dev, "failed to establish intrhook\n");
256 return (ENOMEM);

--- 51 unchanged lines hidden ---
259 * Mailbox relies on it to get data from VideoCore
260 */
261 sc->init_hook.ich_func = bcm_fb_init;
262 sc->init_hook.ich_arg = sc;
263
264 if (config_intrhook_establish(&sc->init_hook) != 0) {
265 device_printf(dev, "failed to establish intrhook\n");
266 return (ENOMEM);

--- 51 unchanged lines hidden ---