1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+ 2989ce049SDarwin Rambo /* 3989ce049SDarwin Rambo * Copyright 2013 Broadcom Corporation. 4989ce049SDarwin Rambo */ 5989ce049SDarwin Rambo 6989ce049SDarwin Rambo #include <common.h> 7989ce049SDarwin Rambo #include <asm/io.h> 81221ce45SMasahiro Yamada #include <linux/errno.h> 9989ce049SDarwin Rambo #include <asm/arch/sysmap.h> 10989ce049SDarwin Rambo #include <asm/kona-common/clk.h> 11989ce049SDarwin Rambo #include "clk-core.h" 12989ce049SDarwin Rambo 13989ce049SDarwin Rambo /* Enable appropriate clocks for a BSC/I2C port */ clk_bsc_enable(void * base)14989ce049SDarwin Ramboint clk_bsc_enable(void *base) 15989ce049SDarwin Rambo { 16989ce049SDarwin Rambo int ret; 17989ce049SDarwin Rambo char *bscstr, *apbstr; 18989ce049SDarwin Rambo 19989ce049SDarwin Rambo switch ((u32) base) { 20989ce049SDarwin Rambo case PMU_BSC_BASE_ADDR: 21989ce049SDarwin Rambo /* PMU clock is always enabled */ 22989ce049SDarwin Rambo return 0; 23989ce049SDarwin Rambo case BSC1_BASE_ADDR: 24989ce049SDarwin Rambo bscstr = "bsc1_clk"; 25989ce049SDarwin Rambo apbstr = "bsc1_apb_clk"; 26989ce049SDarwin Rambo break; 27989ce049SDarwin Rambo case BSC2_BASE_ADDR: 28989ce049SDarwin Rambo bscstr = "bsc2_clk"; 29989ce049SDarwin Rambo apbstr = "bsc2_apb_clk"; 30989ce049SDarwin Rambo break; 31989ce049SDarwin Rambo case BSC3_BASE_ADDR: 32989ce049SDarwin Rambo bscstr = "bsc3_clk"; 33989ce049SDarwin Rambo apbstr = "bsc3_apb_clk"; 34989ce049SDarwin Rambo break; 35989ce049SDarwin Rambo default: 36989ce049SDarwin Rambo printf("%s: base 0x%p not found\n", __func__, base); 37989ce049SDarwin Rambo return -EINVAL; 38989ce049SDarwin Rambo } 39989ce049SDarwin Rambo 40989ce049SDarwin Rambo /* Note that the bus clock must be enabled first */ 41989ce049SDarwin Rambo 42989ce049SDarwin Rambo ret = clk_get_and_enable(apbstr); 43989ce049SDarwin Rambo if (ret) 44989ce049SDarwin Rambo return ret; 45989ce049SDarwin Rambo 46989ce049SDarwin Rambo ret = clk_get_and_enable(bscstr); 47989ce049SDarwin Rambo if (ret) 48989ce049SDarwin Rambo return ret; 49989ce049SDarwin Rambo 50989ce049SDarwin Rambo return 0; 51989ce049SDarwin Rambo } 52