Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2013 Broadcom Corporation. |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 6 | #include <asm/io.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 7 | #include <linux/errno.h> |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 8 | #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 */ |
| 13 | int 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 | } |