1*be82b3a0SEmmanuel Vadot#- 2*be82b3a0SEmmanuel Vadot# Copyright 2016 Michal Meloun <mmel@FreeBSD.org> 3*be82b3a0SEmmanuel Vadot# All rights reserved. 4*be82b3a0SEmmanuel Vadot# 5*be82b3a0SEmmanuel Vadot# Redistribution and use in source and binary forms, with or without 6*be82b3a0SEmmanuel Vadot# modification, are permitted provided that the following conditions 7*be82b3a0SEmmanuel Vadot# are met: 8*be82b3a0SEmmanuel Vadot# 1. Redistributions of source code must retain the above copyright 9*be82b3a0SEmmanuel Vadot# notice, this list of conditions and the following disclaimer. 10*be82b3a0SEmmanuel Vadot# 2. Redistributions in binary form must reproduce the above copyright 11*be82b3a0SEmmanuel Vadot# notice, this list of conditions and the following disclaimer in the 12*be82b3a0SEmmanuel Vadot# documentation and/or other materials provided with the distribution. 13*be82b3a0SEmmanuel Vadot# 14*be82b3a0SEmmanuel Vadot# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*be82b3a0SEmmanuel Vadot# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*be82b3a0SEmmanuel Vadot# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*be82b3a0SEmmanuel Vadot# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*be82b3a0SEmmanuel Vadot# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*be82b3a0SEmmanuel Vadot# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*be82b3a0SEmmanuel Vadot# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*be82b3a0SEmmanuel Vadot# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*be82b3a0SEmmanuel Vadot# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*be82b3a0SEmmanuel Vadot# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*be82b3a0SEmmanuel Vadot# SUCH DAMAGE. 25*be82b3a0SEmmanuel Vadot# 26*be82b3a0SEmmanuel Vadot# 27*be82b3a0SEmmanuel Vadot 28*be82b3a0SEmmanuel VadotINTERFACE clknode; 29*be82b3a0SEmmanuel Vadot 30*be82b3a0SEmmanuel VadotHEADER { 31*be82b3a0SEmmanuel Vadot struct clknode; 32*be82b3a0SEmmanuel Vadot} 33*be82b3a0SEmmanuel Vadot 34*be82b3a0SEmmanuel Vadot# 35*be82b3a0SEmmanuel Vadot# Initialize clock node, get shanpshot of cached values 36*be82b3a0SEmmanuel Vadot# 37*be82b3a0SEmmanuel VadotMETHOD int init { 38*be82b3a0SEmmanuel Vadot struct clknode *clk; 39*be82b3a0SEmmanuel Vadot device_t dev; 40*be82b3a0SEmmanuel Vadot}; 41*be82b3a0SEmmanuel Vadot 42*be82b3a0SEmmanuel Vadot# 43*be82b3a0SEmmanuel Vadot# Recalculate frequency 44*be82b3a0SEmmanuel Vadot# req - in/out recalulated frequency 45*be82b3a0SEmmanuel Vadot# 46*be82b3a0SEmmanuel VadotMETHOD int recalc_freq { 47*be82b3a0SEmmanuel Vadot struct clknode *clk; 48*be82b3a0SEmmanuel Vadot uint64_t *freq; 49*be82b3a0SEmmanuel Vadot}; 50*be82b3a0SEmmanuel Vadot 51*be82b3a0SEmmanuel Vadot# 52*be82b3a0SEmmanuel Vadot# Set frequency 53*be82b3a0SEmmanuel Vadot# fin - parent (input)frequency. 54*be82b3a0SEmmanuel Vadot# fout - requested output freqency. If clock cannot change frequency, 55*be82b3a0SEmmanuel Vadot# then must return new requested frequency for his parent 56*be82b3a0SEmmanuel VadotMETHOD int set_freq { 57*be82b3a0SEmmanuel Vadot struct clknode *clk; 58*be82b3a0SEmmanuel Vadot uint64_t fin; 59*be82b3a0SEmmanuel Vadot uint64_t *fout; 60*be82b3a0SEmmanuel Vadot int flags; 61*be82b3a0SEmmanuel Vadot int *done; 62*be82b3a0SEmmanuel Vadot}; 63*be82b3a0SEmmanuel Vadot 64*be82b3a0SEmmanuel Vadot# 65*be82b3a0SEmmanuel Vadot# Enable/disable clock 66*be82b3a0SEmmanuel Vadot# 67*be82b3a0SEmmanuel VadotMETHOD int set_gate { 68*be82b3a0SEmmanuel Vadot struct clknode *clk; 69*be82b3a0SEmmanuel Vadot bool enable; 70*be82b3a0SEmmanuel Vadot}; 71*be82b3a0SEmmanuel Vadot 72*be82b3a0SEmmanuel Vadot# 73*be82b3a0SEmmanuel Vadot# Get gate status 74*be82b3a0SEmmanuel Vadot# Return: ENXIO - method is not implemented 75*be82b3a0SEmmanuel Vadot# ENOENT - HW doesn't support reading of gate enable 76*be82b3a0SEmmanuel Vadot# 0 - success 77*be82b3a0SEmmanuel Vadot# 78*be82b3a0SEmmanuel VadotMETHOD int get_gate { 79*be82b3a0SEmmanuel Vadot struct clknode *clk; 80*be82b3a0SEmmanuel Vadot bool *enabled; 81*be82b3a0SEmmanuel Vadot}; 82*be82b3a0SEmmanuel Vadot 83*be82b3a0SEmmanuel Vadot# 84*be82b3a0SEmmanuel Vadot# Set multiplexer 85*be82b3a0SEmmanuel Vadot# 86*be82b3a0SEmmanuel VadotMETHOD int set_mux { 87*be82b3a0SEmmanuel Vadot struct clknode *clk; 88*be82b3a0SEmmanuel Vadot int idx; 89*be82b3a0SEmmanuel Vadot}; 90