Commit 5cf91d6bdc3e60bd43f9ba1bbb97a43ee49b2b2d

Authored by wdenk
1 parent e35745bb64

* Modify KUP4X board configuration to use SL811 driver for USB memory

sticks (including FAT / VFAT filesystem support)

* Add SL811 Host Controller Interface driver for USB

* Add CFG_I2C_EEPROM_ADDR_OVERFLOW desription to README

* Patch by Pantelis Antoniou, 19 Apr 2004:
  Allow to use shell style syntax (i. e. ${var} ) with standard parser.
  Minor patches for Intracom boards.

* Patch by Christian Pell, 19 Apr 2004:
  cleanup support for CF/IDE on PCMCIA for PXA25X

Showing 20 changed files with 954 additions and 187 deletions Side-by-side Diff

... ... @@ -2,6 +2,20 @@
2 2 Changes for U-Boot 1.1.1:
3 3 ======================================================================
4 4  
  5 +* Modify KUP4X board configuration to use SL811 driver for USB memory
  6 + sticks (including FAT / VFAT filesystem support)
  7 +
  8 +* Add SL811 Host Controller Interface driver for USB
  9 +
  10 +* Add CFG_I2C_EEPROM_ADDR_OVERFLOW desription to README
  11 +
  12 +* Patch by Pantelis Antoniou, 19 Apr 2004:
  13 + Allow to use shell style syntax (i. e. ${var} ) with standard parser.
  14 + Minor patches for Intracom boards.
  15 +
  16 +* Patch by Christian Pell, 19 Apr 2004:
  17 + cleanup support for CF/IDE on PCMCIA for PXA25X
  18 +
5 19 * Temporarily disabled John Kerl's extended MII command code because
6 20 "miivals.h" is missing
7 21  
... ... @@ -1751,6 +1751,17 @@
1751 1751 The length in bytes of the EEPROM memory array address. Note
1752 1752 that this is NOT the chip address length!
1753 1753  
  1754 + - CFG_I2C_EEPROM_ADDR_OVERFLOW:
  1755 + EEPROM chips that implement "address overflow" are ones
  1756 + like Catalyst 24WC04/08/16 which has 9/10/11 bits of
  1757 + address and the extra bits end up in the "chip address" bit
  1758 + slots. This makes a 24WC08 (1Kbyte) chip look like four 256
  1759 + byte chips.
  1760 +
  1761 + Note that we consider the length of the address field to
  1762 + still be one byte because the extra address bits are hidden
  1763 + in the chip address.
  1764 +
1754 1765 - CFG_EEPROM_SIZE:
1755 1766 The size in bytes of the EEPROM device.
1756 1767  
... ... @@ -1971,6 +1982,16 @@
1971 1982 Enable RMII mode for all FECs.
1972 1983 Note that this is a global option, we can't
1973 1984 have one FEC in standard MII mode and another in RMII mode.
  1985 +
  1986 +- CONFIG_CRC32_VERIFY
  1987 + Add a verify option to the crc32 command.
  1988 + The syntax is:
  1989 +
  1990 + => crc32 -v <address> <count> <crc32>
  1991 +
  1992 + Where address/count indicate a memory area
  1993 + and crc32 is the correct crc32 which the
  1994 + area should have.
1974 1995  
1975 1996 Building the Software:
1976 1997 ======================
board/icecube/icecube.c
... ... @@ -42,7 +42,7 @@
42 42 /* unlock mode register */
43 43 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit;
44 44 __asm__ volatile ("sync");
45   -
  45 +
46 46 /* precharge all banks */
47 47 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
48 48 __asm__ volatile ("sync");
... ... @@ -68,7 +68,7 @@
68 68 /* set mode register */
69 69 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
70 70 __asm__ volatile ("sync");
71   -
  71 +
72 72 /* normal operation */
73 73 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
74 74 __asm__ volatile ("sync");
... ... @@ -88,7 +88,7 @@
88 88 ulong dramsize2 = 0;
89 89 #ifndef CFG_RAMBOOT
90 90 ulong test1, test2;
91   -
  91 +
92 92 /* setup SDRAM chip selects */
93 93 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;/* 2G at 0x0 */
94 94 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;/* disabled */
... ... @@ -121,7 +121,7 @@
121 121 if (dramsize < (1 << 20)) {
122 122 dramsize = 0;
123 123 }
124   -
  124 +
125 125 /* set SDRAM CS0 size according to the amount of RAM found */
126 126 if (dramsize > 0) {
127 127 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + __builtin_ffs(dramsize >> 20) - 1;
... ... @@ -129,7 +129,6 @@
129 129 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
130 130 }
131 131  
132   -
133 132 /* let SDRAM CS1 start right after CS0 */
134 133 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;/* 2G */
135 134  
136 135  
... ... @@ -144,12 +143,12 @@
144 143 } else {
145 144 dramsize2 = test2;
146 145 }
147   -
  146 +
148 147 /* memory smaller than 1MB is impossible */
149 148 if (dramsize2 < (1 << 20)) {
150 149 dramsize2 = 0;
151 150 }
152   -
  151 +
153 152 /* set SDRAM CS1 size according to the amount of RAM found */
154 153 if (dramsize2 > 0) {
155 154 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize
... ... @@ -188,7 +187,7 @@
188 187 ulong dramsize = 0;
189 188 #ifndef CFG_RAMBOOT
190 189 ulong test1, test2;
191   -
  190 +
192 191 /* setup and enable SDRAM chip selects */
193 192 *(vu_long *)MPC5XXX_SDRAM_START = 0x00000000;
194 193 *(vu_long *)MPC5XXX_SDRAM_STOP = 0x0000ffff;/* 2G */
... ... @@ -217,7 +216,7 @@
217 216  
218 217 /* set SDRAM end address according to size */
219 218 *(vu_long *)MPC5XXX_SDRAM_STOP = ((dramsize - 1) >> 15);
220   -
  219 +
221 220 #else /* CFG_RAMBOOT */
222 221  
223 222 /* Retrieve amount of SDRAM available */
board/kup/kup4x/Makefile
... ... @@ -25,7 +25,7 @@
25 25  
26 26 LIB = lib$(BOARD).a
27 27  
28   -OBJS = $(BOARD).o ../common/flash.o ../common/kup.o usb.o
  28 +OBJS = $(BOARD).o ../common/flash.o ../common/kup.o
29 29  
30 30 $(LIB): .depend $(OBJS)
31 31 $(AR) crv $@ $(OBJS)
board/kup/kup4x/usb.c
1   -/*
2   - * (C) Copyright 2004
3   - * Klaus Heydeck, Kieback & Peter GmbH & Co KG, heydeck@kieback-peter.de
4   - *
5   - * See file CREDITS for list of people who contributed to this
6   - * project.
7   - *
8   - * This program is free software; you can redistribute it and/or
9   - * modify it under the terms of the GNU General Public License as
10   - * published by the Free Software Foundation; either version 2 of
11   - * the License, or (at your option) any later version.
12   - *
13   - * This program is distributed in the hope that it will be useful,
14   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16   - * GNU General Public License for more details.
17   - *
18   - * You should have received a copy of the GNU General Public License
19   - * along with this program; if not, write to the Free Software
20   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21   - * MA 02111-1307 USA
22   - */
23   -
24   -#include <common.h>
25   -#include <mpc8xx.h>
26   -#include "../common/kup.h"
27   -
28   -
29   -#define SL811_ADR (0x50000000)
30   -#define SL811_DAT (0x50000001)
31   -
32   -
33   -static void sl811_write_index_data (__u8 index, __u8 data)
34   -{
35   - *(volatile unsigned char *) (SL811_ADR) = index;
36   - __asm__ ("eieio");
37   - *(volatile unsigned char *) (SL811_DAT) = data;
38   - __asm__ ("eieio");
39   -}
40   -
41   -static __u8 sl811_read_index_data (__u8 index)
42   -{
43   - __u8 data;
44   -
45   - *(volatile unsigned char *) (SL811_ADR) = index;
46   - __asm__ ("eieio");
47   - data = *(volatile unsigned char *) (SL811_DAT);
48   - __asm__ ("eieio");
49   - return (data);
50   -}
51   -
52   -int usb_init_kup4x (void)
53   -{
54   - volatile immap_t *immap = (immap_t *) CFG_IMMR;
55   - volatile memctl8xx_t *memctl = &immap->im_memctl;
56   - int i;
57   - unsigned char tmp;
58   -
59   - memctl = &immap->im_memctl;
60   - memctl->memc_or7 = 0xFFFF8726;
61   - memctl->memc_br7 = 0x50000401; /* start at 0x50000000 */
62   - /* BP 14 low = USB ON */
63   - immap->im_cpm.cp_pbdat &= ~(BP_USB_VCC);
64   - /* PB 14 nomal port */
65   - immap->im_cpm.cp_pbpar &= ~(BP_USB_VCC);
66   - /* output */
67   - immap->im_cpm.cp_pbdir |= (BP_USB_VCC);
68   -
69   - puts ("USB: ");
70   -
71   - for (i = 0x10; i < 0xff; i++) {
72   - sl811_write_index_data (i, i);
73   - tmp = (sl811_read_index_data (i));
74   - if (tmp != i) {
75   - printf ("SL811 compare error index=0x%02x read=0x%02x\n", i, tmp);
76   - return (-1);
77   - }
78   - }
79   - printf ("SL811 ready\n");
80   - return (0);
81   -}
board/netphone/netphone.c
... ... @@ -30,6 +30,7 @@
30 30 #include <common.h>
31 31 #include <miiphy.h>
32 32 #include <sed156x.h>
  33 +#include <status_led.h>
33 34  
34 35 #include "mpc8xx.h"
35 36  
... ... @@ -659,6 +660,7 @@
659 660  
660 661 extern int drv_phone_init(void);
661 662 extern int drv_phone_use_me(void);
  663 +extern int drv_phone_is_idle(void);
662 664  
663 665 int misc_init_r(void)
664 666 {
... ... @@ -691,6 +693,12 @@
691 693 do_poll();
692 694  
693 695 if (drv_phone_use_me()) {
  696 + status_led_set(0, STATUS_LED_ON);
  697 + while (!drv_phone_is_idle()) {
  698 + do_poll();
  699 + udelay(1000000 / CFG_HZ);
  700 + }
  701 +
694 702 console_assign(stdin, "phone");
695 703 console_assign(stdout, "phone");
696 704 console_assign(stderr, "phone");
board/netphone/phone_console.c
... ... @@ -179,7 +179,6 @@
179 179 static int refresh_time;
180 180 static int blink_time;
181 181 static char last_fast_punct;
182   -static int last_tab_indicator = -1;
183 182  
184 183 /*************************************************************************************************/
185 184  
... ... @@ -239,8 +238,6 @@
239 238 refresh_time = REFRESH_HZ;
240 239 blink_time = BLINK_HZ;
241 240  
242   - tab_indicator = 1;
243   -
244 241 memset(vty_buf, ' ', sizeof(vty_buf));
245 242  
246 243 memset(last_visible_buf, ' ', sizeof(last_visible_buf));
... ... @@ -253,6 +250,8 @@
253 250 sed156x_init();
254 251 width = sed156x_text_width;
255 252 height = sed156x_text_height - 1;
  253 +
  254 + tab_indicator = 0;
256 255 }
257 256  
258 257 /*****************************************************************************/
259 258  
... ... @@ -718,8 +717,10 @@
718 717 if (input_mode != last_input_mode)
719 718 sed156x_output_at(sed156x_text_width - 3, sed156x_text_height - 1, input_mode_txt[input_mode], 3);
720 719  
721   - if (tab_indicator != last_tab_indicator)
  720 + if (tab_indicator == 0) {
722 721 sed156x_output_at(0, sed156x_text_height - 1, "\\t", 2);
  722 + tab_indicator = 1;
  723 + }
723 724  
724 725 if (fast_punct != last_fast_punct)
725 726 sed156x_output_at(4, sed156x_text_height - 1, &fast_punct, 1);
... ... @@ -779,7 +780,6 @@
779 780  
780 781 last_input_mode = input_mode;
781 782 last_fast_punct = fast_punct;
782   - last_tab_indicator = tab_indicator;
783 783 }
784 784  
785 785 /* ensure visibility; the trick is to minimize the screen movement */
... ... @@ -891,7 +891,8 @@
891 891 blink_time = BLINK_HZ;
892 892  
893 893 switch (c) {
894   - case 13: /* ignore */
  894 + case '\a': /* ignore bell */
  895 + case '\r': /* ignore carriage return */
895 896 break;
896 897  
897 898 case '\n': /* next line */
... ... @@ -1140,5 +1141,12 @@
1140 1141  
1141 1142 break;
1142 1143 }
  1144 +}
  1145 +
  1146 +/**************************************************************************************/
  1147 +
  1148 +int drv_phone_is_idle(void)
  1149 +{
  1150 + return kp_state == SCAN;
1143 1151 }
... ... @@ -60,6 +60,11 @@
60 60 # define SHOW_BOOT_PROGRESS(arg)
61 61 #endif
62 62  
  63 +#ifdef __PPC__
  64 +# define EIEIO __asm__ volatile ("eieio")
  65 +#else
  66 +# define EIEIO /* nothing */
  67 +#endif
63 68  
64 69 #undef IDE_DEBUG
65 70  
... ... @@ -790,9 +795,7 @@
790 795 dev, port, val, (ATA_CURR_BASE(dev)+port));
791 796  
792 797 /* Ensure I/O operations complete */
793   -#ifdef __PPC__
794   - __asm__ volatile("eieio");
795   -#endif
  798 + EIEIO;
796 799 *((uchar *)(ATA_CURR_BASE(dev)+port)) = val;
797 800 }
798 801 #else /* ! __PPC__ */
... ... @@ -810,9 +813,7 @@
810 813 {
811 814 uchar val;
812 815 /* Ensure I/O operations complete */
813   -#ifdef __PPC__
814   - __asm__ volatile("eieio");
815   -#endif
  816 + EIEIO;
816 817 val = *((uchar *)(ATA_CURR_BASE(dev)+port));
817 818 PRINTF ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
818 819 dev, port, (ATA_CURR_BASE(dev)+port), val);
819 820  
... ... @@ -837,9 +838,9 @@
837 838 pbuf = (ushort *)(ATA_CURR_BASE(dev)+ATA_DATA_REG);
838 839 dbuf = (ushort *)sect_buf;
839 840 while (words--) {
840   - __asm__ volatile ("eieio");
  841 + EIEIO;
841 842 *pbuf = *dbuf++;
842   - __asm__ volatile ("eieio");
  843 + EIEIO;
843 844 }
844 845  
845 846 if (words&1)
846 847  
... ... @@ -895,13 +896,9 @@
895 896 pbuf = (ushort *)(ATA_CURR_BASE(dev)+ATA_DATA_REG);
896 897 dbuf = (ushort *)sect_buf;
897 898 while (words--) {
898   -#ifdef __PPC__
899   - __asm__ volatile ("eieio");
900   -#endif
  899 + EIEIO;
901 900 *pbuf = *dbuf++;
902   -#ifdef __PPC__
903   - __asm__ volatile ("eieio");
904   -#endif
  901 + EIEIO;
905 902 *pbuf = *dbuf++;
906 903 }
907 904 #else /* CONFIG_HMI10 */
908 905  
909 906  
910 907  
... ... @@ -913,13 +910,13 @@
913 910 pbuf_odd = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_ODD);
914 911 dbuf = (uchar *)sect_buf;
915 912 while (words--) {
916   - __asm__ volatile ("eieio");
  913 + EIEIO;
917 914 *pbuf_even = *dbuf++;
918   - __asm__ volatile ("eieio");
  915 + EIEIO;
919 916 *pbuf_odd = *dbuf++;
920   - __asm__ volatile ("eieio");
  917 + EIEIO;
921 918 *pbuf_even = *dbuf++;
922   - __asm__ volatile ("eieio");
  919 + EIEIO;
923 920 *pbuf_odd = *dbuf++;
924 921 }
925 922 #endif /* CONFIG_HMI10 */
926 923  
... ... @@ -946,13 +943,9 @@
946 943 PRINTF("in input data base for read is %lx\n", (unsigned long) pbuf);
947 944  
948 945 while (words--) {
949   -#ifdef __PPC__
950   - __asm__ volatile ("eieio");
951   -#endif
  946 + EIEIO;
952 947 *dbuf++ = *pbuf;
953   -#ifdef __PPC__
954   - __asm__ volatile ("eieio");
955   -#endif
  948 + EIEIO;
956 949 *dbuf++ = *pbuf;
957 950 }
958 951 #else /* CONFIG_HMI10 */
959 952  
960 953  
961 954  
... ... @@ -964,13 +957,13 @@
964 957 pbuf_odd = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_ODD);
965 958 dbuf = (uchar *)sect_buf;
966 959 while (words--) {
967   - __asm__ volatile ("eieio");
  960 + EIEIO;
968 961 *dbuf++ = *pbuf_even;
969   - __asm__ volatile ("eieio");
  962 + EIEIO;
970 963 *dbuf++ = *pbuf_odd;
971   - __asm__ volatile ("eieio");
  964 + EIEIO;
972 965 *dbuf++ = *pbuf_even;
973   - __asm__ volatile ("eieio");
  966 + EIEIO;
974 967 *dbuf++ = *pbuf_odd;
975 968 }
976 969 #endif /* CONFIG_HMI10 */
977 970  
... ... @@ -994,9 +987,9 @@
994 987 pbuf = (ushort *)(ATA_CURR_BASE(dev)+ATA_DATA_REG);
995 988 dbuf = (ushort *)sect_buf;
996 989 while (words--) {
997   - __asm__ volatile ("eieio");
  990 + EIEIO;
998 991 *dbuf++ = *pbuf;
999   - __asm__ volatile ("eieio");
  992 + EIEIO;
1000 993 }
1001 994  
1002 995 if (words&1) {
... ... @@ -1608,9 +1601,7 @@
1608 1601 PRINTF("in output data shorts base for read is %lx\n", (unsigned long) pbuf);
1609 1602  
1610 1603 while (shorts--) {
1611   -#ifdef __PPC__
1612   - __asm__ volatile ("eieio");
1613   -#endif
  1604 + EIEIO;
1614 1605 *pbuf = *dbuf++;
1615 1606 }
1616 1607 #else /* CONFIG_HMI10 */
1617 1608  
... ... @@ -1621,9 +1612,9 @@
1621 1612 pbuf_even = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_EVEN);
1622 1613 pbuf_odd = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_ODD);
1623 1614 while (shorts--) {
1624   - __asm__ volatile ("eieio");
  1615 + EIEIO;
1625 1616 *pbuf_even = *dbuf++;
1626   - __asm__ volatile ("eieio");
  1617 + EIEIO;
1627 1618 *pbuf_odd = *dbuf++;
1628 1619 }
1629 1620 #endif /* CONFIG_HMI10 */
... ... @@ -1642,9 +1633,7 @@
1642 1633 PRINTF("in input data shorts base for read is %lx\n", (unsigned long) pbuf);
1643 1634  
1644 1635 while (shorts--) {
1645   -#ifdef __PPC__
1646   - __asm__ volatile ("eieio");
1647   -#endif
  1636 + EIEIO;
1648 1637 *dbuf++ = *pbuf;
1649 1638 }
1650 1639 #else /* CONFIG_HMI10 */
1651 1640  
... ... @@ -1655,9 +1644,9 @@
1655 1644 pbuf_even = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_EVEN);
1656 1645 pbuf_odd = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_ODD);
1657 1646 while (shorts--) {
1658   - __asm__ volatile ("eieio");
  1647 + EIEIO;
1659 1648 *dbuf++ = *pbuf_even;
1660   - __asm__ volatile ("eieio");
  1649 + EIEIO;
1661 1650 *dbuf++ = *pbuf_odd;
1662 1651 }
1663 1652 #endif /* CONFIG_HMI10 */
... ... @@ -413,7 +413,7 @@
413 413 }
414 414 }
415 415  
416   -// ----------------------------------------------------------------
  416 +/* ---------------------------------------------------------------- */
417 417 int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
418 418 {
419 419 char op;
... ... @@ -598,14 +598,14 @@
598 598 usb, 5, 1, do_usb,
599 599 "usb - USB sub-system\n",
600 600 "reset - reset (rescan) USB controller\n"
601   - "usb stop [f] - stop USB [f]=force stop\n"
602   - "usb tree - show USB device tree\n"
603   - "usb info [dev] - show available USB devices\n"
604   - "usb scan - (re-)scan USB bus for storage devices\n"
605   - "usb device [dev] - show or set current USB storage device\n"
606   - "usb part [dev] - print partition table of one or all USB storage devices\n"
607   - "usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
608   - " to memory address `addr'\n"
  601 + "usb stop [f] - stop USB [f]=force stop\n"
  602 + "usb tree - show USB device tree\n"
  603 + "usb info [dev] - show available USB devices\n"
  604 + "usb scan - (re-)scan USB bus for storage devices\n"
  605 + "usb device [dev] - show or set current USB storage device\n"
  606 + "usb part [dev] - print partition table of one or all USB storage devices\n"
  607 + "usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
  608 + " to memory address `addr'\n"
609 609 );
610 610  
611 611  
... ... @@ -726,8 +726,8 @@
726 726 int inputcnt = strlen (input);
727 727 int outputcnt = CFG_CBSIZE;
728 728 int state = 0; /* 0 = waiting for '$' */
729   - /* 1 = waiting for '(' */
730   - /* 2 = waiting for ')' */
  729 + /* 1 = waiting for '(' or '{' */
  730 + /* 2 = waiting for ')' or '}' */
731 731 /* 3 = waiting for ''' */
732 732 #ifdef DEBUG_PARSER
733 733 char *output_start = output;
... ... @@ -765,7 +765,7 @@
765 765 }
766 766 break;
767 767 case 1: /* Waiting for ( */
768   - if (c == '(') {
  768 + if (c == '(' || c == '{') {
769 769 state++;
770 770 varname_start = input;
771 771 } else {
... ... @@ -780,7 +780,7 @@
780 780 }
781 781 break;
782 782 case 2: /* Waiting for ) */
783   - if (c == ')') {
  783 + if (c == ')' || c == '}') {
784 784 int i;
785 785 char envname[CFG_CBSIZE], *envval;
786 786 int envcnt = input-varname_start-1; /* Varname # of chars */
... ... @@ -40,7 +40,7 @@
40 40 rtl8019.o rtl8139.o rtl8169.o \
41 41 s3c24x0_i2c.o sed13806.o sed156x.o \
42 42 serial.o serial_max3100.o serial_pl010.o serial_pl011.o \
43   - serial_xuartlite.o \
  43 + serial_xuartlite.o sl811_usb.o \
44 44 smc91111.o smiLynxEM.o status_led.o sym53c8xx.o \
45 45 ti_pci1410a.o tigon3.o w83c553f.o omap1510_i2c.o \
46 46 usbdcore.o usbdcore_ep0.o usbdcore_omap1510.o usbtty.o \
  1 +#ifndef __UBOOT_SL811_H
  2 +#define __UBOOT_SL811_H
  3 +
  4 +#undef SL811_DEBUG
  5 +
  6 +#ifdef SL811_DEBUG
  7 + #define PDEBUG(level, fmt, args...) \
  8 + if (debug >= (level)) printf("[%s:%d] " fmt, \
  9 + __PRETTY_FUNCTION__, __LINE__ , ## args)
  10 +#else
  11 + #define PDEBUG(level, fmt, args...) do {} while(0)
  12 +#endif
  13 +
  14 +/* Sl811 host control register */
  15 +#define SL811_CTRL_A 0x00
  16 +#define SL811_ADDR_A 0x01
  17 +#define SL811_LEN_A 0x02
  18 +#define SL811_STS_A 0x03 /* read */
  19 +#define SL811_PIDEP_A 0x03 /* write */
  20 +#define SL811_CNT_A 0x04 /* read */
  21 +#define SL811_DEV_A 0x04 /* write */
  22 +#define SL811_CTRL1 0x05
  23 +#define SL811_INTR 0x06
  24 +#define SL811_CTRL_B 0x08
  25 +#define SL811_ADDR_B 0x09
  26 +#define SL811_LEN_B 0x0A
  27 +#define SL811_STS_B 0x0B /* read */
  28 +#define SL811_PIDEP_B 0x0B /* write */
  29 +#define SL811_CNT_B 0x0C /* read */
  30 +#define SL811_DEV_B 0x0C /* write */
  31 +#define SL811_INTRSTS 0x0D /* write clears bitwise */
  32 +#define SL811_HWREV 0x0E /* read */
  33 +#define SL811_SOFLOW 0x0E /* write */
  34 +#define SL811_SOFCNTDIV 0x0F /* read */
  35 +#define SL811_CTRL2 0x0F /* write */
  36 +
  37 +/* USB control register bits (addr 0x00 and addr 0x08) */
  38 +#define SL811_USB_CTRL_ARM 0x01
  39 +#define SL811_USB_CTRL_ENABLE 0x02
  40 +#define SL811_USB_CTRL_DIR_OUT 0x04
  41 +#define SL811_USB_CTRL_ISO 0x10
  42 +#define SL811_USB_CTRL_SOF 0x20
  43 +#define SL811_USB_CTRL_TOGGLE_1 0x40
  44 +#define SL811_USB_CTRL_PREAMBLE 0x80
  45 +
  46 +/* USB status register bits (addr 0x03 and addr 0x0B) */
  47 +#define SL811_USB_STS_ACK 0x01
  48 +#define SL811_USB_STS_ERROR 0x02
  49 +#define SL811_USB_STS_TIMEOUT 0x04
  50 +#define SL811_USB_STS_TOGGLE_1 0x08
  51 +#define SL811_USB_STS_SETUP 0x10
  52 +#define SL811_USB_STS_OVERFLOW 0x20
  53 +#define SL811_USB_STS_NAK 0x40
  54 +#define SL811_USB_STS_STALL 0x80
  55 +
  56 +/* Control register 1 bits (addr 0x05) */
  57 +#define SL811_CTRL1_SOF 0x01
  58 +#define SL811_CTRL1_RESET 0x08
  59 +#define SL811_CTRL1_JKSTATE 0x10
  60 +#define SL811_CTRL1_SPEED_LOW 0x20
  61 +#define SL811_CTRL1_SUSPEND 0x40
  62 +
  63 +/* Interrut enable (addr 0x06) and interrupt status register bits (addr 0x0D) */
  64 +#define SL811_INTR_DONE_A 0x01
  65 +#define SL811_INTR_DONE_B 0x02
  66 +#define SL811_INTR_SOF 0x10
  67 +#define SL811_INTR_INSRMV 0x20
  68 +#define SL811_INTR_DETECT 0x40
  69 +#define SL811_INTR_NOTPRESENT 0x40
  70 +#define SL811_INTR_SPEED_FULL 0x80 /* only in status reg */
  71 +
  72 +/* HW rev and SOF lo register bits (addr 0x0E) */
  73 +#define SL811_HWR_HWREV 0xF0
  74 +
  75 +/* SOF counter and control reg 2 (addr 0x0F) */
  76 +#define SL811_CTL2_SOFHI 0x3F
  77 +#define SL811_CTL2_DSWAP 0x40
  78 +#define SL811_CTL2_HOST 0x80
  79 +
  80 +/* Set up for 1-ms SOF time. */
  81 +#define SL811_12M_LOW 0xE0
  82 +#define SL811_12M_HI 0x2E
  83 +
  84 +#define SL811_DATA_START 0x10
  85 +#define SL811_DATA_LIMIT 240
  86 +
  87 +/* Requests: bRequest << 8 | bmRequestType */
  88 +#define RH_GET_STATUS 0x0080
  89 +#define RH_CLEAR_FEATURE 0x0100
  90 +#define RH_SET_FEATURE 0x0300
  91 +#define RH_SET_ADDRESS 0x0500
  92 +#define RH_GET_DESCRIPTOR 0x0680
  93 +#define RH_SET_DESCRIPTOR 0x0700
  94 +#define RH_GET_CONFIGURATION 0x0880
  95 +#define RH_SET_CONFIGURATION 0x0900
  96 +#define RH_GET_STATE 0x0280
  97 +#define RH_GET_INTERFACE 0x0A80
  98 +#define RH_SET_INTERFACE 0x0B00
  99 +#define RH_SYNC_FRAME 0x0C80
  100 +
  101 +
  102 +#define PIDEP(pid, ep) (((pid) & 0x0f) << 4 | (ep))
  103 +
  104 +#endif /* __UBOOT_SL811_H */
  1 +/*
  2 + * (C) Copyright 2004
  3 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4 + *
  5 + * This code is based on linux driver for sl811hs chip, source at
  6 + * drivers/usb/host/sl811.c:
  7 + *
  8 + * SL811 Host Controller Interface driver for USB.
  9 + *
  10 + * Copyright (c) 2003/06, Courage Co., Ltd.
  11 + *
  12 + * Based on:
  13 + * 1.uhci.c by Linus Torvalds, Johannes Erdfelt, Randy Dunlap,
  14 + * Georg Acher, Deti Fliegl, Thomas Sailer, Roman Weissgaerber,
  15 + * Adam Richter, Gregory P. Smith;
  16 + * 2.Original SL811 driver (hc_sl811.o) by Pei Liu <pbl@cypress.com>
  17 + * 3.Rewrited as sl811.o by Yin Aihua <yinah:couragetech.com.cn>
  18 + *
  19 + * See file CREDITS for list of people who contributed to this
  20 + * project.
  21 + *
  22 + * This program is free software; you can redistribute it and/or
  23 + * modify it under the terms of the GNU General Public License as
  24 + * published by the Free Software Foundation; either version 2 of
  25 + * the License, or (at your option) any later version.
  26 + *
  27 + * This program is distributed in the hope that it will be useful,
  28 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  29 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30 + * GNU General Public License for more details.
  31 + *
  32 + * You should have received a copy of the GNU General Public License
  33 + * along with this program; if not, write to the Free Software
  34 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  35 + * MA 02111-1307 USA
  36 + */
  37 +
  38 +#include <common.h>
  39 +#ifdef CONFIG_USB_SL811HS
  40 +#include <mpc8xx.h>
  41 +#include <usb.h>
  42 +#include "sl811.h"
  43 +
  44 +#include "../board/kup/common/kup.h"
  45 +
  46 +#ifdef __PPC__
  47 +# define EIEIO __asm__ volatile ("eieio")
  48 +#else
  49 +# define EIEIO /* nothing */
  50 +#endif
  51 +
  52 +#define SL811_ADR (0x50000000)
  53 +#define SL811_DAT (0x50000001)
  54 +
  55 +#define mdelay(n) ({unsigned long msec=(n); while (msec--) udelay(1000);})
  56 +
  57 +#ifdef SL811_DEBUG
  58 +static int debug = 9;
  59 +#endif
  60 +
  61 +static int root_hub_devnum = 0;
  62 +static struct usb_port_status rh_status = { 0 };/* root hub port status */
  63 +
  64 +static int sl811_rh_submit_urb(struct usb_device *usb_dev, unsigned long pipe,
  65 + void *data, int buf_len, struct devrequest *cmd);
  66 +
  67 +static void sl811_write (__u8 index, __u8 data)
  68 +{
  69 + *(volatile unsigned char *) (SL811_ADR) = index;
  70 + EIEIO;
  71 + *(volatile unsigned char *) (SL811_DAT) = data;
  72 + EIEIO;
  73 +}
  74 +
  75 +static __u8 sl811_read (__u8 index)
  76 +{
  77 + __u8 data;
  78 +
  79 + *(volatile unsigned char *) (SL811_ADR) = index;
  80 + EIEIO;
  81 + data = *(volatile unsigned char *) (SL811_DAT);
  82 + EIEIO;
  83 + return (data);
  84 +}
  85 +
  86 +/*
  87 + * Read consecutive bytes of data from the SL811H/SL11H buffer
  88 + */
  89 +static void inline sl811_read_buf(__u8 offset, __u8 *buf, __u8 size)
  90 +{
  91 + *(volatile unsigned char *) (SL811_ADR) = offset;
  92 + EIEIO;
  93 + while (size--) {
  94 + *buf++ = *(volatile unsigned char *) (SL811_DAT);
  95 + EIEIO;
  96 + }
  97 +}
  98 +
  99 +/*
  100 + * Write consecutive bytes of data to the SL811H/SL11H buffer
  101 + */
  102 +static void inline sl811_write_buf(__u8 offset, __u8 *buf, __u8 size)
  103 +{
  104 + *(volatile unsigned char *) (SL811_ADR) = offset;
  105 + EIEIO;
  106 + while (size--) {
  107 + *(volatile unsigned char *) (SL811_DAT) = *buf++;
  108 + EIEIO;
  109 + }
  110 +}
  111 +
  112 +int usb_init_kup4x (void)
  113 +{
  114 + volatile immap_t *immap = (immap_t *) CFG_IMMR;
  115 + volatile memctl8xx_t *memctl = &immap->im_memctl;
  116 + int i;
  117 + unsigned char tmp;
  118 +
  119 + memctl = &immap->im_memctl;
  120 + memctl->memc_or7 = 0xFFFF8726;
  121 + memctl->memc_br7 = 0x50000401; /* start at 0x50000000 */
  122 + /* BP 14 low = USB ON */
  123 + immap->im_cpm.cp_pbdat &= ~(BP_USB_VCC);
  124 + /* PB 14 nomal port */
  125 + immap->im_cpm.cp_pbpar &= ~(BP_USB_VCC);
  126 + /* output */
  127 + immap->im_cpm.cp_pbdir |= (BP_USB_VCC);
  128 +
  129 + puts ("USB: ");
  130 +
  131 + for (i = 0x10; i < 0xff; i++) {
  132 + sl811_write(i, i);
  133 + tmp = (sl811_read(i));
  134 + if (tmp != i) {
  135 + printf ("SL811 compare error index=0x%02x read=0x%02x\n", i, tmp);
  136 + return (-1);
  137 + }
  138 + }
  139 + printf ("SL811 ready\n");
  140 + return (0);
  141 +}
  142 +
  143 +/*
  144 + * This function resets SL811HS controller and detects the speed of
  145 + * the connecting device
  146 + *
  147 + * Return: 0 = no device attached; 1 = USB device attached
  148 + */
  149 +static int sl811_hc_reset(void)
  150 +{
  151 + int status ;
  152 +
  153 + sl811_write(SL811_CTRL2, SL811_CTL2_HOST | SL811_12M_HI);
  154 + sl811_write(SL811_CTRL1, SL811_CTRL1_RESET);
  155 +
  156 + mdelay(20);
  157 +
  158 + /* Disable hardware SOF generation, clear all irq status. */
  159 + sl811_write(SL811_CTRL1, 0);
  160 + mdelay(2);
  161 + sl811_write(SL811_INTRSTS, 0xff);
  162 + status = sl811_read(SL811_INTRSTS);
  163 +
  164 + if (status & SL811_INTR_NOTPRESENT) {
  165 + /* Device is not present */
  166 + PDEBUG(0, "Device not present\n");
  167 + rh_status.wPortStatus &= ~(USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE);
  168 + rh_status.wPortChange |= USB_PORT_STAT_C_CONNECTION;
  169 + sl811_write(SL811_INTR, SL811_INTR_INSRMV);
  170 + return 0;
  171 + }
  172 +
  173 + /* Send SOF to address 0, endpoint 0. */
  174 + sl811_write(SL811_LEN_B, 0);
  175 + sl811_write(SL811_PIDEP_B, PIDEP(USB_PID_SOF, 0));
  176 + sl811_write(SL811_DEV_B, 0x00);
  177 + sl811_write(SL811_SOFLOW, SL811_12M_LOW);
  178 +
  179 + if (status & SL811_INTR_SPEED_FULL) {
  180 + /* full speed device connect directly to root hub */
  181 + PDEBUG (0, "Full speed Device attached\n");
  182 +
  183 + sl811_write(SL811_CTRL1, SL811_CTRL1_RESET);
  184 + mdelay(20);
  185 + sl811_write(SL811_CTRL2, SL811_CTL2_HOST | SL811_12M_HI);
  186 + sl811_write(SL811_CTRL1, SL811_CTRL1_SOF);
  187 +
  188 + /* start the SOF or EOP */
  189 + sl811_write(SL811_CTRL_B, SL811_USB_CTRL_ARM);
  190 + rh_status.wPortStatus |= USB_PORT_STAT_CONNECTION;
  191 + rh_status.wPortStatus &= ~USB_PORT_STAT_LOW_SPEED;
  192 + mdelay(2);
  193 + sl811_write(SL811_INTRSTS, 0xff);
  194 + } else {
  195 + /* slow speed device connect directly to root-hub */
  196 + PDEBUG(0, "Low speed Device attached\n");
  197 +
  198 + sl811_write(SL811_CTRL1, SL811_CTRL1_RESET);
  199 + mdelay(20);
  200 + sl811_write(SL811_CTRL2, SL811_CTL2_HOST | SL811_CTL2_DSWAP | SL811_12M_HI);
  201 + sl811_write(SL811_CTRL1, SL811_CTRL1_SPEED_LOW | SL811_CTRL1_SOF);
  202 +
  203 + /* start the SOF or EOP */
  204 + sl811_write(SL811_CTRL_B, SL811_USB_CTRL_ARM);
  205 + rh_status.wPortStatus |= USB_PORT_STAT_CONNECTION | USB_PORT_STAT_LOW_SPEED;
  206 + mdelay(2);
  207 + sl811_write(SL811_INTRSTS, 0xff);
  208 + }
  209 +
  210 + rh_status.wPortChange |= USB_PORT_STAT_C_CONNECTION;
  211 + sl811_write(SL811_INTR, /*SL811_INTR_INSRMV*/SL811_INTR_DONE_A);
  212 +
  213 + return 1;
  214 +}
  215 +
  216 +int usb_lowlevel_init(void)
  217 +{
  218 + root_hub_devnum = 0;
  219 + sl811_hc_reset();
  220 + return 0;
  221 +}
  222 +
  223 +int usb_lowlevel_stop(void)
  224 +{
  225 + sl811_hc_reset();
  226 + return 0;
  227 +}
  228 +
  229 +int sl811_send_packet(int dir_to_host, int data1, __u8 *buffer, int len)
  230 +{
  231 + __u8 ctrl = SL811_USB_CTRL_ARM | SL811_USB_CTRL_ENABLE;
  232 + __u16 status;
  233 + int err = 0;
  234 +
  235 + if (len > 239)
  236 + return -1;
  237 +
  238 + if (!dir_to_host)
  239 + ctrl |= SL811_USB_CTRL_DIR_OUT;
  240 + if (data1)
  241 + ctrl |= SL811_USB_CTRL_TOGGLE_1;
  242 +
  243 + sl811_write(SL811_ADDR_A, 0x10);
  244 + sl811_write(SL811_LEN_A, len);
  245 + if (!dir_to_host && len)
  246 + sl811_write_buf(0x10, buffer, len);
  247 +
  248 + while (err < 3) {
  249 + if (sl811_read(SL811_SOFCNTDIV)*64 < len * 8 * 2)
  250 + ctrl |= SL811_USB_CTRL_SOF;
  251 + else
  252 + ctrl &= ~SL811_USB_CTRL_SOF;
  253 + sl811_write(SL811_CTRL_A, ctrl);
  254 + while (!(sl811_read(SL811_INTRSTS) & SL811_INTR_DONE_A))
  255 + ; /* do nothing */
  256 +
  257 + sl811_write(SL811_INTRSTS, 0xff);
  258 + status = sl811_read(SL811_STS_A);
  259 +
  260 + if (status & SL811_USB_STS_ACK) {
  261 + int remainder = sl811_read(SL811_CNT_A);
  262 + if (remainder) {
  263 + PDEBUG(0, "usb transfer remainder = %d\n", remainder);
  264 + len -= remainder;
  265 + }
  266 + if (dir_to_host && len)
  267 + sl811_read_buf(0x10, buffer, len);
  268 + return len;
  269 + }
  270 +
  271 + if ((status & SL811_USB_STS_NAK) == SL811_USB_STS_NAK)
  272 + continue;
  273 +
  274 + PDEBUG(0, "usb transfer error %#x\n", (int)status);
  275 + err++;
  276 + }
  277 +
  278 + return -1;
  279 +}
  280 +
  281 +int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  282 + int len)
  283 +{
  284 + int dir_out = usb_pipeout(pipe);
  285 + int ep = usb_pipeendpoint(pipe);
  286 + __u8* buf = (__u8*)buffer;
  287 + int max = usb_maxpacket(dev, pipe);
  288 + int done = 0;
  289 +
  290 + PDEBUG(7, "dev = %ld pipe = %ld buf = %p size = %d dir_out = %d\n",
  291 + usb_pipedevice(pipe), usb_pipeendpoint(pipe), buffer, len, dir_out);
  292 +
  293 + dev->status = 0;
  294 +
  295 + sl811_write(SL811_DEV_A, usb_pipedevice(pipe));
  296 + sl811_write(SL811_PIDEP_A, PIDEP(!dir_out ? USB_PID_IN : USB_PID_OUT, ep));
  297 + while (done < len) {
  298 + int res = sl811_send_packet(!dir_out, usb_gettoggle(dev, ep, dir_out),
  299 + buf+done,
  300 + max > len - done ? len - done : max);
  301 + if (res < 0) {
  302 + dev->status = res;
  303 + return res;
  304 + }
  305 +
  306 + if (!dir_out && res < max) /* short packet */
  307 + break;
  308 +
  309 + done += res;
  310 + usb_dotoggle(dev, ep, dir_out);
  311 + }
  312 +
  313 + dev->act_len = done;
  314 +
  315 + return 0;
  316 +}
  317 +
  318 +int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  319 + int len,struct devrequest *setup)
  320 +{
  321 + int done = 0;
  322 + int devnum = usb_pipedevice(pipe);
  323 +
  324 + dev->status = 0;
  325 +
  326 + if (devnum == root_hub_devnum)
  327 + return sl811_rh_submit_urb(dev, pipe, buffer, len, setup);
  328 +
  329 + PDEBUG(7, "dev = %d pipe = %ld buf = %p size = %d rt = %#x req = %#x\n",
  330 + devnum, usb_pipeendpoint(pipe), buffer, len, (int)setup->requesttype,
  331 + (int)setup->request);
  332 +
  333 + sl811_write(SL811_DEV_A, devnum);
  334 + sl811_write(SL811_PIDEP_A, PIDEP(USB_PID_SETUP, 0));
  335 + /* setup phase */
  336 + if (sl811_send_packet(0, 0, (__u8*)setup, sizeof(*setup)) == sizeof(*setup)) {
  337 + int dir_in = setup->requesttype & USB_DIR_IN;
  338 + __u8* buf = (__u8*)buffer;
  339 + int data1 = 1;
  340 + int max = usb_maxpacket(dev, pipe);
  341 +
  342 + /* data phase */
  343 + sl811_write(SL811_PIDEP_A,
  344 + PIDEP(dir_in ? USB_PID_IN : USB_PID_OUT, 0));
  345 + while (done < len) {
  346 + int res = sl811_send_packet(dir_in, data1, buf+done,
  347 + max > len - done ? len - done : max);
  348 + if (res < 0)
  349 + return res;
  350 + done += res;
  351 +
  352 + if (dir_in && res < max) /* short packet */
  353 + break;
  354 +
  355 + data1 = !data1;
  356 + }
  357 +
  358 + /* status phase */
  359 + sl811_write(SL811_PIDEP_A,
  360 + PIDEP(!dir_in ? USB_PID_IN : USB_PID_OUT, 0));
  361 + if (sl811_send_packet(!dir_in, 1, 0, 0) < 0) {
  362 + PDEBUG(0, "status phase failed!\n");
  363 + dev->status = -1;
  364 + }
  365 + } else {
  366 + PDEBUG(0, "setup phase failed!\n");
  367 + dev->status = -1;
  368 + }
  369 +
  370 + dev->act_len = done;
  371 +
  372 + return done;
  373 +}
  374 +
  375 +int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  376 + int len, int interval)
  377 +{
  378 + PDEBUG(7, "dev = %p pipe = %#lx buf = %p size = %d int = %d\n", dev, pipe,
  379 + buffer, len, interval);
  380 + return -1;
  381 +}
  382 +
  383 +/*
  384 + * SL811 Virtual Root Hub
  385 + */
  386 +
  387 +/* Device descriptor */
  388 +static __u8 sl811_rh_dev_des[] =
  389 +{
  390 + 0x12, /* __u8 bLength; */
  391 + 0x01, /* __u8 bDescriptorType; Device */
  392 + 0x10, /* __u16 bcdUSB; v1.1 */
  393 + 0x01,
  394 + 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
  395 + 0x00, /* __u8 bDeviceSubClass; */
  396 + 0x00, /* __u8 bDeviceProtocol; */
  397 + 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */
  398 + 0x00, /* __u16 idVendor; */
  399 + 0x00,
  400 + 0x00, /* __u16 idProduct; */
  401 + 0x00,
  402 + 0x00, /* __u16 bcdDevice; */
  403 + 0x00,
  404 + 0x00, /* __u8 iManufacturer; */
  405 + 0x02, /* __u8 iProduct; */
  406 + 0x01, /* __u8 iSerialNumber; */
  407 + 0x01 /* __u8 bNumConfigurations; */
  408 +};
  409 +
  410 +/* Configuration descriptor */
  411 +static __u8 sl811_rh_config_des[] =
  412 +{
  413 + 0x09, /* __u8 bLength; */
  414 + 0x02, /* __u8 bDescriptorType; Configuration */
  415 + 0x19, /* __u16 wTotalLength; */
  416 + 0x00,
  417 + 0x01, /* __u8 bNumInterfaces; */
  418 + 0x01, /* __u8 bConfigurationValue; */
  419 + 0x00, /* __u8 iConfiguration; */
  420 + 0x40, /* __u8 bmAttributes;
  421 + Bit 7: Bus-powered, 6: Self-powered, 5 Remote-wakwup,
  422 + 4..0: resvd */
  423 + 0x00, /* __u8 MaxPower; */
  424 +
  425 + /* interface */
  426 + 0x09, /* __u8 if_bLength; */
  427 + 0x04, /* __u8 if_bDescriptorType; Interface */
  428 + 0x00, /* __u8 if_bInterfaceNumber; */
  429 + 0x00, /* __u8 if_bAlternateSetting; */
  430 + 0x01, /* __u8 if_bNumEndpoints; */
  431 + 0x09, /* __u8 if_bInterfaceClass; HUB_CLASSCODE */
  432 + 0x00, /* __u8 if_bInterfaceSubClass; */
  433 + 0x00, /* __u8 if_bInterfaceProtocol; */
  434 + 0x00, /* __u8 if_iInterface; */
  435 +
  436 + /* endpoint */
  437 + 0x07, /* __u8 ep_bLength; */
  438 + 0x05, /* __u8 ep_bDescriptorType; Endpoint */
  439 + 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */
  440 + 0x03, /* __u8 ep_bmAttributes; Interrupt */
  441 + 0x08, /* __u16 ep_wMaxPacketSize; */
  442 + 0x00,
  443 + 0xff /* __u8 ep_bInterval; 255 ms */
  444 +};
  445 +
  446 +/* root hub class descriptor*/
  447 +static __u8 sl811_rh_hub_des[] =
  448 +{
  449 + 0x09, /* __u8 bLength; */
  450 + 0x29, /* __u8 bDescriptorType; Hub-descriptor */
  451 + 0x01, /* __u8 bNbrPorts; */
  452 + 0x00, /* __u16 wHubCharacteristics; */
  453 + 0x00,
  454 + 0x50, /* __u8 bPwrOn2pwrGood; 2ms */
  455 + 0x00, /* __u8 bHubContrCurrent; 0 mA */
  456 + 0xfc, /* __u8 DeviceRemovable; *** 7 Ports max *** */
  457 + 0xff /* __u8 PortPwrCtrlMask; *** 7 ports max *** */
  458 +};
  459 +
  460 +/*
  461 + * helper routine for returning string descriptors in UTF-16LE
  462 + * input can actually be ISO-8859-1; ASCII is its 7-bit subset
  463 + */
  464 +static int ascii2utf (char *s, u8 *utf, int utfmax)
  465 +{
  466 + int retval;
  467 +
  468 + for (retval = 0; *s && utfmax > 1; utfmax -= 2, retval += 2) {
  469 + *utf++ = *s++;
  470 + *utf++ = 0;
  471 + }
  472 + return retval;
  473 +}
  474 +
  475 +/*
  476 + * root_hub_string is used by each host controller's root hub code,
  477 + * so that they're identified consistently throughout the system.
  478 + */
  479 +int usb_root_hub_string (int id, int serial, char *type, __u8 *data, int len)
  480 +{
  481 + char buf [30];
  482 +
  483 + /* assert (len > (2 * (sizeof (buf) + 1)));
  484 + assert (strlen (type) <= 8);*/
  485 +
  486 + /* language ids */
  487 + if (id == 0) {
  488 + *data++ = 4; *data++ = 3; /* 4 bytes data */
  489 + *data++ = 0; *data++ = 0; /* some language id */
  490 + return 4;
  491 +
  492 + /* serial number */
  493 + } else if (id == 1) {
  494 + sprintf (buf, "%x", serial);
  495 +
  496 + /* product description */
  497 + } else if (id == 2) {
  498 + sprintf (buf, "USB %s Root Hub", type);
  499 +
  500 + /* id 3 == vendor description */
  501 +
  502 + /* unsupported IDs --> "stall" */
  503 + } else
  504 + return 0;
  505 +
  506 + data [0] = 2 + ascii2utf (buf, data + 2, len - 2);
  507 + data [1] = 3;
  508 + return data [0];
  509 +}
  510 +
  511 +/* helper macro */
  512 +#define OK(x) len = (x); break
  513 +
  514 +/*
  515 + * This function handles all USB request to the the virtual root hub
  516 + */
  517 +static int sl811_rh_submit_urb(struct usb_device *usb_dev, unsigned long pipe,
  518 + void *data, int buf_len, struct devrequest *cmd)
  519 +{
  520 + __u8 data_buf[16];
  521 + __u8 *bufp = data_buf;
  522 + int len = 0;
  523 + int status = 0;
  524 +
  525 + __u16 bmRType_bReq;
  526 + __u16 wValue;
  527 + __u16 wIndex;
  528 + __u16 wLength;
  529 +
  530 + if (usb_pipeint(pipe)) {
  531 + PDEBUG(0, "interrupt transfer unimplemented!\n");
  532 + return 0;
  533 + }
  534 +
  535 + bmRType_bReq = cmd->requesttype | (cmd->request << 8);
  536 + wValue = le16_to_cpu (cmd->value);
  537 + wIndex = le16_to_cpu (cmd->index);
  538 + wLength = le16_to_cpu (cmd->length);
  539 +
  540 + PDEBUG(5, "submit rh urb, req = %d(%x) val = %#x index = %#x len=%d\n",
  541 + bmRType_bReq, bmRType_bReq, wValue, wIndex, wLength);
  542 +
  543 + /* Request Destination:
  544 + without flags: Device,
  545 + USB_RECIP_INTERFACE: interface,
  546 + USB_RECIP_ENDPOINT: endpoint,
  547 + USB_TYPE_CLASS means HUB here,
  548 + USB_RECIP_OTHER | USB_TYPE_CLASS almost ever means HUB_PORT here
  549 + */
  550 + switch (bmRType_bReq) {
  551 + case RH_GET_STATUS:
  552 + *(__u16 *)bufp = cpu_to_le16(1);
  553 + OK(2);
  554 +
  555 + case RH_GET_STATUS | USB_RECIP_INTERFACE:
  556 + *(__u16 *)bufp = cpu_to_le16(0);
  557 + OK(2);
  558 +
  559 + case RH_GET_STATUS | USB_RECIP_ENDPOINT:
  560 + *(__u16 *)bufp = cpu_to_le16(0);
  561 + OK(2);
  562 +
  563 + case RH_GET_STATUS | USB_TYPE_CLASS:
  564 + *(__u32 *)bufp = cpu_to_le32(0);
  565 + OK(4);
  566 +
  567 + case RH_GET_STATUS | USB_RECIP_OTHER | USB_TYPE_CLASS:
  568 + *(__u32 *)bufp = cpu_to_le32(rh_status.wPortChange<<16 | rh_status.wPortStatus);
  569 + OK(4);
  570 +
  571 + case RH_CLEAR_FEATURE | USB_RECIP_ENDPOINT:
  572 + switch (wValue) {
  573 + case 1:
  574 + OK(0);
  575 + }
  576 + break;
  577 +
  578 + case RH_CLEAR_FEATURE | USB_TYPE_CLASS:
  579 + switch (wValue) {
  580 + case C_HUB_LOCAL_POWER:
  581 + OK(0);
  582 +
  583 + case C_HUB_OVER_CURRENT:
  584 + OK(0);
  585 + }
  586 + break;
  587 +
  588 + case RH_CLEAR_FEATURE | USB_RECIP_OTHER | USB_TYPE_CLASS:
  589 + switch (wValue) {
  590 + case USB_PORT_FEAT_ENABLE:
  591 + rh_status.wPortStatus &= ~USB_PORT_STAT_ENABLE;
  592 + OK(0);
  593 +
  594 + case USB_PORT_FEAT_SUSPEND:
  595 + rh_status.wPortStatus &= ~USB_PORT_STAT_SUSPEND;
  596 + OK(0);
  597 +
  598 + case USB_PORT_FEAT_POWER:
  599 + rh_status.wPortStatus &= ~USB_PORT_STAT_POWER;
  600 + OK(0);
  601 +
  602 + case USB_PORT_FEAT_C_CONNECTION:
  603 + rh_status.wPortChange &= ~USB_PORT_STAT_C_CONNECTION;
  604 + OK(0);
  605 +
  606 + case USB_PORT_FEAT_C_ENABLE:
  607 + rh_status.wPortChange &= ~USB_PORT_STAT_C_ENABLE;
  608 + OK(0);
  609 +
  610 + case USB_PORT_FEAT_C_SUSPEND:
  611 + rh_status.wPortChange &= ~USB_PORT_STAT_C_SUSPEND;
  612 + OK(0);
  613 +
  614 + case USB_PORT_FEAT_C_OVER_CURRENT:
  615 + rh_status.wPortChange &= ~USB_PORT_STAT_C_OVERCURRENT;
  616 + OK(0);
  617 +
  618 + case USB_PORT_FEAT_C_RESET:
  619 + rh_status.wPortChange &= ~USB_PORT_STAT_C_RESET;
  620 + OK(0);
  621 + }
  622 + break;
  623 +
  624 + case RH_SET_FEATURE | USB_RECIP_OTHER | USB_TYPE_CLASS:
  625 + switch (wValue) {
  626 + case USB_PORT_FEAT_SUSPEND:
  627 + rh_status.wPortStatus |= USB_PORT_STAT_SUSPEND;
  628 + OK(0);
  629 +
  630 + case USB_PORT_FEAT_RESET:
  631 + rh_status.wPortStatus |= USB_PORT_STAT_RESET;
  632 + rh_status.wPortChange = 0;
  633 + rh_status.wPortChange |= USB_PORT_STAT_C_RESET;
  634 + rh_status.wPortStatus &= ~USB_PORT_STAT_RESET;
  635 + rh_status.wPortStatus |= USB_PORT_STAT_ENABLE;
  636 + OK(0);
  637 +
  638 + case USB_PORT_FEAT_POWER:
  639 + rh_status.wPortStatus |= USB_PORT_STAT_POWER;
  640 + OK(0);
  641 +
  642 + case USB_PORT_FEAT_ENABLE:
  643 + rh_status.wPortStatus |= USB_PORT_STAT_ENABLE;
  644 + OK(0);
  645 + }
  646 + break;
  647 +
  648 + case RH_SET_ADDRESS:
  649 + root_hub_devnum = wValue;
  650 + OK(0);
  651 +
  652 + case RH_GET_DESCRIPTOR:
  653 + switch ((wValue & 0xff00) >> 8) {
  654 + case USB_DT_DEVICE:
  655 + len = sizeof(sl811_rh_dev_des);
  656 + bufp = sl811_rh_dev_des;
  657 + OK(len);
  658 +
  659 + case USB_DT_CONFIG:
  660 + len = sizeof(sl811_rh_config_des);
  661 + bufp = sl811_rh_config_des;
  662 + OK(len);
  663 +
  664 + case USB_DT_STRING:
  665 + len = usb_root_hub_string(wValue & 0xff, (int)(long)0, "SL811HS", data, wLength);
  666 + if (len > 0) {
  667 + bufp = data;
  668 + OK(len);
  669 + }
  670 +
  671 + default:
  672 + status = -32;
  673 + }
  674 + break;
  675 +
  676 + case RH_GET_DESCRIPTOR | USB_TYPE_CLASS:
  677 + len = sizeof(sl811_rh_hub_des);
  678 + bufp = sl811_rh_hub_des;
  679 + OK(len);
  680 +
  681 + case RH_GET_CONFIGURATION:
  682 + bufp[0] = 0x01;
  683 + OK(1);
  684 +
  685 + case RH_SET_CONFIGURATION:
  686 + OK(0);
  687 +
  688 + default:
  689 + PDEBUG(1, "unsupported root hub command\n");
  690 + status = -32;
  691 + }
  692 +
  693 + len = min(len, buf_len);
  694 + if (data != bufp)
  695 + memcpy(data, bufp, len);
  696 +
  697 + PDEBUG(5, "len = %d, status = %d\n", len, status);
  698 +
  699 + usb_dev->status = status;
  700 + usb_dev->act_len = len;
  701 +
  702 + return status == 0 ? len : status;
  703 +}
  704 +
  705 +#endif /* CONFIG_USB_SL811HS */
include/configs/KUP4X.h
... ... @@ -118,7 +118,9 @@
118 118 #define CONFIG_COMMANDS ( CONFIG_CMD_DFL | \
119 119 CFG_CMD_DHCP | \
120 120 CFG_CMD_I2C | \
121   - CFG_CMD_IDE )
  121 + CFG_CMD_IDE | \
  122 + CFG_CMD_USB | \
  123 + CFG_CMD_FAT)
122 124  
123 125 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
124 126 #include <cmd_confdefs.h>
... ... @@ -385,6 +387,9 @@
385 387 #endif
386 388 #define CONFIG_AUTOBOOT_STOP_STR "." /* easy to stop for now */
387 389 #define CONFIG_SILENT_CONSOLE 1
  390 +
  391 +#define CONFIG_USB_STORAGE 1
  392 +#define CONFIG_USB_SL811HS 1
388 393  
389 394 #endif /* __CONFIG_H */
include/configs/NETPHONE.h
... ... @@ -67,8 +67,8 @@
67 67 #undef CONFIG_BOOTARGS
68 68 #define CONFIG_BOOTCOMMAND \
69 69 "tftpboot; " \
70   - "setenv bootargs root=/dev/nfs rw nfsroot=$(serverip):$(rootpath) " \
71   - "ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off; " \
  70 + "setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath} " \
  71 + "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " \
72 72 "bootm"
73 73  
74 74 #define CONFIG_AUTOSCRIPT
include/configs/NETTA.h
... ... @@ -65,8 +65,8 @@
65 65 #undef CONFIG_BOOTARGS
66 66 #define CONFIG_BOOTCOMMAND \
67 67 "tftpboot; " \
68   - "setenv bootargs root=/dev/nfs rw nfsroot=$(serverip):$(rootpath) " \
69   - "ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off; " \
  68 + "setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath} " \
  69 + "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " \
70 70 "bootm"
71 71  
72 72 #define CONFIG_LOADS_ECHO 0 /* echo off for serial download */
include/configs/NETVIA.h
... ... @@ -64,8 +64,8 @@
64 64 #undef CONFIG_BOOTARGS
65 65 #define CONFIG_BOOTCOMMAND \
66 66 "tftpboot; " \
67   - "setenv bootargs root=/dev/nfs rw nfsroot=$(serverip):$(rootpath) " \
68   - "ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off; " \
  67 + "setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath} " \
  68 + "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " \
69 69 "bootm"
70 70  
71 71 #define CONFIG_LOADS_ECHO 0 /* echo off for serial download */
... ... @@ -27,6 +27,8 @@
27 27 #ifndef _FAT_H_
28 28 #define _FAT_H_
29 29  
  30 +#include <asm/byteorder.h>
  31 +
30 32 #define CONFIG_SUPPORT_VFAT
31 33  
32 34 #define SECTOR_SIZE FS_BLOCK_SIZE
... ... @@ -209,13 +211,6 @@
209 211 long file_fat_read(const char *filename, void *buffer, unsigned long maxsize);
210 212 const char *file_getfsname(int idx);
211 213 int fat_register_device(block_dev_desc_t *dev_desc, int part_no);
212   -
213   -#ifdef CONFIG_PXA250
214   -#undef FAT2CPU16
215   -#define FAT2CPU16(x) x
216   -#undef FAT2CPU32
217   -#define FAT2CPU32(x) x
218   -#endif
219 214  
220 215 #endif /* _FAT_H_ */
... ... @@ -12,7 +12,7 @@
12 12 *
13 13 * This program is distributed in the hope that it will be useful,
14 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 16 * GNU General Public License for more details.
17 17 *
18 18 * You should have received a copy of the GNU General Public License
19 19  
... ... @@ -29,15 +29,15 @@
29 29 #include <usb_defs.h>
30 30  
31 31 /* Everything is aribtrary */
32   -#define USB_ALTSETTINGALLOC 4
33   -#define USB_MAXALTSETTING 128 /* Hard limit */
  32 +#define USB_ALTSETTINGALLOC 4
  33 +#define USB_MAXALTSETTING 128 /* Hard limit */
34 34  
35   -#define USB_MAX_DEVICE 32
36   -#define USB_MAXCONFIG 8
37   -#define USB_MAXINTERFACES 8
38   -#define USB_MAXENDPOINTS 16
39   -#define USB_MAXCHILDREN 8 /* This is arbitrary */
40   -#define USB_MAX_HUB 16
  35 +#define USB_MAX_DEVICE 32
  36 +#define USB_MAXCONFIG 8
  37 +#define USB_MAXINTERFACES 8
  38 +#define USB_MAXENDPOINTS 16
  39 +#define USB_MAXCHILDREN 8 /* This is arbitrary */
  40 +#define USB_MAX_HUB 16
41 41  
42 42 #define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
43 43  
44 44  
45 45  
... ... @@ -125,19 +125,19 @@
125 125 unsigned char bmAttributes;
126 126 unsigned char MaxPower;
127 127  
128   - unsigned char no_of_if; /* number of interfaces */
  128 + unsigned char no_of_if; /* number of interfaces */
129 129 struct usb_interface_descriptor if_desc[USB_MAXINTERFACES];
130 130 } __attribute__ ((packed));
131 131  
132 132  
133 133 struct usb_device {
134   - int devnum; /* Device number on USB bus */
135   - int slow; /* Slow device? */
136   - char mf[32]; /* manufacturer */
137   - char prod[32]; /* product */
138   - char serial[32]; /* serial number */
  134 + int devnum; /* Device number on USB bus */
  135 + int slow; /* Slow device? */
  136 + char mf[32]; /* manufacturer */
  137 + char prod[32]; /* product */
  138 + char serial[32]; /* serial number */
139 139  
140   - int maxpacketsize; /* Maximum packet size; encoded as 0,1,2,3 = 8,16,32,64 */
  140 + int maxpacketsize; /* Maximum packet size; encoded as 0,1,2,3 = 8,16,32,64 */
141 141 unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */
142 142 unsigned int halted[2]; /* endpoint halts; one bit per endpoint # & direction; */
143 143 /* [0] = IN, [1] = OUT */
... ... @@ -152,7 +152,7 @@
152 152 int string_langid; /* language ID for strings */
153 153 int (*irq_handle)(struct usb_device *dev);
154 154 unsigned long irq_status;
155   - int irq_act_len; /* transfered bytes */
  155 + int irq_act_len; /* transfered bytes */
156 156 void *privptr;
157 157 /*
158 158 * Child devices - if this is a hub device
... ... @@ -169,7 +169,7 @@
169 169 * this is how the lowlevel part communicate with the outer world
170 170 */
171 171  
172   -#if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI)
  172 +#if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || defined (CONFIG_USB_SL811HS)
173 173 int usb_lowlevel_init(void);
174 174 int usb_lowlevel_stop(void);
175 175 int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,int transfer_len);
... ... @@ -180,7 +180,7 @@
180 180  
181 181 /* Defines */
182 182 #define USB_UHCI_VEND_ID 0x8086
183   -#define USB_UHCI_DEV_ID 0x7112
  183 +#define USB_UHCI_DEV_ID 0x7112
184 184  
185 185 #else
186 186 #error USB Lowlevel not defined
... ... @@ -242,8 +242,8 @@
242 242 ({ unsigned long x_ = (unsigned long)x; \
243 243 (unsigned long)( \
244 244 ((x_ & 0x000000FFUL) << 24) | \
245   - ((x_ & 0x0000FF00UL) << 8) | \
246   - ((x_ & 0x00FF0000UL) >> 8) | \
  245 + ((x_ & 0x0000FF00UL) << 8) | \
  246 + ((x_ & 0x00FF0000UL) >> 8) | \
247 247 ((x_ & 0xFF000000UL) >> 24) ); \
248 248 })
249 249 #endif /* LITTLEENDIAN */
... ... @@ -298,7 +298,7 @@
298 298  
299 299 /* The D0/D1 toggle bits */
300 300 #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> ep) & 1)
301   -#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << ep))
  301 +#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << ep))
302 302 #define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << ep)) | ((bit) << ep))
303 303  
304 304 /* Endpoint halt control/status */