1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2007-2012
4 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
5 * Tom Cubie <tangliang@allwinnertech.com>
7 * (C) Copyright 2013 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
12 #include <asm/arch/clock.h>
13 #include <asm/arch/gpio.h>
14 #include <asm/arch/prcm.h>
15 #include <asm/arch/gtbus.h>
16 #include <asm/arch/sys_proto.h>
18 __weak void clock_init_sec(void)
22 __weak void gtbus_init(void)
28 #ifdef CONFIG_SPL_BUILD
38 /* These functions are shared between various SoCs so put them here. */
39 #if defined CONFIG_SUNXI_GEN_SUN6I && !defined CONFIG_MACH_SUN9I
40 int clock_twi_onoff(int port, int state)
42 struct sunxi_ccm_reg *const ccm =
43 (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
48 PRCM_APB0_GATE_PIO | PRCM_APB0_GATE_I2C);
51 PRCM_APB0_GATE_PIO | PRCM_APB0_GATE_I2C);
55 /* set the apb clock gate and reset for twi */
57 setbits_le32(&ccm->apb2_gate,
58 CLK_GATE_OPEN << (APB2_GATE_TWI_SHIFT + port));
59 setbits_le32(&ccm->apb2_reset_cfg,
60 1 << (APB2_RESET_TWI_SHIFT + port));
62 clrbits_le32(&ccm->apb2_reset_cfg,
63 1 << (APB2_RESET_TWI_SHIFT + port));
64 clrbits_le32(&ccm->apb2_gate,
65 CLK_GATE_OPEN << (APB2_GATE_TWI_SHIFT + port));