softswitch.c 866 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * cmd_softswitch.c - set the softswitch for bf60x
  3. *
  4. * Copyright (c) 2012 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <common.h>
  9. #include <command.h>
  10. #include <asm/blackfin.h>
  11. #include <asm/soft_switch.h>
  12. int do_softswitch(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  13. {
  14. int switchaddr, value, pin, port;
  15. if (argc != 5)
  16. return CMD_RET_USAGE;
  17. if (strcmp(argv[2], "GPA") == 0)
  18. port = IO_PORT_A;
  19. else if (strcmp(argv[2], "GPB") == 0)
  20. port = IO_PORT_B;
  21. else
  22. return CMD_RET_USAGE;
  23. switchaddr = simple_strtoul(argv[1], NULL, 16);
  24. pin = simple_strtoul(argv[3], NULL, 16);
  25. value = simple_strtoul(argv[4], NULL, 16);
  26. config_switch_bit(switchaddr, port, (1 << pin), IO_PORT_OUTPUT, value);
  27. return 0;
  28. }
  29. U_BOOT_CMD(
  30. softswitch_output, 5, 1, do_softswitch,
  31. "switchaddr GPA/GPB pin_offset value",
  32. ""
  33. );