| 223 | } |
| 224 | |
| 225 | static int |
| 226 | versatile_clcdc_attach(device_t dev) |
| 227 | { |
| 228 | struct versatile_clcdc_softc *sc = device_get_softc(dev); |
| 229 | struct video_adapter_softc *va_sc = &va_softc; |
| 230 | int err, rid; |
| 231 | uint32_t reg; |
| 232 | int clcdid; |
| 233 | int dma_size; |
| 234 | |
| 235 | /* Request memory resources */ |
| 236 | rid = 0; |
| 237 | sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); |
| 238 | if (sc->mem_res == NULL) { |
| 239 | device_printf(dev, "could not allocate memory resources\n"); |
| 240 | return (ENXIO); |
| 241 | } |
| 242 | |
| 243 | err = versatile_scm_reg_read_4(SCM_CLCD, ®); |
| 244 | if (err) { |
| 245 | device_printf(dev, "failed to read SCM register\n"); |
| 246 | goto fail; |
| 247 | } |
| 248 | clcdid = (reg >> SCM_CLCD_CLCDID_SHIFT) & SCM_CLCD_CLCDID_MASK; |
| 249 | switch (clcdid) { |
| 250 | case 31: |
| 251 | device_printf(dev, "QEMU VGA 640x480\n"); |
| 252 | sc->width = 640; |
| 253 | sc->height = 480; |
| 254 | break; |
| 255 | default: |
| 256 | device_printf(dev, "Unsupported: %d\n", clcdid); |
| 257 | goto fail; |
| 258 | } |
| 259 | |
| 260 | reg &= ~SCM_CLCD_LCD_MODE_MASK; |
| 261 | reg |= CLCD_MODE_RGB565; |
| 262 | sc->mode = CLCD_MODE_RGB565; |
| 263 | versatile_scm_reg_write_4(SCM_CLCD, reg); |
| 264 | dma_size = sc->width*sc->height*2; |
| 265 | |
| 266 | /* |
| 267 | * Power on LCD |
| 268 | */ |
| 269 | reg |= SCM_CLCD_PWR3V5VSWITCH | SCM_CLCD_NLCDIOON; |
| 270 | versatile_scm_reg_write_4(SCM_CLCD, reg); |
| 271 | |
| 272 | /* |
| 273 | * XXX: hardcoded timing for VGA. For other modes/panels |
| 274 | * we need to keep table of timing register values |
| 275 | */ |
| 276 | /* |
| 277 | * XXX: set SYS_OSC1 |
| 278 | */ |
| 279 | versatile_clcdc_write_4(sc, CLCDC_TIMING0, 0x3F1F3F9C); |
| 280 | versatile_clcdc_write_4(sc, CLCDC_TIMING1, 0x090B61DF); |
| 281 | versatile_clcdc_write_4(sc, CLCDC_TIMING2, 0x067F1800); |
| 282 | /* XXX: timing 3? */ |
nothing calls this directly
no test coverage detected