-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r316370: [versatilepb] Convert VERSATILEPB kernel to INTRNG and switch to upstream DTB Scope of this change is somewhat larger than just converting to INTRNG. The reason for this is that INTRNG support required switching from custom to upstream DTS because custom DTS didn't have interrup routing information. This switch caused rewrite of PCI and CLCD drivers and adding SCM module. List of changes in this commit: - Enable INTRNG and switch to versatile-pb.dts - Add SCM driver that controls various peripheral devices like LCD or PCI controller. Previously registers required for power-up and configuring peripherals were part of their respective nodes. Upstream DTS has dedicated node for SCM - Convert PL190 driver to INTRNG - Convert Versatile SIC (secondary interrupt controller) to INTRNG - Refactor CLCD driver to use SCM API to power up and configuration - Refactor PCI driver to use SCM API to enable controller - Refactor PCI driver to use interrupt map provided in DTS for interrupt routing. As a result it fixes broken IRQ routing and it's no longer required to run QEMU with "-global versatile_pci.broken-irq-mapping=1" command-line arguments r316371: [versatilepb] Fix keyboard driver after switching to upstream DTS FreeBSD's DTS contained only one PL050 node and driver considered it to be PS/2 keyboard. In reality PL050 is a PS/2 port that pushes bytes to/from the periphers connected to it. New DTS contains two nodes and QEMU emulates keyboard connected to port #0 and mouse connected to port #1. Since there is no way to say what's connected to port by checking DTS we hardcode this knowledge in the driver: it assumes keyboard on port #0 and ignores port #1 altogether. Also QEMU defaults emulated keyboard to scan code set 2 while driver used to work with scan code set 1 so when initializing driver make sure keyboard is switched to scan code set 1
- Loading branch information
Showing
7 changed files
with
296 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*- | ||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD | ||
* | ||
* Copyright (c) 2012 Oleksandr Tymoshenko <[email protected]> | ||
* Copyright (c) 2012-2017 Oleksandr Tymoshenko <[email protected]> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
|
@@ -52,22 +52,12 @@ __FBSDID("$FreeBSD$"); | |
#include <dev/fb/fbreg.h> | ||
#include <dev/syscons/syscons.h> | ||
|
||
#include <arm/versatile/versatile_scm.h> | ||
|
||
#include <machine/bus.h> | ||
|
||
#define PL110_VENDOR_ARM926PXP 1 | ||
|
||
#define MEM_SYS 0 | ||
#define MEM_CLCD 1 | ||
#define MEM_REGIONS 2 | ||
|
||
#define SYS_CLCD 0x00 | ||
#define SYS_CLCD_CLCDID_SHIFT 0x08 | ||
#define SYS_CLCD_CLCDID_MASK 0x1f | ||
#define SYS_CLCD_PWR3V5VSWITCH (1 << 4) | ||
#define SYS_CLCD_VDDPOSSWITCH (1 << 3) | ||
#define SYS_CLCD_NLCDIOON (1 << 2) | ||
#define SYS_CLCD_LCD_MODE_MASK 0x03 | ||
|
||
#define CLCD_MODE_RGB888 0x0 | ||
#define CLCD_MODE_RGB555 0x01 | ||
#define CLCD_MODE_RBG565 0x02 | ||
|
@@ -122,18 +112,13 @@ __FBSDID("$FreeBSD$"); | |
#define dprintf(fmt, args...) | ||
#endif | ||
|
||
#define versatile_clcdc_sys_read_4(sc, reg) \ | ||
bus_read_4((sc)->mem_res[MEM_SYS], (reg)) | ||
#define versatile_clcdc_sys_write_4(sc, reg, val) \ | ||
bus_write_4((sc)->mem_res[MEM_SYS], (reg), (val)) | ||
|
||
#define versatile_clcdc_read_4(sc, reg) \ | ||
bus_read_4((sc)->mem_res[MEM_CLCD], (reg)) | ||
bus_read_4((sc)->mem_res, (reg)) | ||
#define versatile_clcdc_write_4(sc, reg, val) \ | ||
bus_write_4((sc)->mem_res[MEM_CLCD], (reg), (val)) | ||
bus_write_4((sc)->mem_res, (reg), (val)) | ||
|
||
struct versatile_clcdc_softc { | ||
struct resource* mem_res[MEM_REGIONS]; | ||
struct resource* mem_res; | ||
|
||
struct mtx mtx; | ||
|
||
|
@@ -208,12 +193,6 @@ static u_char mouse_pointer[16] = { | |
|
||
static struct video_adapter_softc va_softc; | ||
|
||
static struct resource_spec versatile_clcdc_mem_spec[] = { | ||
{ SYS_RES_MEMORY, 0, RF_ACTIVE }, | ||
{ SYS_RES_MEMORY, 1, RF_ACTIVE }, | ||
{ -1, 0, 0 } | ||
}; | ||
|
||
static int versatilefb_configure(int); | ||
static void versatilefb_update_margins(video_adapter_t *adp); | ||
|
||
|
@@ -249,21 +228,25 @@ versatile_clcdc_attach(device_t dev) | |
{ | ||
struct versatile_clcdc_softc *sc = device_get_softc(dev); | ||
struct video_adapter_softc *va_sc = &va_softc; | ||
int err; | ||
int err, rid; | ||
uint32_t reg; | ||
int clcdid; | ||
int dma_size; | ||
|
||
/* Request memory resources */ | ||
err = bus_alloc_resources(dev, versatile_clcdc_mem_spec, | ||
sc->mem_res); | ||
if (err) { | ||
device_printf(dev, "Error: could not allocate memory resources\n"); | ||
rid = 0; | ||
sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); | ||
if (sc->mem_res == NULL) { | ||
device_printf(dev, "could not allocate memory resources\n"); | ||
return (ENXIO); | ||
} | ||
|
||
reg = versatile_clcdc_sys_read_4(sc, SYS_CLCD); | ||
clcdid = (reg >> SYS_CLCD_CLCDID_SHIFT) & SYS_CLCD_CLCDID_MASK; | ||
err = versatile_scm_reg_read_4(SCM_CLCD, ®); | ||
if (err) { | ||
device_printf(dev, "failed to read SCM register\n"); | ||
goto fail; | ||
} | ||
clcdid = (reg >> SCM_CLCD_CLCDID_SHIFT) & SCM_CLCD_CLCDID_MASK; | ||
switch (clcdid) { | ||
case 31: | ||
device_printf(dev, "QEMU VGA 640x480\n"); | ||
|
@@ -275,17 +258,17 @@ versatile_clcdc_attach(device_t dev) | |
goto fail; | ||
} | ||
|
||
reg &= ~SYS_CLCD_LCD_MODE_MASK; | ||
reg &= ~SCM_CLCD_LCD_MODE_MASK; | ||
reg |= CLCD_MODE_RGB565; | ||
sc->mode = CLCD_MODE_RGB565; | ||
versatile_clcdc_sys_write_4(sc, SYS_CLCD, reg); | ||
dma_size = sc->width*sc->height*2; | ||
|
||
/* | ||
versatile_scm_reg_write_4(SCM_CLCD, reg); | ||
dma_size = sc->width*sc->height*2; | ||
/* | ||
* Power on LCD | ||
*/ | ||
reg |= SYS_CLCD_PWR3V5VSWITCH | SYS_CLCD_NLCDIOON; | ||
versatile_clcdc_sys_write_4(sc, SYS_CLCD, reg); | ||
reg |= SCM_CLCD_PWR3V5VSWITCH | SCM_CLCD_NLCDIOON; | ||
versatile_scm_reg_write_4(SCM_CLCD, reg); | ||
|
||
/* | ||
* XXX: hardcoded timing for VGA. For other modes/panels | ||
|
@@ -658,7 +641,6 @@ versatilefb_init(int unit, video_adapter_t *adp, int flags) | |
sc->xmargin = (sc->width - (vi->vi_width * vi->vi_cwidth)) / 2; | ||
sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight))/2; | ||
|
||
|
||
adp->va_window = (vm_offset_t) versatilefb_static_window; | ||
adp->va_flags |= V_ADP_FONT /* | V_ADP_COLOR | V_ADP_MODECHANGE */; | ||
|
||
|
Oops, something went wrong.