#include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "../port/error.h" #include "io.h" #include "image.h" #include #include "screen.h" #include "bootparam.h" enum { /* * GPIO asignments. Not all used in this file, but gathered here for * documental purposes. */ gpio_ee_cs = 0, /* out */ gpio_wheaties = 1, /* out */ /* lcd lower = GPIO 2-9 */ gpio_spi_dout = 10, /* out, spi data */ gpio_spi_din = 11, /* in, spi data */ gpio_spi_sclk = 12, /* out, spi clock */ gpio_spi_unkn = 13, /* unknown, may be spi framing */ gpio_spi_rtsn = 14, /* ??, spi ?? */ gpio_spi_cts = 15, /* ??, spi ?? */ gpio_irq_codec = 16, /* in, irq from ucb1200 */ gpio_dsp_reset = 17, /* out */ gpio_codec_reset = 18, /* out */ gpio_u3_rts = 19, /* ?? */ gpio_u3_cts = 20, /* ?? */ gpio_sense12v = 21, /* in, 12v flash unprotect detected */ gpio_disp_en = 22, /* out */ gpio_23 = 23, /* XXX GPIO 23 unaccounted for */ GPIOeject_0= 24, /* in */ GPIOeject_1= 25, /* in */ GPIOrdy_0= 26, /* in */ GPIOrdy_1= 27, /* in */ /* MCP UCB codec GPIO pins... */ BACKLIGHT_m = BIT(9), BACKLIGHT_s = 9, BRIGHT_m = BITS(6,8), BRIGHT_s = 6, CONTRAST_m = BITS(0,5), CONTRAST_s = 0, MAX_BRIGHT = 7, MAX_CONTRAST = 0x3f, }; int gpio_irq_ucb1200 = 16; extern int cflag; extern int consoleprint; extern int redirectconsole; extern int main_pool_pcnt; extern int heap_pool_pcnt; extern int image_pool_pcnt; extern int kernel_pool_pcnt; extern char debug_keys; extern Vmode default_vmode; int smodem_HybridDelay = 0x23; /* see comment in devsm.c */ void archreset(void) { GpioReg *g; /* put the hardware in a known state */ g = GPIOREG; g->gfer = 0; g->grer = 0; g->gedr = g->gedr; g->gpdr = 0; dmareset(); /* reset codec and enable display */ g->gpdr |= (1<gpcr = (1<gpsr = (1<himem; conf.flashbase = bootparam->flashbase; conf.cpuspeed = bootparam->cpuspeed; conf.pagetable = bootparam->pagetable; conf.usebabycache = 1; conf.cansetbacklight = 1; conf.cansetcontrast = 1; conf.remaplo = 1; } void archreboot(void) { bootparam->reboot(1); } static int backlight = 0; static int brightness = 0; static int contrast = 0x20; static void updatecodecio(void) { mcpgpiowrite(BACKLIGHT_m|BRIGHT_m|CONTRAST_m, (backlight << BACKLIGHT_s) |(brightness << BRIGHT_s) |(contrast << CONTRAST_s)); } void lights(ulong) { } void lcd_setbacklight(int on) { backlight = !on; updatecodecio(); } void lcd_setbrightness(ushort level) { brightness = MAX_BRIGHT-((level*(MAX_BRIGHT+1))>>16); updatecodecio(); } void lcd_setcontrast(ushort level) { contrast = (level*(MAX_CONTRAST+1))>>16; updatecodecio(); } int archflash12v(int /*on*/) { ulong b; b = (1<gplr & b) == 0) { print("waiting for 12V (10 sec)\n"); if(timer_devwait(&GPIOREG->gplr, b, b, MS2TMR(10000)) < 0) return 0; print("got 12V\n"); microdelay(2); // spec says 1, let's just be safe... } return 1; } void archflashwp(int /*wp*/) { } int touch_read_delay = 50; /* usec between setup and first reading */ int touch_l2nreadings = 2; /* log2 of number of readings to take */ int touch_minpdelta = 20; /* minimum pressure difference to detect a change during calibration */ int touch_filterlevel = 512; /* -1024(off) to 1024(full): 1024*cos(angle) */ TouchCal touchcal = { { {10, 10}, {630, 10}, {630, 470}, {10, 470}, }, { { {73, 932}, {938, 932}, {945, 77}, {71, 75}, }, { {73, 76}, {938, 76}, {945, 931}, {73, 933}, }, { {931, 932}, {65, 932}, {60, 77}, {930, 75}, }, { {929, 77}, {65, 77}, {60, 931}, {931, 933}, }, }, { { 46977, 384, 0, -35261, -2920328, 33482554 }, { 46973, -384, 0, 35258, -2579941, -2059021 }, { -46916, 274, 0, -35256, 44172739, 33480036 }, { -47028, -275, 0, 35300, 44530275, -2097860 }, }, {3, 1}, {2, 2}, 145, 110, }; int archhooksw(int offhook) { extern int modemControl(int); return modemControl(offhook); } void archspeaker(int, int) { } /* * PCMCIA support. Shannon only permits 3v for Vcc and Vpp, * and has no status change lines. */ void pcmsetvcc(int slotno, int vcc) { if (vcc != 3) print("illegal vcc voltage %d for slot %d\n", vcc, slotno); /* error? */ } void pcmsetvpp(int slotno, int vpp) /* set power and enable device */ { if (vpp != 3) print("illegal vpp voltage %d for slot %d\n", vpp, slotno); /* error? */ } void pcmpower(int slotno, int on) { USED(slotno); if (on) delay(300); } int pcmpowered(int) { return 3; } int pcmpin(int slot, int type) { switch (type) { case PCMready: return (slot == 0) ? GPIOrdy_0 : GPIOrdy_1; case PCMeject: return (slot == 0) ? GPIOeject_0 : GPIOeject_1; case PCMstschng: return -1; /* unsupported by Shannon hardware */ } } int isaconfig(char *class, int ctlrno, ISAConf *isa) { char cc[NAMELEN]; sprint(cc, "%s%d", class, ctlrno); if (strcmp(cc, "ether0") == 0) { strcpy(isa->type, "tdk"); return 1; } else return 0; }