diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2005-01-21 16:22:35 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2005-01-21 16:22:35 +0000 |
commit | 6405d08b800a0b4df1a326899f3fac2c24649acb (patch) | |
tree | 0e82d443e5f01328416142c48bc5172dd92d4cc4 /sys/arch/zaurus | |
parent | a682022fdcaf037e0749c3d29b5b238237ef6ea9 (diff) |
Overhaul of the pxa2x0_lcd code, to allow early (before autoconf) attachment,
and collateral changes.
Because this driver requires us_dma (and as such, vm services) to work, it
can not be selected in consinit(). Instead, add a hook to the arm
cpu_startup() which will, on zaurus, switch console from serial (selected
in consinit()) to lcd.
This also makes the zaurus-specific early pxa2x0_clkman() substitute code
cleaner.
While there, move boot -c handling later, after the glass console is set up.
Tested by drahn@ and uwe@
Diffstat (limited to 'sys/arch/zaurus')
-rw-r--r-- | sys/arch/zaurus/zaurus/zaurus_lcd.c | 107 | ||||
-rw-r--r-- | sys/arch/zaurus/zaurus/zaurus_machdep.c | 158 |
2 files changed, 135 insertions, 130 deletions
diff --git a/sys/arch/zaurus/zaurus/zaurus_lcd.c b/sys/arch/zaurus/zaurus/zaurus_lcd.c index b42fed15bf9..1a41096caef 100644 --- a/sys/arch/zaurus/zaurus/zaurus_lcd.c +++ b/sys/arch/zaurus/zaurus/zaurus_lcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_lcd.c,v 1.10 2005/01/13 17:44:43 drahn Exp $ */ +/* $OpenBSD: zaurus_lcd.c,v 1.11 2005/01/21 16:22:34 miod Exp $ */ /* $NetBSD: lubbock_lcd.c,v 1.1 2003/08/09 19:38:53 bsh Exp $ */ /* @@ -60,9 +60,9 @@ #include <machine/zaurus_reg.h> #include <machine/zaurus_var.h> -int lcd_match(struct device *, void *, void *); void lcd_attach(struct device *, struct device *, void *); -int lcdintr(void *); +int lcd_match(struct device *, void *, void *); +int lcd_cnattach(void (*)(u_int, int)); /* * wsdisplay glue @@ -70,31 +70,13 @@ int lcdintr(void *); struct pxa2x0_wsscreen_descr lcd_bpp16_screen = { { - "std" /* "bpp16" */ + "std" }, 16 /* bits per pixel */ -#ifdef notyet -}, lcd_bpp8_screen = { - { - "bpp8" - }, - 8 /* bits per pixel */ -}, lcd_bpp4_screen = { - { - "bpp4" - }, - 4 /* bits per pixel */ -#endif }; - static const struct wsscreen_descr *lcd_scr_descr[] = { -#ifdef notyet - /* bpp4 needs a patch to rasops4 */ - &lcd_bpp4_screen.c, - &lcd_bpp8_screen.c, -#endif - &lcd_bpp16_screen.c, + &lcd_bpp16_screen.c }; const struct wsscreen_list lcd_screen_list = { @@ -125,68 +107,48 @@ struct cfdriver lcd_cd = { NULL, "lcd_pxaip", DV_DULL }; -int -lcd_match(struct device *parent, void *cf, void *aux) -{ - return 1; -} - #define CURRENT_DISPLAY &sharp_zaurus_C3000 -static const struct lcd_panel_geometry sharp_zaurus_C3000 = +const struct lcd_panel_geometry sharp_zaurus_C3000 = { - 480, /* Width */ - 640, /* Height */ - 0, /* No extra lines */ + 480, /* Width */ + 640, /* Height */ + 0, /* No extra lines */ - LCDPANEL_ACTIVE | LCDPANEL_VSP | LCDPANEL_HSP, - 1, /* clock divider */ - 0, /* AC bias pin freq */ + LCDPANEL_ACTIVE | LCDPANEL_VSP | LCDPANEL_HSP, + 1, /* clock divider */ + 0, /* AC bias pin freq */ - 0x28, /* horizontal sync pulse width */ - 0x2e, /* BLW */ - 0x7d, /* ELW */ + 0x28, /* horizontal sync pulse width */ + 0x2e, /* BLW */ + 0x7d, /* ELW */ - 2, /* vertical sync pulse width */ - 1, /* BFW */ - 0, /* EFW */ + 2, /* vertical sync pulse width */ + 1, /* BFW */ + 0, /* EFW */ }; +int +lcd_match(struct device *parent, void *cf, void *aux) +{ + return 1; +} + void lcd_attach(struct device *parent, struct device *self, void *aux) { struct pxa2x0_lcd_softc *sc = (struct pxa2x0_lcd_softc *)self; struct wsemuldisplaydev_attach_args aa; - long defattr; - - pxa2x0_lcd_attach_sub(sc, aux, CURRENT_DISPLAY); + int console; - /* make wsdisplay screen list */ - pxa2x0_lcd_setup_wsscreen(sc, &lcd_bpp16_screen, CURRENT_DISPLAY, NULL); -#ifdef notyet - pxa2x0_lcd_setup_wsscreen(sc, &lcd_bpp8_screen, CURRENT_DISPLAY, NULL); - pxa2x0_lcd_setup_wsscreen(sc, &lcd_bpp4_screen, CURRENT_DISPLAY, NULL); -#endif + console = 1; /* XXX allow user configuration? */ printf("\n"); - aa.console = 1; /* XXX allow user configuration? */ - - if (aa.console != 0) { - if (pxa2x0_lcd_setup_console(sc, &lcd_bpp16_screen) == 0) { - /* assumes 16bpp */ - sc->sc_ro.ri_ops.alloc_attr(&sc->sc_ro, 0, 0, 0, - &defattr); - - wsdisplay_cnattach(&lcd_bpp16_screen.c, &sc->sc_ro, - sc->sc_ro.ri_ccol, sc->sc_ro.ri_crow, defattr); - } else { - printf("%s: failed to initialize console!\n", - sc->dev.dv_xname); - aa.console = 0; /* better than panicing... */ - } - } + pxa2x0_lcd_attach_sub(sc, aux, &lcd_bpp16_screen, CURRENT_DISPLAY, + console); + aa.console = console; aa.scrdata = &lcd_screen_list; aa.accessops = &lcd_accessops; aa.accesscookie = sc; @@ -194,6 +156,17 @@ lcd_attach(struct device *parent, struct device *self, void *aux) (void)config_found(self, &aa, wsemuldisplaydevprint); } +int +lcd_cnattach(void (*clkman)(u_int, int)) +{ + return + (pxa2x0_lcd_cnattach(&lcd_bpp16_screen, CURRENT_DISPLAY, clkman)); +} + +/* + * wsdisplay accessops overrides + */ + void lcd_burner(void *v, u_int on, u_int flags) { diff --git a/sys/arch/zaurus/zaurus/zaurus_machdep.c b/sys/arch/zaurus/zaurus/zaurus_machdep.c index d05b1e2ed6e..ea5f3e67c96 100644 --- a/sys/arch/zaurus/zaurus/zaurus_machdep.c +++ b/sys/arch/zaurus/zaurus/zaurus_machdep.c @@ -112,10 +112,6 @@ * S20: no-dot: set RB_SINGLE. don't go multi user mode. */ -#include <sys/cdefs.h> -#include "rd.h" -#include "lcd.h" - #include <sys/param.h> #include <sys/device.h> #include <sys/systm.h> @@ -155,6 +151,8 @@ #include <machine/zaurus_reg.h> #include <machine/zaurus_var.h> +#include "wsdisplay.h" + /* Kernel text starts 2MB in from the bottom of the kernel address space. */ #define KERNEL_TEXT_BASE (KERNEL_BASE + 0x00200000) #define KERNEL_VM_BASE (KERNEL_BASE + 0x04000000) @@ -244,6 +242,7 @@ void parse_mi_bootargs(char *args); #endif void consinit(void); +void early_clkman(u_int, int); void kgdb_port_init(void); void change_clock(uint32_t v); @@ -499,7 +498,7 @@ bootstrap_bs_map(void *t, bus_addr_t bpa, bus_size_t size, startpa = trunc_page(bpa); pmap_map_section((vaddr_t)pagedir, va, startpa, - VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE); + VM_PROT_READ | VM_PROT_WRITE, PTE_NOCACHE); cpu_tlb_flushD(); *bshp = (bus_space_handle_t)(va + (bpa - startpa)); @@ -595,12 +594,12 @@ initarm(void *arg) #ifdef DIAGNOSTIC extern vsize_t xscale_minidata_clean_size; /* used in KASSERT */ #endif + /* early bus_space_map support */ struct bus_space tmp_bs_tag; int (*map_func_save)(void *, bus_addr_t, bus_size_t, int, bus_space_handle_t *); - #if 0 /* XXX */ /* start 32.768KHz OSC */ @@ -689,18 +688,25 @@ initarm(void *arg) #if 1 /* turn on clock to UART block. - XXX: this should not be done here. */ - ioreg_write(ZAURUS_CLKMAN_VBASE+CLKMAN_CKEN, CKEN_FFUART|CKEN_BTUART | - ioreg_read(ZAURUS_CLKMAN_VBASE+CLKMAN_CKEN)); + XXX this should not be necessary, consinit() will do it */ + early_clkman(CKEN_FFUART | CKEN_BTUART, 1); #endif green_on(0); + /* + * Temporarily replace bus_space_map() functions so that + * console devices can get mapped. + * + * Note that this relies upon the fact that both regular + * and a4x bus_space tags use the same map function. + */ tmp_bs_tag = pxa2x0_bs_tag; tmp_bs_tag.bs_map = bootstrap_bs_map; - map_func_save = pxa2x0_a4x_bs_tag.bs_map; - pxa2x0_a4x_bs_tag.bs_map = bootstrap_bs_map; + map_func_save = pxa2x0_bs_tag.bs_map; + pxa2x0_a4x_bs_tag.bs_map = pxa2x0_bs_tag.bs_map = bootstrap_bs_map; + /* setup a serial console for very early boot */ consinit(); #ifdef KGDB kgdb_port_init(); @@ -1076,15 +1082,6 @@ initarm(void *arg) printf("bootstrap done.\n"); #endif - if (boothowto & RB_CONFIG) { -#ifdef BOOT_CONFIG - user_config(); -#else - printf("kernel does not support -c; continuing..\n"); -#endif - } - - arm32_vector_init(ARM_VECTORS_LOW, ARM_VEC_ALL); /* @@ -1162,6 +1159,11 @@ initarm(void *arg) } #endif + /* + * Restore proper bus_space operation, now that pmap is initialized. + */ + pxa2x0_a4x_bs_tag.bs_map = pxa2x0_bs_tag.bs_map = map_func_save; + #ifdef DDB db_machine_init(); @@ -1172,8 +1174,6 @@ initarm(void *arg) Debugger(); #endif - pxa2x0_a4x_bs_tag.bs_map = map_func_save ; - /* We return the new stack pointer address */ return(kernelstack.pv_va + USPACE_SVC_STACK_TOP); } @@ -1225,12 +1225,10 @@ int comkgdbmode = KGDB_DEVMODE; #endif /* KGDB */ - void consinit(void) { static int consinit_called = 0; - uint32_t ckenreg = ioreg_read(ZAURUS_CLKMAN_VBASE+CLKMAN_CKEN); #if 0 char *console = CONSDEVNAME; #endif @@ -1243,45 +1241,32 @@ consinit(void) #if NCOM > 0 #ifdef FFUARTCONSOLE - if (0) { - /* We don't use FF serial when S17=no-dot position */ - } #ifdef KGDB - else if (0 == strcmp(kgdb_devname, "ffuart")) { + if (strcmp(kgdb_devname, "ffuart") == 0) { /* port is reserved for kgdb */ - } -#endif - else if (0 == comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_FFUART_BASE, - comcnspeed, PXA2X0_COM_FREQ, comcnmode)) { -#if 0 - /* XXX: can't call pxa2x0_clkman_config yet */ - pxa2x0_clkman_config(CKEN_FFUART, 1); -#else - ioreg_write(ZAURUS_CLKMAN_VBASE+CLKMAN_CKEN, - ckenreg|CKEN_FFUART); + } else #endif - + if (comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_FFUART_BASE, comcnspeed, + PXA2X0_COM_FREQ, comcnmode) == 0) { + early_clkman(CKEN_FFUART, 1); return; } #endif /* FFUARTCONSOLE */ #ifdef BTUARTCONSOLE #ifdef KGDB - if (0 == strcmp(kgdb_devname, "btuart")) { + if (strcmp(kgdb_devname, "btuart") == 0) { /* port is reserved for kgdb */ } else #endif - if (0 == comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_BTUART_BASE, - comcnspeed, PXA2X0_COM_FREQ, comcnmode)) { - ioreg_write(ZAURUS_CLKMAN_VBASE+CLKMAN_CKEN, - ckenreg|CKEN_BTUART); + if (comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_BTUART_BASE, comcnspeed, + PXA2X0_COM_FREQ, comcnmode) == 0) { + early_clkman(CKEN_BTUART, 1); return; } #endif /* BTUARTCONSOLE */ - #endif /* NCOM */ - } #ifdef KGDB @@ -1289,28 +1274,75 @@ void kgdb_port_init(void) { #if (NCOM > 0) && defined(COM_PXA2X0) - paddr_t paddr = 0; - enum pxa2x0_uart_id uart_id; - uint32_t ckenreg = ioreg_read(ZAURUS_CLKMAN_VBASE+CLKMAN_CKEN); + paddr_t paddr; + u_int cken; - if (0 == strcmp(kgdb_devname, "ffuart")) { + if (strcmp(kgdb_devname, "ffuart") == 0) { paddr = PXA2X0_FFUART_BASE; - clenreg |= CKEN_FFUART; - } - else if (0 == strcmp(kgdb_devname, "btuart")) { + cken = CKEN_FFUART; + } else if (strcmp(kgdb_devname, "btuart") == 0) { paddr = PXA2X0_BTUART_BASE; - clenreg |= CKEN_BTUART; + cken = CKEN_BTUART; + } else + return; + + if (com_kgdb_attach_pxa2x0(&pxa2x0_a4x_bs_tag, paddr, + kgdb_rate, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comkgdbmode) == 0) { + early_clkman(cken, 1); } +#endif +} +#endif + +/* same as pxa2x0_clkman, but before autoconf */ +void +early_clkman(u_int clk, int enable) +{ + u_int32_t rv; - if (paddr && - 0 == com_kgdb_attach_pxa2x0(&pxa2x0_a4x_bs_tag, paddr, - kgdb_rate, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comkgdbmode)) { + rv = ioreg_read(ZAURUS_CLKMAN_VBASE + CLKMAN_CKEN); + if (enable) + rv |= clk; + else + rv &= ~clk; + ioreg_write(ZAURUS_CLKMAN_VBASE + CLKMAN_CKEN, rv); +} + +void +board_startup(void) +{ + extern int lcd_cnattach(void (*)(u_int, int)); + extern bus_addr_t comconsaddr; + +#if NWSDISPLAY > 0 + /* + * Try to attach the display console now that VM services + * are available. + */ - ioreg_write(ZAURUS_CLKMAN_VBASE+CLKMAN_CKEN, ckenreg); + printf("attempting to switch console to lcd screen\n"); + if (lcd_cnattach(early_clkman) == 0) { + /* + * Kill the existing serial console. + * XXX need to bus_space_unmap resources and disable + * clocks... + */ + comconsaddr = 0; + + /* Display the copyright notice again on the new console */ + extern const char copyright[]; + printf("%s\n", copyright); } #endif -} + + if (boothowto & RB_CONFIG) { +#ifdef BOOT_CONFIG + user_config(); +#else + printf("kernel does not support -c; continuing..\n"); #endif + } +} /* * Cotulla's integrated ICU doesn't have IRQ0..7, so @@ -1370,11 +1402,11 @@ pxa2x0_spllower(int ipl) void pxa2x0_setsoftintr(int si) { - #if 0 +#if 0 atomic_set_bit( (u_int *)&softint_pending, SI_TO_IRQBIT(si) ); - #else - softint_pending |= SI_TO_IRQBIT(si); - #endif +#else + softint_pending |= SI_TO_IRQBIT(si); +#endif /* Process unmasked pending soft interrupts. */ if ( softint_pending & intr_mask ) |