environmentalTemperatureAnalysis.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * clkt_clksel.c - OMAP2/3/4 clksel clock functions
  3. *
  4. * Copyright (C) 2005-2008 Texas Instruments, Inc.
  5. * Copyright (C) 2004-2010 Nokia Corporation
  6. *
  7. * Contacts:
  8. * Richard Woodruff <r-woodruff2@ti.com>
  9. * Paul Walmsley
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. *
  15. *
  16. * clksel clocks are clocks that do not have a fixed parent, or that
  17. * can divide their parent's rate, or possibly both at the same time, based
  18. * on the contents of a hardware register bitfield.
  19. *
  20. * All of the various mux and divider settings can be encoded into
  21. * struct clksel* data structures, and then these can be autogenerated
  22. * from some hardware database for each new chip generation. This
  23. * should avoid the need to write, review, and validate a lot of new
  24. * clock code for each new chip, since it can be exported from the SoC
  25. * design flow. This is now done on OMAP4.
  26. *
  27. * The fusion of mux and divider clocks is a software creation. In
  28. * hardware reality, the multiplexer (parent selection) and the
  29. * divider exist separately. XXX At some point these clksel clocks
  30. * should be split into "divider" clocks and "mux" clocks to better
  31. * match the hardware.
  32. *
  33. * (The name "clksel" comes from the name of the corresponding
  34. * register field in the OMAP2/3 family of SoCs.)
  35. *
  36. * XXX Currently these clocks are only used in the OMAP2/3/4 code, but
  37. * many of the OMAP1 clocks should be convertible to use this
  38. * mechanism.
  39. */
  40. #undef DEBUG
  41. #include <linux/kernel.h>
  42. #include <linux/errno.h>
  43. #include <linux/clk-provider.h>
  44. #include <linux/io.h>
  45. #include <linux/bug.h>
  46. #include "clock.h"
  47. /* Private functions */
  48. /**
  49. * _get_clksel_by_parent() - return clksel struct for a given clk & parent
  50. * @clk: OMAP struct clk ptr to inspect
  51. * @src_clk: OMAP struct clk ptr of the parent clk to search for
  52. *
  53. * Scan the struct clksel array associated with the clock to find
  54. * the element associated with the supplied parent clock address.
  55. * Returns a pointer to the struct clksel on success or NULL on error.
  56. */
  57. static const struct clksel *_get_clksel_by_parent(struct clk_hw_omap *clk,
  58. struct clk *src_clk)
  59. {
  60. const struct clksel *clks;
  61. if (!src_clk)
  62. return NULL;
  63. for (clks = clk->clksel; clks->parent; clks++)
  64. if (clks->parent == src_clk)
  65. break; /* Found the requested parent */
  66. if (!clks->parent) {
  67. /* This indicates a data problem */
  68. WARN(1, "clock: %s: could not find parent clock %s in clksel array\n",
  69. __clk_get_name(clk->hw.clk), __clk_get_name(src_clk));
  70. return NULL;
  71. }
  72. return clks;
  73. }
  74. /**
  75. * _write_clksel_reg() - program a clock's clksel register in hardware
  76. * @clk: struct clk * to program
  77. * @v: clksel bitfield value to program (with LSB at bit 0)
  78. *
  79. * Shift the clksel register bitfield value @v to its appropriate
  80. * location in the clksel register and write it in. This function
  81. * will ensure that the write to the clksel_reg reaches its
  82. * destination before returning -- important since PRM and CM register
  83. * accesses can be quite slow compared to ARM cycles -- but does not