ebi_smc911x.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. * MA 02111-1307 USA
  18. */
  19. #include <common.h>
  20. #include <asm/io.h>
  21. #include "vct.h"
  22. /*
  23. * EBI initialization for SMC911x access
  24. */
  25. int ebi_init_smc911x(void)
  26. {
  27. reg_write(EBI_DEV1_CONFIG1(EBI_BASE), 0x00003020);
  28. reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
  29. reg_write(EBI_DEV1_TIM1_RD1(EBI_BASE), 0x00501100);
  30. reg_write(EBI_DEV1_TIM1_RD2(EBI_BASE), 0x0FF02111);
  31. reg_write(EBI_DEV1_TIM_EXT(EBI_BASE), 0xFFF00000);
  32. reg_write(EBI_DEV1_EXT_ACC(EBI_BASE), 0x0FFFFFFF);
  33. reg_write(EBI_DEV1_TIM1_WR1(EBI_BASE), 0x05001100);
  34. reg_write(EBI_DEV1_TIM1_WR2(EBI_BASE), 0x3FC21110);
  35. return 0;
  36. }
  37. /*
  38. * Accessor functions replacing the "weak" functions in
  39. * drivers/net/smc911x.c
  40. */
  41. u32 smc911x_reg_read(u32 addr)
  42. {
  43. volatile u32 data;
  44. reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
  45. ebi_wait();
  46. reg_write(EBI_CPU_IO_ACCS(EBI_BASE), (EXT_DEVICE_CHANNEL_1 | addr));
  47. ebi_wait();
  48. data = reg_read(EBI_IO_ACCS_DATA(EBI_BASE));
  49. return (data);
  50. }
  51. void smc911x_reg_write(u32 addr, u32 data)
  52. {
  53. reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
  54. ebi_wait();
  55. reg_write(EBI_IO_ACCS_DATA(EBI_BASE), data);
  56. reg_write(EBI_CPU_IO_ACCS(EBI_BASE),
  57. EXT_DEVICE_CHANNEL_1 | EBI_CPU_WRITE | addr);
  58. ebi_wait();
  59. }
  60. void pkt_data_push(u32 addr, u32 data)
  61. {
  62. reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004A);
  63. ebi_wait();
  64. reg_write(EBI_IO_ACCS_DATA(EBI_BASE), data);
  65. reg_write(EBI_CPU_IO_ACCS(EBI_BASE),
  66. EXT_DEVICE_CHANNEL_1 | EBI_CPU_WRITE | addr);
  67. ebi_wait();
  68. return;
  69. }
  70. u32 pkt_data_pull(u32 addr)
  71. {
  72. volatile u32 data;
  73. reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004A);
  74. ebi_wait();
  75. reg_write(EBI_CPU_IO_ACCS(EBI_BASE), (EXT_DEVICE_CHANNEL_1 | addr));
  76. ebi_wait();
  77. data = reg_read(EBI_IO_ACCS_DATA(EBI_BASE));
  78. return data;
  79. }