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