/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2017 Emmanuel Vadot <[email protected]>4*5* Copyright (c) 2020 Oskar Holmlund <[email protected]>6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR17* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES18* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.19* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,20* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,21* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED23* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,24* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _TI_DPLL_CLOCK_H_30#define _TI_DPLL_CLOCK_H_3132#include <dev/clk/clk.h>3334/* Registers are described in AM335x TRM chapter 8.1.12.2.* */3536/* Register offsets */37#define CM_CLKSEL_DPLL_PERIPH 0x49C3839/* CM_IDLEST_DPLL_xxx */40#define ST_MN_BYPASS_MASK 0x010041#define ST_MN_BYPASS_SHIFT 842#define ST_DPLL_CLK_MASK 0x00014344/* CM_CLKMODE_DPLL_DPLL_EN feature flag */45#define LOW_POWER_STOP_MODE_FLAG 0x0146#define MN_BYPASS_MODE_FLAG 0x0247#define IDLE_BYPASS_LOW_POWER_MODE_FLAG 0x0448#define IDLE_BYPASS_FAST_RELOCK_MODE_FLAG 0x0849#define LOCK_MODE_FLAG 0x105051/* CM_CLKMODE_DPLL_xxx */52#define DPLL_EN_LOW_POWER_STOP_MODE 0x0153#define DPLL_EN_MN_BYPASS_MODE 0x0454#define DPLL_EN_IDLE_BYPASS_LOW_POWER_MODE 0x0555#define DPLL_EN_IDLE_BYPASS_FAST_RELOCK_MODE 0x0656#define DPLL_EN_LOCK_MODE 0x075758#define TI_CLK_FACTOR_ZERO_BASED 0x000259#define TI_CLK_FACTOR_FIXED 0x000860#define TI_CLK_FACTOR_MIN_VALUE 0x002061#define TI_CLK_FACTOR_MAX_VALUE 0x00406263/* Based on aw_clk_factor sys/arm/allwinner/clkng/aw_clk.h */64struct ti_clk_factor {65uint32_t shift; /* Shift bits for the factor */66uint32_t mask; /* Mask to get the factor */67uint32_t width; /* Number of bits for the factor */68uint32_t value; /* Fixed value */6970uint32_t min_value;71uint32_t max_value;7273uint32_t flags; /* Flags */74};7576struct ti_clk_dpll_def {77struct clknode_init_def clkdef;7879uint32_t ti_clkmode_offset; /* control */80uint8_t ti_clkmode_flags;8182uint32_t ti_idlest_offset;8384uint32_t ti_clksel_offset; /* mult-div1 */85struct ti_clk_factor ti_clksel_mult;86struct ti_clk_factor ti_clksel_div;8788uint32_t ti_autoidle_offset;89};9091int ti_clknode_dpll_register(struct clkdom *clkdom, struct ti_clk_dpll_def *clkdef);9293#endif /* _TI_DPLL_CLOCK_H_ */949596