? arch/zaurus/conf/C700 ? arch/zaurus/conf/C700_INSTALL ? arch/zaurus/dev/w100.c ? arch/zaurus/dev/w100lcd.c ? arch/zaurus/dev/w100lcdvar.h ? arch/zaurus/dev/w100reg.h ? arch/zaurus/dev/w100var.h Index: arch/arm/xscale/pxa2x0_dmac.c =================================================================== RCS file: /cvsroot/src/sys/arch/arm/xscale/pxa2x0_dmac.c,v retrieving revision 1.9 diff -u -p -r1.9 pxa2x0_dmac.c --- arch/arm/xscale/pxa2x0_dmac.c 23 Nov 2011 23:07:29 -0000 1.9 +++ arch/arm/xscale/pxa2x0_dmac.c 25 Jan 2012 17:20:32 -0000 @@ -766,24 +766,39 @@ static inline int dmac_validate_desc(struct dmac_xfer_desc *xd, size_t *psize, bool *misaligned_flag) { + bus_dma_segment_t *dma_segs = xd->xd_dma_segs; + bus_addr_t periph_end; + bus_size_t align; size_t size; - int i; + int i, nsegs = xd->xd_nsegs; /* * Make sure the transfer parameters are acceptable. */ if (xd->xd_addr_hold && - (xd->xd_nsegs != 1 || xd->xd_dma_segs[0].ds_len == 0)) + (nsegs != 1 || dma_segs[0].ds_len == 0)) return (EINVAL); - for (i = 0, size = 0; i < xd->xd_nsegs; i++) { - if (xd->xd_dma_segs[i].ds_addr & 0x7) { + periph_end = CPU_IS_PXA270 ? PXA270_PERIPH_END : PXA250_PERIPH_END; + for (i = 0, size = 0; i < nsegs; i++) { + if (dma_segs[i].ds_addr >= PXA2X0_PERIPH_START && + dma_segs[i].ds_addr + dma_segs[i].ds_len < periph_end) + /* Internal Peripherals. */ + align = 0x03; + else /* Companion-Chip/External Peripherals/External Memory. */ + align = 0x07; + /* + * XXXX: + * Also PXA27x has more constraints by pairs Source/Target. + */ + + if (dma_segs[i].ds_addr & align) { if (!CPU_IS_PXA270) return (EFAULT); *misaligned_flag = true; } - size += xd->xd_dma_segs[i].ds_len; + size += dma_segs[i].ds_len; } *psize = size; Index: arch/zaurus/conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/conf/GENERIC,v retrieving revision 1.50 diff -u -p -r1.50 GENERIC --- arch/zaurus/conf/GENERIC 25 Jan 2012 17:18:47 -0000 1.50 +++ arch/zaurus/conf/GENERIC 25 Jan 2012 17:20:32 -0000 @@ -224,6 +224,8 @@ wskbd* at zrc? mux 1 lcd0 at pxaip? # PXA2x0 integrated LCD Controller options PXA2X0_LCD_WRITETHROUGH wsdisplay* at lcd? console ? +w100lcd0 at pxaip? # ATI Imageon100 LCDcontroller +wsdisplay* at w100lcd? console ? lcdctl0 at zssp0 # WM8750 Audio Index: arch/zaurus/conf/files.zaurus =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/conf/files.zaurus,v retrieving revision 1.10 diff -u -p -r1.10 files.zaurus --- arch/zaurus/conf/files.zaurus 25 Jan 2012 16:51:17 -0000 1.10 +++ arch/zaurus/conf/files.zaurus 25 Jan 2012 17:20:32 -0000 @@ -71,10 +71,16 @@ device zssp {} attach zssp at pxaip file arch/zaurus/dev/zssp.c zssp -# LCD frame buffer +# PXA2x0 integrated LCDC frame buffer attach lcd at pxaip with zlcd file arch/zaurus/dev/zlcd.c zlcd +# LCD frame buffer for SL-C7x0 +device w100lcd: wsemuldisplaydev, rasops16, rasops8, rasops4, rasops_rotation +attach w100lcd at pxaip +file arch/zaurus/dev/w100lcd.c w100lcd needs-flag +file arch/zaurus/dev/w100.c w100lcd + # backlight, brightness Controller device lcdctl attach lcdctl at zssp Index: arch/zaurus/dev/lcdctl.c =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/lcdctl.c,v retrieving revision 1.1 diff -u -p -r1.1 lcdctl.c --- arch/zaurus/dev/lcdctl.c 25 Jan 2012 16:51:17 -0000 1.1 +++ arch/zaurus/dev/lcdctl.c 25 Jan 2012 17:20:32 -0000 @@ -116,8 +116,14 @@ lcdctl_attach(device_t parent, device_t sc->sc_islit = true; sc->sc_isblank = false; - sc->sc_nbacklighttbl = __arraycount(lcdctl_backlight_c3000); - sc->sc_backlighttbl = lcdctl_backlight_c3000; + if (ZAURUS_ISC1000 || ZAURUS_ISC3000) { + sc->sc_nbacklighttbl = __arraycount(lcdctl_backlight_c3000); + sc->sc_backlighttbl = lcdctl_backlight_c3000; + } else { + /* XXX: Is this okay for C7x0/860? */ + sc->sc_nbacklighttbl = __arraycount(lcdctl_backlight_c3000); + sc->sc_backlighttbl = lcdctl_backlight_c3000; + } /* schedule adjustment of LCD brightness after all devices are ready */ config_finalize_register(self, lcdctl_finalize); Index: arch/zaurus/dev/scoop.c =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/scoop.c,v retrieving revision 1.9 diff -u -p -r1.9 scoop.c --- arch/zaurus/dev/scoop.c 19 Jul 2011 15:11:49 -0000 1.9 +++ arch/zaurus/dev/scoop.c 25 Jan 2012 17:20:32 -0000 @@ -161,25 +161,19 @@ scoop_gpio_pin_ctl(struct scoop_softc *s void scoop_set_backlight(int on, int cont) { - struct scoop_softc *sc; -#if 0 struct scoop_softc *sc0; + struct scoop_softc *sc1; sc0 = device_lookup_private(&scoop_cd, 0); -#endif - - sc = device_lookup_private(&scoop_cd, 1); - if (sc != NULL) { + sc1 = device_lookup_private(&scoop_cd, 1); + if (sc1 != NULL) { /* C3000 */ - scoop_gpio_pin_write(sc, SCOOP1_BACKLIGHT_CONT, !cont); - scoop_gpio_pin_write(sc, SCOOP1_BACKLIGHT_ON, on); - } -#if 0 - else if (sc0 != NULL) { - scoop_gpio_pin_write(sc0, - SCOOP0_BACKLIGHT_CONT, cont); + scoop_gpio_pin_write(sc1, SCOOP1_BACKLIGHT_CONT, !cont); + scoop_gpio_pin_write(sc1, SCOOP1_BACKLIGHT_ON, on); + } else if (sc0 != NULL) { + /* C860 */ + scoop_gpio_pin_write(sc0, SCOOP0_BACKLIGHT_CONT, cont); } -#endif } /* @@ -291,6 +285,9 @@ scoop_charge_battery(int enable, int vol { struct scoop_softc *sc; + if (!ZAURUS_ISC1000 && !ZAURUS_ISC3000) + return; + sc = device_lookup_private(&scoop_cd, 0); if (sc != NULL) { @@ -304,6 +301,9 @@ scoop_discharge_battery(int enable) { struct scoop_softc *sc; + if (!ZAURUS_ISC1000 && !ZAURUS_ISC3000) + return; + sc = device_lookup_private(&scoop_cd, 0); if (sc != NULL) { @@ -333,6 +333,9 @@ scoop0_set_card_power(enum scoop_card ca bus_space_handle_t ioh; uint16_t cpr; + if (!ZAURUS_ISC1000 && !ZAURUS_ISC3000) + return; + sc = device_lookup_private(&scoop_cd, 0); if (sc == NULL) return; @@ -399,6 +402,9 @@ scoop_suspend(void) struct scoop_softc *sc, *sc0, *sc1; uint32_t rv; + if (!ZAURUS_ISC1000 && !ZAURUS_ISC3000) + return; + sc0 = device_lookup_private(&scoop_cd, 0); sc1 = device_lookup_private(&scoop_cd, 1); Index: arch/zaurus/dev/scoopreg.h =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/scoopreg.h,v retrieving revision 1.4 diff -u -p -r1.4 scoopreg.h --- arch/zaurus/dev/scoopreg.h 17 Oct 2007 19:58:34 -0000 1.4 +++ arch/zaurus/dev/scoopreg.h 25 Jan 2012 17:20:32 -0000 @@ -61,7 +61,9 @@ #define SCOOP0_LED_GREEN 1 #define SCOOP0_JK_B_C3000 2 +#define SCOOP0_SWA_C860 2 #define SCOOP0_CHARGE_OFF_C3000 3 +#define SCOOP0_SWB_C860 3 #define SCOOP0_MUTE_L 4 #define SCOOP0_MUTE_R 5 #define SCOOP0_AKIN_PULLUP 6 Index: arch/zaurus/dev/zapm.c =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/zapm.c,v retrieving revision 1.11 diff -u -p -r1.11 zapm.c --- arch/zaurus/dev/zapm.c 19 Jun 2011 16:20:09 -0000 1.11 +++ arch/zaurus/dev/zapm.c 25 Jan 2012 17:20:32 -0000 @@ -649,9 +649,11 @@ static void zapm_set_charging(struct zapm_softc *sc, int enable) { - scoop_discharge_battery(0); - scoop_charge_battery(enable, 0); - scoop_led_set(SCOOP_LED_ORANGE, enable); + if (ZAURUS_ISC1000 || ZAURUS_ISC3000) { + scoop_discharge_battery(0); + scoop_charge_battery(enable, 0); + scoop_led_set(SCOOP_LED_ORANGE, enable); + } } /* @@ -867,7 +869,8 @@ zapm_poll1(void *v, int do_suspend) if (charging) zapm_set_charging(sc, 0); sc->discharging = 1; - scoop_discharge_battery(1); + if (ZAURUS_ISC1000 || ZAURUS_ISC3000) + scoop_discharge_battery(1); callout_schedule(&sc->sc_discharge_poll, DISCHARGE_TIMEOUT); } else if (!ac_state) { Index: arch/zaurus/dev/zaudio.c =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/zaudio.c,v retrieving revision 1.18 diff -u -p -r1.18 zaudio.c --- arch/zaurus/dev/zaudio.c 25 Jan 2012 15:58:10 -0000 1.18 +++ arch/zaurus/dev/zaudio.c 25 Jan 2012 17:20:32 -0000 @@ -320,6 +320,9 @@ zaudio_match(device_t parent, cfdata_t c { struct i2c_attach_args *ia = aux; + if (!ZAURUS_ISC1000 && !ZAURUS_ISC3000) + return 0; /* XXX for now */ + if (ia->ia_name) { /* direct config - check name */ if (strcmp(ia->ia_name, "zaudio") == 0) Index: arch/zaurus/dev/zkbd.c =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/zkbd.c,v retrieving revision 1.15 diff -u -p -r1.15 zkbd.c --- arch/zaurus/dev/zkbd.c 25 Jan 2012 16:51:17 -0000 1.15 +++ arch/zaurus/dev/zkbd.c 25 Jan 2012 17:20:32 -0000 @@ -75,6 +75,32 @@ static const int gpio_strobe_pins_c3000[ 114 }; +static const int gpio_sense_pins_c860[] = { + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65 +}; + +static const int gpio_strobe_pins_c860[] = { + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77 +}; + static const int stuck_keys[] = { 7, 15, @@ -90,8 +116,10 @@ struct zkbd_softc { const int *sc_sense_array; const int *sc_strobe_array; + const int *sc_stuck_keys; int sc_nsense; int sc_nstrobe; + int sc_nstuck; short sc_onkey_pin; short sc_sync_pin; @@ -111,6 +139,7 @@ struct zkbd_softc { /* wskbd bits */ struct device *sc_wskbddev; + struct wskbd_mapdata *sc_keymapdata; int sc_rawkbd; #ifdef WSDISPLAY_COMPAT_RAWKBD const char *sc_xt_keymap; @@ -164,6 +193,11 @@ static struct wskbd_mapdata zkbd_keymapd KB_US, }; +static struct wskbd_mapdata zkbd_keymapdata_c860 = { + zkbd_keydesctab_c860, + KB_US, +}; + static int zkbd_match(device_t parent, cfdata_t cf, void *aux) { @@ -204,14 +238,33 @@ zkbd_attach(device_t parent, device_t se sc->sc_strobe_array = gpio_strobe_pins_c3000; sc->sc_nsense = __arraycount(gpio_sense_pins_c3000); sc->sc_nstrobe = __arraycount(gpio_strobe_pins_c3000); + sc->sc_stuck_keys = stuck_keys; + sc->sc_nstuck = __arraycount(stuck_keys); sc->sc_maxkbdcol = 10; sc->sc_onkey_pin = 95; sc->sc_sync_pin = 16; sc->sc_swa_pin = 97; sc->sc_swb_pin = 96; + sc->sc_keymapdata = &zkbd_keymapdata; #ifdef WSDISPLAY_COMPAT_RAWKBD sc->sc_xt_keymap = xt_keymap; #endif + } else if (ZAURUS_ISC860) { + sc->sc_sense_array = gpio_sense_pins_c860; + sc->sc_strobe_array = gpio_strobe_pins_c860; + sc->sc_nsense = __arraycount(gpio_sense_pins_c860); + sc->sc_nstrobe = __arraycount(gpio_strobe_pins_c860); + sc->sc_stuck_keys = NULL; + sc->sc_nstuck = 0; + sc->sc_maxkbdcol = 0; + sc->sc_onkey_pin = -1; + sc->sc_sync_pin = -1; + sc->sc_swa_pin = -1; + sc->sc_swb_pin = -1; + sc->sc_keymapdata = &zkbd_keymapdata_c860; +#ifdef WSDISPLAY_COMPAT_RAWKBD + sc->sc_xt_keymap = xt_keymap_c860; +#endif } else { /* XXX */ return; @@ -247,22 +300,26 @@ zkbd_attach(device_t parent, device_t se zkbd_irq, sc); } - pxa2x0_gpio_intr_establish(sc->sc_onkey_pin, IST_EDGE_BOTH, IPL_TTY, - zkbd_on, sc); - pxa2x0_gpio_intr_establish(sc->sc_sync_pin, IST_EDGE_RISING, IPL_TTY, - zkbd_sync, sc); - pxa2x0_gpio_intr_establish(sc->sc_swa_pin, IST_EDGE_BOTH, IPL_TTY, - zkbd_hinge, sc); - pxa2x0_gpio_intr_establish(sc->sc_swb_pin, IST_EDGE_BOTH, IPL_TTY, - zkbd_hinge, sc); + if (sc->sc_onkey_pin >= 0) + pxa2x0_gpio_intr_establish(sc->sc_onkey_pin, IST_EDGE_BOTH, + IPL_TTY, zkbd_on, sc); + if (sc->sc_sync_pin >= 0) + pxa2x0_gpio_intr_establish(sc->sc_sync_pin, IST_EDGE_RISING, + IPL_TTY, zkbd_sync, sc); + if (sc->sc_swa_pin >= 0) + pxa2x0_gpio_intr_establish(sc->sc_swa_pin, IST_EDGE_BOTH, + IPL_TTY, zkbd_hinge, sc); + if (sc->sc_swb_pin >= 0) + pxa2x0_gpio_intr_establish(sc->sc_swb_pin, IST_EDGE_BOTH, + IPL_TTY, zkbd_hinge, sc); if (glass_console) { - wskbd_cnattach(&zkbd_consops, sc, &zkbd_keymapdata); + wskbd_cnattach(&zkbd_consops, sc, sc->sc_keymapdata); a.console = 1; } else { a.console = 0; } - a.keymap = &zkbd_keymapdata; + a.keymap = sc->sc_keymapdata; a.accessops = &zkbd_accessops; a.accesscookie = sc; @@ -380,8 +437,8 @@ zkbd_poll(void *v) stuck = 0; /* extend xt_keymap to do this faster. */ /* ignore 'stuck' keys' */ - for (j = 0; j < __arraycount(stuck_keys); j++) { - if (stuck_keys[j] == i) { + for (j = 0; j < sc->sc_nstuck; j++) { + if (sc->sc_stuck_keys[j] == i) { stuck = 1; break; } @@ -464,7 +521,12 @@ zkbd_on(void *v) { #if NAPM > 0 struct zkbd_softc *sc = (struct zkbd_softc *)v; - int down = pxa2x0_gpio_get_bit(sc->sc_onkey_pin) ? 1 : 0; + int down; + + if (sc->sc_onkey_pin < 0) + return 1; + + down = pxa2x0_gpio_get_bit(sc->sc_onkey_pin) ? 1 : 0; /* * Change run mode depending on how long the key is held down. @@ -506,8 +568,13 @@ static int zkbd_hinge(void *v) { struct zkbd_softc *sc = (struct zkbd_softc *)v; - int a = pxa2x0_gpio_get_bit(sc->sc_swa_pin) ? 1 : 0; - int b = pxa2x0_gpio_get_bit(sc->sc_swb_pin) ? 2 : 0; + int a, b; + + if (sc->sc_swa_pin < 0 || sc->sc_swb_pin < 0) + return 1; + + a = pxa2x0_gpio_get_bit(sc->sc_swa_pin) ? 1 : 0; + b = pxa2x0_gpio_get_bit(sc->sc_swb_pin) ? 2 : 0; sc->sc_hinge = a | b; Index: arch/zaurus/dev/zkbdmap.h =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/zkbdmap.h,v retrieving revision 1.5 diff -u -p -r1.5 zkbdmap.h --- arch/zaurus/dev/zkbdmap.h 19 Jun 2011 16:20:09 -0000 1.5 +++ arch/zaurus/dev/zkbdmap.h 25 Jan 2012 17:20:32 -0000 @@ -86,6 +86,73 @@ static const keysym_t zkbd_keydesc_us[] KC(93), KS_Mode_switch /* Fn */ }; +static const keysym_t zkbd_keydesc_us_c860[] = { + KC(2), KS_Tab, KS_Tab, KS_Caps_Lock, + KC(3), KS_Cmd_Screen0, KS_f1, /* Cal, */ + KC(4), KS_Cmd_Screen1, KS_f2, /* Addr, */ + KC(5), KS_Cmd_Screen2, KS_f3, /* Mail, */ + KC(6), KS_Cmd_Screen3, KS_f4, /* Home, */ + KC(7), KS_Power, /* XXX */ + KC(8), KS_1, KS_exclam, + KC(9), KS_2, KS_quotedbl, + KC(10), KS_q, + KC(11), KS_w, KS_W, KS_asciicircum, + KC(12), KS_a, + KC(13), KS_z, + KC(14), KS_Cmd, KS_Alt_L, + KC(15), KS_KP_Right, /* OK, (ext) */ + KC(16), KS_Cmd_BrightnessDown, KS_3, KS_numbersign, + KC(17), KS_Cmd_BrightnessUp, KS_4, KS_dollar, + KC(18), KS_e, KS_E, KS_equal, + KC(19), KS_s, + KC(20), KS_d, KS_D, KS_grave, + KC(21), KS_x, + KC(22), KS_Control_L, + KC(23), KS_KP_Left, /*Cancel (ext)*/ + KC(24), KS_5, KS_percent, + KC(25), KS_r, KS_R, KS_plus, + KC(26), KS_t, KS_T, KS_bracketleft, + KC(27), KS_f, KS_F, KS_backslash, + KC(28), KS_c, + KC(29), KS_minus, KS_minus, KS_at, + KC(30), KS_Cmd_Debugger,KS_Escape, /* Cancel, */ + KC(31), KS_KP_Down, /* tog left, */ + KC(32), KS_6, KS_ampersand, + KC(33), KS_y, KS_Y, KS_bracketright, + KC(34), KS_g, KS_G, KS_semicolon, + KC(35), KS_v, + KC(36), KS_b, KS_B, KS_underscore, + KC(37), KS_space, + KC(38), KS_KP_Enter, /* OK, */ + KC(39), KS_KP_Up, /* tog right, */ + KC(40), KS_7, KS_apostrophe, + KC(41), KS_8, KS_parenleft, + KC(42), KS_u, KS_U, KS_braceleft, + KC(43), KS_h, KS_H, KS_colon, + KC(44), KS_n, + KC(45), KS_comma, KS_slash, KS_less, + KC(46), KS_Cmd_Screen4, KS_f5, /* Menu, */ + KC(48), KS_9, KS_parenright, + KC(49), KS_i, KS_I, KS_braceright, + KC(50), KS_j, KS_J, KS_asterisk, + KC(51), KS_m, + KC(52), KS_period, KS_question, KS_greater, + KC(54), KS_KP_Left, KS_KP_Left, KS_Home, /* left, */ + KC(56), KS_0, KS_asciitilde, + KC(57), KS_o, + KC(58), KS_k, + KC(59), KS_l, KS_L, KS_bar, + KC(61), KS_KP_Up, KS_KP_Up, KS_Prior, /* up, */ + KC(62), KS_KP_Down, KS_KP_Down, KS_Next, /* down, */ + KC(64), KS_Delete, KS_BackSpace, + KC(65), KS_p, + KC(68), KS_Return, + KC(70), KS_KP_Right, KS_KP_Right, KS_End, /* right, */ + KC(75), KS_Shift_R, + KC(84), KS_Shift_L, + KC(93), KS_Mode_switch /* Fn */ +}; + #ifdef WSDISPLAY_COMPAT_RAWKBD static const char xt_keymap[] = { /* KC(0), */ 0x1d, /* KS_Control_L, */ @@ -183,6 +250,103 @@ static const char xt_keymap[] = { /* KC(92), */ 0x00, /* NC */ /* KC(93), */ 0xb8, /* KS_Mode_switch Fn */ }; + +static const char xt_keymap_c860[] = { + /* KC(0), */ 0x00, /* NC */ + /* KC(1), */ 0x00, /* NC */ + /* KC(2), */ 0x0f, /* KS_Tab, KS_Tab, KS_Caps_Lock, */ + /* KC(3), */ 0x3b, /* KS_Cmd_Screen0, KS_f1, Cal, */ + /* KC(4), */ 0x3c, /* KS_Cmd_Screen1, KS_f2, Addr, */ + /* KC(5), */ 0x3d, /* KS_Cmd_Screen2, KS_f3, Mail, */ + /* KC(6), */ 0x3e, /* KS_Cmd_Screen3, KS_f4, Home, */ + /* KC(7), */ 0x00, /* XXX */ + /* KC(8), */ 0x02, /* KS_1, KS_exclam, */ + /* KC(9), */ 0x03, /* KS_2, KS_quotedbl, */ + /* KC(10), */ 0x10, /* KS_q, */ + /* KC(11), */ 0x11, /* KS_w, KS_W, KS_asciicircum, */ + /* KC(12), */ 0x1e, /* KS_a, */ + /* KC(13), */ 0x2c, /* KS_z, */ + /* KC(14), */ 0x38, /* KS_Cmd, KS_Alt_L, */ + /* KC(15), */ 0xcd, /* KS_KP_Right, OK, (ext) */ + /* KC(16), */ 0x04, /* KS_3, KS_numbersign, */ + /* KC(17), */ 0x05, /* KS_4, KS_dollar, */ + /* KC(18), */ 0x12, /* KS_e, KS_E, KS_equal, */ + /* KC(19), */ 0x1f, /* KS_s, */ + /* KC(20), */ 0x20, /* KS_d, KS_D, KS_grave, */ + /* KC(21), */ 0x2d, /* KS_x, */ + /* KC(22), */ 0x1d, /* KS_Control_L, */ + /* KC(23), */ 0xcb, /* KS_KP_Left, cancel (ext), */ + /* KC(24), */ 0x06, /* KS_5, KS_percent, */ + /* KC(25), */ 0x13, /* KS_r, KS_R, KS_plus, */ + /* KC(26), */ 0x14, /* KS_t, KS_T, KS_bracketleft, */ + /* KC(27), */ 0x21, /* KS_f, KS_F, KS_backslash, */ + /* KC(28), */ 0x2e, /* KS_c, */ + /* KC(29), */ 0x0c, /* KS_minus, KS_minus, KS_at, */ + /* KC(30), */ 0x01, /* KS_Escape, Cancel */ + /* KC(31), */ 0xd0, /* KS_KP_Down, tog left, */ + /* KC(32), */ 0x07, /* KS_6, KS_ampersand, */ + /* KC(33), */ 0x15, /* KS_y, KS_Y, KS_bracketright, */ + /* KC(34), */ 0x22, /* KS_g, KS_G, KS_semicolon, */ + /* KC(35), */ 0x2f, /* KS_v, */ + /* KC(36), */ 0x30, /* KS_b, KS_B, KS_underscore, */ + /* KC(37), */ 0x39, /* KS_space, */ + /* KC(38), */ 0x9c, /* KS_KP_Enter, ok */ + /* KC(39), */ 0xc8, /* KS_KP_Up, tog right, */ + /* KC(40), */ 0x08, /* KS_7, KS_apostrophe, */ + /* KC(41), */ 0x09, /* KS_8, KS_parenleft, */ + /* KC(42), */ 0x16, /* KS_u, KS_U, KS_braceleft, */ + /* KC(43), */ 0x23, /* KS_h, KS_H, KS_colon, */ + /* KC(44), */ 0x31, /* KS_n, */ + /* KC(45), */ 0x33, /* KS_comma, KS_slash, KS_less, */ + /* KC(46), */ 0x3f, /* KS_Cmd_Screen4, KS_f5, Menu, */ + /* KC(47), */ 0x00, /* NC */ + /* KC(48), */ 0x0a, /* KS_9, KS_parenright, */ + /* KC(49), */ 0x17, /* KS_i, KS_I, KS_braceright, */ + /* KC(50), */ 0x24, /* KS_j, KS_J, KS_asterisk, */ + /* KC(51), */ 0x32, /* KS_m, */ + /* KC(52), */ 0x34, /* KS_period, KS_question, KS_greater, */ + /* KC(53), */ 0x00, /* NC */ + /* KC(54), */ 0xcb, /* KS_KP_Left, left, */ + /* KC(55), */ 0x00, /* NC */ + /* KC(56), */ 0x0b, /* KS_0, KS_asciitilde, */ + /* KC(57), */ 0x18, /* KS_o, */ + /* KC(58), */ 0x25, /* KS_k, */ + /* KC(59), */ 0x26, /* KS_l, KS_L, KS_bar, */ + /* KC(60), */ 0x00, /* NC */ + /* KC(61), */ 0xc8, /* KS_KP_Up, up, */ + /* KC(62), */ 0xd0, /* KS_KP_Down, down, */ + /* KC(63), */ 0x00, /* NC */ + /* KC(64), */ 0x0e, /* KS_Delete, KS_BackSpace, */ + /* KC(65), */ 0x19, /* KS_p, */ + /* KC(66), */ 0x00, /* NC */ + /* KC(67), */ 0x00, /* NC */ + /* KC(68), */ 0x1c, /* KS_Return, */ + /* KC(69), */ 0x00, /* NC */ + /* KC(70), */ 0xcd, /* KS_KP_Right, right, */ + /* KC(71), */ 0x00, /* NC */ + /* KC(72), */ 0x00, /* NC */ + /* KC(73), */ 0x00, /* NC */ + /* KC(74), */ 0x00, /* NC */ + /* KC(75), */ 0x00, /* NC */ + /* KC(76), */ 0x00, /* NC */ + /* KC(77), */ 0x00, /* NC */ + /* KC(78), */ 0x00, /* NC */ + /* KC(79), */ 0x00, /* NC */ + /* KC(80), */ 0x00, /* NC */ + /* KC(81), */ 0x00, /* NC */ + /* KC(82), */ 0x00, /* NC */ + /* KC(83), */ 0x36, /* KS_Shift_R, */ + /* KC(84), */ 0x2a, /* KS_Shift_L, */ + /* KC(85), */ 0x00, /* NC */ + /* KC(86), */ 0x00, /* NC */ + /* KC(87), */ 0x00, /* NC */ + /* KC(88), */ 0x00, /* NC */ + /* KC(89), */ 0x00, /* NC */ + /* KC(90), */ 0x00, /* NC */ + /* KC(91), */ 0x00, /* NC */ + /* KC(92), */ 0x00, /* NC */ + /* KC(93), */ 0xb8, /* KS_Mode_switch Fn */ +}; #endif #define KBD_MAP(name, base, map) \ @@ -194,5 +358,11 @@ static const struct wscons_keydesc zkbd_ {0, 0, 0, 0} }; +static const struct wscons_keydesc zkbd_keydesctab_c860[] = { + KBD_MAP(KB_US, 0, zkbd_keydesc_us_c860), + + {0, 0, 0, 0} +}; + #undef KBD_MAP #undef KC Index: arch/zaurus/dev/zlcd.c =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/zlcd.c,v retrieving revision 1.16 diff -u -p -r1.16 zlcd.c --- arch/zaurus/dev/zlcd.c 25 Jan 2012 16:51:17 -0000 1.16 +++ arch/zaurus/dev/zlcd.c 25 Jan 2012 17:20:32 -0000 @@ -167,7 +167,8 @@ void lcd_cnattach(void) { - pxa2x0_lcd_cnattach(&lcd_std_screen, &lcd_panel_geometry_c3000); + if (ZAURUS_ISC1000 || ZAURUS_ISC3000) + pxa2x0_lcd_cnattach(&lcd_std_screen, &lcd_panel_geometry_c3000); } /* Index: arch/zaurus/dev/zmci.c =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/zmci.c,v retrieving revision 1.4 diff -u -p -r1.4 zmci.c --- arch/zaurus/dev/zmci.c 21 Jan 2012 18:56:51 -0000 1.4 +++ arch/zaurus/dev/zmci.c 25 Jan 2012 17:20:32 -0000 @@ -62,6 +62,7 @@ struct zmci_softc { void *sc_detect_ih; int sc_detect_pin; int sc_wp_pin; + int sc_power_pin; }; static int pxamci_match(device_t, cfdata_t, void *); @@ -81,7 +82,7 @@ static int pxamci_match(device_t parent, cfdata_t cf, void *aux) { - if (ZAURUS_ISC1000 || ZAURUS_ISC3000) + if (ZAURUS_ISC860 || ZAURUS_ISC1000 || ZAURUS_ISC3000) return 1; return 0; } @@ -100,8 +101,13 @@ pxamci_attach(device_t parent, device_t pxa2x0_gpio_set_function(sc->sc_detect_pin, GPIO_IN); pxa2x0_gpio_set_function(sc->sc_wp_pin, GPIO_IN); } else { - /* XXX: C7x0/C8x0 */ - return; + /* C860 */ + sc->sc_detect_pin = C860_GPIO_SD_DETECT_PIN; + sc->sc_wp_pin = C860_GPIO_SD_WP_PIN; + sc->sc_power_pin = C860_GPIO_SD_POWER_PIN; + pxa2x0_gpio_set_function(sc->sc_detect_pin, GPIO_IN); + pxa2x0_gpio_set_function(sc->sc_wp_pin, GPIO_IN); + pxa2x0_gpio_set_function(sc->sc_power_pin, GPIO_OUT|GPIO_SET); } /* Establish SD detect interrupt */ @@ -161,7 +167,10 @@ zmci_set_power(void *arg, uint32_t ocr) struct zmci_softc *sc = (struct zmci_softc *)arg; if (ISSET(ocr, MMC_OCR_3_2V_3_3V|MMC_OCR_3_3V_3_4V)) { - scoop_set_sdmmc_power(1); + if (ZAURUS_ISC3000 || ZAURUS_ISC1000) + scoop_set_sdmmc_power(1); + else if (ZAURUS_ISC860) + pxa2x0_gpio_set_bit(sc->sc_power_pin); return 0; } @@ -172,7 +181,10 @@ zmci_set_power(void *arg, uint32_t ocr) } /* power off */ - scoop_set_sdmmc_power(0); + if (ZAURUS_ISC3000 || ZAURUS_ISC1000) + scoop_set_sdmmc_power(0); + else if(ZAURUS_ISC860) + pxa2x0_gpio_clear_bit(sc->sc_power_pin); return 0; } Index: arch/zaurus/dev/zssp.c =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/zssp.c,v retrieving revision 1.12 diff -u -p -r1.12 zssp.c --- arch/zaurus/dev/zssp.c 25 Jan 2012 16:51:17 -0000 1.12 +++ arch/zaurus/dev/zssp.c 25 Jan 2012 17:20:32 -0000 @@ -35,15 +35,40 @@ __KERNEL_RCSID(0, "$NetBSD: zssp.c,v 1.1 #define GPIO_ADS7846_CS_C3000 14 /* SSP SFRM */ #define GPIO_MAX1111_CS_C3000 20 #define GPIO_TG_CS_C3000 53 +#define GPIO_ADS7846_CS_C860 24 /* SSP SFRM */ +#define GPIO_MAX1111_CS_C860 20 +#define GPIO_TG_CS_C860 19 #define SSCR0_ADS7846_C3000 0x06ab /* 12bit/Microwire/div by 7 */ #define SSCR0_MAX1111 0x0387 #define SSCR0_LZ9JG18 0x01ab +#define SSCR0_ADS7846_C860 0x00ab /* 12bit/Microwire/div by 7 */ + +struct zssp_ads7846 { + u_int gpio; + uint32_t sscr0; +}; +struct zssp_max1111 { + u_int gpio; + uint32_t sscr0; +}; +struct zssp_lz9jg18 { + u_int gpio; + uint32_t sscr0; + int sclk_pin; + int sfrm_pin; + int txd_pin; + int rxd_pin; +}; struct zssp_softc { device_t sc_dev; bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; + bus_addr_t sc_ssp; + struct zssp_ads7846 ads7846; + struct zssp_max1111 max1111; + struct zssp_lz9jg18 lz9jg18; }; static int zssp_match(device_t, cfdata_t, void *); @@ -80,7 +105,33 @@ zssp_attach(device_t parent, device_t se aprint_naive("\n"); sc->sc_iot = &pxa2x0_bs_tag; - if (bus_space_map(sc->sc_iot, PXA2X0_SSP1_BASE, PXA2X0_SSP_SIZE, + if (ZAURUS_ISC1000 || ZAURUS_ISC3000) { + sc->sc_ssp = PXA2X0_SSP1_BASE; + sc->ads7846.gpio = GPIO_ADS7846_CS_C3000; + sc->ads7846.sscr0 = SSCR0_ADS7846_C3000; + sc->max1111.gpio = GPIO_MAX1111_CS_C3000; + sc->max1111.sscr0 = SSCR0_MAX1111; + sc->lz9jg18.gpio = GPIO_TG_CS_C3000; + sc->lz9jg18.sscr0 = SSCR0_LZ9JG18; + sc->lz9jg18.sclk_pin = 19; + sc->lz9jg18.sfrm_pin = 14; + sc->lz9jg18.txd_pin = 87; + sc->lz9jg18.rxd_pin = 86; + } else { + sc->sc_ssp = PXA2X0_SSP_BASE; + sc->ads7846.gpio = GPIO_ADS7846_CS_C860; + sc->ads7846.sscr0 = SSCR0_ADS7846_C860; + sc->max1111.gpio = GPIO_MAX1111_CS_C860; + sc->max1111.sscr0 = SSCR0_MAX1111; + sc->lz9jg18.gpio = GPIO_TG_CS_C860; + sc->lz9jg18.sscr0 = SSCR0_LZ9JG18; + sc->lz9jg18.sclk_pin = 23; + sc->lz9jg18.sfrm_pin = 24; + sc->lz9jg18.txd_pin = 25; + sc->lz9jg18.rxd_pin = 26; + } + + if (bus_space_map(sc->sc_iot, sc->sc_ssp, PXA2X0_SSP_SIZE, 0, &sc->sc_ioh)) { aprint_error_dev(sc->sc_dev, "can't map bus space\n"); return; @@ -133,12 +184,12 @@ zssp_init(void) pxa2x0_clkman_config(CKEN_SSP, 1); - bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, SSCR0_LZ9JG18); + bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, sc->lz9jg18.sscr0); bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR1, 0); - pxa2x0_gpio_set_function(GPIO_ADS7846_CS_C3000, GPIO_OUT|GPIO_SET); - pxa2x0_gpio_set_function(GPIO_MAX1111_CS_C3000, GPIO_OUT|GPIO_SET); - pxa2x0_gpio_set_function(GPIO_TG_CS_C3000, GPIO_OUT|GPIO_SET); + pxa2x0_gpio_set_function(sc->ads7846.gpio, GPIO_OUT|GPIO_SET); + pxa2x0_gpio_set_function(sc->max1111.gpio, GPIO_OUT|GPIO_SET); + pxa2x0_gpio_set_function(sc->lz9jg18.gpio, GPIO_OUT|GPIO_SET); } static bool @@ -172,28 +223,28 @@ zssp_ic_start(int ic, uint32_t data) /* disable other ICs */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, 0); if (ic != ZSSP_IC_ADS7846) - pxa2x0_gpio_set_bit(GPIO_ADS7846_CS_C3000); + pxa2x0_gpio_set_bit(sc->ads7846.gpio); if (ic != ZSSP_IC_LZ9JG18) - pxa2x0_gpio_set_bit(GPIO_TG_CS_C3000); + pxa2x0_gpio_set_bit(sc->lz9jg18.gpio); if (ic != ZSSP_IC_MAX1111) - pxa2x0_gpio_set_bit(GPIO_MAX1111_CS_C3000); + pxa2x0_gpio_set_bit(sc->max1111.gpio); /* activate the chosen one */ switch (ic) { case ZSSP_IC_ADS7846: bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, - SSCR0_ADS7846_C3000); - pxa2x0_gpio_clear_bit(GPIO_ADS7846_CS_C3000); + sc->ads7846.sscr0); + pxa2x0_gpio_clear_bit(sc->ads7846.gpio); bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSDR, data); while ((bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSSR) & SSSR_TNF) != SSSR_TNF) continue; /* poll */ break; case ZSSP_IC_LZ9JG18: - pxa2x0_gpio_clear_bit(GPIO_TG_CS_C3000); + pxa2x0_gpio_clear_bit(sc->lz9jg18.gpio); break; case ZSSP_IC_MAX1111: - pxa2x0_gpio_clear_bit(GPIO_MAX1111_CS_C3000); + pxa2x0_gpio_clear_bit(sc->max1111.gpio); break; } } @@ -229,9 +280,9 @@ zssp_ic_stop(int ic) break; } - pxa2x0_gpio_set_bit(GPIO_ADS7846_CS_C3000); - pxa2x0_gpio_set_bit(GPIO_TG_CS_C3000); - pxa2x0_gpio_set_bit(GPIO_MAX1111_CS_C3000); + pxa2x0_gpio_set_bit(sc->ads7846.gpio); + pxa2x0_gpio_set_bit(sc->lz9jg18.gpio); + pxa2x0_gpio_set_bit(sc->max1111.gpio); return rv; } @@ -276,11 +327,11 @@ zssp_read_max1111(uint32_t cmd) s = splhigh(); bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, 0); - bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, SSCR0_MAX1111); + bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, sc->max1111.sscr0); - pxa2x0_gpio_set_bit(GPIO_TG_CS_C3000); - pxa2x0_gpio_set_bit(GPIO_ADS7846_CS_C3000); - pxa2x0_gpio_clear_bit(GPIO_MAX1111_CS_C3000); + pxa2x0_gpio_set_bit(sc->lz9jg18.gpio); + pxa2x0_gpio_set_bit(sc->ads7846.gpio); + pxa2x0_gpio_clear_bit(sc->max1111.gpio); delay(1); @@ -300,9 +351,9 @@ zssp_read_max1111(uint32_t cmd) SSP_SSDR); } - pxa2x0_gpio_set_bit(GPIO_TG_CS_C3000); - pxa2x0_gpio_set_bit(GPIO_ADS7846_CS_C3000); - pxa2x0_gpio_set_bit(GPIO_MAX1111_CS_C3000); + pxa2x0_gpio_set_bit(sc->lz9jg18.gpio); + pxa2x0_gpio_set_bit(sc->ads7846.gpio); + pxa2x0_gpio_set_bit(sc->max1111.gpio); bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, 0); @@ -319,7 +370,6 @@ uint32_t zssp_read_ads7846(uint32_t cmd) { struct zssp_softc *sc; - unsigned int cr0; uint32_t val; int s; @@ -331,33 +381,34 @@ zssp_read_ads7846(uint32_t cmd) s = splhigh(); - if (ZAURUS_ISC1000 || ZAURUS_ISC3000) { - cr0 = SSCR0_ADS7846_C3000; - } else { - cr0 = 0x00ab; - } bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, 0); - bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, cr0); + delay(10); + bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, sc->ads7846.sscr0); - pxa2x0_gpio_set_bit(GPIO_TG_CS_C3000); - pxa2x0_gpio_set_bit(GPIO_MAX1111_CS_C3000); - pxa2x0_gpio_clear_bit(GPIO_ADS7846_CS_C3000); + pxa2x0_gpio_set_bit(sc->lz9jg18.gpio); + pxa2x0_gpio_set_bit(sc->max1111.gpio); + pxa2x0_gpio_clear_bit(sc->ads7846.gpio); + delay(10); bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSDR, cmd); + delay(10); while ((bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSSR) & SSSR_TNF) != SSSR_TNF) continue; /* poll */ - delay(1); + delay(10); while ((bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSSR) - & SSSR_RNE) != SSSR_RNE) + & SSSR_RNE) != SSSR_RNE) { + delay(1); continue; /* poll */ + } val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSDR); + delay(10); - pxa2x0_gpio_set_bit(GPIO_ADS7846_CS_C3000); + pxa2x0_gpio_set_bit(sc->ads7846.gpio); splx(s); @@ -367,66 +418,58 @@ zssp_read_ads7846(uint32_t cmd) void zssp_write_lz9jg18(uint32_t data) { - int sclk_pin, sclk_fn; - int sfrm_pin, sfrm_fn; - int txd_pin, txd_fn; - int rxd_pin, rxd_fn; + struct zssp_softc *sc; + int sclk_fn; + int sfrm_fn; + int txd_fn; + int rxd_fn; int i; int s; + KASSERT(zssp_sc != NULL); + sc = zssp_sc; + /* XXX this creates a DAC command from a backlight duty value. */ data = 0x40 | (data & 0x1f); - if (ZAURUS_ISC1000 || ZAURUS_ISC3000) { - sclk_pin = 19; - sfrm_pin = 14; - txd_pin = 87; - rxd_pin = 86; - } else { - sclk_pin = 23; - sfrm_pin = 24; - txd_pin = 25; - rxd_pin = 26; - } - s = splhigh(); - sclk_fn = pxa2x0_gpio_get_function(sclk_pin); - sfrm_fn = pxa2x0_gpio_get_function(sfrm_pin); - txd_fn = pxa2x0_gpio_get_function(txd_pin); - rxd_fn = pxa2x0_gpio_get_function(rxd_pin); - - pxa2x0_gpio_set_function(sfrm_pin, GPIO_OUT | GPIO_SET); - pxa2x0_gpio_set_function(sclk_pin, GPIO_OUT | GPIO_CLR); - pxa2x0_gpio_set_function(txd_pin, GPIO_OUT | GPIO_CLR); - pxa2x0_gpio_set_function(rxd_pin, GPIO_IN); - - pxa2x0_gpio_set_bit(GPIO_MAX1111_CS_C3000); - pxa2x0_gpio_set_bit(GPIO_ADS7846_CS_C3000); - pxa2x0_gpio_clear_bit(GPIO_TG_CS_C3000); + sclk_fn = pxa2x0_gpio_get_function(sc->lz9jg18.sclk_pin); + sfrm_fn = pxa2x0_gpio_get_function(sc->lz9jg18.sfrm_pin); + txd_fn = pxa2x0_gpio_get_function(sc->lz9jg18.txd_pin); + rxd_fn = pxa2x0_gpio_get_function(sc->lz9jg18.rxd_pin); + + pxa2x0_gpio_set_function(sc->lz9jg18.sfrm_pin, GPIO_OUT | GPIO_SET); + pxa2x0_gpio_set_function(sc->lz9jg18.sclk_pin, GPIO_OUT | GPIO_CLR); + pxa2x0_gpio_set_function(sc->lz9jg18.txd_pin, GPIO_OUT | GPIO_CLR); + pxa2x0_gpio_set_function(sc->lz9jg18.rxd_pin, GPIO_IN); + + pxa2x0_gpio_set_bit(sc->max1111.gpio); + pxa2x0_gpio_set_bit(sc->ads7846.gpio); + pxa2x0_gpio_clear_bit(sc->lz9jg18.gpio); delay(10); for (i = 0; i < 8; i++) { if (data & 0x80) - pxa2x0_gpio_set_bit(txd_pin); + pxa2x0_gpio_set_bit(sc->lz9jg18.txd_pin); else - pxa2x0_gpio_clear_bit(txd_pin); + pxa2x0_gpio_clear_bit(sc->lz9jg18.txd_pin); delay(10); - pxa2x0_gpio_set_bit(sclk_pin); + pxa2x0_gpio_set_bit(sc->lz9jg18.sclk_pin); delay(10); - pxa2x0_gpio_clear_bit(sclk_pin); + pxa2x0_gpio_clear_bit(sc->lz9jg18.sclk_pin); delay(10); data <<= 1; } - pxa2x0_gpio_clear_bit(txd_pin); - pxa2x0_gpio_set_bit(GPIO_TG_CS_C3000); + pxa2x0_gpio_clear_bit(sc->lz9jg18.txd_pin); + pxa2x0_gpio_set_bit(sc->lz9jg18.gpio); - pxa2x0_gpio_set_function(sclk_pin, sclk_fn); - pxa2x0_gpio_set_function(sfrm_pin, sfrm_fn); - pxa2x0_gpio_set_function(txd_pin, txd_fn); - pxa2x0_gpio_set_function(rxd_pin, rxd_fn); + pxa2x0_gpio_set_function(sc->lz9jg18.sclk_pin, sclk_fn); + pxa2x0_gpio_set_function(sc->lz9jg18.sfrm_pin, sfrm_fn); + pxa2x0_gpio_set_function(sc->lz9jg18.txd_pin, txd_fn); + pxa2x0_gpio_set_function(sc->lz9jg18.rxd_pin, rxd_fn); splx(s); } Index: arch/zaurus/dev/ztp.c =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/dev/ztp.c,v retrieving revision 1.12 diff -u -p -r1.12 ztp.c --- arch/zaurus/dev/ztp.c 25 Jan 2012 16:51:17 -0000 1.12 +++ arch/zaurus/dev/ztp.c 25 Jan 2012 17:20:32 -0000 @@ -21,6 +21,7 @@ __KERNEL_RCSID(0, "$NetBSD: ztp.c,v 1.12 2012/01/25 16:51:17 tsutsui Exp $"); #include "lcd.h" +#include "w100lcd.h" #include #include @@ -45,6 +46,9 @@ __KERNEL_RCSID(0, "$NetBSD: ztp.c,v 1.12 #if NLCD > 0 #include #endif +#if NW100LCD > 0 +#include +#endif #include #include @@ -66,16 +70,22 @@ __KERNEL_RCSID(0, "$NetBSD: ztp.c,v 1.12 #define GPIO_TP_INT_C3K 11 #define GPIO_HSYNC_C3K 22 +#define GPIO_TP_INT_C860 5 +#define GPIO_HSYNC_C860 44 #define POLL_TIMEOUT_RATE0 ((hz * 150)/1000) #define POLL_TIMEOUT_RATE1 (hz / 100) /* XXX every tick */ #define CCNT_HS_400_VGA_C3K 6250 /* 15.024us */ +#define CCNT_HS_400_VGA_C860 7013 /* 17.615us */ /* XXX need to ask lcd drivers for the screen dimension */ #if NLCD > 0 extern const struct lcd_panel_geometry lcd_panel_geometry_c3000; #endif +#if NW100LCD > 0 +extern const struct w100_panel_geometry lcd_panel_geometry_c700; +#endif /* Settable via sysctl. */ int ztp_rawmode; @@ -109,6 +119,10 @@ struct ztp_softc { int sc_resx; int sc_resy; struct tpcalib_softc sc_tpcalib; + + u_int sc_tp_int_pin; + u_int sc_hsync_pin; + u_int sc_ccnt_hs; }; static int ztp_match(device_t, cfdata_t, void *); @@ -162,13 +176,35 @@ ztp_attach(device_t parent, device_t sel a.accessops = &ztp_accessops; a.accesscookie = sc; +#if NLCD > 0 || NW100LCD > 0 /* XXX */ #if NLCD > 0 - sc->sc_resx = lcd_panel_geometry_c3000.panel_height; - sc->sc_resy = lcd_panel_geometry_c3000.panel_width; -#else - sc->sc_resx = 480; /* XXX */ - sc->sc_resy = 640; /* XXX */ + if (ZAURUS_ISC1000 || ZAURUS_ISC3000) { + sc->sc_resx = lcd_panel_geometry_c3000.panel_height; + sc->sc_resy = lcd_panel_geometry_c3000.panel_width; + } else +#endif +#if NW100LCD > 0 + if (ZAURUS_ISC860) { + sc->sc_resx = lcd_panel_geometry_c700.panel_height; + sc->sc_resy = lcd_panel_geometry_c700.panel_width; + } else +#endif #endif + { + sc->sc_resx = 480; /* XXX */ + sc->sc_resy = 640; /* XXX */ + } + + if (ZAURUS_ISC1000 || ZAURUS_ISC3000) { + sc->sc_tp_int_pin = GPIO_TP_INT_C3K; + sc->sc_hsync_pin = GPIO_HSYNC_C3K; + sc->sc_ccnt_hs = CCNT_HS_400_VGA_C3K; + } else { + /* C860 */ + sc->sc_tp_int_pin = GPIO_TP_INT_C860; + sc->sc_hsync_pin = GPIO_HSYNC_C860; + sc->sc_ccnt_hs = CCNT_HS_400_VGA_C860; + } sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint); @@ -217,11 +253,11 @@ ztp_enable(void *v) aprint_error_dev(sc->sc_dev, "couldn't establish power handler\n"); - pxa2x0_gpio_set_function(GPIO_TP_INT_C3K, GPIO_IN); + pxa2x0_gpio_set_function(sc->sc_tp_int_pin, GPIO_IN); /* XXX */ if (sc->sc_gh == NULL) { - sc->sc_gh = pxa2x0_gpio_intr_establish(GPIO_TP_INT_C3K, + sc->sc_gh = pxa2x0_gpio_intr_establish(sc->sc_tp_int_pin, IST_EDGE_FALLING, IPL_TTY, ztp_irq, sc); } else { pxa2x0_gpio_intr_unmask(sc->sc_gh); @@ -269,7 +305,7 @@ ztp_suspend(device_t dv, const pmf_qual_ (void)zssp_ic_send(ZSSP_IC_ADS7846, (1 << ADSCTRL_PD1_SH) | (1 << ADSCTRL_ADR_SH) | (1 << ADSCTRL_STS_SH)); - pxa2x0_gpio_set_function(GPIO_TP_INT_C3K, GPIO_OUT | GPIO_SET); + pxa2x0_gpio_set_function(sc->sc_tp_int_pin, GPIO_OUT | GPIO_SET); return true; } @@ -281,7 +317,7 @@ ztp_resume(device_t dv, const pmf_qual_t DPRINTF(("%s: ztp_resume()\n", device_xname(sc->sc_dev))); - pxa2x0_gpio_set_function(GPIO_TP_INT_C3K, GPIO_IN); + pxa2x0_gpio_set_function(sc->sc_tp_int_pin, GPIO_IN); pxa2x0_gpio_intr_mask(sc->sc_gh); /* Enable automatic low power mode. */ @@ -296,17 +332,17 @@ ztp_resume(device_t dv, const pmf_qual_t #define HSYNC() \ do { \ - while (pxa2x0_gpio_get_bit(GPIO_HSYNC_C3K) == 0) \ + while (pxa2x0_gpio_get_bit(sc->sc_hsync_pin) == 0) \ continue; \ - while (pxa2x0_gpio_get_bit(GPIO_HSYNC_C3K) != 0) \ + while (pxa2x0_gpio_get_bit(sc->sc_hsync_pin) != 0) \ continue; \ } while (/*CONSTCOND*/0) static inline uint32_t pxa2x0_ccnt_enable(uint32_t); static inline uint32_t pxa2x0_read_ccnt(void); -static uint32_t ztp_sync_ads784x(int, int, uint32_t); -static void ztp_sync_send(uint32_t); -static int ztp_readpos(struct ztp_pos *); +static uint32_t ztp_sync_ads784x(struct ztp_softc *, int, int, uint32_t); +static void ztp_sync_send(struct ztp_softc *, uint32_t); +static int ztp_readpos(struct ztp_softc *, struct ztp_pos *); static inline uint32_t pxa2x0_ccnt_enable(uint32_t reg) @@ -333,7 +369,8 @@ pxa2x0_read_ccnt(void) * Communicate synchronously with the ADS784x touch screen controller. */ static uint32_t -ztp_sync_ads784x(int dorecv/* XXX */, int dosend/* XXX */, uint32_t cmd) +ztp_sync_ads784x(struct ztp_softc *sc, int dorecv/* XXX */, + int dosend/* XXX */, uint32_t cmd) { uint32_t ccen; uint32_t rv = 0; @@ -351,7 +388,7 @@ ztp_sync_ads784x(int dorecv/* XXX */, in } if (dosend) { - ztp_sync_send(cmd); + ztp_sync_send(sc, cmd); } /* stop clock counter */ @@ -361,13 +398,13 @@ ztp_sync_ads784x(int dorecv/* XXX */, in } void -ztp_sync_send(uint32_t cmd) +ztp_sync_send(struct ztp_softc *sc, uint32_t cmd) { volatile uint32_t base, now; uint32_t tck; /* XXX */ - tck = CCNT_HS_400_VGA_C3K - 151; + tck = sc->sc_ccnt_hs - 151; /* send dummy command; discard SSDR */ (void)zssp_ic_send(ZSSP_IC_ADS7846, cmd); @@ -386,14 +423,14 @@ ztp_sync_send(uint32_t cmd) } static int -ztp_readpos(struct ztp_pos *pos) +ztp_readpos(struct ztp_softc *sc, struct ztp_pos *pos) { int cmd; int t0, t1; int down; /* XXX */ - pxa2x0_gpio_set_function(GPIO_HSYNC_C3K, GPIO_IN); + pxa2x0_gpio_set_function(sc->sc_hsync_pin, GPIO_IN); /* check that pen is down */ cmd = (1 << ADSCTRL_PD0_SH) | (1 << ADSCTRL_PD1_SH) | @@ -408,30 +445,30 @@ ztp_readpos(struct ztp_pos *pos) /* Y */ cmd = (1 << ADSCTRL_PD0_SH) | (1 << ADSCTRL_PD1_SH) | (1 << ADSCTRL_ADR_SH) | (1 << ADSCTRL_STS_SH); - (void)ztp_sync_ads784x(0, 1, cmd); + (void)ztp_sync_ads784x(sc, 0, 1, cmd); /* Y */ cmd = (1 << ADSCTRL_PD0_SH) | (1 << ADSCTRL_PD1_SH) | (1 << ADSCTRL_ADR_SH) | (1 << ADSCTRL_STS_SH); - (void)ztp_sync_ads784x(1, 1, cmd); + (void)ztp_sync_ads784x(sc, 1, 1, cmd); /* X */ cmd = (1 << ADSCTRL_PD0_SH) | (1 << ADSCTRL_PD1_SH) | (5 << ADSCTRL_ADR_SH) | (1 << ADSCTRL_STS_SH); - pos->y = ztp_sync_ads784x(1, 1, cmd); + pos->y = ztp_sync_ads784x(sc, 1, 1, cmd); DPRINTF(("ztp_readpos(): y = %d\n", pos->y)); /* T0 */ cmd = (1 << ADSCTRL_PD0_SH) | (1 << ADSCTRL_PD1_SH) | (3 << ADSCTRL_ADR_SH) | (1 << ADSCTRL_STS_SH); - pos->x = ztp_sync_ads784x(1, 1, cmd); + pos->x = ztp_sync_ads784x(sc, 1, 1, cmd); DPRINTF(("ztp_readpos(): x = %d\n", pos->x)); /* T1 */ cmd = (1 << ADSCTRL_PD0_SH) | (1 << ADSCTRL_PD1_SH) | (4 << ADSCTRL_ADR_SH) | (1 << ADSCTRL_STS_SH); - t0 = ztp_sync_ads784x(1, 1, cmd); - t1 = ztp_sync_ads784x(1, 0, cmd); + t0 = ztp_sync_ads784x(sc, 1, 1, cmd); + t1 = ztp_sync_ads784x(sc, 1, 0, cmd); DPRINTF(("ztp_readpos(): t0 = %d, t1 = %d\n", t0, t1)); /* check that pen is still down */ @@ -474,14 +511,14 @@ ztp_irq(void *v) s = splhigh(); - pindown = pxa2x0_gpio_get_bit(GPIO_TP_INT_C3K) ? 0 : 1; + pindown = pxa2x0_gpio_get_bit(sc->sc_tp_int_pin) ? 0 : 1; DPRINTF(("%s: pindown = %d\n", device_xname(sc->sc_dev), pindown)); if (pindown) { pxa2x0_gpio_intr_mask(sc->sc_gh); callout_schedule(&sc->sc_tp_poll, POLL_TIMEOUT_RATE1); } - down = ztp_readpos(&tp); + down = ztp_readpos(sc, &tp); DPRINTF(("%s: x = %d, y = %d, z = %d, down = %d\n", device_xname(sc->sc_dev), tp.x, tp.y, tp.z, down)); @@ -489,7 +526,7 @@ ztp_irq(void *v) pxa2x0_gpio_intr_unmask(sc->sc_gh); callout_schedule(&sc->sc_tp_poll, POLL_TIMEOUT_RATE0); } - pxa2x0_gpio_clear_intr(GPIO_TP_INT_C3K); + pxa2x0_gpio_clear_intr(sc->sc_tp_int_pin); splx(s); Index: arch/zaurus/zaurus/machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/zaurus/machdep.c,v retrieving revision 1.29 diff -u -p -r1.29 machdep.c --- arch/zaurus/zaurus/machdep.c 25 Jan 2012 16:51:17 -0000 1.29 +++ arch/zaurus/zaurus/machdep.c 25 Jan 2012 17:20:32 -0000 @@ -168,6 +168,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include #include +#include #include @@ -455,13 +456,19 @@ zaurus_restart(void) { uint32_t rv; - rv = pxa2x0_memctl_read(MEMCTL_MSC0); - if ((rv & 0xffff0000) == 0x7ff00000) { - pxa2x0_memctl_write(MEMCTL_MSC0, (rv & 0xffff) | 0x7ee00000); - } + if (ZAURUS_ISC1000 || ZAURUS_ISC3000) { + rv = pxa2x0_memctl_read(MEMCTL_MSC0); + if ((rv & 0xffff0000) == 0x7ff00000) { + pxa2x0_memctl_write(MEMCTL_MSC0, + (rv & 0xffff) | 0x7ee00000); + } - /* External reset circuit presumably asserts nRESET_GPIO. */ - pxa2x0_gpio_set_function(89, GPIO_OUT | GPIO_SET); + /* External reset circuit presumably asserts nRESET_GPIO. */ + pxa2x0_gpio_set_function(89, GPIO_OUT | GPIO_SET); + } else if (ZAURUS_ISC860) { + /* XXX not yet */ + printf("zaurus_restart() for C7x0 is not implemented yet.\n"); + } delay(1 * 1000* 1000); /* wait 1s */ } @@ -1242,6 +1249,7 @@ parseopts(const char *opts, int *howto) #endif #include "lcd.h" +#include "w100lcd.h" #include "wsdisplay.h" #ifndef CONSPEED @@ -1300,9 +1308,16 @@ consinit(void) } else #endif if (strcmp(console, "glass") == 0) { -#if (NLCD > 0) && (NWSDISPLAY > 0) +#if ((NLCD > 0) || (NW100LCD > 0)) && (NWSDISPLAY > 0) glass_console = 1; - lcd_cnattach(); +#if NLCD > 0 + if (ZAURUS_ISC1000 || ZAURUS_ISC3000) + lcd_cnattach(); +#endif +#if NW100LCD > 0 + if (ZAURUS_ISC860) + w100lcd_cnattach(); +#endif #endif } Index: arch/zaurus/zaurus/zaurus_reg.h =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/zaurus/zaurus_reg.h,v retrieving revision 1.3 diff -u -p -r1.3 zaurus_reg.h --- arch/zaurus/zaurus/zaurus_reg.h 31 Mar 2008 23:35:39 -0000 1.3 +++ arch/zaurus/zaurus/zaurus_reg.h 25 Jan 2012 17:20:32 -0000 @@ -73,7 +73,11 @@ #define C3000_CF1_IRQ 106 /* processor GPIO pins */ +#define C860_GPIO_SD_DETECT_PIN 9 +#define C860_RC_IRQ_PIN 4 /* remote control */ +#define C860_GPIO_SD_WP_PIN 7 #define C860_CF0_IRQ_PIN 14 +#define C860_GPIO_SD_POWER_PIN 33 #define C3000_GPIO_SD_DETECT_PIN 9 #define C3000_RC_IRQ_PIN 13 /* remote control */ #define C3000_GPIO_SD_WP_PIN 81 Index: arch/zaurus/zaurus/zaurus_start.S =================================================================== RCS file: /cvsroot/src/sys/arch/zaurus/zaurus/zaurus_start.S,v retrieving revision 1.1 diff -u -p -r1.1 zaurus_start.S --- arch/zaurus/zaurus/zaurus_start.S 16 Dec 2006 05:57:48 -0000 1.1 +++ arch/zaurus/zaurus/zaurus_start.S 25 Jan 2012 17:20:32 -0000 @@ -35,6 +35,7 @@ #include #include /* for PMAP_DOMAIN_KERNEL */ +/* #define PROGRESS */ /* * CPWAIT -- Canonical method to wait for CP15 update. * NOTE: Clobbers the specified temp reg. @@ -61,6 +62,21 @@ _C_LABEL(zaurus_start): * in VA 0xc0200000.. */ +#ifdef PROGRESS + mov r0, #0x7a /*'z'*/ + bl .Lputchar + mov r0, #0x61 /*'a'*/ + bl .Lputchar + mov r0, #0x75 /*'u'*/ + bl .Lputchar + mov r0, #0x72 /*'r'*/ + bl .Lputchar + mov r0, #0x75 /*'u'*/ + bl .Lputchar + mov r0, #0x73 /*'s'*/ + bl .Lputchar +#endif + /* build page table from scratch */ ldr r0, Lstartup_pagetable adr r4, mmu_init_table @@ -73,6 +89,10 @@ _C_LABEL(zaurus_start): adds r1, r1, #-1 bhi 2b 3: +#ifdef PROGRESS + bl .Lprogress + ldr r0, Lstartup_pagetable +#endif ldmia r4!, {r1,r2,r3} /* # of sections, PA|attr, VA */ cmp r1, #0 bne 2b @@ -92,6 +112,19 @@ _C_LABEL(zaurus_start): CPWAIT(r0) /* Jump to kernel code in TRUE VA */ +#ifdef PROGRESS + mov r0, #0x73 /*'s'*/ + bl .Lputchar + mov r0, #0x74 /*'t'*/ + bl .Lputchar + mov r0, #0x61 /*'a'*/ + bl .Lputchar + mov r0, #0x72 /*'r'*/ + bl .Lputchar + mov r0, #0x74 /*'t'*/ + bl .Lputchar + bl .Lputcrlf +#endif adr r0, Lstart ldr pc, [r0] @@ -115,3 +148,62 @@ mmu_init_table: MMU_INIT(0xc0000000, 0xa0000000, 64, L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW)) .word 0,0,0 /* end of table */ + +#ifdef PROGRESS +.Lprogress: + mov r0, #0x2e /*'.'*/ + b .Lputchar + +.Lputchar: + ldr r2, .Lffuart_txdata + ldr r1, .Lffuart_txbusy +1: + ldr r9, [r1] + tst r9, #0x20 + beq 1b + str r0, [r2] + mov pc, lr + +.Lhexprint: + ldr r2, .Lffuart_txdata + ldr r1, .Lffuart_txbusy + mov r10, #32 +1: sub r10, r10, #4 + mov r11, r0, lsr r10 + and r11, r11, #0xf +2: ldr r9, [r1] + tst r9, #0x20 + beq 2b + adr r12, .Lhextable + ldrb r9, [r12, r11] + str r9, [r2] + cmp r10, #0 + bne 1b +3: ldr r9, [r1] + tst r9, #0x20 + beq 3b + mov r9, #0x0d + str r9, [r2] +4: ldr r9, [r1] + tst r9, #0x20 + beq 4b + mov r9, #0x0a + str r9, [r2] + mov pc, lr + +.Lputcrlf: + ldr r2, .Lffuart_txdata + ldr r1, .Lffuart_txbusy + b 3b + + .align 2 + +.Lffuart_txdata: + .word 0x40100000 +.Lffuart_txbusy: + .word 0x40100014 + +.Lhextable: + .asciz "0123456789abcdef" +#endif + --- /dev/null 2012-01-26 01:57:27.000000000 +0900 +++ arch/zaurus/conf/C700 2012-01-21 15:11:41.000000000 +0900 @@ -0,0 +1,19 @@ +# $NetBSD$ +# +# kernel config file for SL-C700 +# + +include "arch/zaurus/conf/GENERIC" + +options CPU_XSCALE_PXA250 +no options CPU_XSCALE_PXA270 + +no makeoptions KERNEL_BASE_PHYS +makeoptions KERNEL_BASE_PHYS="0xa0400000" +no makeoptions LOADADDRESS +makeoptions LOADADDRESS="0xc0400000" + +no scoop1 at pxaip? + +no lcd0 at pxaip? +no wsdisplay* at lcd? --- /dev/null 2012-01-26 01:57:27.000000000 +0900 +++ arch/zaurus/conf/C700_INSTALL 2012-01-21 15:11:41.000000000 +0900 @@ -0,0 +1,7 @@ +# $NetBSD$ +# +# INSTALL config file (C700 with memory disk root) +# + +include "arch/zaurus/conf/C700" +include "arch/zaurus/conf/INSTALL" --- /dev/null 2012-01-26 01:57:27.000000000 +0900 +++ arch/zaurus/dev/w100.c 2012-01-21 16:12:36.000000000 +0900 @@ -0,0 +1,589 @@ +/* $NetBSD$ */ +/* + * Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved. + * Written by Hiroyuki Bessho for Genetec Corporation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of Genetec Corporation may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include +#include +#include +#include +#include /* for cold */ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "wsdisplay.h" + +#include "w100var.h" +#include "w100reg.h" + +/* Console */ +struct { + int is_console; + struct w100_wsscreen_descr *descr; + const struct w100_panel_geometry *geom; +} w100_console; + +static void w100_initialize(struct w100_softc *sc, + const struct w100_panel_geometry *geom); +static int w100_new_screen(struct w100_softc *sc, int depth, + struct w100_screen **scrpp); +static void w100_lcd_geometry(struct w100_softc *sc, + const struct w100_panel_geometry *geom); +#if NWSDISPLAY > 0 +static void w100_setup_rasops(struct w100_softc *sc, + struct rasops_info *rinfo, + struct w100_wsscreen_descr *descr, + const struct w100_panel_geometry *geom); +#endif + +#define w100_reg_write(sc, offset, value) \ + bus_space_write_4((sc)->iot, (sc)->ioh_reg, offset, value) + +static void +w100_lcd_geometry(struct w100_softc *sc, + const struct w100_panel_geometry *geom) +{ + sc->geometry = geom; + switch (geom->rotate) { + case W100_PANEL_ROTATE_CW: + sc->display_width = geom->panel_height; + sc->display_height = geom->panel_width; + w100_reg_write(sc, W100_REG_PCLK_CTRL, 0x00000061); + w100_reg_write(sc, W100_REG_GRAPHIC_CTRL, 0x00de1d0e); + w100_reg_write(sc, W100_REG_GRAPHIC_OFFSET, 0x00895b00); + w100_reg_write(sc, W100_REG_GRAPHIC_PITCH, 0x00000500); + break; + case W100_PANEL_ROTATE_CCW: + sc->display_width = geom->panel_height; + sc->display_height = geom->panel_width; + w100_reg_write(sc, W100_REG_PCLK_CTRL, 0x00000061); + w100_reg_write(sc, W100_REG_GRAPHIC_CTRL, 0x00de1d16); + w100_reg_write(sc, W100_REG_GRAPHIC_OFFSET, 0x008004fc); + w100_reg_write(sc, W100_REG_GRAPHIC_PITCH, 0x00000500); + break; + case W100_PANEL_ROTATE_UD: + sc->display_width = geom->panel_width; + sc->display_height = geom->panel_height; + w100_reg_write(sc, W100_REG_PCLK_CTRL, 0x00000021); + w100_reg_write(sc, W100_REG_GRAPHIC_CTRL, 0x00ded7e); + w100_reg_write(sc, W100_REG_GRAPHIC_OFFSET, 0x00895ffc); + w100_reg_write(sc, W100_REG_GRAPHIC_PITCH, 0x000003c0); + break; + default: + sc->display_width = geom->panel_width; + sc->display_height = geom->panel_height; + w100_reg_write(sc, W100_REG_PCLK_CTRL, 0x00000021); + w100_reg_write(sc, W100_REG_GRAPHIC_CTRL, 0x00de1d66); + w100_reg_write(sc, W100_REG_GRAPHIC_OFFSET, 0x00800000); + w100_reg_write(sc, W100_REG_GRAPHIC_PITCH, 0x000003c0); + break; + } + w100_reg_write(sc, W100_REG_DISP_DB_BUF_CTRL, 0x0000007b); +} + +/* + * Initialize the LCD controller. + */ +static void w100_initialize(struct w100_softc *sc, + const struct w100_panel_geometry *geom) +{ + w100_lcd_geometry(sc, geom); + return; +} + + +/* + * Common driver attachment code. + */ +void +w100_attach_subr(struct w100_softc *sc, bus_space_tag_t iot, + const struct w100_panel_geometry *geom) +{ + bus_space_handle_t ioh_cfg, ioh_reg, ioh_vram; + int error; + + aprint_normal(": ATI Imageon100 LCD controller\n"); + aprint_naive("\n"); + + sc->n_screens = 0; + LIST_INIT(&sc->screens); + + /* config handler */ + error = bus_space_map(iot, W100_CFG_ADDRESS, W100_CFG_SIZE, 0, + &ioh_cfg); + if (error) { + aprint_error_dev(sc->dev, + "failed to map config (errorno=%d)\n", error); + return; + } + + /* register handler */ + error = bus_space_map(iot, W100_REG_ADDRESS, W100_REG_SIZE, 0, + &ioh_reg); + if (error) { + aprint_error_dev(sc->dev, + "failed to map register (errorno=%d)\n", error); + return; + } + + /* videomem handler */ + error = bus_space_map(iot, W100_EXTMEM_ADDRESS, W100_EXTMEM_SIZE, 0, + &ioh_vram); + if (error) { + aprint_error_dev(sc->dev, + "failed to vram register (errorno=%d)\n", error); + return; + } + + sc->iot = iot; + sc->ioh_cfg = ioh_cfg; + sc->ioh_reg = ioh_reg; + sc->ioh_vram = ioh_vram; + + w100_initialize(sc, geom); + +#if NWSDISPLAY > 0 + if (w100_console.is_console) { + struct w100_wsscreen_descr *descr = w100_console.descr; + struct w100_screen *scr; + struct rasops_info *ri; + long defattr; + + error = w100_new_screen(sc, descr->depth, &scr); + if (error) { + aprint_error_dev(sc->dev, + "unable to create new screen (errno=%d)", error); + return; + } + + ri = &scr->rinfo; + ri->ri_hw = (void *)scr; + ri->ri_bits = scr->buf_va; + w100_setup_rasops(sc, ri, descr, geom); + + /* assumes 16 bpp */ + (*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr); + +// pxa2x0_lcd_start_dma(sc, scr); + sc->active = scr; + + wsdisplay_cnattach(&descr->c, ri, ri->ri_ccol, ri->ri_crow, + defattr); + + aprint_normal_dev(sc->dev, "console\n"); + } +#endif +} + +int +w100_cnattach(struct w100_wsscreen_descr *descr, + const struct w100_panel_geometry *geom) +{ + w100_console.descr = descr; + w100_console.geom = geom; + w100_console.is_console = 1; + + return 0; +} + +/* + * Create and initialize a new screen buffer. + */ +static int +w100_new_screen(struct w100_softc *sc, int depth, struct w100_screen **scrpp) +{ + struct w100_screen *scr = NULL; + int error = 0; + + scr = malloc(sizeof(*scr), M_DEVBUF, M_NOWAIT); + if (scr == NULL) + return ENOMEM; + + memset(scr, 0, sizeof(*scr)); + + scr->buf_va = (u_char *)bus_space_vaddr(sc->iot, sc->ioh_vram); + scr->depth = depth; + + LIST_INSERT_HEAD(&sc->screens, scr, link); + sc->n_screens++; + + *scrpp = scr; + + return error; +} + +#if NWSDISPLAY > 0 +/* + * Initialize rasops for a screen, as well as struct wsscreen_descr if this + * is the first screen creation. + */ +static void +w100_setup_rasops(struct w100_softc *sc, struct rasops_info *rinfo, + struct w100_wsscreen_descr *descr, const struct w100_panel_geometry *geom) +{ + rinfo->ri_flg = descr->flags; + rinfo->ri_depth = descr->depth; + rinfo->ri_width = sc->display_width; + rinfo->ri_height = sc->display_height; + rinfo->ri_stride = rinfo->ri_width * rinfo->ri_depth / 8; +#ifdef notyet + rinfo->ri_wsfcookie = -1; /* XXX */ +#endif + + /* swap B and R */ + if (descr->depth == 16) { + rinfo->ri_rnum = 5; + rinfo->ri_rpos = 11; + rinfo->ri_gnum = 6; + rinfo->ri_gpos = 5; + rinfo->ri_bnum = 5; + rinfo->ri_bpos = 0; + } + + if (descr->c.nrows == 0) { + /* get rasops to compute screen size the first time */ + rasops_init(rinfo, 100, 100); + } else { + rasops_init(rinfo, descr->c.nrows, descr->c.ncols); + } + + descr->c.nrows = rinfo->ri_rows; + descr->c.ncols = rinfo->ri_cols; + descr->c.capabilities = rinfo->ri_caps; + descr->c.textops = &rinfo->ri_ops; +} +#endif + +/* + * Power management + */ +void +w100_suspend(struct w100_softc *sc) +{ + + if (sc->active) { + //pxa2x0_lcd_stop_dma(sc); + //pxa2x0_clkman_config(CKEN_LCD, 0); + } +} + +void +w100_resume(struct w100_softc *sc) +{ + + if (sc->active) { + w100_initialize(sc, sc->geometry); + //pxa2x0_lcd_start_dma(sc, sc->active); + } +} + +void +w100_power(int why, void *v) +{ + struct w100_softc *sc = v; + + switch (why) { + case PWR_SUSPEND: + case PWR_STANDBY: + w100_suspend(sc); + break; + + case PWR_RESUME: + w100_resume(sc); + break; + } +} + +/* + * Initialize struct wsscreen_descr based on values calculated by + * raster operation subsystem. + */ +#if 0 +int +w100_setup_wsscreen(struct w100_wsscreen_descr *descr, + const struct w100_panel_geometry *geom, + const char *fontname) +{ + int width = geom->panel_width; + int height = geom->panel_height; + int cookie = -1; + struct rasops_info rinfo; + + memset(&rinfo, 0, sizeof rinfo); + + if (fontname) { + wsfont_init(); + cookie = wsfont_find(fontname, 0, 0, 0, + WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R); + if (cookie < 0 || + wsfont_lock(cookie, &rinfo.ri_font)) + return -1; + } + else { + /* let rasops_init() choose any font */ + } + + /* let rasops_init calculate # of cols and rows in character */ + rinfo.ri_flg = 0; + rinfo.ri_depth = descr->depth; + rinfo.ri_bits = NULL; + rinfo.ri_width = width; + rinfo.ri_height = height; + rinfo.ri_stride = width * rinfo.ri_depth / 8; + rinfo.ri_wsfcookie = cookie; + + rasops_init(&rinfo, 100, 100); + + descr->c.nrows = rinfo.ri_rows; + descr->c.ncols = rinfo.ri_cols; + descr->c.capabilities = rinfo.ri_caps; + + return cookie; +} +#endif + +int +w100_show_screen(void *v, void *cookie, int waitok, + void (*cb)(void *, int, int), void *cbarg) +{ + return 0; +} + +int +w100_alloc_screen(void *v, const struct wsscreen_descr *_type, + void **cookiep, int *curxp, int *curyp, long *attrp) +{ + struct w100_softc *sc = v; + struct w100_screen *scr; + const struct w100_wsscreen_descr *type = + (const struct w100_wsscreen_descr *)_type; + int error; + + if (sc->n_screens > 0) + return ENOMEM; + + error = w100_new_screen(sc, type->depth, &scr); + if (error) + return error; + + /* + * initialize raster operation for this screen. + */ + scr->rinfo.ri_flg = 0; + scr->rinfo.ri_depth = type->depth; + scr->rinfo.ri_bits = scr->buf_va; + scr->rinfo.ri_width = sc->display_width; + scr->rinfo.ri_height = sc->display_height; + scr->rinfo.ri_stride = scr->rinfo.ri_width * scr->rinfo.ri_depth / 8; + scr->rinfo.ri_wsfcookie = -1; /* XXX */ + + rasops_init(&scr->rinfo, type->c.nrows, type->c.ncols); + + (*scr->rinfo.ri_ops.allocattr)(&scr->rinfo, 0, 0, 0, attrp); + + *cookiep = scr; + *curxp = 0; + *curyp = 0; + + return 0; +} + +void +w100_free_screen(void *v, void *cookie) +{ + struct w100_softc *sc = v; + struct w100_screen *scr = cookie; + + LIST_REMOVE(scr, link); + sc->n_screens--; +} + +int +w100_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, + struct lwp *l) +{ + struct w100_softc *sc = v; + struct w100_screen *scr = sc->active; /* ??? */ + struct wsdisplay_fbinfo *wsdisp_info; + + switch (cmd) { + case WSDISPLAYIO_GTYPE: + *(int *)data = WSDISPLAY_TYPE_UNKNOWN; + return 0; + + case WSDISPLAYIO_GINFO: + wsdisp_info = (struct wsdisplay_fbinfo *)data; + wsdisp_info->height = sc->display_height; + wsdisp_info->width = sc->display_width; + wsdisp_info->depth = scr->depth; + wsdisp_info->cmsize = 0; + return 0; + + case WSDISPLAYIO_LINEBYTES: + *(u_int *)data = scr->rinfo.ri_stride; + return 0; + + case WSDISPLAYIO_GETCMAP: + case WSDISPLAYIO_PUTCMAP: + return EPASSTHROUGH; /* XXX Colormap */ + + case WSDISPLAYIO_SVIDEO: + if (*(int *)data == WSDISPLAYIO_VIDEO_ON) { + /* turn it on */ + } + else { + /* start LCD shutdown */ + /* sleep until interrupt */ + } + return 0; + + case WSDISPLAYIO_GVIDEO: +// ccr0 = bus_space_read_4(sc->iot, sc->ioh, LCDC_LCCR0); +// *(u_int *)data = (ccr0 & (LCCR0_ENB|LCCR0_DIS)) == LCCR0_ENB ? +// WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF; + *(u_int *)data = WSDISPLAYIO_VIDEO_ON; + return 0; + + case WSDISPLAYIO_GCURPOS: + case WSDISPLAYIO_SCURPOS: + case WSDISPLAYIO_GCURMAX: + case WSDISPLAYIO_GCURSOR: + case WSDISPLAYIO_SCURSOR: + return EPASSTHROUGH; /* XXX */ + } + + return EPASSTHROUGH; +} + +paddr_t +w100_mmap(void *v, void *vs, off_t offset, int prot) +{ + struct w100_softc *sc = v; + struct w100_screen *scr = sc->active; /* ??? */ + + if (scr == NULL) + return -1; + + if (offset < 0 || + offset >= scr->rinfo.ri_stride * scr->rinfo.ri_height) + return -1; + + return arm_btop(W100_EXTMEM_ADDRESS + offset); +} + + +static void +w100_cursor(void *cookie, int on, int row, int col) +{ + struct w100_screen *scr = cookie; + + (*scr->rinfo.ri_ops.cursor)(&scr->rinfo, on, row, col); +} + +static int +w100_mapchar(void *cookie, int c, unsigned int *cp) +{ + struct w100_screen *scr = cookie; + + return (*scr->rinfo.ri_ops.mapchar)(&scr->rinfo, c, cp); +} + +static void +w100_putchar(void *cookie, int row, int col, u_int uc, long attr) +{ + struct w100_screen *scr = cookie; + + (*scr->rinfo.ri_ops.putchar)(&scr->rinfo, row, col, uc, attr); +} + +static void +w100_copycols(void *cookie, int row, int src, int dst, int num) +{ + struct w100_screen *scr = cookie; + + (*scr->rinfo.ri_ops.copycols)(&scr->rinfo, row, src, dst, num); +} + +static void +w100_erasecols(void *cookie, int row, int col, int num, long attr) +{ + struct w100_screen *scr = cookie; + + (*scr->rinfo.ri_ops.erasecols)(&scr->rinfo, row, col, num, attr); +} + +static void +w100_copyrows(void *cookie, int src, int dst, int num) +{ + struct w100_screen *scr = cookie; + + (*scr->rinfo.ri_ops.copyrows)(&scr->rinfo, src, dst, num); +} + +static void +w100_eraserows(void *cookie, int row, int num, long attr) +{ + struct w100_screen *scr = cookie; + + (*scr->rinfo.ri_ops.eraserows)(&scr->rinfo, row, num, attr); +} + +static int +w100_alloc_attr(void *cookie, int fg, int bg, int flg, long *attr) +{ + struct w100_screen *scr = cookie; + + return (*scr->rinfo.ri_ops.allocattr)(&scr->rinfo, fg, bg, flg, attr); +} + +const struct wsdisplay_emulops w100_emulops = { + w100_cursor, + w100_mapchar, + w100_putchar, + w100_copycols, + w100_erasecols, + w100_copyrows, + w100_eraserows, + w100_alloc_attr +}; + + --- /dev/null 2012-01-26 01:57:27.000000000 +0900 +++ arch/zaurus/dev/w100lcd.c 2012-01-21 16:16:45.000000000 +0900 @@ -0,0 +1,227 @@ +/* $NetBSD$ */ +/* + * Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved. + * Written by Hiroyuki Bessho for Genetec Corporation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of Genetec Corporation may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * LCD driver for Sharp Zaurus (based on the Intel Lubbock driver). + * + * Controlling LCD is almost completely done through PXA2X0's + * integrated LCD controller. Codes for it is arm/xscale/pxa2x0_lcd.c. + * + * Codes in this file provide platform specific things including: + * LCD on/off switch and backlight brightness + * LCD panel geometry + */ +#include +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include +#include + +#include +#include +#include +//#include +#include +#include + +#include +#include + +#include +#include + +/* + * wsdisplay glue + */ +static struct w100_wsscreen_descr w100lcd_std_screen = { + .c = { + .name = "std", + .textops = &w100_emulops, + .fontwidth = 8, + .fontheight = 16, + .capabilities = WSSCREEN_WSCOLORS, + }, + .depth = 16, /* bits per pixel */ + .flags = 0, +}; + +static const struct wsscreen_descr *w100lcd_scr_descr[] = { + &w100lcd_std_screen.c +}; + +static const struct wsscreen_list w100lcd_screen_list = { + .nscreens = __arraycount(w100lcd_scr_descr), + .screens = w100lcd_scr_descr, +}; + +static int w100lcd_ioctl(void *, void *, u_long, void *, int, + struct lwp *); +static int w100lcd_show_screen(void *, void *, int, + void (*)(void *, int, int), void *); + +struct wsdisplay_accessops w100lcd_accessops = { + w100lcd_ioctl, + w100_mmap, + w100_alloc_screen, + w100_free_screen, + w100lcd_show_screen, + NULL, + NULL, + NULL, +}; + +const struct w100_panel_geometry lcd_panel_geometry_c700 = +{ + 480, /* Width */ + 640, /* Height */ + W100_PANEL_ROTATE_CW, /* Rotate */ +}; + +static int w100lcd_match(device_t, cfdata_t, void *); +static void w100lcd_attach(device_t, device_t, void *); + +CFATTACH_DECL_NEW(w100lcd, sizeof(struct w100_softc), + w100lcd_match, w100lcd_attach, NULL, NULL); + +static bool w100lcd_suspend(device_t, const pmf_qual_t *); +static bool w100lcd_resume(device_t, const pmf_qual_t *); + +static int +w100lcd_match(device_t parent, cfdata_t cf, void *aux) +{ + + if (ZAURUS_ISC860) + return 1; + return 0; +} + +static void +w100lcd_attach(device_t parent, device_t self, void *aux) +{ + struct w100_softc *sc = device_private(self); + struct pxaip_attach_args *pxa = (struct pxaip_attach_args *)aux; + struct wsemuldisplaydev_attach_args aa; + + sc->dev = self; + + w100_attach_subr(sc, pxa->pxa_iot, &lcd_panel_geometry_c700); + + aa.console = glass_console; + aa.scrdata = &w100lcd_screen_list; + aa.accessops = &w100lcd_accessops; + aa.accesscookie = sc; + + (void)config_found(self, &aa, wsemuldisplaydevprint); + + if (!pmf_device_register(self, w100lcd_suspend, w100lcd_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); +} + +void +w100lcd_cnattach(void) +{ + + if (ZAURUS_ISC860) + w100_cnattach(&w100lcd_std_screen, &lcd_panel_geometry_c700); +} + +/* + * power management + */ +static bool +w100lcd_suspend(device_t dv, const pmf_qual_t *qual) +{ + struct w100_softc *sc = device_private(dv); + +#if NLCDCTL > 0 + lcdctl_onoff(false); +#endif + w100_suspend(sc); + + return true; +} + +static bool +w100lcd_resume(device_t dv, const pmf_qual_t *qual) +{ + struct w100_softc *sc = device_private(dv); + + w100_resume(sc); +#if NLCDCTL > 0 + lcdctl_onoff(true); +#endif + + return true; +} + +/* + * wsdisplay accessops overrides + */ +static int +w100lcd_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l) +{ + int res = EINVAL; + + switch (cmd) { +#if NLCDCTL > 0 + case WSDISPLAYIO_GETPARAM: + case WSDISPLAYIO_SETPARAM: + res = lcdctl_param(cmd, (struct wsdisplay_param *)data); + break; +#endif + + default: + break; + } + + if (res == EINVAL) + res = w100_ioctl(v, vs, cmd, data, flag, l); + + return res; +} + +static int +w100lcd_show_screen(void *v, void *cookie, int waitok, + void (*cb_func)(void *, int, int), void *cb_arg) +{ + int error; + + error = w100_show_screen(v, cookie, waitok, cb_func, cb_arg); + if (error) + return (error); + + /* Turn on LCD */ +#if NLCDCTL > 0 + lcdctl_onoff(true); +#endif + + return 0; +} --- /dev/null 2012-01-26 01:57:27.000000000 +0900 +++ arch/zaurus/dev/w100lcdvar.h 2012-01-21 15:41:34.000000000 +0900 @@ -0,0 +1,8 @@ +/* $NetBSD$ */ + +#ifndef _ZAURUS_DEV_W100LCDVAR_H_ +#define _ZAURUS_DEV_W100LCDVAR_H_ + +void w100lcd_cnattach(void); + +#endif /* _ZAURUS_DEV_W100LCDVAR_H_ */