clk-bsc.c 967 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2013 Broadcom Corporation.
  4. */
  5. #include <common.h>
  6. #include <asm/io.h>
  7. #include <linux/errno.h>
  8. #include <asm/arch/sysmap.h>
  9. #include <asm/kona-common/clk.h>
  10. #include "clk-core.h"
  11. /* Enable appropriate clocks for a BSC/I2C port */
  12. int clk_bsc_enable(void *base)
  13. {
  14. int ret;
  15. char *bscstr, *apbstr;
  16. switch ((u32) base) {
  17. case PMU_BSC_BASE_ADDR:
  18. /* PMU clock is always enabled */
  19. return 0;
  20. case BSC1_BASE_ADDR:
  21. bscstr = "bsc1_clk";
  22. apbstr = "bsc1_apb_clk";
  23. break;
  24. case BSC2_BASE_ADDR:
  25. bscstr = "bsc2_clk";
  26. apbstr = "bsc2_apb_clk";
  27. break;
  28. case BSC3_BASE_ADDR:
  29. bscstr = "bsc3_clk";
  30. apbstr = "bsc3_apb_clk";
  31. break;
  32. default:
  33. printf("%s: base 0x%p not found\n", __func__, base);
  34. return -EINVAL;
  35. }
  36. /* Note that the bus clock must be enabled first */
  37. ret = clk_get_and_enable(apbstr);
  38. if (ret)
  39. return ret;
  40. ret = clk_get_and_enable(bscstr);
  41. if (ret)
  42. return ret;
  43. return 0;
  44. }