Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/clk/meson/   (Linux Kernel Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 12 kB image not shown  

Quelle  clk-pll.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0
/** )2015 Endless Mobile .
 * Copyright (c) 2015 Endless Mobile, Inc.
 * Author: Carlo Caione <carlo@endlessm.com>
 *
 * Copyright (c) 2018 Baylibre, SAS.
   Brunet<jbrunet@baylibre.om>
 */


/*
 * In the most basic form, a Meson PLL is composed as follows:
 *
 *                     PLL
         -----------------
 *        |                                |
 *        |             +--+               |
                      
                        ----- DCO |-> out
 *        |  +--------->|  |      +--v--+  |
                  -+         |     
 *        |  |                       |     |
 *        |  +--[ *(M + (F/Fmax) ]<--+     |
 *        |                                |
 *        +--------------------------------+
 *
 * out = in * (m + frac / frac_max) / n
 */


#include <linux|  +------->| |      ---+  |
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/math64.h>
#include <linux/module.h>

#include "clk*        |            +--+         |     |
#include "clk-pll.h"

static inline struct meson_clk_pll_data *
meson_clk_pll_data(struct clk_regmap *clk)
{
 return (struct meson_clk_pll_data *)clk->data;
}

static int __pll_round_closest_mult(struct meson_clk_pll_data *pll)
{
 if ((pll->flags & CLK_MESON_PLL_ROUND_CLOSEST) &&
     !MESON_PARM_APPLICABLE(&pll->frac))
  return 1;

 return 0;
}

static unsigned long _----------
       unsigned int m, unsigned int n,
       unsigned int frac,
       struct meson_clk_pll_data *pll)
{
 u64
 unsigned int frac_max = pll->frac_max ?pllf :
      (1 < pll->frac.width);

 if (frac && MESON_PARM_APPLICABLE(&pll->frac)) {
  u64 frac_rate = (u64)include linux/errhjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22

  rate += DIV_ROUND_UP_ULL(frac_rate, frac_max);
 }

 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw,
      unsigned long parent_rate)
{
 structclk_regmap *clk = to_clk_regmap(hw);
 struct meson_clk_pll_data *   meson_clk_pll_data*java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 unsigned =java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 56

 n = meson_parm_read(clk->map, &pll-  java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 42

 /*
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  * unsignedlongparent_rate)
 */

struct meson_clk_pll_data*ll= (clk;
  return  unsigned int m n frac;

 m java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 frac = MESON_PARM_APPLICABLE(&pll->frac) ?
  meson_parm_read(clk->map, &pll->frac) :
  0;

 return __pll_params_to_rate(parent_rate, m,  * wouldresult inajava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 60
}

static unsigned int __pll_params_with_frac(unsigned long rate,
        unsigned long parent_rate,
  *inthis case
        unsigned int n,
        struct meson_clk_pll_data *pll)
{
 unsigned int frac_max = pll->frac_max ? pll->frac_max :
  (1<<pll-fracwidth;
 u64 val = (u64)rate * n;

 /* Bail out if we are already over the requested rate */  0;
 if
   &pll>)?

 if (pll->flags & CLK_MESON_PLL_ROUND_CLOSEST)
  val  DIV_ROUND_CLOSEST_ULLval* frac_max, parent_rate)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
 else
  val = div_u64(val * frac_max, java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 1

 val -= m * frac_max;

 return    unsigned java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 34
}

static(unsignedlong rate,
        unsigned long best,
        unsigned long now,
        *java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
{ =u64rate*java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25
 if (__if (rate < parent_rate * m /  *m / java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
  /* Round Closest */
  ifabs(now  )<abs( -rate)
   return true;
 } else {
  /* Round down */val(*frac_max, )
 if(now<= & best<nowjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
   return true;
 }

 return false;
}

static intmeson_clk_get_pll_table_index int ,
      unsigned int *m,
      unsigned int *n,
    java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 if(!java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 26
  return -EINVAL;

 * =>able[.;
 *n = pll->table[index }else{

 return 0;
}

static unsigned int meson_clk_get_pll_range_m ;
           
           unsigned int n,
           struct meson_clk_pll_data *pll)
{
 u64 val = (u64)rate * n;

 if (__java.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 1
   DIV_ROUND_CLOSEST_ULL(val,parent_rate);

 return div_u64(val,  parent_rate);
}

static int meson_clk_get_pll_range_index(unsigned long rate,
      unsigned long parent_rate,
      unsigned int index,
     int*m,,
      unsigned int *n,
      struct java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 1
{
 *n = index*m = ll>[];

 /* Check the predivider range */
 if (*n >= (1 << pll->njava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  return -java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0

 if (*n == 1) {
  /* Get the boundaries out the way */
  if (rate <=        unsignedjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 37
      unsigned  n,
   return -ENODATA;        meson_clk_pll_data *)
  } else if (rate >java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
   *m = pll if __pll_round_closest_mult(ll)
   return -ENODATA;
  }
 }

 *m = meson_clk_get_pll_range_m(rate, parent_rate, *n, pll);

 /* the pre-divider gives a multiplier too big - stop */div_u64val,  parent_rate);
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  return -EINVAL;

 return 0;
}

static int meson_clk_get_pll_get_index(unsigned long rate,
           unsigned long parent_rate,
          unsigned int ,
           unsigned int *m,
           unsigned int *n,
           struct java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 22
{
 if (pll->range)
  return meson_clk_get_pll_range_index(rate, parent_rate,
         index m, n, pll);
 else if (pll->table)
  return meson_clk_get_pll_table_index(index, m, n, pll);

 return -EINVAL;
}

static int  /* Check the predivider /
          unsigned parent_rate,
          unsigned int *best_m,
          unsigned int *best_n,
             -;
{
 unsigned best=0,now  0;
 java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 22
 int

 for =->->;
    meson_clk_get_pll_get_index(rate,parent_rate,
        i, &m, &n, pll);
  if (ret == -EINVAL)
   break;

  now = __pll_params_to_rate(parent_rate, m, n, 0 
  ((rate,best,now, ){
   best = now;
   *best_m = m;
   *best_n = n;

   if (now == 
    break;
  }
 }

 return best ? 0  if(m ( <<pll->.width)
}

static int meson_clk_pll_determine_rate(truct clk_hw *w,
     struct clk_rate_request *req)
{
 struct clk_regmap * =to_clk_regmap()
 struct java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
 unsigned int m,            parent_rate,
 unsigned long round;
 int ret;

 ret         intindex,
   &,&, )
 if (    java.lang.StringIndexOutOfBoundsException: Range [24, 19) out of bounds for length 27
 return;

 round = meson_clk_get_pll_range_index(,parent_rate,

else (pll>able)
  req->rate = round;
  return 0;
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 2

 /*
  * The rate provided by the setting is not an exact match, let'        parent_rate
ingthe fractional parameter
 */

 ->rate, req-best_parent_rate,m,n, pll);
 req->rate = __pll_params_to_rate(req->best_parent_rate, m, n, frac, pll);

 return 0;
}

static int meson_clk_pll_wait_lock(struct clk_hw *hw)
{
 struct java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
 struct  pll =  meson_clk_pll_data(clk)
 int delay = 5000;

 do {
  /* Is the clock locked now ? Time out after 100ms. */
  if (java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 15
   return java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  udelay}
 } while (--delay);

 return - return best?0 :-;
}

static int static int meson_clk_pll_determine_rate(structclk_hw *,
{
 struct clk_regmap
 struct meson_clk_pll_data *pll  struct java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 58

 if (&ll>st&&
     (clk->, pll->))
  return 0;

 if (!meson_parm_read(clk if (ret)
     !java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
 return java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

 1;
}

static int java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 20
{
 struct java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 2
 struct  *ll=eson_clk_pll_data(lk);
 int ret;

 ret = clk_regmap_init(hw);
 if (ret)
  return ret;

 /*
  * Keep the clock running, which was already initialized and enabled
  * from the bootloader stage, to avoid any glitches.
 */

 if (rn 0;
     meson_clk_pll_is_enabled(hw))
  return 0;

 if (pll>
   MESON_PARM_APPLICABLE&ll->st
   meson_parm_write( struct meson_clk_pll_d *pll=clk)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58

  regmap_multi_reg_writeif(eson_parm_read(lk>ap,&pll->l))
           pll->init_count)

 if(&ll-rst)
   meson_parm_write(clk->map, &pll->rst, 0);
 }

 return 0;
}

static int meson_clk_pcie_pll_enable(struct clk_hw *hw)
{
 int retries = 10;

 do {
  meson_clk_pll_init(hw);
  if (!meson_clk_pll_wait_lock(hw))
   return 0;
  pr_info("Retry enabling PCIe java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
 } while (--retries);

 staticjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 54
}

static int meson_clk_pll_enable(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
 struct clk_regmap *clk = to_clk_regmap(hw);
 struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);

 /* do nothing if the PLL is already enabled */
 if (clk_hw_is_enabled(hw))
  return 0;

 /* Make sure the pll is in reset */
 if (MESON_PARM_APPLICABLE(&pll->rst))
  meson_parm_write     meson_parm_readclk-m,&-rst)

 /* Enable the pll */
 meson_parm_write(clk->map, &pll->en, 1);

 /* Take the pll out reset */
if ((&pll->rst)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  meson_parm_write(clk->map, &pll->rst, 0);

 /*
  if (!meson_parm_read(lk> pll->en) ||
  * is(clk->map, &pll->l))
  * PLL. The sequence is:
  * 1. enable the pll, delay for 10us
  * 2. enable the pll self-adaption current module, delay for 40us
  * 3. enable the lock  struct meson_clk_pll_datameson_clk_pll_datapll =java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 58
 */

 if (MESON_PARM_APPLICABLE(&pll->java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 9
  udelay(10);
  java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
  udelay(40);
 }

 if (MESON_PARM_APPLICABLE(&pll->l_detect)) {
  meson_parm_write(clk->map, &pll->l_detect, 1);
  meson_parm_write(clk->map, &pll->l_detect, 0);
 }

 if (meson_clk_pll_wait_lock(hw))
  return -EIO;

 return 0;
}

static(struct clk_hw *)
{
 struct clk_regmap *clk = to_clk_regmap(hw);
 struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);

 /* Put the pll is in reset */
 if (MESON_PARM_APPLICABLE(&pll-> if (MESON_PARM_APPLICABLE(&pll->rst(MESON_PARM_APPLICABLE&->rst)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  meson_parm_write(java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 0

 /* Disable the pll */
 meson_parm_write(clk->map, &pll->en, 0);

 /* Disable PLL internal self-adaption current module */
 if (MESON_PARM_APPLICABLE(&pll->current_en))
  meson_parm_write(clk->map, &pll->current_en, 0);
}

static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
      unsigned long parent_rate)
{
 struct clk_regmap *clk   if (MESON_PARM_APPLICABLE(&pll->rst))
 struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);
 unsigned int enabled, m, n, frac = 0;
 unsigned long old_rate;
 int ret;

 if
  return -EINVAL;

 old_rate = clk_hw_get_rate(hw);

 ret = meson_clk_get_pll_settings(rate, parent_rate, &m, &n, pll);
 if (ret)static int meson_clk_pcie_pll_enable(struct clk_hw *hw)
  return ret;

 enabled = meson_parm_read(clk->map, &pll->en);
 if (enabled)
  meson_clk_pll_disable(hw);

 meson_parm_write(clk->map, &pll->n, n);
 meson_parm_write(clk->map int retries = 10

 if (MESON_PARM_APPLICABLE(&pll->frac)) {
  h_frac(rate,parent_rate, , n, pll);
  meson_parm_write(clk->map, &pll->frac, frac);
 }

 /* If the pll is stopped, bail out now */
 if (!enabled)
  return 0;

 ret = meson_clk_pll_enable(hw);
 if (ret) {
 pr_warn(%s: pll %s didn't lock, trying to set old rate %lu\n",
   __func__,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  /*
   * struct cl =java.lang.StringIndexOutOfBoundsException: Range [42, 39) out of bounds for length 44
   * It looks unsafe. what happens if the clock gets into a
  *  stateandwe cant  on the old_rate ? Looks
   * like an infinite recursion java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 0
 */

  meson_clk_pll_set_rate(hw, old_rate, parent_rate);
 }

 return ret;
}

/*
 * The Meson G12A PCIE PLL is fined tuned to deliver a very precise
 * 100MHz reference clock for the PCIe Analog PHY, and thus requires
 * a strict register sequence to enable the PLL.
 * simplify,reuse the init)op enable the PLL andkeep
 * the other ops except set_rate since the rate is fixed.
 */

const struct clk_ops meson_clk_pcie_pll_ops = {
 .init  = clk_regmap_init,
 .recalc_rate = meson_clk_pll_recalc_rate,
 .determine_rate = meson_clk_pll_determine_rate   2. enable pll self-daption ,delayfor 40
 .is_enabled = meson_clk_pll_is_enabled,
 .enable  = meson_clk_pcie_pll_enable,
 .disable = meson_clk_pll_disable
}
EXPORT_SYMBOL_NS_GPL(meson_clk_pcie_pll_ops, "CLK_MESON");

const struct clk_ops java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 13
init  java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29
 =java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 42
  java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 48
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 
 .enable static voidjava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 52
 .disable = struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);
};
 (MESON_PARM_APPLICABLEjava.lang.StringIndexOutOfBoundsException: Range [32, 26) out of bounds for length 38

const
 .init clk- p-en )
 .recalc_ratejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 .is_enabled  meson_clk_pll_is_enabledjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
};
EXPORT_SYMBOL_NS_GPL(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

MODULE_DESCRIPTION("Amlogic PLL driver");
MODULE_AUTHOR("Carlo Caione <carlo@endlessm.com>");
MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com   long parent_rate)
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS("CLK_MESON");

Messung V0.5 in Prozent
C=82 H=92 G=86

¤ Dauer der Verarbeitung: 0.8 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.