mpp.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * arch/arm/mach-kirkwood/mpp.c
  3. *
  4. * MPP functions for Marvell Kirkwood SoCs
  5. * Referenced from Linux kernel source
  6. *
  7. * This file is licensed under the terms of the GNU General Public
  8. * License version 2. This program is licensed "as is" without any
  9. * warranty of any kind, whether express or implied.
  10. */
  11. #include <common.h>
  12. #include <asm/arch/kirkwood.h>
  13. #include <asm/arch/mpp.h>
  14. static u32 kirkwood_variant(void)
  15. {
  16. switch (readl(KW_REG_DEVICE_ID) & 0x03) {
  17. case 1:
  18. return MPP_F6192_MASK;
  19. case 2:
  20. return MPP_F6281_MASK;
  21. default:
  22. debug("MPP setup: unknown kirkwood variant\n");
  23. return 0;
  24. }
  25. }
  26. #define MPP_CTRL(i) (KW_MPP_BASE + (i* 4))
  27. #define MPP_NR_REGS (1 + MPP_MAX/8)
  28. void kirkwood_mpp_conf(u32 *mpp_list)
  29. {
  30. u32 mpp_ctrl[MPP_NR_REGS];
  31. unsigned int variant_mask;
  32. int i;
  33. variant_mask = kirkwood_variant();
  34. if (!variant_mask)
  35. return;
  36. debug( "initial MPP regs:");
  37. for (i = 0; i < MPP_NR_REGS; i++) {
  38. mpp_ctrl[i] = readl(MPP_CTRL(i));
  39. debug(" %08x", mpp_ctrl[i]);
  40. }
  41. debug("\n");
  42. while (*mpp_list) {
  43. unsigned int num = MPP_NUM(*mpp_list);
  44. unsigned int sel = MPP_SEL(*mpp_list);
  45. int shift;
  46. if (num > MPP_MAX) {
  47. debug("kirkwood_mpp_conf: invalid MPP "
  48. "number (%u)\n", num);
  49. continue;
  50. }
  51. if (!(*mpp_list & variant_mask)) {
  52. debug("kirkwood_mpp_conf: requested MPP%u config "
  53. "unavailable on this hardware\n", num);
  54. continue;
  55. }
  56. shift = (num & 7) << 2;
  57. mpp_ctrl[num / 8] &= ~(0xf << shift);
  58. mpp_ctrl[num / 8] |= sel << shift;
  59. mpp_list++;
  60. }
  61. debug(" final MPP regs:");
  62. for (i = 0; i < MPP_NR_REGS; i++) {
  63. writel(mpp_ctrl[i], MPP_CTRL(i));
  64. debug(" %08x", mpp_ctrl[i]);
  65. }
  66. debug("\n");
  67. }