diff options
-rw-r--r-- | board/goldelico/gta04/Makefile | 2 | ||||
-rw-r--r-- | board/goldelico/gta04/commands.c | 175 | ||||
-rw-r--r-- | board/goldelico/gta04/dssfb.c | 4 | ||||
-rw-r--r-- | board/goldelico/gta04/gta04.c | 179 | ||||
-rw-r--r-- | board/goldelico/gta04/gta04.h | 106 | ||||
-rw-r--r-- | board/goldelico/gta04/shutdown.c | 6 | ||||
-rw-r--r-- | board/goldelico/gta04/shutdown.h | 1 | ||||
-rw-r--r-- | board/goldelico/gta04/systest.c | 239 | ||||
-rw-r--r-- | board/goldelico/gta04/systest.h | 5 | ||||
-rw-r--r-- | board/goldelico/gta04/tsc2007.c | 24 | ||||
-rw-r--r-- | board/goldelico/gta04/tsc2007.h | 1 | ||||
-rw-r--r-- | board/goldelico/gta04/twl4030-additions.c | 509 | ||||
-rw-r--r-- | board/goldelico/gta04/twl4030-additions.h | 203 | ||||
-rw-r--r-- | board/goldelico/gta04/ulpi-phy.c | 73 | ||||
-rw-r--r-- | board/goldelico/gta04/ulpi-phy.h | 6 | ||||
-rw-r--r-- | board/goldelico/gta04b2/COM37H3M05DTC.c | 2 | ||||
-rw-r--r-- | board/goldelico/gta04b2/Makefile | 2 | ||||
-rw-r--r-- | include/configs/omap3_beagle.h | 2 | ||||
-rw-r--r-- | include/configs/omap3_gta04.h | 5 | ||||
-rw-r--r-- | include/configs/omap3_gta04b2.h | 30 |
20 files changed, 1426 insertions, 148 deletions
diff --git a/board/goldelico/gta04/Makefile b/board/goldelico/gta04/Makefile index d822767..5afd6df 100644 --- a/board/goldelico/gta04/Makefile +++ b/board/goldelico/gta04/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o -COBJS := gta04.o ../gta04/TD028TTEC1.o ../gta04/jbt6k74.o ../gta04/backlight.o ../gta04/status.o ../gta04/tsc2007.o ../gta04/dssfb.o ../gta04/gps.o ../gta04/shutdown.o ../gta04/systest.o ../gta04/commands.o ../gta04/i2c1-fix.o +COBJS := gta04.o ../gta04/TD028TTEC1.o ../gta04/jbt6k74.o ../gta04/backlight.o ../gta04/status.o ../gta04/tsc2007.o ../gta04/dssfb.o ../gta04/gps.o ../gta04/shutdown.o ../gta04/systest.o ../gta04/commands.o ../gta04/i2c1-fix.o ../gta04/ulpi-phy.o ../gta04/twl4030-additions.o SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/board/goldelico/gta04/commands.c b/board/goldelico/gta04/commands.c index c2f8117..f4b237e 100644 --- a/board/goldelico/gta04/commands.c +++ b/board/goldelico/gta04/commands.c @@ -38,6 +38,7 @@ #include "tsc2007.h" #include "shutdown.h" #include "systest.h" +#include "twl4030-additions.h" /* LCM commands */ @@ -77,44 +78,57 @@ static int do_lcd_backlight(int argc, char *const argv[]) return 0; } +static char *lcdmodel="td028"; + static int do_lcd_power(int argc, char *const argv[]) { - int state=JBT_STATE_NORMAL; - if (argc < 3) + if(strcmp(lcdmodel, "td028") == 0) { + int state=JBT_STATE_NORMAL; + if (argc < 3) + { printf ("lcm power: missing state (0..2).\n"); return (-1); - } - state=simple_strtoul(argv[2], NULL, 10); - if(state > 2) - { + } + state=simple_strtoul(argv[2], NULL, 10); + if(state > 2) + { printf ("lcm power: invalid state (0..2).\n"); return (-1); + } + jbt6k74_enter_state(state); + printf("lcm state set to %s\n", jbt_state()); } - jbt6k74_enter_state(state); - printf("lcm state set to %s\n", jbt_state()); return 0; } static int do_lcd_onoff(int argc, char *const argv[], int flag) { - jbt6k74_display_onoff(flag); + if(strcmp(lcdmodel, "td028") == 0) + jbt6k74_display_onoff(flag); + else + jbt6k74_display_onoff(flag); printf("display power %s\n", flag?"on":"off"); return 0; } static int do_lcd_init(int argc, char *const argv[]) { + // check argv for user specified lcdmodel return board_video_init(NULL); } static int do_lcd_start(int argc, char *const argv[]) { + // check argv for user specified lcdmodel if(board_video_init(NULL)) return 1; - jbt6k74_enter_state(2); - jbt6k74_display_onoff(1); - backlight_set_level(255); + if(strcmp(lcdmodel, "td028") == 0) + { + jbt6k74_enter_state(2); + jbt6k74_display_onoff(1); + backlight_set_level(255); + } return 0; } @@ -152,12 +166,12 @@ static int do_lcd(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) } U_BOOT_CMD(lcm, 3, 0, do_lcd, "LCM sub-system", - "init - initialize DSS, GPIOs and LCM controller\n" + "init [model] - initialize DSS, GPIOs and LCM controller\n" "backlight level - set backlight level\n" "off - switch off\n" "on - switch on\n" "power mode - set power mode\n" - "start - initialize, switch on power and enable backlight\n" + "start [model] - initialize, switch on power and enable backlight\n" "color hhhhhh - switch color (can be used without init)\n" "fb address - set framebuffer address (can be used without init)\n" ); @@ -233,30 +247,6 @@ static int do_tsc_selection(int argc, char *const argv[]) return tsc_choice == simple_strtoul(argv[2], NULL, 10)?0:1; } -static int pendown(int *x, int *y) -{ -#if 1 - int z; - int xx; - int yy; - xx=read_adc(0); - yy=read_adc(1); - z=read_adc(2); // read Z - if(z < 0) - return 0; // read error -#if 0 - printf("z=%04d x:%04d y:%04d\n", z, xx, yy); -#endif - if(x) *x=xx; - if(y) *y=yy; - udelay(10000); // reduce I2C traffic and debounce... - return z > 200; // was pressed -#else - // must be in PENIRQ mode... - return (status_get_buttons() & (1 << 4)) == 0; -#endif -} - static int do_tsc_choose(int argc, char *const argv[]) { // tsc choose cols rows int cols; @@ -567,31 +557,109 @@ U_BOOT_CMD(gps, 3, 0, do_gps, "GPS sub-system", "echo - echo GPS out to console\n" ); +#include "ulpi-phy.h" + +static int do_systest_all(int argc, char *const argv[]) +{ + unsigned short *fb=(void *) 0x81000000; // base address to be used as RGB16 framebuffer + printf("permanently doing complete systest.\n" + "Press any key to stop\n\n"); + omap3_dss_set_fb(fb); + audiotest_init(0); + while (!tstc() && (status_get_buttons()&0x09) == 0) + { + int i; + for(i=0; i<8; i++) + { + int val=(480*read_adc(i))/4096; + int x, y; + printf("%d: %d\n", i, val); + for(y=16*i; y<16*i+16; y++) + { // draw colored bar depending on current value + for(x=0; x<480; x++) + fb[x+480*y]=(x < val)?0xfc00:0x03ff; + } + } + // show hardware test results (chip availability) + // continue to play some sound every loop... + } + if(tstc()) + getc(); + printf("\n"); + return 0; +} + static int do_systest(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { if(argc >= 2) { if (strncmp ("au", argv[1], 2) == 0) { return audiotest(0); } + if (strncmp ("al", argv[1], 2) == 0) { + return do_systest_all (argc, argv); + } + if (strncmp ("ir", argv[1], 2) == 0) { + return irdatest(); + } + if (strncmp ("wl", argv[1], 2) == 0) { + return wlanbttest(1); + } + if (strncmp ("wp", argv[1], 2) == 0) { + return wlanbttest(0); // just power on + } + if (strncmp ("ch", argv[1], 2) == 0) { + return twl4030_init_battery_charging(); + } + } + if(argc == 3) { + if (strncmp ("ot", argv[1], 2) == 0) { + return OTGchargepump(simple_strtoul(argv[2], NULL, 10)); + } + if (strncmp ("ul", argv[1], 2) == 0) { + int port=simple_strtoul(argv[2], NULL, 10); /* 0, 1, ... */ + int reg; + for(reg=0; reg <= 0x3f; reg++) + printf("ulpi reg %02x: %02x\n", reg, ulpi_direct_access(port, reg, 0, 0)); + } } return systest(); } U_BOOT_CMD(systest, 3, 0, do_systest, "System Test", - "audio - test audio\n"); + "all - graphical test mode\n" + "audio - test audio\n" + "irda - test IrDA\n" + "wlanbt - test WLAN/BT module\n" + "wp - apply power to WLAN/BT module\n" + "charging - init and test BCI/BKBAT\n" + "otg n - enable/disable OTG charge pump\n" + ); -static int do_halt(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +static int do_powerdown(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { backlight_set_level(0); jbt6k74_enter_state(0); jbt6k74_display_onoff(0); shutdown(); // finally shut down power - printf ("failed to power off\n"); + printf ("failed to power down\n"); + return (0); +} + +U_BOOT_CMD(powerdown, 2, 0, do_powerdown, "Powerdown", + ""); + +static int do_suspend(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + backlight_set_level(0); + jbt6k74_enter_state(0); + jbt6k74_display_onoff(0); + suspend(); // put CPU in sleep mode so that it can be waked up by pressing the AUX button or other events + printf ("suspend finished\n"); return (0); } -U_BOOT_CMD(halt, 2, 0, do_halt, "Powerdown", +U_BOOT_CMD(suspend, 2, 0, do_suspend, "Suspend", ""); @@ -625,21 +693,34 @@ U_BOOT_CMD(mux, 2, 0, do_mux, "Pinmux", ""); static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { + int g; if(argc == 3) { if (strncmp ("on", argv[1], 2) == 0) { - omap_set_gpio_dataout(simple_strtoul(argv[2], NULL, 10), 1); + g=simple_strtoul(argv[2], NULL, 10); + omap_request_gpio(g); + omap_set_gpio_dataout(g, 1); + // omap_free_gpio(g); - switches back to input return 0; } else if (strncmp ("of", argv[1], 2) == 0) { - omap_set_gpio_dataout(simple_strtoul(argv[2], NULL, 10), 0); + g=simple_strtoul(argv[2], NULL, 10); + omap_request_gpio(g); + omap_set_gpio_dataout(g, 0); + // omap_free_gpio(g); - switches back to input return 0; } else if (strncmp ("in", argv[1], 2) == 0) { - omap_set_gpio_direction(simple_strtoul(argv[2], NULL, 10), 1); + g=simple_strtoul(argv[2], NULL, 10); + omap_request_gpio(g); + omap_set_gpio_direction(g, 1); + // omap_free_gpio(g); - switches back to input return 0; } else if (strncmp ("ou", argv[1], 2) == 0) { - omap_set_gpio_direction(simple_strtoul(argv[2], NULL, 10), 0); + g=simple_strtoul(argv[2], NULL, 10); + omap_request_gpio(g); + omap_set_gpio_direction(g, 0); + // omap_free_gpio(g); - switches back to input return 0; } } @@ -691,5 +772,5 @@ U_BOOT_CMD(gpio, 3, 0, do_gpio, "GPIO sub-system", "on n - set to 1\n" "of[f] n - set to 0\n" "in n - switch to input\n" - "ou[t] n - switch to out (dangerous!)\n" + "ou[t] n - switch to out (does not change pinmux!)\n" ); diff --git a/board/goldelico/gta04/dssfb.c b/board/goldelico/gta04/dssfb.c index 22a77d3..4eff169 100644 --- a/board/goldelico/gta04/dssfb.c +++ b/board/goldelico/gta04/dssfb.c @@ -231,9 +231,9 @@ void dssfb_init(const struct panel_config *lcm_cfg) printf("fck_dss_on\n"); sr32(&prcm_base->fclken_dss, 0, 32, FCK_DSS_ON); sdelay(1000); - printf("fck_cam_on\n"); +// printf("fck_cam_on\n"); // sr32(&prcm_base->fclken_cam, 0, 32, FCK_CAM_ON); - printf("ick_cam_on\n"); +// printf("ick_cam_on\n"); // sr32(&prcm_base->iclken_cam, 0, 32, ICK_CAM_ON); sdelay(1000); #else diff --git a/board/goldelico/gta04/gta04.c b/board/goldelico/gta04/gta04.c index 875f0c4..e9bdd87 100644 --- a/board/goldelico/gta04/gta04.c +++ b/board/goldelico/gta04/gta04.c @@ -10,6 +10,9 @@ * Richard Woodruff <r-woodruff2@ti.com> * Syed Mohammed Khasim <khasim@ti.com> * + * Authos: + * Nikolaus Schaller <hns@goldelico.com> + * adapted to GTA04 * * See file CREDITS for list of people who contributed to this * project. @@ -40,7 +43,6 @@ #include <asm/mach-types.h> #include "gta04.h" - #if 1 /* testing tool; you can call notify() anywhere even before initialization to see how far the code comes */ /****************************************************************************** @@ -103,33 +105,7 @@ int board_init(void) */ int get_board_revision(void) { -#ifdef CONFIG_OMAP3_GTA04 return 6; // configure pinmux for C1/2/3 -#else - int revision; - - if (!omap_request_gpio(171) && - !omap_request_gpio(172) && - !omap_request_gpio(173)) { - - omap_set_gpio_direction(171, 1); - omap_set_gpio_direction(172, 1); - omap_set_gpio_direction(173, 1); - - revision = omap_get_gpio_datain(173) << 2 | - omap_get_gpio_datain(172) << 1 | - omap_get_gpio_datain(171); - - omap_free_gpio(171); - omap_free_gpio(172); - omap_free_gpio(173); - } else { - printf("Error: unable to acquire board revision GPIOs\n"); - revision = -1; - } - - return revision; -#endif } /* @@ -137,7 +113,6 @@ int get_board_revision(void) * Description: Configure board specific parts */ -#ifdef CONFIG_OMAP3_GTA04 #define TCA6507_BUS (2-1) // I2C2 #define TCA6507_ADDRESS 0x45 @@ -145,13 +120,11 @@ int get_board_revision(void) #define TCA6507_SELECT0 0 #define TCA6507_SELECT1 1 #define TCA6507_SELECT2 2 -#endif int misc_init_r(void) { struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE; struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE; -#ifdef CONFIG_OMAP3_GTA04 /* ITG3200 & HMC5883L VAUX2 = 2.8V */ twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, @@ -170,63 +143,25 @@ int misc_init_r(void) i2c_reg_write(TCA6507_ADDRESS, TCA6507_SELECT2, 0x40); // pull down reset for WLAN&BT chip i2c_set_bus_num(0); // write I2C1 +#if 0 // FIXME: enable only on demand if we want to test BT/WIFI - and apply RESET /* Bluetooth VAUX4 = 3.3V -- CHECKME: 3.3 V is not officially supported! We use 0x09 = 2.8V here*/ twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX4_DEDICATED, /*TWL4030_PM_RECEIVER_VAUX4_VSEL_33*/ 0x09, TWL4030_PM_RECEIVER_VAUX4_DEV_GRP, TWL4030_PM_RECEIVER_DEV_GRP_P1); - -#else - switch (get_board_revision()) { - case REVISION_AXBX: -// printf("Beagle Rev Ax/Bx\n"); -// setenv("beaglerev", "AxBx"); - setenv("mpurate", "600"); - break; - case REVISION_CX: -// printf("Beagle Rev C1/C2/C3\n"); -// setenv("beaglerev", "Cx"); - setenv("mpurate", "600"); - MUX_BEAGLE_C(); - break; - case REVISION_C4: -// printf("Beagle Rev C4\n"); -// setenv("beaglerev", "C4"); - setenv("mpurate", "720"); - MUX_BEAGLE_C(); - /* Set VAUX2 to 1.8V for EHCI PHY */ - twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, - TWL4030_PM_RECEIVER_VAUX2_VSEL_18, - TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, - TWL4030_PM_RECEIVER_DEV_GRP_P1); - break; - case REVISION_XM: -// printf("Beagle xM Rev A\n"); -// setenv("beaglerev", "xMA"); - setenv("mpurate", "1000"); - MUX_BEAGLE_XM(); - /* Set VAUX2 to 1.8V for EHCI PHY */ - twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, - TWL4030_PM_RECEIVER_VAUX2_VSEL_18, - TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, - TWL4030_PM_RECEIVER_DEV_GRP_P1); - break; - default: - printf("Beagle unknown 0x%02x\n", get_board_revision()); - } #endif - + + /* make dependent on CPU type */ + setenv("mpurate", "600"); + setenv("mpurate", "800"); + twl4030_power_init(); -#ifdef CONFIG_OMAP3_GTA04 // we have no LEDs on TPS on GTA04 // but a power on/off button (8 seconds) twl4030_power_reset_init(); -#else - // LEDs on BeagleBoard - twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); -#endif - + +#if 0 // FIXME: check this!!! /* Configure GPIOs to output */ @@ -239,9 +174,99 @@ int misc_init_r(void) &gpio6_base->setdataout); writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout); +#endif - dieid_num_r(); +#if 1 // duplicate with twl4030-additions + +#define TWL4030_BB_CFG_BBCHEN (1 << 4) +#define TWL4030_BB_CFG_BBSEL_3200MV (3 << 2) +#define TWL4030_BB_CFG_BBISEL_500UA 2 + /* Enable battery backup capacitor (3.2V, 0.5mA charge current) */ + twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, + TWL4030_BB_CFG_BBCHEN | TWL4030_BB_CFG_BBSEL_3200MV | + TWL4030_BB_CFG_BBISEL_500UA, TWL4030_PM_RECEIVER_BB_CFG); +#endif + + dieid_num_r(); + +#if 0 // check if watchdog is switched off + { + struct _watchdog { + u32 widr; /* 0x00 r */ + u8 res1[0x0c]; + u32 wd_sysconfig; /* 0x10 rw */ + u32 ws_sysstatus; /* 0x14 r */ + u32 wisr; + u32 wier; + u8 res2[0x04]; + u32 wclr; /* 0x24 rw */ + u32 wcrr; + u32 wldr; + u32 wtgr; + u32 wwps; /* 0x34 r */ + u8 res3[0x10]; + u32 wspr; /* 0x48 rw */ + }; + struct _watchdog *wd2_base = (struct watchdog *)WD2_BASE; + struct prcm *prcm_base = (struct prcm *)PRCM_BASE; + + printf("idlest_wkup = %08x\n", readl(&prcm_base->idlest_wkup)); + printf("widr = %08x\n", readl(&wd2_base->widr)); + printf("wd_sysconfig = %08x\n", readl(&wd2_base->wd_sysconfig)); + printf("ws_sysstatus = %08x\n", readl(&wd2_base->ws_sysstatus)); + printf("wisr = %08x\n", readl(&wd2_base->wisr)); + printf("wier = %08x\n", readl(&wd2_base->wier)); + printf("wclr = %08x\n", readl(&wd2_base->wclr)); + printf("wcrr = %08x\n", readl(&wd2_base->wcrr)); + printf("wldr = %08x\n", readl(&wd2_base->wldr)); + printf("wtgr = %08x\n", readl(&wd2_base->wtgr)); + printf("wwps = %08x\n", readl(&wd2_base->wwps)); + printf("wspr = %08x\n", readl(&wd2_base->wspr)); + + writel(WD_UNLOCK2, &wd2_base->wspr); + myudelay(100); + writel(WD_UNLOCK1, &wd2_base->wspr); + myudelay(100); + writel(WD_UNLOCK2, &wd2_base->wspr); + myudelay(100); + writel(WD_UNLOCK1, &wd2_base->wspr); + myudelay(100); + writel(WD_UNLOCK2, &wd2_base->wspr); + + myudelay(10000); // so that we can see if the counter counts... + + printf("idlest_wkup = %08x\n", readl(&prcm_base->idlest_wkup)); + printf("widr = %08x\n", readl(&wd2_base->widr)); + printf("wd_sysconfig = %08x\n", readl(&wd2_base->wd_sysconfig)); + printf("ws_sysstatus = %08x\n", readl(&wd2_base->ws_sysstatus)); + printf("wisr = %08x\n", readl(&wd2_base->wisr)); + printf("wier = %08x\n", readl(&wd2_base->wier)); + printf("wclr = %08x\n", readl(&wd2_base->wclr)); + printf("wcrr = %08x\n", readl(&wd2_base->wcrr)); + printf("wldr = %08x\n", readl(&wd2_base->wldr)); + printf("wtgr = %08x\n", readl(&wd2_base->wtgr)); + printf("wwps = %08x\n", readl(&wd2_base->wwps)); + printf("wspr = %08x\n", readl(&wd2_base->wspr)); + + writel(readl(&wd2_base->wtgr) + 1, &wd2_base->wtgr); + + printf("idlest_wkup = %08x\n", readl(&prcm_base->idlest_wkup)); + printf("widr = %08x\n", readl(&wd2_base->widr)); + printf("wd_sysconfig = %08x\n", readl(&wd2_base->wd_sysconfig)); + printf("ws_sysstatus = %08x\n", readl(&wd2_base->ws_sysstatus)); + printf("wisr = %08x\n", readl(&wd2_base->wisr)); + printf("wier = %08x\n", readl(&wd2_base->wier)); + printf("wclr = %08x\n", readl(&wd2_base->wclr)); + printf("wcrr = %08x\n", readl(&wd2_base->wcrr)); + printf("wldr = %08x\n", readl(&wd2_base->wldr)); + printf("wtgr = %08x\n", readl(&wd2_base->wtgr)); + printf("wwps = %08x\n", readl(&wd2_base->wwps)); + printf("wspr = %08x\n", readl(&wd2_base->wspr)); + + } +#endif + return 0; } diff --git a/board/goldelico/gta04/gta04.h b/board/goldelico/gta04/gta04.h index 40f7da2..92b7758 100644 --- a/board/goldelico/gta04/gta04.h +++ b/board/goldelico/gta04/gta04.h @@ -279,8 +279,8 @@ MUX_VAL(CP(MCSPI2_SIMO), (IEN | PTU | DIS | M3)) /*HSUSB2_DATA4*/\ MUX_VAL(CP(MCSPI2_SOMI), (IEN | PTU | DIS | M3)) /*HSUSB2_DATA5*/\ MUX_VAL(CP(MCSPI2_CS0), (IEN | PTU | DIS | M3)) /*HSUSB2_DATA6*/\ MUX_VAL(CP(MCSPI2_CS1), (IEN | PTU | DIS | M3)) /*HSUSB2_DATA3*/\ -MUX_VAL(CP(ETK_D10_ES2), (IDIS | PTU | DIS | M3)) /*HSUSB2_CLK*/\ -MUX_VAL(CP(ETK_D11_ES2), (IDIS | PTU | DIS | M3)) /*HSUSB2_STP*/\ +MUX_VAL(CP(ETK_D10_ES2), (IEN | PTU | DIS | M3)) /*HSUSB2_CLK*/\ +MUX_VAL(CP(ETK_D11_ES2), (IDIS | PTU | EN | M3)) /*HSUSB2_STP*/\ MUX_VAL(CP(ETK_D12_ES2), (IEN | PTU | DIS | M3)) /*HSUSB2_DIR*/\ MUX_VAL(CP(ETK_D13_ES2), (IEN | PTU | DIS | M3)) /*HSUSB2_NXT*/\ MUX_VAL(CP(ETK_D14_ES2), (IEN | PTU | DIS | M3)) /*HSUSB2_DATA0*/\ @@ -302,10 +302,10 @@ MUX_VAL(CP(SYS_CLKOUT2), (IEN | PTU | EN | M4)) /*GPIO_186*/\ /* should be removed or initialized correctly from the beginning since it may result in a glitch on these pins that we use as GPIOs */\ MUX_VAL(CP(ETK_CLK_ES2), (IDIS | PTU | EN | M3)) /*HSUSB1_STP*/\ MUX_VAL(CP(ETK_CTL_ES2), (IDIS | PTU | DIS | M3)) /*HSUSB1_CLK*/\ -MUX_VAL(CP(ETK_D0_ES2), (IEN | PTU | DIS | M3)) /*HSUSB1_DATA0*/\ -MUX_VAL(CP(ETK_D1_ES2), (IEN | PTU | DIS | M3)) /*HSUSB1_DATA1*/\ -MUX_VAL(CP(ETK_D2_ES2), (IEN | PTU | DIS | M3)) /*HSUSB1_DATA2*/\ -MUX_VAL(CP(ETK_D3_ES2), (IEN | PTU | DIS | M3)) /*HSUSB1_DATA7*/\ +MUX_VAL(CP(ETK_D0_ES2), (IEN | PTU | DIS | M1)) /*MCSPI3_SIMO*/\ +MUX_VAL(CP(ETK_D1_ES2), (IEN | PTU | DIS | M1)) /*MCSPI3_SOMI*/\ +MUX_VAL(CP(ETK_D2_ES2), (IEN | PTU | DIS | M1)) /*MCSPI3_CS0*/\ +MUX_VAL(CP(ETK_D3_ES2), (IEN | PTU | DIS | M1)) /*MCSPI3_CLK*/\ MUX_VAL(CP(ETK_D4_ES2), (IEN | PTU | DIS | M3)) /*HSUSB1_DATA4*/\ MUX_VAL(CP(ETK_D5_ES2), (IEN | PTU | DIS | M3)) /*HSUSB1_DATA5*/\ MUX_VAL(CP(ETK_D6_ES2), (IEN | PTU | DIS | M3)) /*HSUSB1_DATA6*/\ @@ -461,7 +461,7 @@ MUX_VAL(CP(MCBSP1_FSX), (IDIS | PTU | DIS | M1)) /*MCSPI4_CS0*/ /* * IEN - Input Enable - * IDIS - Input Disable (i.e. output enable) + * IDIS - Input Disable (i.e. output only; IEN means bidirectional mode) * PTD - Pull type Down * PTU - Pull type Up * DIS - Pull type selection is inactive @@ -470,7 +470,7 @@ MUX_VAL(CP(MCBSP1_FSX), (IDIS | PTU | DIS | M1)) /*MCSPI4_CS0*/ * M4 - Mode 4 (GPIO) */ -// FIXME: GTA04A3ff has some improved mux assignments +#if defined(CONFIG_I2C_OMAP_GTA04A2) #define MUX_BEAGLE_GTA04() \ MUX_VAL(CP(ETK_CLK_ES2), (IDIS | PTU | EN | M4)) /*GPIO_12 - Display serial clock*/\ @@ -503,15 +503,99 @@ MUX_VAL(CP(MCBSP1_CLKR), (IDIS | PTD | DIS | M0)) /*GPIO_156 - FM TRX*/\ MUX_VAL(CP(MCBSP1_FSR), (IEN | PTU | EN | M0)) /*GPIO_157 - */\ MUX_VAL(CP(MCBSP1_DX), (IDIS | PTD | EN | M0)) /*GPIO_158 - */\ MUX_VAL(CP(MCBSP1_DR), (IEN | PTU | DIS | M0)) /*GPIO_159 - */\ +MUX_VAL(CP(MCBSP_CLKS), (IEN | PTU | EN | M4)) /*GPIO_160 - PENIRQ*/\ MUX_VAL(CP(MCBSP1_FSX), (IDIS | PTU | EN | M0)) /*GPIO_161 - */\ MUX_VAL(CP(MCBSP1_CLKX), (IDIS | PTD | EN | M0)) /*GPIO_162 - */\ -MUX_VAL(CP(MCBSP_CLKS), (IEN | PTU | DIS | M4)) /*GPIO_160 - PENIRQ*/\ +MUX_VAL(CP(MCBSP4_CLKX), (IEN | PTD | DIS | M0)) /*MCBSP4_CLKX*/\ +MUX_VAL(CP(MCBSP4_DR), (IEN | PTD | DIS | M0)) /*MCBSP4_DR*/\ +MUX_VAL(CP(MCBSP4_DX), (IEN | PTD | DIS | M0)) /*MCBSP4_DX*/\ +MUX_VAL(CP(MCBSP4_FSX), (IEN | PTD | DIS | M0)) /*MCBSP4_FSX*/\ MUX_VAL(CP(MCSPI1_CLK), (IEN | PTU | EN | M4)) /*GPIO_171 - Version sense*/\ MUX_VAL(CP(MCSPI1_SIMO), (IEN | PTU | EN | M4)) /*GPIO_172 - Version sense*/\ MUX_VAL(CP(MCSPI1_SOMI), (IEN | PTU | EN | M4)) /*GPIO_173 - Version sense*/\ MUX_VAL(CP(MCSPI1_CS0), (IEN | PTD | EN | M4)) /*GPIO_174 - USB-PHY-RESET*/\ -MUX_VAL(CP(MCSPI1_CS1), (IEN | PTD | EN | M4)) /*GPIO_175/MMC3CMD - WAKE_WWAN */\ -MUX_VAL(CP(MCSPI1_CS2), (IEN | PTD | EN | M4)) /*GPIO_176/MMC3CLK - 3G_WOE */\ +MUX_VAL(CP(MCSPI1_CS1), (IEN | PTU | DIS | M4)) /*GPIO_175/MMC3CMD - WAKE_WWAN */\ +MUX_VAL(CP(MCSPI1_CS2), (IEN | PTD | DIS | M4)) /*GPIO_176/MMC3CLK - 3G_WOE */\ + +#else // GTA04A3ff has some improved mux assignments + +#define MUX_BEAGLE_GTA04() \ +/*GPIO10 - Keyboard Controller INT - n/a*/\ +MUX_VAL(CP(ETK_CLK_ES2), (IDIS | PTU | EN | M4)) /*GPIO_12 - Display serial clock*/\ +MUX_VAL(CP(ETK_CTL_ES2), (IEN | PTU | EN | M4)) /*GPIO_13 - RS232 enable*/\ +MUX_VAL(CP(ETK_D4_ES2), (IEN | PTU | DIS | M4)) /*GPIO_18 - Display DIN*/\ +MUX_VAL(CP(ETK_D5_ES2), (IDIS | PTU | EN | M4)) /*GPIO_19 - Display chip select*/\ +MUX_VAL(CP(ETK_D6_ES2), (IDIS | PTU | EN | M4)) /*GPIO_20 - Display DOUT*/\ +MUX_VAL(CP(ETK_D7_ES2), (IEN | PTU | EN | M4)) /*GPIO_21 - RS232 EXT line*/\ +MUX_VAL(CP(ETK_D8_ES2), (IEN | PTU | EN | M4)) /*GPIO_22 - MSECURE*/\ +MUX_VAL(CP(ETK_D9_ES2), (IEN | PTD | EN | M4)) /*GPIO_23 - Video Out Enable*/\ +MUX_VAL(CP(GPMC_NCS3), (IEN | PTD | DIS | M4)) /*GPIO_54 - PoP Temp INT*/\ +MUX_VAL(CP(GPMC_NCS4), (IEN | PTU | EN | M4)) /*GPIO_55 - AUX Out enable*/\ +MUX_VAL(CP(GPMC_NCS5), (IEN | PTD | DIS | M4)) /*GPIO_56 - Gyro INT*/\ +MUX_VAL(CP(GPMC_NCS6), (IEN | PTU | EN | M4)) /*GPIO_57(GPT_11) - Backlight enable*/\ +MUX_VAL(CP(CSI2_DX0), (IEN | PTU | EN | M4)) /*GPIO_112 - Compass DRDY*/\ +MUX_VAL(CP(CSI2_DY0), (IEN | PTU | DIS | M4)) /*GPIO_113 - Barometer EOC*/\ +MUX_VAL(CP(CSI2_DX1), (IEN | PTU | DIS | M4)) /*GPIO_114 - Accel1 INT*/\ +MUX_VAL(CP(CSI2_DY1), (IEN | PTU | DIS | M4)) /*GPIO_115 - Accel2 INT*/\ +MUX_VAL(CP(MMC2_CLK), (IEN | PTU | EN | M0)) /*GPIO_130 -> MMC2_CLK*/\ +MUX_VAL(CP(MMC2_CMD), (IEN | PTU | EN | M0)) /*GPIO_131 -> MMC2_CMD*/\ +MUX_VAL(CP(MMC2_DAT0), (IEN | PTU | EN | M0)) /*GPIO_132 -> MMC2_DAT0*/\ +MUX_VAL(CP(MMC2_DAT1), (IEN | PTU | EN | M0)) /*GPIO_133 -> MMC2_DAT1*/\ +MUX_VAL(CP(MMC2_DAT2), (IEN | PTU | EN | M0)) /*GPIO_134 -> MMC2_DAT2*/\ +MUX_VAL(CP(MMC2_DAT3), (IEN | PTU | EN | M0)) /*GPIO_135 -> MMC2_DAT3*/\ +MUX_VAL(CP(MMC2_DAT4), (IEN | PTU | EN | M1)) /*GPIO_136 -> MMC2_DIR_DAT0 */\ +MUX_VAL(CP(MMC2_DAT5), (IEN | PTU | EN | M1)) /*GPIO_137 -> MMC2_DIR_DAT1 */\ +MUX_VAL(CP(MMC2_DAT6), (IEN | PTU | EN | M1)) /*GPIO_138 -> MMC2_DIR_CMD */\ +MUX_VAL(CP(MMC2_DAT7), (IEN | PTU | EN | M1)) /*GPIO_139 -> MMC2_DIR_CLKIN */\ +MUX_VAL(CP(UART2_CTS), (IEN | PTU | DIS | M4)) /*GPIO_144 - ext Ant */\ +MUX_VAL(CP(UART2_RTS), (IEN | PTD | DIS | M4)) /*GPIO_145 - GPS ON(0)/OFF(1)*/\ +MUX_VAL(CP(UART2_TX), (IDIS | PTU | DIS | M0)) /*GPIO_146 -> GPS_TX */\ +MUX_VAL(CP(UART2_RX), (IEN | PTU | DIS | M0)) /*GPIO_147 -> GPS_RX */\ +MUX_VAL(CP(UART1_TX), (IDIS | PTD | DIS | M0)) /*UART1_TX -> Bluetooth HCI */\ +MUX_VAL(CP(UART1_RTS), (IDIS | PTD | DIS | M0)) /*UART1_RTS -> Bluetooth HCI */ \ +MUX_VAL(CP(UART1_CTS), (IEN | PTD | DIS | M0)) /*UART1_CTS -> Bluetooth HCI */ \ +MUX_VAL(CP(UART1_RX), (IEN | PTD | DIS | M0)) /*UART1_RX -> Bluetooth HCI */\ +MUX_VAL(CP(MCBSP3_DX), (IDIS | PTD | DIS | M0)) /*McBSP3 -> Bluetooth PCM */\ +MUX_VAL(CP(MCBSP3_DR), (IEN | PTD | DIS | M0)) /**/\ +MUX_VAL(CP(MCBSP3_CLKX), (IDIS | PTD | DIS | M0)) /**/\ +MUX_VAL(CP(MCBSP3_FSX), (IEN | PTD | DIS | M0)) /**/\ +MUX_VAL(CP(MCBSP1_CLKR), (IDIS | PTD | DIS | M0)) /*GPIO_156 -> FM TRX*/\ +MUX_VAL(CP(MCBSP1_FSR), (IEN | PTU | EN | M0)) /*GPIO_157 -> MCBSP1_FSR */\ +MUX_VAL(CP(MCBSP1_DX), (IDIS | PTD | EN | M0)) /*GPIO_158 -> MCBSP1_DX */\ +MUX_VAL(CP(MCBSP1_DR), (IEN | PTU | DIS | M0)) /*GPIO_159 -> MCBSP1_DR */\ +MUX_VAL(CP(MCBSP_CLKS), (IEN | PTU | DIS | M4)) /*GPIO_160 - PENIRQ*/\ +MUX_VAL(CP(MCBSP1_FSX), (IDIS | PTU | EN | M0)) /*GPIO_161 -> MCBSP1_FSX */\ +MUX_VAL(CP(MCBSP1_CLKX), (IDIS | PTD | EN | M0)) /*GPIO_162 -> MCBSP1_CLKX */\ +MUX_VAL(CP(MCBSP4_CLKX), (IEN | PTD | DIS | M0)) /*MCBSP4_CLKX*/\ +MUX_VAL(CP(MCBSP4_DR), (IEN | PTD | DIS | M0)) /*MCBSP4_DR*/\ +MUX_VAL(CP(MCBSP4_DX), (IEN | PTD | DIS | M0)) /*MCBSP4_DX*/\ +MUX_VAL(CP(MCBSP4_FSX), (IEN | PTD | DIS | M0)) /*MCBSP4_FSX*/\ +MUX_VAL(CP(HDQ_SIO), (IEN | PTU | EN | M0)) /*GPIO_170 -> HDQ*/\ +MUX_VAL(CP(MCSPI1_CLK), (IEN | PTU | EN | M4)) /*GPIO_171 - Version sense*/\ +MUX_VAL(CP(MCSPI1_SIMO), (IEN | PTU | EN | M4)) /*GPIO_172 - Version sense*/\ +MUX_VAL(CP(MCSPI1_SOMI), (IEN | PTU | EN | M4)) /*GPIO_173 - Version sense*/\ +MUX_VAL(CP(MCSPI1_CS0), (IEN | PTU | EN | M4)) /*GPIO_174 - USB-PHY-RESET*/\ +MUX_VAL(CP(MCSPI1_CS1), (IEN | PTU | DIS | M4)) /*GPIO_175/MMC3CMD - WAKE_WWAN */\ +MUX_VAL(CP(MCSPI1_CS2), (IEN | PTD | DIS | M4)) /*GPIO_176/MMC3CLK - 3G_WOE */\ +/*GPIO186 - spare (reserved for WLAN/BT power control)*/\ + +#if 0 // test HSUSB2 wiring +/* USB EHCI (port 2) */\ +MUX_VAL(CP(MCSPI1_CS3), (IEN | PTU | EN | M4)) /*GPIO177 - HSUSB2_DATA2*/\ +MUX_VAL(CP(MCSPI2_CLK), (IEN | PTU | EN | M4)) /*GPIO178 - HSUSB2_DATA7*/\ +MUX_VAL(CP(MCSPI2_SIMO), (IEN | PTU | EN | M4)) /*GPIO179 - HSUSB2_DATA4*/\ +MUX_VAL(CP(MCSPI2_SOMI), (IEN | PTU | EN | M4)) /*GPIO180 - HSUSB2_DATA5*/\ +MUX_VAL(CP(MCSPI2_CS0), (IEN | PTU | EN | M4)) /*GPIO181 - HSUSB2_DATA6*/\ +MUX_VAL(CP(MCSPI2_CS1), (IEN | PTU | EN | M4)) /*GPIO182 - HSUSB2_DATA3*/\ +MUX_VAL(CP(ETK_D10_ES2), (IEN | PTU | EN | M4)) /*GPIO24 - HSUSB2_CLK*/\ +MUX_VAL(CP(ETK_D11_ES2), (IEN | PTU | EN | M4)) /*GPIO25 - HSUSB2_STP*/\ +MUX_VAL(CP(ETK_D12_ES2), (IEN | PTU | EN | M4)) /*GPIO26 - HSUSB2_DIR*/\ +MUX_VAL(CP(ETK_D13_ES2), (IEN | PTU | EN | M4)) /*GPIO27 - HSUSB2_NXT*/\ +MUX_VAL(CP(ETK_D14_ES2), (IEN | PTU | EN | M4)) /*GPIO28 - HSUSB2_DATA0*/\ +MUX_VAL(CP(ETK_D15_ES2), (IEN | PTU | EN | M4)) /*GPIO29 - HSUSB2_DATA1*/\ +#endif + +#endif #endif /* _GTA04_H_ */ diff --git a/board/goldelico/gta04/shutdown.c b/board/goldelico/gta04/shutdown.c index 8e474f4..1ebe661 100644 --- a/board/goldelico/gta04/shutdown.c +++ b/board/goldelico/gta04/shutdown.c @@ -55,3 +55,9 @@ void shutdown(void) // CHECKME: do we have to write PM_MASTER_P2 and _P3? } +void suspend(void) +{ + // enable the AUX button interrupt for Wakeup + // suspend (sleep) the CPU + // the TPS should remain powered on +} diff --git a/board/goldelico/gta04/shutdown.h b/board/goldelico/gta04/shutdown.h index a14695c..b1638ea 100644 --- a/board/goldelico/gta04/shutdown.h +++ b/board/goldelico/gta04/shutdown.h @@ -25,5 +25,6 @@ #define _SHUTDOWN_H void shutdown(void); +void suspend(void); #endif diff --git a/board/goldelico/gta04/systest.c b/board/goldelico/gta04/systest.c index a5969f0..6b04c73 100644 --- a/board/goldelico/gta04/systest.c +++ b/board/goldelico/gta04/systest.c @@ -30,13 +30,121 @@ #include <asm/mach-types.h> #include <i2c.h> #include <twl4030.h> +#include <ns16550.h> #include "systest.h" #include "TD028TTEC1.h" +#include "ulpi-phy.h" +#include "status.h" +#include "tsc2007.h" +#include "twl4030-additions.h" #define TWL4030_I2C_BUS (1-1) +int bt_hci(int msg) +{ +#define MODE_X_DIV 16 + int baudrate=9600; + int divisor=(CONFIG_SYS_NS16550_CLK + (baudrate * (MODE_X_DIV / 2))) / (MODE_X_DIV * baudrate); + char send[]={ + 0x01, // command +#define OGF 0x01 +#define OCF 0x0002 // HCI_Inquiry_Cancel +#define OP ((OGF<<10)+OCF) + OP&0xff, OP>>8 + }; + NS16550_reinit((NS16550_t)CONFIG_SYS_NS16550_COM1, divisor); // initialize UART + int i; + int bytes=0; + long timer=(1*1000*1000)/40; // 1 second total timeout +#if 1 // GPIO test for UART lines + if(msg) + { // print states of UART lines + MUX_VAL(CP(UART1_TX), (IEN | PTU | EN | M4)) /*UART1_TX -> Bluetooth HCI */\ + MUX_VAL(CP(UART1_RTS), (IEN | PTU | EN | M4)) /*UART1_RTS -> Bluetooth HCI */ \ + MUX_VAL(CP(UART1_CTS), (IEN | PTU | EN | M4)) /*UART1_CTS -> Bluetooth HCI */ \ + MUX_VAL(CP(UART1_RX), (IEN | PTU | EN | M4)) /*UART1_RX -> Bluetooth HCI */ + + MUX_VAL(CP(UART2_CTS), (IEN | PTU | DIS | M4)) /*GPIO_144 - ext Ant */\ + MUX_VAL(CP(UART2_RTS), (IEN | PTD | DIS | M4)) /*GPIO_145 - GPS ON(0)/OFF(1)*/\ + MUX_VAL(CP(UART2_TX), (IEN | PTU | DIS | M4)) /*GPIO_146 - GPS_TX */\ + MUX_VAL(CP(UART2_RX), (IEN | PTU | DIS | M4)) /*GPIO_147 - GPS_RX */\ + + udelay(100); + + omap_request_gpio(148); + omap_request_gpio(149); + omap_request_gpio(150); + omap_request_gpio(151); + omap_set_gpio_direction(148, 1); // 1=input + omap_set_gpio_direction(149, 1); // 1=input + omap_set_gpio_direction(150, 1); // 1=input + omap_set_gpio_direction(151, 1); // 1=input + printf("UART1 RTS: %d\n", omap_get_gpio_datain(149)); + printf("UART1 CTS: %d\n", omap_get_gpio_datain(150)); + printf("UART1 TX: %d\n", omap_get_gpio_datain(148)); + printf("UART1 RX: %d\n", omap_get_gpio_datain(151)); + + omap_request_gpio(144); + omap_request_gpio(145); + omap_request_gpio(146); + omap_request_gpio(147); + omap_set_gpio_direction(144, 1); // 1=input + omap_set_gpio_direction(145, 1); // 1=input + omap_set_gpio_direction(146, 1); // 1=input + omap_set_gpio_direction(147, 1); // 1=input + printf("UART2 RTS: %d\n", omap_get_gpio_datain(145)); + printf("UART2 CTS: %d\n", omap_get_gpio_datain(144)); + printf("UART2 TX: %d\n", omap_get_gpio_datain(146)); + printf("UART2 RX: %d\n", omap_get_gpio_datain(147)); + + MUX_VAL(CP(UART1_TX), (IDIS | PTD | DIS | M0)) /*UART1_TX -> Bluetooth HCI */\ + MUX_VAL(CP(UART1_RTS), (IDIS | PTD | DIS | M0)) /*UART1_RTS -> Bluetooth HCI */ \ + MUX_VAL(CP(UART1_CTS), (IEN | PTD | DIS | M0)) /*UART1_CTS -> Bluetooth HCI */ \ + MUX_VAL(CP(UART1_RX), (IEN | PTD | DIS | M0)) /*UART1_RX -> Bluetooth HCI */\ + + MUX_VAL(CP(UART2_CTS), (IEN | PTU | DIS | M4)) /*GPIO_144 - ext Ant */\ + MUX_VAL(CP(UART2_RTS), (IDIS | PTD | DIS | M4)) /*GPIO_145 - GPS ON(0)/OFF(1)*/\ + MUX_VAL(CP(UART2_TX), (IDIS | PTU | DIS | M0)) /*GPIO_146 - GPS_TX */\ + MUX_VAL(CP(UART2_RX), (IEN | PTU | DIS | M0)) /*GPIO_147 - GPS_RX */\ + udelay(100); + } +#endif + if(msg) + printf("HCI send:"); + for (i=0; i<sizeof(send); i++) + { // send bytes on HCI port + if(msg) + printf(" %02x", send[i]); + NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, send[i]); + } + if(msg) + printf("\n"); + if(msg) + printf("HCI receive:"); + while (timer-- > 0) + { // + if(NS16550_tstc((NS16550_t)CONFIG_SYS_NS16550_COM1)) + { // byte received + int c=NS16550_getc((NS16550_t)CONFIG_SYS_NS16550_COM1); + if(msg) + printf(" %02x", c); // from GPS to console + bytes++; // one more received + } + udelay(40); // 115200 bit/s is approx. 86 us per byte + } + if(bytes == 0) + { + if(msg) + printf(" timed out\n"); + return 0; + } + if(msg) + printf("\n"); + return 1; +} + int systest(void) -{ // do mixture of gps_echo, tsc_loop, status mirror status blink +{ int r; i2c_set_bus_num(TWL4030_I2C_BUS); // I2C1 printf("TPS65950: %s\n", !(r=i2c_probe(TWL4030_CHIP_USB))?"found":"-"); // responds on 4 addresses 0x48..0x4b @@ -45,7 +153,7 @@ int systest(void) u8 val; u8 val2; twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER, &val, TWL4030_PM_MASTER_STS_HW_CONDITIONS); - printf(" STS_HW_CND: %02x", val); // decode bits + printf(" STS_HW_CON: %02x", val); // decode bits if(val & 0x80) printf(" VBUS"); if(val & 0x08) printf(" NRESWARM"); if(val & 0x04) printf(" USB"); @@ -53,7 +161,7 @@ int systest(void) if(val & 0x01) printf(" PWRON"); printf("\n"); twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER, &val, 0x2e); - printf(" PWR_ISR: %02x", val); + printf(" PWR_ISR1: %02x", val); // decode bits printf("\n"); twl4030_i2c_read_u8(TWL4030_CHIP_PM_RECEIVER, &val, TWL4030_PM_MASTER_SC_DETECT1); @@ -105,19 +213,22 @@ int systest(void) printf("DISPLAY: ok\n"); else printf("DISPLAY: failed\n"); - +#if HAVE_ULPI_TEST + printf("PHY-WWAN: %s\n", (ulpi_direct_access(1, 1, 0, 0) == 0x04)?"found":"-"); // read reg 1 (vendor id) of HSUSB2 +#endif // LEDs - // GPS UART + // GPS/UART // RAM-Test // NAND-Test // Buttons // Power - // Display communication + // real Display communication // PCM // OTG USB // Charger // internal USB // UMTS Module + printf("BT HCI: %s\n", bt_hci(0)?"found":"-"); return (0); } @@ -160,11 +271,10 @@ static ushort tone[] = { 0xDA5B, 0xDA5A, 0xE67B, 0xE67B, 0xF31B, 0xF3AC, 0x0000, 0x0000 }; -int audiotest(int channel) +int audiotest_init(int channel) { unsigned char byte; - int count = 0; printf("Test Audio Tone on Speaker\n"); printf("Initializing over I2C1"); @@ -361,7 +471,13 @@ int audiotest(int channel) *((uint *) 0x49022010) = 0x00000201; // MCBSPLP_SPCR2_REG / FREE, XRST *((uint *) 0x49022008) = 0x000056f3; // MCBSPLP_DXR_REG - write first byte printf(" ... complete\n"); + return 0; +} + +int audiotest_send(void) +{ + int count = 0; printf("Sending data"); for (count = 0; count < 50; count++) { @@ -375,3 +491,110 @@ int audiotest(int channel) return 0; } + +int audiotest(int channel) +{ + return audiotest_init(channel) || audiotest_send(); +} + +#define RS232_ENABLE 13 +#define RS232_RX 165 // UART3 +#define RS232_TX 166 // UART3 + +int irdatest(void) +{ +#ifdef CONFIG_OMAP3_GTA04 + printf("Stop through touch screen or AUX button - RS232 is disabled\n"); + udelay(50000); // wait until RS232 is finished + // switch RS232_ENABLE to IrDA through Pull-Down and RXTX to GPIO mode + MUX_VAL(CP(UART3_RX_IRRX), (IEN | PTD | DIS | M4)); /*UART3_RX_IRRX*/ + MUX_VAL(CP(UART3_TX_IRTX), (IDIS | PTD | DIS | M4)); /*UART3_TX_IRTX*/ + omap_request_gpio(RS232_RX); + omap_set_gpio_direction(RS232_RX, 1); // 1=input + omap_request_gpio(RS232_TX); + omap_set_gpio_direction(RS232_TX, 0); + omap_set_gpio_dataout(RS232_TX, 0); // set TX=low to select SIR mode + udelay(10); + MUX_VAL(CP(ETK_CTL_ES2), (IEN | PTD | EN | M4)); /*GPIO_13 - RS232 enable*/ + udelay(1000); + while(!pendown(NULL, NULL) && (status_get_buttons()&0x09) == 0) + { + // make IrDA blink + omap_set_gpio_dataout(RS232_TX, 1); + udelay(150); + omap_set_gpio_dataout(RS232_TX, 0); + udelay(150); + if(!omap_get_gpio_datain(RS232_RX)) // RX is active low + status_set_status(0x018); // echo IrDA sensor status to red power button led + else + status_set_status(0x00); + } + // switch back to UART mode + MUX_VAL(CP(UART3_RX_IRRX), (IEN | PTD | DIS | M0)); /*UART3_RX_IRRX*/ + MUX_VAL(CP(UART3_TX_IRTX), (IDIS | PTD | DIS | M0)); /*UART3_TX_IRTX*/ + MUX_VAL(CP(ETK_CTL_ES2), (IEN | PTU | EN | M4)); /*GPIO_13 - RS232 enable*/ + udelay(1000); + printf("done.\n"); + return 0; +#else + printf("n/a\n"); + return 1; +#endif +} + +#ifdef CONFIG_OMAP3_GTA04 +int wlabbtpower(void) +{ /* Bluetooth VAUX4 = 3.3V -- CHECKME: 3.3 V is not officially supported by TPS! We use 0x09 = 2.8V here*/ +#define TCA6507_BUS (2-1) // I2C2 +#define TCA6507_ADDRESS 0x45 + + /* register numbers */ +#define TCA6507_SELECT0 0 +#define TCA6507_SELECT1 1 +#define TCA6507_SELECT2 2 + + printf("activate WiFi/BT reset\n"); + i2c_set_bus_num(TCA6507_BUS); // write I2C2 + i2c_reg_write(TCA6507_ADDRESS, TCA6507_SELECT0, 0); + i2c_reg_write(TCA6507_ADDRESS, TCA6507_SELECT1, 0); + i2c_reg_write(TCA6507_ADDRESS, TCA6507_SELECT2, 0x40); // pull down reset for WLAN&BT chip + i2c_set_bus_num(0); // write I2C1 + printf("power on VAUX4\n"); + twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX4_DEDICATED, + /* 2.8V: */ 0x09 /* 3.15V: 0x0c */, + TWL4030_PM_RECEIVER_VAUX4_DEV_GRP, + TWL4030_PM_RECEIVER_DEV_GRP_P1); + udelay(20*1000); // wait a little until power stabilizes + printf("release WiFi/BT reset\n"); + i2c_set_bus_num(TCA6507_BUS); // write I2C2 + i2c_reg_write(TCA6507_ADDRESS, TCA6507_SELECT0, 0); + i2c_reg_write(TCA6507_ADDRESS, TCA6507_SELECT1, 0); + i2c_reg_write(TCA6507_ADDRESS, TCA6507_SELECT2, 0); // release reset for WLAN&BT chip + i2c_set_bus_num(0); // write I2C1 + return 0; +} +#endif + +int wlanbttest(int test) +{ /* Bluetooth VAUX4 = 3.3V -- CHECKME: 3.3 V is not officially supported! We use 0x09 = 2.8V here*/ +#ifdef CONFIG_OMAP3_GTA04 + wlabbtpower(); + if(test) + { + // now, we should be able to test the UART for the BT part... + return !bt_hci(1); + } + return 0; +#else + printf("n/a\n"); + return 1; +#endif +} + +int OTGchargepump(int enable) +{ + if(enable) + twl4030_i2c_write_u8(TWL4030_CHIP_USB, 0x20, TWL4030_USB_OTG_CTRL_SET); + else + twl4030_i2c_write_u8(TWL4030_CHIP_USB, 0x20, TWL4030_USB_OTG_CTRL_CLR); +} diff --git a/board/goldelico/gta04/systest.h b/board/goldelico/gta04/systest.h index e682c5e..5c7a8da 100644 --- a/board/goldelico/gta04/systest.h +++ b/board/goldelico/gta04/systest.h @@ -25,6 +25,11 @@ #define _SYSTEST_H int systest(void); +int audiotest_init(int channel); +int audiotest_send(void); int audiotest(int channel); +int irdatest(void); +int wlanbttest(int serial); +int OTGchargepump(int enable); #endif diff --git a/board/goldelico/gta04/tsc2007.c b/board/goldelico/gta04/tsc2007.c index 430ecbc..b2a0cfa 100644 --- a/board/goldelico/gta04/tsc2007.c +++ b/board/goldelico/gta04/tsc2007.c @@ -155,3 +155,27 @@ void print_adc(void) read_adc(7)); } +int pendown(int *x, int *y) +{ +#if 1 + int z; + int xx; + int yy; + xx=read_adc(0); + yy=read_adc(1); + z=read_adc(2); // read Z + if(z < 0) + return 0; // read error +#if 0 + printf("z=%04d x:%04d y:%04d\n", z, xx, yy); +#endif + if(x) *x=xx; + if(y) *y=yy; + udelay(10000); // reduce I2C traffic and debounce... + return z > 200; // was pressed +#else + // must be in PENIRQ mode... + return (status_get_buttons() & (1 << 4)) == 0; +#endif +} + diff --git a/board/goldelico/gta04/tsc2007.h b/board/goldelico/gta04/tsc2007.h index fc85159..476d253 100644 --- a/board/goldelico/gta04/tsc2007.h +++ b/board/goldelico/gta04/tsc2007.h @@ -4,5 +4,6 @@ int tsc2007_init(void); int read_adc(int adcnum); void print_adc(void); +int pendown(int *x, int *y); #endif diff --git a/board/goldelico/gta04/twl4030-additions.c b/board/goldelico/gta04/twl4030-additions.c new file mode 100644 index 0000000..89d94f2 --- /dev/null +++ b/board/goldelico/gta04/twl4030-additions.c @@ -0,0 +1,509 @@ +/* + * Copyright (C) 2007-2008 Texas Instruments, Inc. + * + * (C) Copyright 2009 + * Windriver, <www.windriver.com> + * Tom Rix <Tom.Rix@windriver.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * this patch was found here: https://gforge.ti.com/gf/project/omapandroid/mailman/?action=ListThreads&mailman_id=22&_forum_action=ForumMessageBrowse&thread_id=1252 + * + */ +#include <twl4030.h> +#include "twl4030-additions.h" + +/* + * Battery + */ + +#define mdelay(n) ({ unsigned long msec = (n); while (msec--) udelay(1000); }) + +static inline int clear_n_set(u8 chip_no, u8 clear, u8 set, u8 reg) +{ + int ret; + u8 val = 0; + + /* Gets the initial register value */ + ret = twl4030_i2c_read_u8(chip_no, &val, reg); + if (ret) { + printf("a\n"); + return ret; + } + + /* Clearing all those bits to clear */ + val &= ~(clear); + + /* Setting all those bits to set */ + val |= set; + + /* Update the register */ + ret = twl4030_i2c_write_u8(chip_no, val, reg); + if (ret) { + printf("b\n"); + return ret; + } + return 0; +} + +/* + * Disable/Enable AC Charge funtionality. + */ +static int twl4030_ac_charger_enable(int enable) +{ + int ret; + + if (enable) { + /* forcing the field BCIAUTOAC (BOOT_BCI[0]) to 1 */ + ret = clear_n_set(TWL4030_CHIP_PM_MASTER, 0, + + (CONFIG_DONE | BCIAUTOWEN | BCIAUTOAC), + + REG_BOOT_BCI); + if (ret) + return ret; + } else { + /* forcing the field BCIAUTOAC (BOOT_BCI[0]) to 0 */ + ret = clear_n_set(TWL4030_CHIP_PM_MASTER, BCIAUTOAC, + + (CONFIG_DONE | BCIAUTOWEN), + + REG_BOOT_BCI); + if (ret) + return ret; + } + return 0; +} + +/* + * Disable/Enable USB Charge funtionality. + */ +static int twl4030_usb_charger_enable(int enable) +{ + u8 value; + int ret; + + if (enable) { + /* enable access to BCIIREF1 */ + ret = twl4030_i2c_write_u8(TWL4030_CHIP_MAIN_CHARGE, 0xE7, + + REG_BCIMFKEY); + if (ret) + return ret; + + /* set charging current = 852mA */ + ret = twl4030_i2c_write_u8(TWL4030_CHIP_MAIN_CHARGE, 0xFF, + + REG_BCIIREF1); + if (ret) + return ret; + + /* forcing the field BCIAUTOUSB (BOOT_BCI[1]) to 1 */ + ret = clear_n_set(TWL4030_CHIP_PM_MASTER, 0, + + (CONFIG_DONE | BCIAUTOWEN | BCIAUTOUSB), + + REG_BOOT_BCI); + if (ret) + return ret; + + /* Enabling interfacing with usb thru OCP */ + ret = clear_n_set(TWL4030_CHIP_USB, 0, PHY_DPLL_CLK, + + REG_PHY_CLK_CTRL); + if (ret) + return ret; + + value = 0; + + while (!(value & PHY_DPLL_CLK)) { + udelay(10); + ret = twl4030_i2c_read_u8(TWL4030_CHIP_USB, &value, + + REG_PHY_CLK_CTRL_STS); + if (ret) + return ret; + } + + /* OTG_EN (POWER_CTRL[5]) to 1 */ + ret = clear_n_set(TWL4030_CHIP_USB, 0, OTG_EN, + + REG_POWER_CTRL); + if (ret) + return ret; + + mdelay(50); + + /* forcing USBFASTMCHG(BCIMFSTS4[2]) to 1 */ + ret = clear_n_set(TWL4030_CHIP_MAIN_CHARGE, 0, + + USBFASTMCHG, REG_BCIMFSTS4); + if (ret) + return ret; + } else { + ret = clear_n_set(TWL4030_CHIP_PM_MASTER, BCIAUTOUSB, + + (CONFIG_DONE | BCIAUTOWEN), REG_BOOT_BCI); + if (ret) + return ret; + } + + return 0; +} + +/* + * Setup the twl4030 MADC module to measure the backup + * battery voltage. + */ +static int twl4030_madc_setup(void) +{ + int ret = 0; + + /* turning MADC clocks on */ + ret = clear_n_set(TWL4030_CHIP_INTBR, 0, + + (MADC_HFCLK_EN | DEFAULT_MADC_CLK_EN), REG_GPBR1); + if (ret) + return ret; + + /* turning adc_on */ + ret = twl4030_i2c_write_u8(TWL4030_CHIP_MADC, MADC_ON, + + REG_CTRL1); + if (ret) + return ret; + + /* setting MDC channel 9 to trigger by SW1 */ + ret = clear_n_set(TWL4030_CHIP_MADC, 0, SW1_CH9_SEL, + + REG_SW1SELECT_MSB); + + return ret; +} + +/* + * Charge backup battery through main battery + */ +static int twl4030_charge_backup_battery(void) +{ + int ret; + + ret = clear_n_set(TWL4030_CHIP_PM_RECIEVER, 0xff, + + (BBCHEN | BBSEL_3200mV | BBISEL_500uA), REG_BB_CFG); + if (ret) + return ret; + + return 0; +} + +/* + * Helper function to read a 2-byte register on BCI module + */ +static int read_bci_val(u8 reg) +{ + int ret = 0, temp = 0; + u8 val; + + /* reading MSB */ + ret = twl4030_i2c_read_u8(TWL4030_CHIP_MAIN_CHARGE, &val, reg + 1); + if (ret) + return ret; + + temp = ((int)(val & 0x03)) << 8; + + /* reading LSB */ + ret = twl4030_i2c_read_u8(TWL4030_CHIP_MAIN_CHARGE, &val, reg); + if (ret) + return ret; + + return temp + val; +} + +/* + * Triggers the sw1 request for the twl4030 module to measure the sw1 selected + * channels + */ +static int twl4030_madc_sw1_trigger(void) +{ + u8 val; + int ret; + + /* Triggering SW1 MADC convertion */ + ret = twl4030_i2c_read_u8(TWL4030_CHIP_MADC, &val, REG_CTRL_SW1); + if (ret) + return ret; + + val |= SW1_TRIGGER; + + ret = twl4030_i2c_write_u8(TWL4030_CHIP_MADC, val, REG_CTRL_SW1); + if (ret) + return ret; + + /* Waiting until the SW1 conversion ends*/ + val = BUSY; + + while (!((val & EOC_SW1) && (!(val & BUSY)))) { + ret = twl4030_i2c_read_u8(TWL4030_CHIP_MADC, &val, + + REG_CTRL_SW1); + if (ret) + return ret; + mdelay(10); + } + + return 0; +} + +/* + * Return battery voltage + */ +static int twl4030_get_battery_voltage(void) +{ + int volt; + + volt = read_bci_val(T2_BATTERY_VOLT); + return (volt * 588) / 100; +} + +/* + * Return battery temperature (uncalibrated) + * current = 10uA, full scale 1023 = 1.5V; prescaler=1 + * 10k @ 25C -> 0.1V -> 68 + * 26.6k @ 0C -> 0.26V -> 182 + */ + +#define R0C 26600 +#define R25C 10000 + +#define VSTEP ((15*10000)/1023)) +#define VAL0C (R0C/VSTEP) +#define VAL25C (R25C/VSTEP) + +static int twl4030_get_battery_temperature(void) +{ + int temperature; + + temperature = read_bci_val(T2_BATTERY_TEMP); + return ((R0C - temperature) * 25) / (R0C - R25C); // CHECKME +// return ((182 - temperature) * 25) / (182 - 68); // CHECKME +} + +/* + * Return battery current + */ +static int twl4030_get_battery_current(void) +{ + int current; + + /* from linux driver + int curr; + int ret; + u8 bcictl1; + + curr = twl4030bci_read_adc_val(TWL4030_BCIICHG); + if (curr < 0) + return curr; + + ret = twl4030_bci_read(TWL4030_BCICTL1, &bcictl1); + if (ret) + return ret; + + ret = (curr * 16618 - 850 * 10000) / 10; + if (bcictl1 & TWL4030_CGAIN) + ret *= 2; + + return ret; +*/ + + current = read_bci_val(T2_BATTERY_CUR); + return ((current - 512) * 1) / 1; // FIXME +} + +/* + * Return the battery backup voltage + */ +static int twl4030_get_backup_battery_voltage(void) +{ + int ret, temp; + u8 volt; + + /* trigger MADC convertion */ + twl4030_madc_sw1_trigger(); + + ret = twl4030_i2c_read_u8(TWL4030_CHIP_MADC, &volt, REG_GPCH9 + 1); + if (ret) + return ret; + + temp = ((int) volt) << 2; + + ret = twl4030_i2c_read_u8(TWL4030_CHIP_MADC, &volt, REG_GPCH9); + if (ret) + return ret; + + temp = temp + ((int) ((volt & MADC_LSB_MASK) >> 6)); + + return (temp * 441) / 100; +} + +/* + * Return the AC power supply voltage + */ +static int twl4030_get_ac_charger_voltage(void) +{ + int volt = read_bci_val(T2_BATTERY_ACVOLT); + return (volt * 735) / 100; +} + +/* + * Return the USB power supply voltage + */ +static int twl4030_get_usb_charger_voltage(void) +{ + int volt = read_bci_val(T2_BATTERY_USBVOLT); + return (volt * 2058) / 300; +} + +/* + * Battery charging main function called from board-specific file + */ + +int twl4030_init_battery_charging(void) +{ + u8 batstsmchg, batstspchg, hwsts; + int battery_volt = 0, charger_present = 0; + int ret = 0; + +#ifdef CONFIG_3430ZOOM2 + /* For Zoom2 enable Main charge Automatic mode: + * by enabling MADC clocks + */ + + /* Enable AC charging */ + ret = clear_n_set(TWL4030_CHIP_INTBR, 0, + + (MADC_HFCLK_EN | DEFAULT_MADC_CLK_EN), REG_GPBR1); + + udelay(100); + + + ret = twl4030_i2c_write_u8(TWL4030_CHIP_MAIN_CHARGE, 0xE7, + + REG_BCIMFKEY); + /* set MAX charging current */ + ret = twl4030_i2c_write_u8(TWL4030_CHIP_MAIN_CHARGE, 0xFF, + + REG_BCIIREF1); + + /* Done for Zoom2 */ + return 0; +#endif + + /* check for battery presence */ + ret = twl4030_i2c_read_u8(TWL4030_CHIP_MAIN_CHARGE, &batstsmchg, + + REG_BCIMFSTS3); + if (ret) + return ret; + + ret = twl4030_i2c_read_u8(TWL4030_CHIP_PRECHARGE, &batstspchg, + + REG_BCIMFSTS1); + if (ret) + return ret; + + if (!((batstspchg & BATSTSPCHG) || (batstsmchg & BATSTSMCHG))) { + printf("no battery\n"); + return ret; /* no battery */ + } + + ret = twl4030_madc_setup(); + if (ret) { + printf("twl4030 madc setup error %d\n", ret); + return ret; + } + /* backup battery charges through main battery */ + ret = twl4030_charge_backup_battery(); + if (ret) { + printf("backup battery charging error\n"); + return ret; + } + + // SPLITME here - up to here it is init, all below can be a systest user command + + /* check for charger presence */ + ret = twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER, &hwsts, + + REG_STS_HW_CONDITIONS); + if (ret) + return ret; + + if (hwsts & STS_CHG) { + printf("AC charger detected\n"); + ret = twl4030_ac_charger_enable(1); + if (ret) + return ret; + charger_present = 1; + } else { + if (hwsts & STS_VBUS) { + printf("USB charger detected\n"); + charger_present = 1; + } + /* usb charging is enabled regardless of the whether the + * charger is attached, otherwise the main battery voltage + * cannot be read + */ + ret = twl4030_usb_charger_enable(1); + if (ret) + return ret; + } + battery_volt = twl4030_get_battery_voltage(); + printf("Main battery charge: %d mV\n", battery_volt); + printf("Battery temperature: %d C\n", twl4030_get_battery_temperature()); + printf("Backup battery voltage: %d mV\n", twl4030_get_backup_battery_voltage()); + printf("AC charger voltage: %d mV\n", twl4030_get_ac_charger_voltage()); + printf("USB charger voltage: %d mV\n", twl4030_get_usb_charger_voltage()); + printf("Charging current: %d mA\n", twl4030_get_battery_current()); + return ret; +} + +#if (defined(CONFIG_TWL4030_KEYPAD) && (CONFIG_TWL4030_KEYPAD)) +/* + * Keypad + */ +int twl4030_keypad_init(void) +{ + int ret = 0; + u8 ctrl; + ret = twl4030_i2c_read_u8(TWL4030_CHIP_KEYPAD, &ctrl, KEYPAD_KEYP_CTRL_REG); + if (!ret) { + ctrl |= CTRL_KBD_ON | CTRL_SOFT_NRST; + ctrl &= ~CTRL_SOFTMODEN; + ret = twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD, ctrl, KEYPAD_KEYP_CTRL_REG); + } + return ret; +} + +int twl4030_keypad_reset(void) +{ + int ret = 0; + u8 ctrl; + ret = twl4030_i2c_read_u8(TWL4030_CHIP_KEYPAD, &ctrl, KEYPAD_KEYP_CTRL_REG); + if (!ret) { + ctrl &= ~CTRL_SOFT_NRST; + ret = twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD, ctrl, KEYPAD_KEYP_CTRL_REG); + } + return ret; +} + +int twl4030_keypad_keys_pressed(unsigned char *key1, unsigned char *key2) +{ + int ret = 0; + u8 cb, c, rb, r; + for (cb = 0; cb < 8; cb++) { + c = 0xff & ~(1 << cb); + twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD, c, KEYPAD_KBC_REG); + twl4030_i2c_read_u8(TWL4030_CHIP_KEYPAD, &r, KEYPAD_KBR_REG); + for (rb = 0; rb < 8; rb++) { + if (!(r & (1 << rb))) { + if (!ret) + *key1 = cb << 3 | rb; + else if (1 == ret) + *key2 = cb << 3 | rb; + ret++; + } + } + } + return ret; +} + +#endif diff --git a/board/goldelico/gta04/twl4030-additions.h b/board/goldelico/gta04/twl4030-additions.h new file mode 100644 index 0000000..4ddd8e2 --- /dev/null +++ b/board/goldelico/gta04/twl4030-additions.h @@ -0,0 +1,203 @@ +/* + * (C) Copyright 2009 + * Windriver, <www.windriver.com> + * Tom Rix <Tom.Rix@windriver.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <i2c.h> + +/* I2C chip addresses */ + +/* USB ID */ +#define TWL4030_CHIP_USB 0x48 +/* AUD ID */ +#define TWL4030_CHIP_AUDIO_VOICE 0x49 +#define TWL4030_CHIP_GPIO 0x49 +#define TWL4030_CHIP_INTBR 0x49 +#define TWL4030_CHIP_PIH 0x49 +#define TWL4030_CHIP_TEST 0x49 +/* AUX ID */ +#define TWL4030_CHIP_KEYPAD 0x4a +#define TWL4030_CHIP_MADC 0x4a +#define TWL4030_CHIP_INTERRUPTS 0x4a +#define TWL4030_CHIP_LED 0x4a +#define TWL4030_CHIP_MAIN_CHARGE 0x4a +#define TWL4030_CHIP_PRECHARGE 0x4a +#define TWL4030_CHIP_PWM0 0x4a +#define TWL4030_CHIP_PWM1 0x4a +#define TWL4030_CHIP_PWMA 0x4a +#define TWL4030_CHIP_PWMB 0x4a +/* POWER ID */ +#define TWL4030_CHIP_BACKUP 0x4b +#define TWL4030_CHIP_INT 0x4b +#define TWL4030_CHIP_PM_MASTER 0x4b +#define TWL4030_CHIP_PM_RECIEVER 0x4b +#define TWL4030_CHIP_RTC 0x4b +#define TWL4030_CHIP_SECURED_REG 0x4b + +/* Register base addresses */ + +/* USB ID */ +#define TWL4030_BASEADD_USB 0x0000 +/* AUD ID */ +#define TWL4030_BASEADD_AUDIO_VOICE 0x0000 +#define TWL4030_BASEADD_GPIO 0x0098 +#define TWL4030_BASEADD_INTBR 0x0085 +#define TWL4030_BASEADD_PIH 0x0080 +#define TWL4030_BASEADD_TEST 0x004C +/* AUX ID */ +#define TWL4030_BASEADD_INTERRUPTS 0x00B9 +#define TWL4030_BASEADD_LED 0x00EE +#define TWL4030_BASEADD_MADC 0x0000 +#define TWL4030_BASEADD_MAIN_CHARGE 0x0074 +#define TWL4030_BASEADD_PRECHARGE 0x00AA +#define TWL4030_BASEADD_PWM0 0x00F8 +#define TWL4030_BASEADD_PWM1 0x00FB +#define TWL4030_BASEADD_PWMA 0x00EF +#define TWL4030_BASEADD_PWMB 0x00F1 +#define TWL4030_BASEADD_KEYPAD 0x00D2 +/* POWER ID */ +#define TWL4030_BASEADD_BACKUP 0x0014 +#define TWL4030_BASEADD_INT 0x002E +#define TWL4030_BASEADD_PM_MASTER 0x0036 +#define TWL4030_BASEADD_PM_RECIEVER 0x005B +#define TWL4030_BASEADD_RTC 0x001C +#define TWL4030_BASEADD_SECURED_REG 0x0000 + +/* Register addresses */ + +#define REG_STS_HW_CONDITIONS (TWL4030_BASEADD_PM_MASTER + 0x0F) +#define STS_VBUS 0x080 +#define STS_CHG 0x02 +#define REG_BCICTL1 (TWL4030_BASEADD_PM_MASTER + 0x023) +#define REG_BCICTL2 (TWL4030_BASEADD_PM_MASTER + 0x024) +#define CGAIN 0x020 +#define ITHEN 0x010 +#define ITHSENS 0x007 +#define REG_BCIMFTH1 (TWL4030_BASEADD_PM_MASTER + 0x016) +#define REG_BCIMFTH2 (TWL4030_BASEADD_PM_MASTER + 0x017) +#define BCIAUTOWEN (TWL4030_BASEADD_PM_MASTER + 0x020) +#define CONFIG_DONE 0x010 +#define BCIAUTOUSB 0x002 +#define BCIAUTOAC 0x001 +#define BCIMSTAT_MASK 0x03F +#define REG_BOOT_BCI (TWL4030_BASEADD_PM_MASTER + 0x007) + +#define REG_GPBR1 (TWL4030_BASEADD_INTBR + 0x0c) +#define MADC_HFCLK_EN 0x80 +#define DEFAULT_MADC_CLK_EN 0x10 + +#define REG_CTRL1 (TWL4030_BASEADD_MADC + 0x00) +#define MADC_ON 0x01 +#define REG_SW1SELECT_MSB 0x07 +#define SW1_CH9_SEL 0x02 +#define REG_CTRL_SW1 (TWL4030_BASEADD_MADC + 0x012) +#define SW1_TRIGGER 0x020 +#define EOC_SW1 0x002 +#define BUSY 0x001 +#define REG_GPCH9 (TWL4030_BASEADD_MADC + 0x049) + +#define REG_BCIMSTATEC (TWL4030_BASEADD_MAIN_CHARGE + 0x002) +#define REG_BCIMFSTS2 (TWL4030_BASEADD_MAIN_CHARGE + 0x00E) +#define REG_BCIMFSTS3 (TWL4030_BASEADD_MAIN_CHARGE + 0x00F) +#define REG_BCIMFSTS4 (TWL4030_BASEADD_MAIN_CHARGE + 0x010) +#define REG_BCIMFKEY (TWL4030_BASEADD_MAIN_CHARGE + 0x011) +#define REG_BCIIREF1 (TWL4030_BASEADD_MAIN_CHARGE + 0x027) + +#define REG_BCIMFSTS1 (TWL4030_BASEADD_PRECHARGE + 0x001) +#define USBFASTMCHG 0x004 +#define BATSTSPCHG 0x004 +#define BATSTSMCHG 0x040 +#define VBATOV4 0x020 +#define VBATOV3 0x010 +#define VBATOV2 0x008 +#define VBATOV1 0x004 +#define MADC_LSB_MASK 0xC0 +#define REG_BB_CFG (TWL4030_BASEADD_PM_RECIEVER + 0x12) +#define BBCHEN 0x10 +#define BBSEL_2500mV 0x00 +#define BBSEL_3000mV 0x04 +#define BBSEL_3100mV 0x08 +#define BBSEL_3200mV 0x0C +#define BBISEL_25uA 0x00 +#define BBISEL_150uA 0x01 +#define BBISEL_500uA 0x02 +#define BBISEL_1000uA 0x03 + +#define REG_POWER_CTRL (TWL4030_BASEADD_USB + 0x0AC) +#define REG_POWER_CTRL_SET (TWL4030_BASEADD_USB + 0x0AD) +#define REG_POWER_CTRL_CLR (TWL4030_BASEADD_USB + 0x0AE) +#define OTG_EN 0x020 +#define REG_PHY_CLK_CTRL (TWL4030_BASEADD_USB + 0x0FE) +#define REG_PHY_CLK_CTRL_STS (TWL4030_BASEADD_USB + 0x0FF) +#define PHY_DPLL_CLK 0x01 + +/* TWL4030 battery measuring parameters */ +#define T2_BATTERY_VOLT (TWL4030_BASEADD_MAIN_CHARGE + 0x04) +#define T2_BATTERY_TEMP (TWL4030_BASEADD_MAIN_CHARGE + 0x06) +#define T2_BATTERY_CUR (TWL4030_BASEADD_MAIN_CHARGE + 0x08) +#define T2_BATTERY_ACVOLT (TWL4030_BASEADD_MAIN_CHARGE + 0x0A) +#define T2_BATTERY_USBVOLT (TWL4030_BASEADD_MAIN_CHARGE + 0x0C) + +/* Keypad */ +#define KEYPAD_KEYP_CTRL_REG 0xD2 +#define KEYPAD_KEY_DEB_REG 0xD3 +#define KEYPAD_LONG_KEY_REG1 0xD4 +#define KEYPAD_LK_PTV_REG 0xD5 +#define KEYPAD_TIME_OUT_REG1 0xD6 +#define KEYPAD_TIME_OUT_REG2 0xD7 +#define KEYPAD_KBC_REG 0xD8 +#define KEYPAD_KBR_REG 0xD9 +#define KEYPAD_KEYP_SMS 0xDA +#define KEYPAD_FULL_CODE_7_0 0xDB +#define KEYPAD_FULL_CODE_15_8 0xDC +#define KEYPAD_FULL_CODE_23_16 0xDD +#define KEYPAD_FULL_CODE_31_24 0xDE +#define KEYPAD_FULL_CODE_39_32 0xDF +#define KEYPAD_FULL_CODE_47_40 0xE0 +#define KEYPAD_FULL_CODE_55_48 0xE1 +#define KEYPAD_FULL_CODE_63_56 0xE2 +#define KEYPAD_KEYP_ISR1 0xE3 +#define KEYPAD_KEYP_IMR1 0xE4 +#define KEYPAD_KEYP_ISR2 0xE5 +#define KEYPAD_KEYP_IMR2 0xE6 +#define KEYPAD_KEYP_SIR 0xE7 +#define KEYPAD_KEYP_EDR 0xE8 +#define KEYPAD_KEYP_SIH_CTRL 0xE9 + +#define CTRL_KBD_ON (1 << 6) +#define CTRL_RP_EN (1 << 5) +#define CTRL_TOLE_EN (1 << 4) +#define CTRL_TOE_EN (1 << 3) +#define CTRL_LK_EN (1 << 2) +#define CTRL_SOFTMODEN (1 << 1) +#define CTRL_SOFT_NRST (1 << 0) + +int twl4030_init_battery_charging(void); + +/* Declarations for users of the keypad, stubs for everyone else. */ +#if (defined(CONFIG_TWL4030_KEYPAD) && (CONFIG_TWL4030_KEYPAD)) +int twl4030_keypad_init(void); +int twl4030_keypad_reset(void); +int twl4030_keypad_keys_pressed(unsigned char *key1, unsigned char *key2); +#else +#define twl4030_keypad_init() 0 +#define twl4030_keypad_reset() 0 +#define twl4030_keypad_keys_pressed(a, b) 0 +#endif diff --git a/board/goldelico/gta04/ulpi-phy.c b/board/goldelico/gta04/ulpi-phy.c new file mode 100644 index 0000000..15986e5 --- /dev/null +++ b/board/goldelico/gta04/ulpi-phy.c @@ -0,0 +1,73 @@ +/* u-boot driver to access ULPI PHY registers through EHCI controller + * + * Copyright (C) 2010 by Golden Delicious Computers GmbH&Co. KG + * Author: H. Nikolaus Schaller <hns@goldelico.com> + * All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +/* FIXME + * needs to enable clock USBHOST_FCLK etc. + */ + +#include <common.h> +#include <asm/errno.h> +#include <asm/io.h> +#include <asm/arch/mux.h> +#include <asm/arch/sys_proto.h> +#include <asm/arch/gpio.h> +#include <asm/mach-types.h> +#include "ulpi-phy.h" + +#define EHCI_BASE (0x480648A4) + +#define EHCI_INSNREG05_ULPI (0xA4) +#define EHCI_INSNREG05_ULPI_CONTROL_SHIFT 31 +#define EHCI_INSNREG05_ULPI_PORTSEL_SHIFT 24 +#define EHCI_INSNREG05_ULPI_OPSEL_SHIFT 22 +#define EHCI_INSNREG05_ULPI_REGADD_SHIFT 16 +#define EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT 8 +#define EHCI_INSNREG05_ULPI_WRDATA_SHIFT 0 + +/* read/write Registers in ULPI-PHY */ + +u8 ulpi_direct_access(u8 port, u8 reg, int write, u8 value) +{ +#if 0 // FIXME: we need to have the clocks and the EHCI controller enabled! + u32 val; + u32 cmd = (((u32)value) << EHCI_INSNREG05_ULPI_WRDATA_SHIFT); /* value to write */ + if(reg > 0x3f || reg == 0x2f) + cmd |= (((u32)reg & 0xff) << EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT) | (0x2f << EHCI_INSNREG05_ULPI_REGADD_SHIFT); /* extended address */ + else + cmd |= (((u32)reg & 0x3f) << EHCI_INSNREG05_ULPI_REGADD_SHIFT); + cmd |= ((write? 0x02 : 0x03) << EHCI_INSNREG05_ULPI_OPSEL_SHIFT); + cmd |= (((u32)(port+1) & 3) << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT); /* port counts 0,1,2 */ + cmd |= (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT); /* Start */ + + writel(cmd, EHCI_BASE + EHCI_INSNREG05_ULPI); /* write EHCI_INSNREG05_ULPI */ + + // do { + udelay(100); /* wait a little */ + val = readl(EHCI_BASE + EHCI_INSNREG05_ULPI); /* read EHCI_INSNREG05_ULPI */ + /* do we need a timepout if the PHY chip is not present? */ + // } while(!(val & (1<<EHCI_INSNREG05_ULPI_CONTROL_SHIFT))); + return val; +#else + return 0; +#endif +} diff --git a/board/goldelico/gta04/ulpi-phy.h b/board/goldelico/gta04/ulpi-phy.h new file mode 100644 index 0000000..7443c37 --- /dev/null +++ b/board/goldelico/gta04/ulpi-phy.h @@ -0,0 +1,6 @@ +#ifndef _ULPI_PHY_H +#define _ULPI_PHY_H + +u8 ulpi_direct_access(u8 port, u8 reg, int write, u8 value); + +#endif diff --git a/board/goldelico/gta04b2/COM37H3M05DTC.c b/board/goldelico/gta04b2/COM37H3M05DTC.c index 526fcb1..e2b4d49 100644 --- a/board/goldelico/gta04b2/COM37H3M05DTC.c +++ b/board/goldelico/gta04b2/COM37H3M05DTC.c @@ -35,6 +35,8 @@ #ifdef CONFIG_OMAP3_BEAGLE_EXPANDER #define GPIO_STBY 158 +#else +#define GPIO_STBY 20 #endif // configure beagle board DSS for the COM37H3M05DTC diff --git a/board/goldelico/gta04b2/Makefile b/board/goldelico/gta04b2/Makefile index feb46c1..9cecfa8 100644 --- a/board/goldelico/gta04b2/Makefile +++ b/board/goldelico/gta04b2/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o -COBJS := gta04b2.o COM37H3M05DTC.o trf7960.o ../gta04/backlight.o ../gta04/status.o ../gta04/tsc2007.o ../gta04/dssfb.o ../gta04/gps.o ../gta04/shutdown.o ../gta04/systest.o ../gta04/commands.o +COBJS := gta04b2.o COM37H3M05DTC.o trf7960.o ../gta04/backlight.o ../gta04/status.o ../gta04/tsc2007.o ../gta04/dssfb.o ../gta04/gps.o ../gta04/shutdown.o ../gta04/systest.o ../gta04/commands.o ../gta04/ulpi-phy.o ../gta04/twl4030-additions.o SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h index f300ecc..438d865 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -89,7 +89,7 @@ #define CONFIG_SYS_NS16550_COM3 OMAP34XX_UART3 #define CONFIG_SERIAL3 3 /* UART3 on Beagle Rev 2 */ -#define CONFIG_SYS_NS16550_COM2 OMAP34XX_UART2 +#define CONFIG_SYS_NS16550_COM2 OMAP34XX_UART2 /* used for GPS */ /* allow to overwrite serial and ethaddr */ #define CONFIG_ENV_OVERWRITE diff --git a/include/configs/omap3_gta04.h b/include/configs/omap3_gta04.h index 10fdd2b..824c650 100644 --- a/include/configs/omap3_gta04.h +++ b/include/configs/omap3_gta04.h @@ -33,4 +33,9 @@ #undef CONFIG_SYS_PROMPT #define CONFIG_SYS_PROMPT "GTA04 # " +#undef CONFIG_BOOTDELAY +#define CONFIG_BOOTDELAY 1 + +#define CONFIG_SYS_NS16550_COM1 OMAP34XX_UART1 /* used for Bluetooth */ + /* __CONFIG_H */ diff --git a/include/configs/omap3_gta04b2.h b/include/configs/omap3_gta04b2.h new file mode 100644 index 0000000..04527db --- /dev/null +++ b/include/configs/omap3_gta04b2.h @@ -0,0 +1,30 @@ +/* + * (C) Copyright 2010 + * Nikolaus Schaller <hns@goldelico.com> + * + * Configuration settings for the GTA04. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#define CONFIG_OMAP3_BEAGLE_EXPANDER y + +#include "omap3_gta04.h" /* share config */ + +/* __CONFIG_H */ |