X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=board%2Fevb64260%2Fmpsc.c;h=98ac7f63df9917c8b2d47f46f64618fc684b3a63;hb=a424a8bb2924b90724b944165d3141f1fa8dfe5b;hp=718fe0566e256eb951649c3ab6abca6d897c2da3;hpb=8bde7f776c77b343aca29b8c7b58464d915ac245;p=u-boot diff --git a/board/evb64260/mpsc.c b/board/evb64260/mpsc.c index 718fe0566e..98ac7f63df 100644 --- a/board/evb64260/mpsc.c +++ b/board/evb64260/mpsc.c @@ -32,6 +32,8 @@ #include #include "mpsc.h" +DECLARE_GLOBAL_DATA_PTR; + int (*mpsc_putchar)(char ch) = mpsc_putchar_early; static volatile unsigned int *rx_desc_base=NULL; @@ -115,7 +117,6 @@ struct _tag_mirror_hack { int mpsc_putchar_early(char ch) { - DECLARE_GLOBAL_DATA_PTR; int mpsc=CHANNEL; int temp=GTREGREAD_MIRROR(GALMPSC_CHANNELREG_2,mpsc,GALMPSC_REG_GAP); galmpsc_set_tcschar(mpsc,ch); @@ -177,79 +178,82 @@ mpsc_putchar_sdma(char ch) return 0; } -char -mpsc_getchar(void) +char mpsc_getchar (void) { - DECLARE_GLOBAL_DATA_PTR; - static unsigned int done = 0; - volatile char ch; - unsigned int len=0, idx=0, temp; - - volatile unsigned int *p; - - - do { - p=&rx_desc_base[rx_desc_index*8]; - - INVALIDATE_DCACHE(&p[0], &p[1]); - /* Wait for character */ - while (p[1] & DESC_OWNER){ - udelay(100); - INVALIDATE_DCACHE(&p[0], &p[1]); - } - - /* Handle error case */ - if (p[1] & (1<<15)) { - printf("oops, error: %08x\n", p[1]); - - temp = GTREGREAD_MIRROR(GALMPSC_CHANNELREG_2,CHANNEL,GALMPSC_REG_GAP); - temp |= (1 << 23); - GT_REG_WRITE_MIRROR(GALMPSC_CHANNELREG_2, CHANNEL,GALMPSC_REG_GAP, temp); - - /* Can't poll on abort bit, so we just wait. */ - udelay(100); - - galsdma_enable_rx(); - } - - /* Number of bytes left in this descriptor */ - len = p[0] & 0xffff; - - if (len) { - /* Where to look */ - idx = 5; - if (done > 3) idx = 4; - if (done > 7) idx = 7; - if (done > 11) idx = 6; + static unsigned int done = 0; + volatile char ch; + unsigned int len = 0, idx = 0, temp; - INVALIDATE_DCACHE(&p[idx], &p[idx+1]); - ch = p[idx] & 0xff; - done++; - } - - if (done < len) { - /* this descriptor has more bytes still - * shift down the char we just read, and leave the - * buffer in place for the next time around - */ - p[idx] = p[idx] >> 8; - FLUSH_DCACHE(&p[idx], &p[idx+1]); - } + volatile unsigned int *p; - if (done == len) { - /* nothing left in this descriptor. - * go to next one - */ - p[1] = DESC_OWNER | DESC_FIRST | DESC_LAST; - p[0] = 0x00100000; - FLUSH_DCACHE(&p[0], &p[1]); - /* Next descriptor */ - rx_desc_index = (rx_desc_index + 1) % RX_DESC; - done = 0; - } - } while (len==0); /* galileo bug.. len might be zero */ - return ch; + do { + p = &rx_desc_base[rx_desc_index * 8]; + + INVALIDATE_DCACHE (&p[0], &p[1]); + /* Wait for character */ + while (p[1] & DESC_OWNER) { + udelay (100); + INVALIDATE_DCACHE (&p[0], &p[1]); + } + + /* Handle error case */ + if (p[1] & (1 << 15)) { + printf ("oops, error: %08x\n", p[1]); + + temp = GTREGREAD_MIRROR (GALMPSC_CHANNELREG_2, + CHANNEL, GALMPSC_REG_GAP); + temp |= (1 << 23); + GT_REG_WRITE_MIRROR (GALMPSC_CHANNELREG_2, CHANNEL, + GALMPSC_REG_GAP, temp); + + /* Can't poll on abort bit, so we just wait. */ + udelay (100); + + galsdma_enable_rx (); + } + + /* Number of bytes left in this descriptor */ + len = p[0] & 0xffff; + + if (len) { + /* Where to look */ + idx = 5; + if (done > 3) + idx = 4; + if (done > 7) + idx = 7; + if (done > 11) + idx = 6; + + INVALIDATE_DCACHE (&p[idx], &p[idx + 1]); + ch = p[idx] & 0xff; + done++; + } + + if (done < len) { + /* this descriptor has more bytes still + * shift down the char we just read, and leave the + * buffer in place for the next time around + */ + p[idx] = p[idx] >> 8; + FLUSH_DCACHE (&p[idx], &p[idx + 1]); + } + + if (done == len) { + /* nothing left in this descriptor. + * go to next one + */ + p[1] = DESC_OWNER | DESC_FIRST | DESC_LAST; + p[0] = 0x00100000; + FLUSH_DCACHE (&p[0], &p[1]); + /* Next descriptor */ + rx_desc_index = (rx_desc_index + 1) % RX_DESC; + done = 0; + } + } while (len == 0); /* galileo bug.. len might be zero */ + + return ch; } int @@ -266,14 +270,12 @@ mpsc_test_char(void) int mpsc_init(int baud) { - DECLARE_GLOBAL_DATA_PTR; - memset(MIRROR_HACK, 0, sizeof(struct _tag_mirror_hack)); MIRROR_HACK->GALMPSC_ROUTING_REGISTER_M=0x3fffffff; /* BRG CONFIG */ galbrg_set_baudrate(CHANNEL, baud); -#ifdef CONFIG_ZUMA_V2 +#if defined(CONFIG_ZUMA_V2) || defined(CONFIG_P3G4) galbrg_set_clksrc(CHANNEL,0x8); /* connect TCLK -> BRG */ #else galbrg_set_clksrc(CHANNEL,0); @@ -382,12 +384,11 @@ mpsc_init2(void) int galbrg_set_baudrate(int channel, int rate) { - DECLARE_GLOBAL_DATA_PTR; int clock; galbrg_disable(channel); -#ifdef CONFIG_ZUMA_V2 +#if defined(CONFIG_ZUMA_V2) || defined(CONFIG_P3G4) /* from tclk */ clock = (CFG_BUS_HZ/(16*rate)) - 1; #else @@ -410,7 +411,6 @@ galbrg_set_baudrate(int channel, int rate) static int galbrg_set_CDV(int channel, int value) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR(GALBRG_0_CONFREG, channel, GALBRG_REG_GAP); @@ -424,7 +424,6 @@ galbrg_set_CDV(int channel, int value) static int galbrg_enable(int channel) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR(GALBRG_0_CONFREG, channel, GALBRG_REG_GAP); @@ -437,7 +436,6 @@ galbrg_enable(int channel) static int galbrg_disable(int channel) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR(GALBRG_0_CONFREG, channel, GALBRG_REG_GAP); @@ -450,7 +448,6 @@ galbrg_disable(int channel) static int galbrg_set_clksrc(int channel, int value) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR(GALBRG_0_CONFREG,channel, GALBRG_REG_GAP); @@ -583,7 +580,6 @@ galsdma_set_burstsize(int channel, unsigned int value) static int galmpsc_connect(int channel, int connect) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR_G(GALMPSC_ROUTING_REGISTER); @@ -629,7 +625,6 @@ galmpsc_route_serial(int channel, int connect) static int galmpsc_route_rx_clock(int channel, int brg) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR_G(GALMPSC_RxC_ROUTE); @@ -647,7 +642,6 @@ galmpsc_route_rx_clock(int channel, int brg) static int galmpsc_route_tx_clock(int channel, int brg) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR_G(GALMPSC_TxC_ROUTE); @@ -688,7 +682,6 @@ galmpsc_write_config_regs(int mpsc, int mode) static int galmpsc_config_channel_regs(int mpsc) { - DECLARE_GLOBAL_DATA_PTR; GT_REG_WRITE_MIRROR(GALMPSC_CHANNELREG_1,mpsc,GALMPSC_REG_GAP, 0); GT_REG_WRITE_MIRROR(GALMPSC_CHANNELREG_2,mpsc,GALMPSC_REG_GAP, 0); GT_REG_WRITE(GALMPSC_CHANNELREG_3+(mpsc*GALMPSC_REG_GAP), 1); @@ -709,7 +702,6 @@ galmpsc_config_channel_regs(int mpsc) static int galmpsc_set_brkcnt(int mpsc, int value) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR(GALMPSC_CHANNELREG_1,mpsc,GALMPSC_REG_GAP); @@ -723,7 +715,6 @@ galmpsc_set_brkcnt(int mpsc, int value) static int galmpsc_set_tcschar(int mpsc, int value) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR(GALMPSC_CHANNELREG_1,mpsc,GALMPSC_REG_GAP); @@ -737,7 +728,6 @@ galmpsc_set_tcschar(int mpsc, int value) static int galmpsc_set_char_length(int mpsc, int value) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR(GALMPSC_PROTOCONF_REG,mpsc,GALMPSC_REG_GAP); @@ -751,7 +741,6 @@ galmpsc_set_char_length(int mpsc, int value) static int galmpsc_set_stop_bit_length(int mpsc, int value) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR(GALMPSC_PROTOCONF_REG,mpsc,GALMPSC_REG_GAP); @@ -764,7 +753,6 @@ galmpsc_set_stop_bit_length(int mpsc, int value) static int galmpsc_set_parity(int mpsc, int value) { - DECLARE_GLOBAL_DATA_PTR; unsigned int temp; temp = GTREGREAD_MIRROR(GALMPSC_CHANNELREG_2,mpsc,GALMPSC_REG_GAP); @@ -784,7 +772,6 @@ galmpsc_set_parity(int mpsc, int value) static int galmpsc_enter_hunt(int mpsc) { - DECLARE_GLOBAL_DATA_PTR; int temp; temp = GTREGREAD_MIRROR(GALMPSC_CHANNELREG_2,mpsc,GALMPSC_REG_GAP); @@ -802,7 +789,7 @@ galmpsc_enter_hunt(int mpsc) static int galmpsc_shutdown(int mpsc) { - DECLARE_GLOBAL_DATA_PTR; +#if 0 unsigned int temp; /* cause RX abort (clears RX) */ @@ -810,9 +797,11 @@ galmpsc_shutdown(int mpsc) temp |= MPSC_RX_ABORT | MPSC_TX_ABORT; temp &= ~MPSC_ENTER_HUNT; GT_REG_WRITE_MIRROR(GALMPSC_CHANNELREG_2,mpsc,GALMPSC_REG_GAP,temp); +#endif - GT_REG_WRITE(GALSDMA_0_COM_REG, 0); - GT_REG_WRITE(GALSDMA_0_COM_REG, SDMA_TX_ABORT | SDMA_RX_ABORT); + GT_REG_WRITE(GALSDMA_0_COM_REG + CHANNEL * GALSDMA_REG_DIFF, 0); + GT_REG_WRITE(GALSDMA_0_COM_REG + CHANNEL * GALSDMA_REG_DIFF, + SDMA_TX_ABORT | SDMA_RX_ABORT); /* shut down the MPSC */ GT_REG_WRITE(GALMPSC_MCONF_LOW, 0); @@ -823,14 +812,15 @@ galmpsc_shutdown(int mpsc) /* shut down the sdma engines. */ /* reset config to default */ - GT_REG_WRITE(GALSDMA_0_CONF_REG, 0x000000fc); + GT_REG_WRITE(GALSDMA_0_CONF_REG + CHANNEL * GALSDMA_REG_DIFF, + 0x000000fc); udelay(100); /* clear the SDMA current and first TX and RX pointers */ - GT_REG_WRITE(GALSDMA_0_CUR_RX_PTR, 0); - GT_REG_WRITE(GALSDMA_0_CUR_TX_PTR, 0); - GT_REG_WRITE(GALSDMA_0_FIR_TX_PTR, 0); + GT_REG_WRITE(GALSDMA_0_CUR_RX_PTR + CHANNEL * GALSDMA_REG_DIFF, 0); + GT_REG_WRITE(GALSDMA_0_CUR_TX_PTR + CHANNEL * GALSDMA_REG_DIFF, 0); + GT_REG_WRITE(GALSDMA_0_FIR_TX_PTR + CHANNEL * GALSDMA_REG_DIFF, 0); udelay(100);