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