usb.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include <common.h>
  24. #include <mpc8xx.h>
  25. #include "../common/kup.h"
  26. #define SL811_ADR (0x50000000)
  27. #define SL811_DAT (0x50000001)
  28. static void sl811_write_index_data (__u8 index, __u8 data)
  29. {
  30. *(volatile unsigned char *) (SL811_ADR) = index;
  31. __asm__ ("eieio");
  32. *(volatile unsigned char *) (SL811_DAT) = data;
  33. __asm__ ("eieio");
  34. }
  35. static __u8 sl811_read_index_data (__u8 index)
  36. {
  37. __u8 data;
  38. *(volatile unsigned char *) (SL811_ADR) = index;
  39. __asm__ ("eieio");
  40. data = *(volatile unsigned char *) (SL811_DAT);
  41. __asm__ ("eieio");
  42. return (data);
  43. }
  44. int usb_init_kup4x (void)
  45. {
  46. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  47. volatile memctl8xx_t *memctl = &immap->im_memctl;
  48. int i;
  49. unsigned char tmp;
  50. memctl = &immap->im_memctl;
  51. memctl->memc_or7 = 0xFFFF8726;
  52. memctl->memc_br7 = 0x50000401; /* start at 0x50000000 */
  53. /* BP 14 low = USB ON */
  54. immap->im_cpm.cp_pbdat &= ~(BP_USB_VCC);
  55. /* PB 14 nomal port */
  56. immap->im_cpm.cp_pbpar &= ~(BP_USB_VCC);
  57. /* output */
  58. immap->im_cpm.cp_pbdir |= (BP_USB_VCC);
  59. puts ("USB: ");
  60. for (i = 0x10; i < 0xff; i++) {
  61. sl811_write_index_data (i, i);
  62. tmp = (sl811_read_index_data (i));
  63. if (tmp != i) {
  64. printf ("SL811 compare error index=0x%02x read=0x%02x\n", i, tmp);
  65. return (-1);
  66. }
  67. }
  68. printf ("SL811 ready\n");
  69. return (0);
  70. }