1 /*
2  * Copyright 2013 Broadcom Corporation.
3  *
4  * SPDX-License-Identifier:      GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <asm/io.h>
9 #include <asm/errno.h>
10 #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 */
15 int 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 }
53