Skip to content
Browse files

initial public release v1.50

initial public release v1.50

Signed-off-by: Patrick Titiano <p-titiano@ti.com>
  • Loading branch information...
1 parent de15c65 commit 4bc042bb650c9ddb6870277e6014f819255313e8 Patrick Titiano committed Sep 21, 2012
Showing with 19,123 additions and 3 deletions.
  1. +10 −0 .gitignore
  2. +3 −0 CHANGELOG
  3. +58 −0 CONTRIBUTE
  4. +124 −0 CREDITS
  5. +413 −0 LICENSE
  6. +140 −0 MAINTAINERS
  7. +180 −0 Makefile
  8. +97 −3 README.md
  9. +566 −0 audioic/twl6040.c
  10. +108 −0 audioic/twl6040.h
  11. +1,612 −0 audioic/twl6040_lib.c
  12. +70 −0 audioic/twl6040_lib.h
  13. +271 −0 bash_completion.d/omapconf
  14. +307 −0 common/abb.c
  15. +57 −0 common/abb.h
  16. +946 −0 common/audit.c
  17. +57 −0 common/audit.h
  18. +318 −0 common/autoadjust_table.c
  19. +77 −0 common/autoadjust_table.h
  20. +163 −0 common/clkdm.c
  21. +78 −0 common/clkdm.h
  22. +114 −0 common/clkdm_dependency.c
  23. +86 −0 common/clkdm_dependency.h
  24. +1,177 −0 common/cpuinfo.c
  25. +146 −0 common/cpuinfo.h
  26. +487 −0 common/dpll.c
  27. +246 −0 common/dpll.h
  28. +115 −0 common/emif.c
  29. +66 −0 common/emif.h
  30. +633 −0 common/genlist.c
  31. +85 −0 common/genlist.h
  32. +356 −0 common/help.c
  33. +93 −0 common/help.h
  34. +1,601 −0 common/lib.c
  35. +240 −0 common/lib.h
  36. +237 −0 common/lib_android.c
  37. +66 −0 common/lib_android.h
  38. +294 −0 common/mem.c
  39. +72 −0 common/mem.h
  40. +291 −0 common/module.c
  41. +149 −0 common/module.h
  42. +473 −0 common/prcm-common.h
  43. +304 −0 common/pwrdm.c
  44. +87 −0 common/pwrdm.h
  45. +288 −0 common/reg.c
  46. +74 −0 common/reg.h
  47. +1,813 −0 common/sr.c
  48. +210 −0 common/sr.h
  49. +59 −0 common/temp.h
  50. +131 −0 common/timestamp_32k.c
  51. +54 −0 common/timestamp_32k.h
  52. +2,903 −0 common/trace.c
  53. +87 −0 common/trace.h
  54. +357 −0 common/vc.c
  55. +74 −0 common/vc.h
Sorry, we could not display the entire diff because too many files (322) changed.
View
10 .gitignore
@@ -0,0 +1,10 @@
+*.ko
+*.cmd
+*.o
+*.mod.c
+/omapconf
+*.pyc
+builddate.c
+Module.symvers
+Module.markers
+modules.order
View
3 CHANGELOG
@@ -0,0 +1,3 @@
+v1.50:
+-------
+ - Initial release.
View
58 CONTRIBUTE
@@ -0,0 +1,58 @@
+###############################################################################
+# #
+# How to submit OMAPCONF changes #
+# #
+###############################################################################
+
+
+Please try to follow the guidelines below. This will make things
+easier on the maintainers. Not all of these guidelines matter for every
+trivial patch so apply some common sense.
+
+1. Always ###TEST### your changes, however small.
+ Run provided OMAPCONF non-regression test suites.
+
+2. Make sure your changes compile correctly (0 warning, 0 error).
+ OMAPCONF follows same coding convention as Linux Kernel.
+ PLEASE check your patch with the Linux Kernel automated style checker
+ (scripts/checkpatch.pl) to catch trival style violations.
+ See Linux Kernel "Documentation/CodingStyle" for guidance.
+
+3. All functions in *.c source files should use the following
+ doxygen-compliant function header:
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION function name (only name, not full prototype)
+ * @BRIEF short description of the function role.
+ * @RETURNS returned value(s)
+ * @param[in] for unchanged argument(s)
+ * @param[in, out] for modified argument(s)
+ * @DESCRIPTION complete description of the function role.
+ *//*------------------------------------------------------------------------ */
+
+ All created files shall come with he following
+ doxygen-compliant file header:
+
+/* ======================================================================= *//**
+ * @Component OMAPCONF
+ * @Filename name of the file
+ * @Description main purpose of the functions in this file
+ * @Author author
+ * @Date year of creation
+ * @Copyright person or company owning this code
+ *//*======================================================================== */
+
+ Please keep the same spacing (with tabs) between tags and descriptions
+
+4. Make patch available to omapconf_contribution@list.ti.com
+
+ PLEASE document known bugs. If it doesn't work for everything
+ or does something very odd once a month document it.
+
+ PLEASE remember that submissions should include a Signed-off-by: line.
+
+5. Make sure you have the right to send any changes you make. If you
+ do changes at work you may find your employer owns the patch
+ not you.
+
+Thanks!
View
124 CREDITS
@@ -0,0 +1,124 @@
+###############################################################################
+# #
+# CREDITS #
+# #
+###############################################################################
+
+ This is at least a partial credits-file of people that have
+ contributed to the OMAPCONF project. It is sorted by name and
+ formatted to allow easy grepping and beautification by
+ scripts. The fields are: name (N), email (E), web-address
+ (W), PGP key ID and fingerprint (P), description (D), and
+ snail-mail address (S).
+----------
+
+N: Sergio Aguirre
+E: saaguirre@ti.com
+D: OMAP4 ISS/CAMERA support
+S: USA
+
+N: Benoit Cousson
+E: b-cousson@ti.com
+D: initiator
+S: France
+
+N: Oleksandr Dmytryshyn
+E: oleksandr.dmytryshyn@ti.com
+D: OMAP4470 support
+S: Ukraine
+
+N: Sebastien Guiriec
+E: s-guiriec@ti.com
+D: ABE HW observability support
+S: France
+
+N: Nourredine Hamoudi
+E: n-hamoudi@ti.com
+D: initiator
+S: France
+
+N: Jon Hunter
+E: jon-hunter@ti.com
+D: PCT support
+D: CTT support
+D: kernel timer statistics support
+D: OMAP4430 ES2.2 detection
+D: misc. fixes/improvements
+S: USA
+
+N: Ivan Khoronzhuk
+E: ivan.khoronzhuk@ti.com
+D: OMAP4 IO PAD Audit Function
+S: USA
+
+N: Louis Lamia
+E: loulamia@ti.com
+D: Performance Trace customization capability
+S: USA
+
+N: Edward Lee
+E: edward.lee@ti.com
+D: OMAP4 ISS/CAMERA support
+S: Taiwan
+
+N: Misael Lopez Cruz
+E: misael.lopez@ti.com
+D: TWL6040 support
+S: USA
+
+N: Nishanth Menon
+E: nm@ti.com
+D: TWL6030 support
+D: Makefile guidelines
+D: misc. bug fixes
+S: USA
+
+N: Vikram Pandita
+E: vikram.pandita@ti.com
+D: OMAP4460 ES1.1 detection fix
+D: Makefile guidelines
+D: misc. bug fixes
+S: USA
+
+N: Erwan Petillon
+E: e-petillon@ti.com
+D: DSS registers dump
+S: France
+
+N: Konstantin Shlyakhovoy
+E: x0155534@ti.com
+D: OMAP4460 setvolt & vminsearch support
+D: OMAP4460 OPP-NITRO-SB support.
+D: OMAP4460 OPP frequency table correction
+S: Ukraine
+
+N: Steve Korson
+E: s-korson@ti.com
+D: OMAP4 EMIF/L2 cache controller counters trace
+S: USA
+
+N: Patrick Titiano
+E: p-titiano@ti.com
+D: initiator
+D: OMAP4 support
+D: OMAP5 support
+D: maintainer
+S: France
+
+N: Fred Turgis
+E: f-turgis@ti.com
+D: EMIF bandwidth monitoring with statistical collectors
+S: France
+
+N: Mike Turquette
+E: mturquette@ti.com
+D: RBB/FBB fix
+D: misc. bug fixes
+S: USA
+
+N: Cedric Vamour
+E: c-vamour@ti.com
+D: HW observability support for PRCM
+D: DPLL configuration audit
+D: misc. fixes/improvements
+S: France
View
413 LICENSE
@@ -0,0 +1,413 @@
+###############################################################################
+# #
+# OMAPCONF LICENSE #
+# #
+# Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ #
+# #
+###############################################################################
+
+
+The following files are published under the terms of the GNU
+General Public License version 2 as published by the Free Software Foundation:
+ - common/prcm-common.h
+ - omap4/cm-regbits-44xx.h
+ - omap4/camera44xx.*
+ - omap4/camera-regbits-44xx.h
+ - omap4/cm44xx.h
+ - omap4/prm-regbits-44xx.h
+ - omap4/prm44xx.h
+ - omap4/
+ - i2c-tools/* (except i2c-tools.h)
+
+
+
+All other files that the ones listed above are published under the terms of the
+BSD License.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of Texas Instruments Incorporated nor the names of
+ its contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+Quoting <http://en.wikipedia.org/wiki/License_compatibility>:
+ GPL compatibility:
+ David A. Wheeler has argued that GPL compatibility is an important feature of
+ software licenses.
+ Many of the most common free software licenses, such as the original
+ MIT/X license, BSD licenses (in the three-clause and two-clause forms,
+ though not the original four-clause form), MPL 2.0, and LGPL,
+ are "GPL-compatible".
+ That is, their code can be combined with a program under the GPL without
+ conflict (the new combination would have the GPL applied to the whole).
+
+
+
+Therefore, the resulting binary license falls under the GNU
+General Public License version 2 as published by the Free Software Foundation.
+
+----------------------------------------
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
View
140 MAINTAINERS
@@ -0,0 +1,140 @@
+###############################################################################
+# #
+# List of maintainers #
+# #
+###############################################################################
+
+Descriptions of section entries:
+
+ P: Person (obsolete)
+ M: Mail patches to: FullName <address@domain>
+ L: Mailing list that is relevant to this area
+ W: Web-page with status/info
+ Q: Patchwork web based patch tracking system site
+ T: SCM tree type and location. Type is one of: git, hg, quilt, stgit.
+ S: Status, one of the following:
+ Supported: Someone is actually paid to look after this.
+ Maintained: Someone actually looks after it.
+ Odd Fixes: It has a maintainer but they don't have time to do
+ much other than throw the odd patch in. See below..
+ Orphan: No current maintainer [but maybe you could take the
+ role as you write your new code].
+ Obsolete: Old code. Something tagged obsolete generally means
+ it has been replaced by a better system and you
+ should be using that.
+ F: Files and directories with wildcard patterns.
+ A trailing slash includes all files and subdirectory files.
+ F: drivers/net/ all files in and below drivers/net
+ F: drivers/net/* all files in drivers/net, but not below
+ F: */net/* all files in "any top level directory"/net
+ One pattern per line. Multiple F: lines acceptable.
+ X: Files and directories that are NOT maintained, same rules as F:
+ Files exclusions are tested before file matches.
+ Can be useful for excluding a specific subdirectory, for instance:
+ F: net/
+ X: net/ipv6/
+ matches all files in and below net excluding net/ipv6/
+ K: Keyword perl extended regex pattern to match content in a
+ patch or file. For instance:
+ K: of_get_profile
+ matches patches or files that contain "of_get_profile"
+ K: \b(printk|pr_(info|err))\b
+ matches patches or files that contain one or more of the words
+ printk, pr_info or pr_err
+ One regex pattern per line. Multiple K: lines acceptable.
+
+Note: For the hard of thinking, this list is meant to remain in alphabetical
+order.
+
+Maintainers List (try to look for most precise areas first)
+
+ -----------------------------------
+
+OMAP44xx ISS/CAMERA Support
+M: Sergio Aguirre (saaguirre@ti.com)
+M: Edward Lee (edward.lee@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: omap4/camera*.*
+
+OMAP4470 Support
+M: Oleksandr Dmytryshyn (oleksandr.dmytryshyn@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: omap4/*
+
+PCT/CTT
+M: Jon Hunter (jon-hunter@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: omap4/ctt44xx.*
+F: omap4/pct44xx.*
+F: omap5/ctt54xx.*
+F: omap5/pct54xx.*
+
+OMAP4 Counters (L2$, EMIF) Trace Support
+M: Steve Korson (s-korson@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: audioic/twl6040*
+
+TWL6040
+M: Misael Lopez Cruz (misael.lopez@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: audioic/twl6040*
+
+OMAP4 Display Support
+M: Erwan Petillon (e-petillon@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: omap4/display*
+
+OMAP4460 Support
+M: Konstantin Shlyakhovoy (x0155534@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: omap4/*
+
+OMAPCONF Global Support & Maintainance
+M: Patrick Titiano (p-titiano@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: *
+
+OMAP4 Support
+M: Patrick Titiano (p-titiano@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: omap4/*
+
+OMAP5 Support
+M: Patrick Titiano (p-titiano@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: omap5/*
+
+PMIC (Power Management IC) Support
+M: Patrick Titiano (p-titiano@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: pmic/*
+
+Linux Support
+M: Patrick Titiano (p-titiano@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: linux/*
+
+Statistical Collectors / BW Trace Support
+M: Frederic Turgis (f-turgis@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: statcoll/*
+
+HW Observability Support
+M: Cedric Vamour (c-vamour@ti.com)
+L: omapconf_contribution@list.ti.com
+S: Supported
+F: omap4/hwobs*
+F: omap5/hwobs*
View
180 Makefile
@@ -0,0 +1,180 @@
+#/*
+# *
+# * @Component OMAPCONF
+# * @Filename Makefile
+# * @Description Makefile for omapconf
+# * @Author Patrick Titiano (p-titiano@ti.com)
+# * @Date 2006
+# * @Copyright Texas Instruments Incorporated
+# *
+# *
+# * Copyright (C) 2006 Texas Instruments Incorporated - http://www.ti.com/
+# *
+# *
+# * Redistribution and use in source and binary forms, with or without
+# * modification, are permitted provided that the following conditions
+# * are met:
+# *
+# * Redistributions of source code must retain the above copyright
+# * notice, this list of conditions and the following disclaimer.
+# *
+# * Redistributions in binary form must reproduce the above copyright
+# * notice, this list of conditions and the following disclaimer in the
+# * documentation and/or other materials provided with the
+# * distribution.
+# *
+# * Neither the name of Texas Instruments Incorporated nor the names of
+# * its contributors may be used to endorse or promote products derived
+# * from this software without specific prior written permission.
+# *
+# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# *
+# */
+
+
+
+CC = $(CROSS_COMPILE)gcc
+DEF_INC := $(shell $(CROSS_COMPILE)gcc -print-file-name=include)
+MYCFLAGS+=$(CFLAGS) -D_OMAP5430 -D_SC_VER_1_16 -c -Wall -Wextra -Wno-missing-field-initializers -I. -Icommon -Ipmic -Iaudioic -Ilinux -Istatcoll -Iomap4 -Iomap5 -Ii2c-tools -I$(DEF_INC) -static
+DESTDIR ?= target
+
+
+OMAP4SOURCES= omap4/clock44xx.c omap4/clkdm44xx.c omap4/pwrdm44xx.c\
+ omap4/voltdm44xx.c omap4/module44xx.c omap4/cpuinfo44xx.c\
+ omap4/lib44xx.c omap4/gfx44xx.c omap4/ivahd44xx.c\
+ omap4/abe44xx.c omap4/wkup44xx.c omap4/audit44xx.c\
+ omap4/l3init44xx.c omap4/mpuss44xx.c omap4/alwon44xx.c\
+ omap4/emu44xx.c omap4/smartreflex44xx.c omap4/main44xx.c\
+ omap4/dpll44xx.c omap4/mpu44xx.c omap4/wkdep44xx.c\
+ omap4/core44xx.c omap4/per44xx.c omap4/dsp44xx.c\
+ omap4/dss44xx.c omap4/cam44xx.c omap4/hwobs44xx.c\
+ omap4/abb44xx.c omap4/temperature44xx.c omap4/ctt44xx.c\
+ omap4/pct44xx.c omap4/emif44xx.c omap4/coresight44xx.c\
+ omap4/stm44xx.c omap4/pmi44xx.c omap4/pmi44xx_pwrdm.c\
+ omap4/counters44xx.c omap4/l2cc44xx.c\
+ omap4/pmi44xx_voltdm.c omap4/power_trace44xx.c\
+ omap4/display44xx.c omap4/prcm44xx.c omap4/camera44xx.c\
+ omap4/dep44xx.c omap4/uc_audit44xx.c\
+ omap4/help44xx.c omap4/module44xx-data.c\
+ omap4/vc44xx.c omap4/sr44xx-data.c omap4/vp44xx.c\
+ omap4/vp44xx-data.c omap4/dpll44xx-data.c\
+ omap4/dpll4470-data-38_4MHz.c\
+ omap4/dpll4460-data-38_4MHz.c\
+ omap4/dpll4430-data-38_4MHz.c omap4/pads44xx.c
+
+
+OMAP4OBJECTS= $(OMAP4SOURCES:.c=.o)
+
+
+OMAP5SOURCES= omap5/cpuinfo54xx.c omap5/main54xx.c omap5/cm54xx-defs.c\
+ omap5/cm54xx.c omap5/prm54xx-defs.c omap5/prm54xx.c\
+ omap5/sr54xx-defs.c omap5/sr54xx.c omap5/dss54xx.c\
+ omap5/wkupaon54xx.c omap5/cam54xx.c omap5/dsp54xx.c\
+ omap5/abe54xx.c omap5/gpu54xx.c omap5/coreaon54xx.c\
+ omap5/iva54xx.c omap5/mpu54xx.c omap5/l3init54xx.c\
+ omap5/core54xx.c omap5/l4per54xx.c omap5/prmdevice54xx.c\
+ omap5/emu54xx.c omap5/ckgen54xx.c omap5/instr54xx.c\
+ omap5/help54xx.c omap5/dpll54xx.c omap5/prcm54xx.c\
+ omap5/clock54xx.c omap5/voltdm54xx.c omap5/pwrdm54xx.c\
+ omap5/clkdm54xx.c omap5/module54xx-data.c\
+ omap5/module54xx.c omap5/dpll54xx-data.c\
+ omap5/dpll54xx-data-19_2MHz.c\
+ omap5/dpll54xx-data-38_4MHz.c\
+ omap5/audit54xx.c omap5/lib54xx.c\
+ omap5/ctrlmod_core54xx-defs.c\
+ omap5/ctrlmod_core_pad54xx-defs.c\
+ omap5/ctrlmod_wkup54xx-defs.c\
+ omap5/ctrlmod_wkup_pad54xx-defs.c omap5/ctrlmod54xx.c\
+ omap5/ctrlmod54xx-data.c omap5/temp54xx.c\
+ omap5/sysconfig54xx-defs.c omap5/hwobs54xx.c\
+ omap5/abb54xx.c omap5/emif54xx-defs.c omap5/emif54xx.c\
+ omap5/clkdm_dependency54xx-data.c\
+ omap5/clkdm_dependency54xx.c omap5/ctt54xx.c\
+ omap5/vp54xx.c omap5/vc54xx.c
+
+OMAP5OBJECTS= $(OMAP5SOURCES:.c=.o)
+
+
+SOURCES= omapconf.c builddate.c common/lib.c common/reg.c\
+ common/autoadjust_table.c common/genlist.c common/abb.c\
+ common/module.c common/clkdm.c common/pwrdm.c pmic/pmic.c\
+ common/cpuinfo.c common/dpll.c i2c-tools/i2cbusses.c\
+ i2c-tools/i2cget.c i2c-tools/i2cset.c i2c-tools/util.c\
+ common/help.c common/clkdm_dependency.c\
+ common/vp.c common/vc.c common/sr.c common/audit.c\
+ statcoll/sci_swcapture.c statcoll/sci.c\
+ statcoll/cToolsHelper.c common/timestamp_32k.c\
+ common/lib_android.c common/mem.c common/emif.c\
+ common/trace.c
+
+OBJECTS= $(SOURCES:.c=.o)
+
+
+PMICSOURCES= pmic/twl603x.c pmic/tps62361.c pmic/twl603x_lib.c
+
+
+PMICOBJECTS= $(PMICSOURCES:.c=.o)
+
+
+AUDIOICSOURCES= audioic/twl6040.c audioic/twl6040_lib.c
+
+
+AUDIOICOBJECTS= $(AUDIOICSOURCES:.c=.o)
+
+
+LINUXSOURCES= linux/cpufreq.c linux/cstate.c linux/interrupts.c\
+ linux/timer_stats.c linux/linux_mem.c
+
+
+LINUXOBJECTS= $(LINUXSOURCES:.c=.o)
+
+
+ALLOBJECTS= $(OBJECTS) $(OMAP4OBJECTS) $(OMAP5OBJECTS) $(LINUXOBJECTS) $(PMICOBJECTS) $(AUDIOICOBJECTS)
+
+
+EXECUTABLE= omapconf
+
+
+all: $(SOURCES) $(ALLOBJECTS) $(EXECUTABLE)
+
+
+$(EXECUTABLE): $(ALLOBJECTS)
+ $(CC) -static $(LDFLAGS) $(ALLOBJECTS) -lrt -o $@
+ rm -f builddate.c
+
+
+.c.o:
+ $(CC) $(MYCFLAGS) $< -o $@
+
+
+builddate.c:
+ echo 'char *builddate="'`date`'";' > builddate.c
+
+
+install: omapconf
+ install -d $(DESTDIR)
+ install omapconf $(DESTDIR)
+
+
+install_android: omapconf
+ adb push omapconf /data/
+
+
+clean:
+ rm -f omapconf *.o builddate.c
+ rm -f $(OBJECTS)
+ rm -f $(LINUXOBJECTS)
+ rm -f $(OMAP4OBJECTS)
+ rm -f $(OMAP5OBJECTS)
+ rm -f $(PMICOBJECTS)
+ rm -f $(AUDIOICOBJECTS)
View
100 README.md
@@ -1,4 +1,98 @@
-omapconf
-========
+###############################################################################
+# #
+# OMAPCONF #
+# #
+# A Powerful Diagnostic Tool for Texas Instruments OMAP Processors #
+###############################################################################
-OMAPCONF: Texas Instruments OMAP Processors Diagnostic Tool
+
+
+ABOUT:
+------
+
+OMAPCONF is a Linux user-space standalone application designed to provide a
+quick'n easy way to diagnose (monitor/debug/audit...) TI OMAP configuration/status
+dynamically at runtime, in any situation:
+ - Any Linux distribution (Ubuntu, ...)
+ - Any Android release (Froyo, GingerBread, HoneyComb,
+ Ice-Cream Sandwich, Jelly Bean, ...)
+ - TI official platforms (blaze, panda, ...),
+ - Custom OMAP platforms, etc.
+ - With no single kernel recompilation needed
+
+OMAPCONF leverages "/dev/mem" special device to directly access complete
+TI OMAP memory space (registers, ...).
+
+
+
+SUPPORT:
+--------
+
+OMAPCONF CURRENTLY SUPPORTS TI OMAP44XX AND OMAP54XX DEVICES.
+LEGACY TI OMAP PLATFORMS (OMAP[1-2-3]) ARE NOT SUPPORTED.
+
+THIS SOFTWARE IS PROVIDED AS IS, WITH NO SUPPORT OR MAINTENANCE COMMITMENT FROM
+TEXAS INSTRUMENTS INCORPORATED.
+
+
+
+Build instructions (Ubuntu):
+----------------------------
+
+OMAPCONF is available as a Ubuntu package.
+To proceed with package installation type the following:
+ # sudo apt-get install tiomapconf
+
+Once package is installed, you can check which omapconf version you are using:
+ # dpkg -l tiomapconf
+
+Package is available via TI OMAP4 Ubuntu PPA.
+See http://www.omappedia.org/wiki/PandaBoard_Ubuntu_PPA for further instructions.
+
+
+
+Build instructions (other Linux Distributions):
+-----------------------------------------------
+To only build the output binary file:
+ # make CROSS_COMPILE=arm-none-linux-gnueabi- omapconf
+
+NB: CROSS_COMPILE variable must be set to point to the correct compiler.
+
+To build and install ompaconf:
+ # make CROSS_COMPILE=arm-none-linux-gnueabi- DESTDIR=YOUR_DIR install
+
+YOUR_DIR is a destination directory where omapconf output binary file will be
+copied (e.g. ubuntu/android filesystem)
+
+That’s it!
+
+
+
+Build instructions and installation via ADB (Android):
+------------------------------------------------------
+Make sure your Android device is connected to host via ADB:
+ # adb kill-server
+ # adb devices
+ * daemon not running. starting it now *
+ * daemon started successfully *
+ List of devices attached
+ emulator-5554 device
+ # adb root
+
+To build and install ompaconf for Android via ADB:
+# make CROSS_COMPILE=arm-none-linux-gnueabi- install_android
+
+OMAPCONF binary will be copied to /data directory (known writable directory)
+on your Android device. You may get it copied to a different directory by
+updating Makefile at your convenience.
+
+
+
+Help:
+-----
+
+Type "./omapconf --help" to get complete list of available commands and options.
+Note that in case of incorrect command/option, help will also be displayed.
+
+A dedicated wiki page is available here:
+ https://github.com/omapconf/omapconf/wiki
View
566 audioic/twl6040.c
@@ -0,0 +1,566 @@
+/*
+ *
+ * @Component OMAPCONF
+ * @Filename twl6040.c
+ * @Description TWL6040 Audio Companion Chip Functions
+ * @Author Misael Lopez Cruz (misael.lopez@ti.com)
+ * @Date 2010
+ * @Copyright Texas Instruments Incorporated
+ *
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+#include <twl6040.h>
+#include <i2c-tools.h>
+#include <stdio.h>
+#include <lib.h>
+#include <twl6040_lib.h>
+#include <autoadjust_table.h>
+#include <help.h>
+#include <cpuinfo.h>
+
+
+/* #define TWL6040_DEBUG */
+#ifdef TWL6040_DEBUG
+#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
+#else
+#define dprintf(format, ...)
+#endif
+
+#define TWL6040_REG_TABLE_SIZE 40
+
+static const reg_table twl6040_reg_table[TWL6040_REG_TABLE_SIZE] = {
+ {"ASICID", TWL6040_REG_ASICID},
+ {"ASICREV", TWL6040_REG_ASICREV},
+ {"INTID", TWL6040_REG_INTID},
+ {"INTMR", TWL6040_REG_INTMR},
+ {"NCPCTL", TWL6040_REG_NCPCTL},
+ {"LDOCTL", TWL6040_REG_LDOCTL},
+ {"HPPLLCTL", TWL6040_REG_HPPLLCTL},
+ {"LPPLLCTL", TWL6040_REG_LPPLLCTL},
+ {"LPPLLDIV", TWL6040_REG_LPPLLDIV},
+ {"AMICBCTL", TWL6040_REG_AMICBCTL},
+ {"DMICBCTL", TWL6040_REG_DMICBCTL},
+ {"MICLCTL", TWL6040_REG_MICLCTL},
+ {"MICRCTL", TWL6040_REG_MICRCTL},
+ {"MICGAIN", TWL6040_REG_MICGAIN},
+ {"LINEGAIN", TWL6040_REG_LINEGAIN},
+ {"HSLCTL", TWL6040_REG_HSLCTL},
+ {"HSRCTL", TWL6040_REG_HSRCTL},
+ {"HSGAIN", TWL6040_REG_HSGAIN},
+ {"EARCTL", TWL6040_REG_EARCTL},
+ {"HFLCTL", TWL6040_REG_HFLCTL},
+ {"HFLGAIN", TWL6040_REG_HFLGAIN},
+ {"HFRCTL", TWL6040_REG_HFRCTL},
+ {"HFRGAIN", TWL6040_REG_HFRGAIN},
+ {"VIBCTLL", TWL6040_REG_VIBCTLL},
+ {"VIBDATL", TWL6040_REG_VIBDATL},
+ {"VIBCTLR", TWL6040_REG_VIBCTLR},
+ {"VIBDATR", TWL6040_REG_VIBDATR},
+ {"HKCTL1", TWL6040_REG_HKCTL1},
+ {"HKCTL2", TWL6040_REG_HKCTL2},
+ {"GPOCTL", TWL6040_REG_GPOCTL},
+ {"ALB", TWL6040_REG_ALB},
+ {"DLB", TWL6040_REG_DLB},
+ {"TRIM1", TWL6040_REG_TRIM1},
+ {"TRIM2", TWL6040_REG_TRIM2},
+ {"TRIM3", TWL6040_REG_TRIM3},
+ {"HSOTRIM", TWL6040_REG_HSOTRIM},
+ {"HFOTRIM", TWL6040_REG_HFOTRIM},
+ {"ACCCTL", TWL6040_REG_ACCCTL},
+ {"STATUS", TWL6040_REG_STATUS},
+ {"END", 0} };
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_dumpregs
+ * @BRIEF dump registers from table given as argument
+ * @RETURNS 0 in case of success
+ * OMAPCONF_ERR_REG_ACCESS
+ * @param[in] none
+ * @DESCRIPTION dump registers from table given as argument
+ *//*------------------------------------------------------------------------ */
+int twl6040_dumpregs(void)
+{
+ unsigned int i = 0;
+ unsigned int val = 0;
+ int ret, err = 0;
+ char autoadjust_table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
+ unsigned int row;
+
+ autoadjust_table_init(autoadjust_table);
+ row = 0;
+
+ strncpy(autoadjust_table[row][0], "Reg. Name", TABLE_MAX_ELT_LEN);
+ strncpy(autoadjust_table[row][1], "Reg. Addr",
+ TABLE_MAX_ELT_LEN);
+ strncpy(autoadjust_table[row][2], "Reg. Val.", TABLE_MAX_ELT_LEN);
+ row++;
+
+ while (strcmp(twl6040_reg_table[i].name, "END") != 0) {
+ ret = i2cget(TWL6040_I2C_BUS, TWL6040_I2C_ADDR,
+ twl6040_reg_table[i].addr, &val);
+ if (ret == 0) {
+ /* Show register name, addr & content (hex) */
+ snprintf(autoadjust_table[row][0], TABLE_MAX_ELT_LEN,
+ "%s", twl6040_reg_table[i].name);
+ snprintf(autoadjust_table[row][1], TABLE_MAX_ELT_LEN,
+ "0x%02X", twl6040_reg_table[i].addr);
+ snprintf(autoadjust_table[row][2], TABLE_MAX_ELT_LEN,
+ "0x%02X", val);
+ row++;
+ } else if (ret == -4) {
+ /*
+ * Some registers maybe unaccessible if
+ * its voltage domain is disabled
+ */
+ snprintf(autoadjust_table[row][0], TABLE_MAX_ELT_LEN,
+ "%s", twl6040_reg_table[i].name);
+ snprintf(autoadjust_table[row][1], TABLE_MAX_ELT_LEN,
+ "0x%02X", twl6040_reg_table[i].addr);
+ snprintf(autoadjust_table[row][2], TABLE_MAX_ELT_LEN,
+ "INACTIVE");
+ row++;
+ } else {
+ printf("omapconf_twl6040_dumpregs(): read error! "
+ "(addr=0x%02X, err=%d)\n",
+ twl6040_reg_table[i].addr, ret);
+ err = OMAPCONF_ERR_REG_ACCESS;
+ break;
+ }
+ i++;
+ }
+
+ autoadjust_table_print(autoadjust_table, row, 3);
+
+ return err;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_name2addr
+ * @BRIEF retrieve physical address of a register, given its name.
+ * @RETURNS 0 on success
+ * -1 if address not found
+ * @param[in,out] name: register name
+ * @param[in,out] addr: register address
+ * @DESCRIPTION retrieve physical address of a register, given its name.
+ *//*------------------------------------------------------------------------ */
+int twl6040_name2addr(char *name, unsigned int *addr)
+{
+ return name2addr(name, addr, (reg_table *) twl6040_reg_table);
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_config
+ * @BRIEF analyze TWL6040 audio configuration
+ * @RETURNS 0 in case of success
+ * OMAPCONF_ERR_REG_ACCESS
+ * @param[in,out] stream: output file stream
+ * @DESCRIPTION analyze TWL6040 audio configuration
+ *//*------------------------------------------------------------------------ */
+int twl6040_config(FILE *stream)
+{
+ unsigned char twl6040_regs[TWL6040_REG_NUM];
+ unsigned int i = 0, val;
+ int ret;
+
+ while (strcmp(twl6040_reg_table[i].name, "END") != 0) {
+ ret = i2cget(TWL6040_I2C_BUS, TWL6040_I2C_ADDR,
+ twl6040_reg_table[i].addr, &val);
+ if (ret != 0) {
+ printf("twl6040_config(): read error! "
+ "(addr=0x%02X, err=%d)\n",
+ twl6040_reg_table[i].addr, ret);
+ return OMAPCONF_ERR_REG_ACCESS;
+ }
+ twl6040_regs[twl6040_reg_table[i].addr] = val;
+ i++;
+ }
+
+ ret = twl6040_display_version_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_control_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_power_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_clocking_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_interrupts_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_biasing_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_uplink_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_downlink1_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_downlink2_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_vibrator_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_loopback_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_gpo_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ ret = twl6040_display_misc_config(stream, twl6040_regs);
+ if (ret != 0)
+ return ret;
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_gains
+ * @BRIEF analyze TWL6040 analog gains
+ * @RETURNS 0 in case of success
+ * OMAPCONF_ERR_REG_ACCESS
+ * @param[in,out] stream: output file stream
+ * @DESCRIPTION analyze TWL6040 analog gains
+ *//*------------------------------------------------------------------------ */
+int twl6040_gains(FILE *stream)
+{
+ unsigned char twl6040_regs[TWL6040_REG_NUM];
+ unsigned int i = 0, val;
+ int ret = 0;
+
+ while (strcmp(twl6040_reg_table[i].name, "END") != 0) {
+ ret = i2cget(TWL6040_I2C_BUS, TWL6040_I2C_ADDR,
+ twl6040_reg_table[i].addr, &val);
+ if (ret != 0) {
+ printf("twl6040_config(): read error! "
+ "(addr=0x%02X, err=%d)\n",
+ twl6040_reg_table[i].addr, ret);
+ return OMAPCONF_ERR_REG_ACCESS;
+ }
+ twl6040_regs[twl6040_reg_table[i].addr] = val;
+ i++;
+ }
+
+ ret = twl6040_display_gains(stream, twl6040_regs);
+
+ return ret;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_readreg
+ * @BRIEF read data from given TWL6040 address
+ * @RETURNS 0 in case of success
+ * -1 in case of incorrect register name/address
+ * -2 in case of incorrect format
+ * OMAPCONF_ERR_REG_ACCESS
+ * @param[in] reg_addr: Register address (name or hex address)
+ * @DESCRIPTION read data from given TWL6040 address
+ *//*------------------------------------------------------------------------ */
+int twl6040_readreg(const char *reg_addr)
+{
+ unsigned int value, addr;
+ char name[OMAPCONF_REG_NAME_MAX_LENGTH + 1] = "";
+ unsigned char by_name = 0;
+ int ret = 0;
+
+ if (reg_addr == NULL) {
+ printf("Oups, missing register name/address!!!\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+ reg_addr = uppercase((char *) reg_addr);
+
+ /* Retrieve and check register address */
+ if ((reg_addr[0] == '0') && (reg_addr[1] == 'X')) {
+ /* As an integer, must start with "0x" */
+ ret = sscanf(reg_addr, "0X%x", &addr);
+ if (ret != 1) {
+ printf("Oups, register address not recognized!!!\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+ } else {
+ /* As a string, must start with alpha character */
+ if (isalpha(reg_addr[0])) {
+ ret = sscanf(reg_addr, "%50s", (char *) name);
+ if (ret != 1) {
+ printf("Oups, register name not recognized!!!"
+ "\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+ by_name = 1;
+ } else {
+ printf("Oups, register name/address not recognized!!!"
+ "\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+ }
+
+ /*
+ * if reg. name was entered, check name is valid and retrieve reg. addr.
+ */
+ if (by_name == 1) {
+ ret = twl6040_name2addr((char *)name, &addr);
+ if (ret != 0) {
+ printf("Oups, not a valid register name!!!\n"
+ "Try \"omapconf dump audioic\" to get valid "
+ "register names.\n\n");
+ return 0;
+ }
+ }
+
+ /* debug */
+ if (by_name == 1) {
+ dprintf("%s reg name=%s\n", __func__, name);
+ }
+ dprintf("%s addr=0x%02x\n", __func__, addr);
+
+ /* Read i2c register (assuming TWL6040 is in bus 1) */
+ ret = i2cget(1, TWL6040_I2C_ADDR, addr, &value);
+ if (ret != 0) {
+ printf("Oups, internal error (failed to read)!!!\n\n");
+ return 0;
+ }
+
+ /* Display value in selected format */
+ printf("%02X\n\n", value);
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_writereg
+ * @BRIEF write given data to given TWL6040 address
+ * @RETURNS 0 in case of success
+ * -1 in case of incorrect register name/address
+ * -2 in case of incorrect format
+ * OMAPCONF_ERR_REG_ACCESS
+ * @param[in] reg_addr: Register address (name or hex address)
+ * @param[in] reg_val: Register value
+ * @DESCRIPTION write given data to given TWL6040 address
+ *//*------------------------------------------------------------------------ */
+int twl6040_writereg(const char *reg_addr, const char *reg_val)
+{
+ unsigned int value, addr;
+ char name[OMAPCONF_REG_NAME_MAX_LENGTH + 1] = "";
+ unsigned char by_name = 0;
+ int ret = 0;
+
+ if (reg_addr == NULL) {
+ printf("Oups, missing register name/address!!!\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+ reg_addr = uppercase((char *) reg_addr);
+
+
+ if (reg_val == NULL) {
+ printf("Oups, missing value to be written!!!\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+ reg_val = uppercase((char *) reg_val);
+
+
+ /* Retrieve and check register address */
+ if ((reg_addr[0] == '0') && (reg_addr[1] == 'X')) {
+ /* As an integer, must start with "0x" */
+ ret = sscanf(reg_addr, "0X%x", &addr);
+ if (ret != 1) {
+ printf("Oups, register address not recognized!!!\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+ } else {
+ /* As a string, must start with alpha character */
+ if (isalpha(reg_addr[0])) {
+ ret = sscanf(reg_addr, "%50s", (char *) name);
+ if (ret != 1) {
+ printf("Oups, register address not recognized"
+ "!!!\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+ by_name = 1;
+ } else {
+ printf("Oups, register address not recognized!!!\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+ }
+
+ /*
+ * if reg. name was entered, check name is valid and retrieve reg. addr.
+ */
+ if (by_name == 1) {
+ ret = twl6040_name2addr((char *)name, &addr);
+ if (ret != 0) {
+ printf("Oups, not a valid register name!!!\n"
+ "Try \"omapconf dump audioic\" to get valid "
+ "register names.\n\n");
+ return 0;
+ }
+ }
+
+ /* Retrieve and check value to be written into register */
+ if ((reg_val[0] == '0') && (reg_val[1] == 'X')) {
+ /* As an integer, must start with "0x" */
+ ret = sscanf(reg_val, "0X%x", &value);
+ if (ret != 1) {
+ printf("Oups, value to be written not recognized!\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+ } else {
+ printf("Oups, value to be written not recognized!\n\n");
+ help(HELP_AUDIOIC);
+ return 0;
+ }
+
+ /* debug */
+ if (by_name == 1) {
+ dprintf("%s reg name=%s\n", __func__, name);
+ }
+ dprintf("%s reg addr=0x%02x\n", __func__, addr);
+ dprintf("%s reg val=0x%02x\n", __func__, value);
+
+ /* Write i2c register */
+ ret = i2cset(TWL6040_I2C_BUS, TWL6040_I2C_ADDR, addr, value);
+ if (ret != 0)
+ printf("Oups, internal error (failed to write)!\n\n");
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_chip_revision_get
+ * @BRIEF return TWL6040 chip revision
+ * @RETURNS >0.0 TWL6030 chip revision
+ * OMAPCONF_ERR_NOT_AVAILABLE
+ * @param[in] none
+ * @DESCRIPTION return TWL6040 chip revision
+ *//*------------------------------------------------------------------------ */
+float twl6040_chip_revision_get(void)
+{
+ int ret;
+ unsigned int revcode;
+ float rev;
+
+ ret = i2cget(TWL6040_I2C_BUS, TWL6040_I2C_ADDR, 0x02, &revcode);
+ if (ret != 0) {
+ dprintf("%s(): could not read register! (%d)\n", __func__, ret);
+ return (float) OMAPCONF_ERR_NOT_AVAILABLE;
+ }
+
+ rev = 0.1 * (float) (revcode & 0x0F);
+ rev += 1 * (float) (1 + ((revcode & 0xF0) >> 4));
+
+ return rev;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_main
+ * @BRIEF main entry point
+ * @RETURNS 0 in case of success
+ * OMAPCONF_ERR_ARG
+ * OMAPCONF_ERR_INTERNAL
+ * @param[in] argc: shell input argument number
+ * @param[in] argv: shell input argument(s)
+ * @DESCRIPTION main entry point
+ *//*------------------------------------------------------------------------ */
+int twl6040_main(int argc, char *argv[])
+{
+ int ret;
+
+ if (argc == 2) {
+ if (strcmp(argv[1], "dump") == 0) {
+ ret = twl6040_dumpregs();
+ } else if (strcmp(argv[1], "cfg") == 0) {
+ ret = twl6040_config(stdout);
+ } else if (strcmp(argv[1], "gains") == 0) {
+ ret = twl6040_gains(stdout);
+ } else {
+ help(HELP_AUDIOIC);
+ ret = OMAPCONF_ERR_ARG;
+ }
+ } else if (argc == 3) {
+ if (strcmp(argv[1], "read") == 0) {
+ ret = twl6040_readreg(uppercase(argv[2]));
+ } else {
+ help(HELP_AUDIOIC);
+ ret = OMAPCONF_ERR_ARG;
+ }
+ } else if (argc == 4) {
+ if (strcmp(argv[1], "write") == 0) {
+ ret = twl6040_writereg(uppercase(argv[2]),
+ uppercase(argv[3]));
+ } else {
+ help(HELP_AUDIOIC);
+ ret = OMAPCONF_ERR_ARG;
+ }
+ } else {
+ help(HELP_AUDIOIC);
+ ret = OMAPCONF_ERR_ARG;
+ }
+
+ return ret;
+}
View
108 audioic/twl6040.h
@@ -0,0 +1,108 @@
+/*
+ *
+ * @Component OMAPCONF
+ * @Filename twl6040.h
+ * @Description TWL6040 Audio Companion Chip Functions
+ * @Author Patrick Titiano (p-titiano@ti.com)
+ * Misael Lopez Cruz <misael.lopez@ti.com>
+ * @Date 2010
+ * @Copyright Texas Instruments Incorporated
+ *
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+#ifndef __TWL6040_H__
+#define __TWL6040_H__
+
+
+#include <stdio.h>
+
+
+#define TWL6040_I2C_BUS 1
+#define TWL6040_I2C_ADDR 0x4B
+
+#define TWL6040_REG_ASICID 0x01
+#define TWL6040_REG_ASICREV 0x02
+#define TWL6040_REG_INTID 0x03
+#define TWL6040_REG_INTMR 0x04
+#define TWL6040_REG_NCPCTL 0x05
+#define TWL6040_REG_LDOCTL 0x06
+#define TWL6040_REG_HPPLLCTL 0x07
+#define TWL6040_REG_LPPLLCTL 0x08
+#define TWL6040_REG_LPPLLDIV 0x09
+#define TWL6040_REG_AMICBCTL 0x0A
+#define TWL6040_REG_DMICBCTL 0x0B
+#define TWL6040_REG_MICLCTL 0x0C
+#define TWL6040_REG_MICRCTL 0x0D
+#define TWL6040_REG_MICGAIN 0x0E
+#define TWL6040_REG_LINEGAIN 0x0F
+#define TWL6040_REG_HSLCTL 0x10
+#define TWL6040_REG_HSRCTL 0x11
+#define TWL6040_REG_HSGAIN 0x12
+#define TWL6040_REG_EARCTL 0x13
+#define TWL6040_REG_HFLCTL 0x14
+#define TWL6040_REG_HFLGAIN 0x15
+#define TWL6040_REG_HFRCTL 0x16
+#define TWL6040_REG_HFRGAIN 0x17
+#define TWL6040_REG_VIBCTLL 0x18
+#define TWL6040_REG_VIBDATL 0x19
+#define TWL6040_REG_VIBCTLR 0x1A
+#define TWL6040_REG_VIBDATR 0x1B
+#define TWL6040_REG_HKCTL1 0x1C
+#define TWL6040_REG_HKCTL2 0x1D
+#define TWL6040_REG_GPOCTL 0x1E
+#define TWL6040_REG_ALB 0x1F
+#define TWL6040_REG_DLB 0x20
+#define TWL6040_REG_TRIM1 0x28
+#define TWL6040_REG_TRIM2 0x29
+#define TWL6040_REG_TRIM3 0x2A
+#define TWL6040_REG_HSOTRIM 0x2B
+#define TWL6040_REG_HFOTRIM 0x2C
+#define TWL6040_REG_ACCCTL 0x2D
+#define TWL6040_REG_STATUS 0x2E
+
+#define TWL6040_REG_NUM (TWL6040_REG_STATUS + 1)
+
+
+float twl6040_chip_revision_get(void);
+int twl6040_dumpregs(void);
+int twl6040_config(FILE *stream);
+int twl6040_gains(FILE *stream);
+int twl6040_readreg(const char *reg_addr);
+int twl6040_writereg(const char *reg_addr, const char *reg_val);
+int twl6040_main(int argc, char *argv[]);
+
+
+#endif
View
1,612 audioic/twl6040_lib.c
@@ -0,0 +1,1612 @@
+/*
+ *
+ * @Component OMAPCONF
+ * @Filename twl6040_lib.c
+ * @Description TWL6040 Audio Companion Chip Functions
+ * @Author Patrick Titiano (p-titiano@ti.com)
+ * Misael Lopez Cruz <misael.lopez@ti.com>
+ * @Date 2010
+ * @Copyright Texas Instruments Incorporated
+ *
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+#include <twl6040_lib.h>
+#include <lib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <twl6040.h>
+
+
+/* #define TWL6040_LIB_DEBUG */
+#ifdef TWL6040_LIB_DEBUG
+#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
+#else
+#define dprintf(format, ...)
+#endif
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_display_version_config
+ * @BRIEF analyze TWL6040 version
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in,out] stream: output file
+ * @param[in,out] regs: register values
+ * @DESCRIPTION analyze TWL6040 version
+ *//*------------------------------------------------------------------------ */
+int twl6040_display_version_config(FILE *stream, unsigned char *regs)
+{
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "| VERSION "
+ " |\n");
+ fprintf(stream, "|--------------------------------|------------------"
+ "-----------|\n");
+
+ /* ASIC Type */
+ fprintf(stream, "| %-30s | 0x%-25X |\n", "ASIC Type",
+ regs[TWL6040_REG_ASICID]);
+
+ /* ASIC Full Mask */
+ fprintf(stream, "| %-30s | Version %-19d |\n", "ASIC Full Mask",
+ extract_bitfield(regs[TWL6040_REG_ASICREV], 4, 4) + 1);
+
+ /* ASIC Metal Mask */
+ fprintf(stream, "| %-30s | Version %-19d |\n", "ASIC Metal Mask",
+ extract_bitfield(regs[TWL6040_REG_ASICREV], 0, 4));
+
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "\n");
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_i2cmode2string
+ * @BRIEF convert I2CMODE bitfield into string
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in] s: destination string (pre-allocated)
+ * @param[in] i2cmode: I2CMODE bitfield
+ * @DESCRIPTION convert I2CMODE bitfield into string
+ *//*------------------------------------------------------------------------ */
+static int twl6040_i2cmode2string(char s[20], unsigned char i2cmode)
+{
+ if (s == NULL)
+ return OMAPCONF_ERR_ARG;
+
+ switch (i2cmode) {
+ case 0:
+ strcpy(s, "Normal Mode");
+ break;
+ case 1:
+ strcpy(s, "Fast Mode");
+ break;
+ case 2:
+ strcpy(s, "Fast Mode Plus");
+ break;
+ case 3:
+ strcpy(s, "High Speed Mode");
+ break;
+ default:
+ strcpy(s, "ERROR!!!");
+ return OMAPCONF_ERR_ARG;
+ }
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_display_control_config
+ * @BRIEF analyze TWL6040 version
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in,out] stream: output file
+ * @param[in,out] regs: register values
+ * @DESCRIPTION analyze TWL6040 version
+ *//*------------------------------------------------------------------------ */
+int twl6040_display_control_config(FILE *stream, unsigned char *regs)
+{
+ char mode[20];
+
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "| CONTROL "
+ " |\n");
+ fprintf(stream, "|--------------------------------|------------------"
+ "-----------|\n");
+
+ /* I2C Mode */
+ twl6040_i2cmode2string(mode,
+ extract_bitfield(regs[TWL6040_REG_ACCCTL], 4, 2));
+ fprintf(stream, "| %-30s | %-27s |\n", "I2C Mode", mode);
+
+ /* Dual Access Registers Control */
+ if (extract_bit(regs[TWL6040_REG_ACCCTL], 1) == 1) {
+ fprintf(stream, "| %-30s | %-27s |\n",
+ "Dual-Access Registers Control",
+ "PDM and I2C interfaces");
+ } else {
+ fprintf(stream, "| %-30s | %-27s |\n",
+ "Dual-Access Registers Control",
+ ((extract_bit(regs[TWL6040_REG_ACCCTL], 0) == 1) ?
+ "I2C interface only" : "PDM interface only"));
+ }
+
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "\n");
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_ncpfetsize2string
+ * @BRIEF convert NCP FET size bitfield into string
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in] s: destination string (pre-allocated)
+ * @param[in] ncpfetsize: NCPFETSIZE bitfield
+ * @DESCRIPTION convert NCP FET size bitfield into string
+ *//*------------------------------------------------------------------------ */
+static int twl6040_ncpfetsize2string(char s[20], unsigned char ncpfetsize)
+{
+ if (s == NULL)
+ return OMAPCONF_ERR_ARG;
+
+ switch (ncpfetsize) {
+ case 0:
+ strcpy(s, "1/8 of total FET");
+ break;
+ case 1:
+ strcpy(s, "1/4 of total FET");
+ break;
+ case 2:
+ strcpy(s, "3/8 of total FET");
+ break;
+ case 3:
+ strcpy(s, "1/2 of total FET");
+ break;
+ case 4:
+ strcpy(s, "5/8 of total FET");
+ break;
+ case 5:
+ strcpy(s, "3/4 of total FET");
+ break;
+ case 6:
+ strcpy(s, "7/8 of total FET");
+ break;
+ case 7:
+ strcpy(s, "Total FET");
+ break;
+ default:
+ strcpy(s, "ERROR!!!");
+ return OMAPCONF_ERR_ARG;
+ }
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_display_power_config
+ * @BRIEF analyze TWL6040 NCP, HSLDO and LSDO configuration
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in,out] stream: output file
+ * @param[in,out] regs: register values
+ * @DESCRIPTION analyze TWL6040 NCP, HSLDO and LSDO configuration
+ *//*------------------------------------------------------------------------ */
+int twl6040_display_power_config(FILE *stream, unsigned char *regs)
+{
+ char ncp[20];
+
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "| POWER "
+ " |\n");
+ fprintf(stream, "|--------------------------------|------------------"
+ "-----------|\n");
+
+ /* Negative Charge Pump */
+ fprintf(stream, "| %-30s | %-27s |\n", "Negative Charge Pump",
+ ((extract_bit(regs[TWL6040_REG_NCPCTL], 0) == 1) ?
+ "Enabled" : "Disabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Mode",
+ ((extract_bit(regs[TWL6040_REG_NCPCTL], 1) == 1) ?
+ "PFM" : "PWM"));
+ if (extract_bit(regs[TWL6040_REG_NCPCTL], 2) == 1) {
+ twl6040_ncpfetsize2string(ncp,
+ extract_bitfield(regs[TWL6040_REG_NCPCTL], 3, 3));
+ fprintf(stream, "| %-30s | %-27s |\n", " FET Size", ncp);
+ } else {
+ fprintf(stream, "| %-30s | %-27s |\n", " FET Size",
+ "Automatic");
+ }
+ fprintf(stream, "| %-30s | %-27s |\n", " Loop",
+ ((extract_bit(regs[TWL6040_REG_NCPCTL], 6) == 1) ?
+ "Open" : "Closed"));
+
+ /* Internal Oscillator */
+ fprintf(stream, "| %-30s | %-27s |\n", "Internal Oscillator",
+ ((extract_bit(regs[TWL6040_REG_LDOCTL], 7) == 1) ?
+ "Enabled (Muxed to NCP)" : "Disabled (PLL muxed to NCP)"));
+
+ /* Reference System */
+ fprintf(stream, "| %-30s | %-27s |\n", "Reference System",
+ ((extract_bit(regs[TWL6040_REG_LDOCTL], 6) == 1) ?
+ "Enabled" : "Disabled"));
+
+ /* High-Side LDO */
+ fprintf(stream, "| %-30s | %-27s |\n", "High Side LDO",
+ ((extract_bit(regs[TWL6040_REG_LDOCTL], 2) == 1) ?
+ "Enabled" : "Disabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Mode",
+ ((extract_bit(regs[TWL6040_REG_LDOCTL], 3) == 1) ?
+ "Sleep" : "Normal"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Output When Disabled",
+ ((extract_bit(regs[TWL6040_REG_LDOCTL], 5) == 1) ?
+ "High-Z" : "Pulled-Down to GND"));
+
+ /* Low-Side LDO */
+ fprintf(stream, "| %-30s | %-27s |\n", "Low Side LDO",
+ ((extract_bit(regs[TWL6040_REG_LDOCTL], 0) == 1) ?
+ "Enabled" : "Disabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Mode",
+ ((extract_bit(regs[TWL6040_REG_LDOCTL], 1) == 1) ?
+ "Sleep" : "Normal"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Output When Disabled",
+ ((extract_bit(regs[TWL6040_REG_LDOCTL], 4) == 1) ?
+ "High-Z" : "Pulled-Down to GND"));
+
+ /* Split Supply Registers and State Machine */
+ fprintf(stream, "| %-30s | %-27s |\n", "Split Supply Reg/State Machine",
+ ((extract_bit(regs[TWL6040_REG_ACCCTL], 2) == 1) ?
+ "Reset" : "Running"));
+
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "\n");
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_lpplldiv2string
+ * @BRIEF convert LPPLLDIV bitfield into string
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in] s: destination string (pre-allocated)
+ * @param[in] lpplldiv: LPPLLDIV bitfield
+ * @DESCRIPTION convert LPPLLDIV bitfield into string
+ *//*------------------------------------------------------------------------ */
+static int twl6040_lpplldiv2string(char s[10], unsigned char lpplldiv)
+{
+ if (s == NULL)
+ return OMAPCONF_ERR_ARG;
+
+ sprintf(s, "%d", lpplldiv + 512);
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_mclk2string
+ * @BRIEF convert MCLK frequency into string
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in] s: destination string (pre-allocated)
+ * @param[in] hppllmclk: HPPLLMCLK bitfield
+ * @DESCRIPTION convert MCLK frequency into string
+ *//*------------------------------------------------------------------------ */
+static int twl6040_mclk2string(char s[10], unsigned char hppllmclk)
+{
+ if (s == NULL)
+ return OMAPCONF_ERR_ARG;
+
+ switch (hppllmclk) {
+ case 0:
+ strcpy(s, "12.0MHz");
+ break;
+ case 1:
+ strcpy(s, "19.2MHz");
+ break;
+ case 2:
+ strcpy(s, "26.0MHz");
+ break;
+ case 3:
+ strcpy(s, "38.4MHz");
+ break;
+ default:
+ strcpy(s, "ERROR!!!");
+ return OMAPCONF_ERR_ARG;
+ }
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_display_clocking_config
+ * @BRIEF analyze TWL6040 HPPLL and LPPLL configuration
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in,out] stream: output file
+ * @param[in,out] regs: register values
+ * @DESCRIPTION analyze TWL6040 HPPLL and LPPLL configuration
+ *//*------------------------------------------------------------------------ */
+int twl6040_display_clocking_config(FILE *stream, unsigned char *regs)
+{
+ char data[10];
+
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "| CLOCKING SYSTEM "
+ " |\n");
+ fprintf(stream, "|--------------------------------|------------------"
+ "-----------|\n");
+
+ /* 32k Internal Oscillator */
+ fprintf(stream, "| %-30s | %-27s |\n", "Clock 32kHz Source",
+ ((extract_bit(regs[TWL6040_REG_ACCCTL], 6) == 1) ?
+ "Internal" : "External"));
+
+ /* SYSCLK Source */
+ fprintf(stream, "| %-30s | %-27s |\n", "SYSCLK source",
+ ((extract_bit(regs[TWL6040_REG_LPPLLCTL], 4) == 1) ?
+ "High-Performance PLL" : "Low-Power PLL"));
+
+ /* Low-Power PLL */
+ fprintf(stream, "| %-30s | %-27s |\n", "Low-Power PLL",
+ ((extract_bit(regs[TWL6040_REG_LPPLLCTL], 0) == 1) ?
+ "Enabled" : "Disabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " State",
+ ((extract_bit(regs[TWL6040_REG_LPPLLCTL], 1) == 1) ?
+ "Reset" : "Normal"));
+ if (extract_bit(regs[TWL6040_REG_LPPLLCTL], 2) == 1) {
+ twl6040_lpplldiv2string(data, regs[TWL6040_REG_LPPLLDIV]);
+ fprintf(stream, "| %-30s | %-27s |\n", " Divider", data);
+ } else {
+ fprintf(stream, "| %-30s | %-27s |\n", " Divider",
+ ((extract_bit(regs[TWL6040_REG_LPPLLCTL], 3) == 1) ?
+ "538 (prefixed)" : "586 (prefixed)"));
+ }
+
+ /* High-Performance PLL */
+ fprintf(stream, "| %-30s | %-27s |\n", "High-Performance PLL",
+ ((extract_bit(regs[TWL6040_REG_HPPLLCTL], 0) == 1) ?
+ "Enabled" : "Disabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " State",
+ ((extract_bit(regs[TWL6040_REG_HPPLLCTL], 1) == 1) ?
+ "Reset" : "Normal"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Mode",
+ ((extract_bit(regs[TWL6040_REG_HPPLLCTL], 2) == 1) ?
+ "Bypass" : "Active"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Clock Slicer",
+ ((extract_bit(regs[TWL6040_REG_HPPLLCTL], 3) == 1) ?
+ "Enabled" : "Disabled"));
+ twl6040_mclk2string(data, extract_bitfield(regs[TWL6040_REG_HPPLLCTL],
+ 5, 2));
+ fprintf(stream, "| %-30s | %-27s |\n", " MCLK frequency", data);
+
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "\n");
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_display_interrupts_config
+ * @BRIEF analyze TWL6040 interrupts and status
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in,out] stream: output file
+ * @param[in,out] regs: register values
+ * @DESCRIPTION analyze TWL6040 interrupts and status
+ *//*------------------------------------------------------------------------ */
+int twl6040_display_interrupts_config(FILE *stream, unsigned char *regs)
+{
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "| INTERRUPT AND STATUS "
+ " |\n");
+ fprintf(stream, "|--------------------------------|------------------"
+ "-----------|\n");
+
+ /* Thermal Interrupt */
+ fprintf(stream, "| %-30s | %-27s |\n", "Thermal Interrupt",
+ ((extract_bit(regs[TWL6040_REG_INTMR], 0) == 1) ?
+ "Disabled" : "Enabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Pending",
+ ((extract_bit(regs[TWL6040_REG_INTID], 0) == 1) ?
+ "Yes" : "No"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Status",
+ ((extract_bit(regs[TWL6040_REG_STATUS], 6) == 1) ?
+ "High" : "Low"));
+
+ /* Plug Detection Interrupt */
+ fprintf(stream, "| %-30s | %-27s |\n", "Plug Detection Interrupt",
+ ((extract_bit(regs[TWL6040_REG_INTMR], 1) == 1) ?
+ "Disabled" : "Enabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Plug Pending",
+ ((extract_bit(regs[TWL6040_REG_INTID], 1) == 1) ?
+ "Yes" : "No"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Unplug Pending",
+ ((extract_bit(regs[TWL6040_REG_INTID], 2) == 1) ?
+ "Yes" : "No"));
+ fprintf(stream, "| %-30s | %-27s |\n", " PLUGDET State",
+ ((extract_bit(regs[TWL6040_REG_STATUS], 1) == 1) ?
+ "Pulled Low" : "Not Pulled Low"));
+
+ /* Hook Send/End Detection Interrupt */
+ fprintf(stream, "| %-30s | %-27s |\n", "Hook Send/End Detection Int",
+ ((extract_bit(regs[TWL6040_REG_INTMR], 3) == 1) ?
+ "Disabled" : "Enabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Pending",
+ ((extract_bit(regs[TWL6040_REG_INTID], 3) == 1) ?
+ "Yes" : "No"));
+ fprintf(stream, "| %-30s | %-27s |\n", " ACONN State",
+ ((extract_bit(regs[TWL6040_REG_STATUS], 0) == 1) ?
+ "Pulled Low" : "Not Pulled Low"));
+
+ /* HF Short Detection Interrupt */
+ fprintf(stream, "| %-30s | %-27s |\n", "HF Short Detection Interrupt",
+ ((extract_bit(regs[TWL6040_REG_INTMR], 4) == 1) ?
+ "Disabled" : "Enabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Pending",
+ ((extract_bit(regs[TWL6040_REG_INTID], 4) == 1) ?
+ "Yes" : "No"));
+ fprintf(stream, "| %-30s | %-27s |\n", " HF Left Overcurrent Det",
+ ((extract_bit(regs[TWL6040_REG_STATUS], 2) == 1) ?
+ "Triggered" : "Not Triggered"));
+ fprintf(stream, "| %-30s | %-27s |\n", " HF Right Overcurrent Det",
+ ((extract_bit(regs[TWL6040_REG_STATUS], 3) == 1) ?
+ "Triggered" : "Not Triggered"));
+
+ /* Vibra Short Detection Interrupt */
+ fprintf(stream, "| %-30s | %-27s |\n", "Vibra Short Detection Int",
+ ((extract_bit(regs[TWL6040_REG_INTMR], 5) == 1) ?
+ "Disabled" : "Enabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Pending",
+ ((extract_bit(regs[TWL6040_REG_INTID], 5) == 1) ?
+ "Yes" : "No"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Vibra Left Overcurrent Det",
+ ((extract_bit(regs[TWL6040_REG_STATUS], 4) == 1) ?
+ "Triggered" : "Not Triggered"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Vibra Right Overcurrent Det",
+ ((extract_bit(regs[TWL6040_REG_STATUS], 5) == 1) ?
+ "Triggered" : "Not Triggered"));
+
+ /* Ready Interrupt */
+ fprintf(stream, "| %-30s | %-27s |\n", "Ready Interrupt",
+ ((extract_bit(regs[TWL6040_REG_INTMR], 6) == 1) ?
+ "Disabled" : "Enabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Pending",
+ ((extract_bit(regs[TWL6040_REG_INTID], 6) == 1) ?
+ "Yes" : "No"));
+
+ /* Interrupt Clear Mode */
+ fprintf(stream, "| %-30s | %-27s |\n", "Interrupt Clear Mode",
+ ((extract_bit(regs[TWL6040_REG_ACCCTL], 3) == 1) ?
+ "On Read" : "On Write"));
+
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "\n");
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_display_biasing_config
+ * @BRIEF analyze TWL6040 biasing module configuration
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in,out] stream: output file
+ * @param[in,out] regs: register values
+ * @DESCRIPTION analyze TWL6040 biasing module configuration
+ *//*------------------------------------------------------------------------ */
+int twl6040_display_biasing_config(FILE *stream, unsigned char *regs)
+{
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "| BIASING "
+ " |\n");
+ fprintf(stream, "|--------------------------------|------------------"
+ "-----------|\n");
+
+ /* Headset Microphone Bias */
+ fprintf(stream, "| %-30s | %-27s |\n", "Headset Microphone Bias",
+ ((extract_bit(regs[TWL6040_REG_AMICBCTL], 0) == 1) ?
+ "Enabled" : "Disabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Mode",
+ ((extract_bit(regs[TWL6040_REG_AMICBCTL], 1) == 1) ?
+ "Sleep" : "Normal"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Output When Disabled",
+ ((extract_bit(regs[TWL6040_REG_AMICBCTL], 2) == 1) ?
+ "Pull-Down" : "High-Z"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Short Circuit Function",
+ ((extract_bit(regs[TWL6040_REG_AMICBCTL], 3) == 1) ?
+ "Disabled" : "Enabled"));
+
+ /* Main Microphone Bias */
+ fprintf(stream, "| %-30s | %-27s |\n", "Main Microphone Bias",
+ ((extract_bit(regs[TWL6040_REG_AMICBCTL], 4) == 1) ?
+ "Enabled" : "Disabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Mode",
+ ((extract_bit(regs[TWL6040_REG_AMICBCTL], 5) == 1) ?
+ "Sleep" : "Normal"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Output When Disabled",
+ ((extract_bit(regs[TWL6040_REG_AMICBCTL], 6) == 1) ?
+ "Pull-Down" : "High-Z"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Short Circuit Function",
+ ((extract_bit(regs[TWL6040_REG_AMICBCTL], 7) == 1) ?
+ "Disabled" : "Enabled"));
+
+ /* Digital Microphone Bias 1 */
+ fprintf(stream, "| %-30s | %-27s |\n", "Digital Microphone Bias 1",
+ ((extract_bit(regs[TWL6040_REG_DMICBCTL], 0) == 1) ?
+ "Enabled" : "Disabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Mode",
+ ((extract_bit(regs[TWL6040_REG_DMICBCTL], 1) == 1) ?
+ "Sleep" : "Normal"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Output Voltage",
+ ((extract_bit(regs[TWL6040_REG_DMICBCTL], 2) == 1) ?
+ "1.85V" : "1.80V"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Short Circuit Function",
+ ((extract_bit(regs[TWL6040_REG_DMICBCTL], 3) == 1) ?
+ "Disabled" : "Enabled"));
+
+ /* Digital Microphone Bias 2 */
+ fprintf(stream, "| %-30s | %-27s |\n", "Digital Microphone Bias 2",
+ ((extract_bit(regs[TWL6040_REG_DMICBCTL], 4) == 1) ?
+ "Enabled" : "Disabled"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Mode",
+ ((extract_bit(regs[TWL6040_REG_DMICBCTL], 5) == 1) ?
+ "Sleep" : "Normal"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Output Voltage",
+ ((extract_bit(regs[TWL6040_REG_DMICBCTL], 6) == 1) ?
+ "1.85V" : "1.80V"));
+ fprintf(stream, "| %-30s | %-27s |\n", " Short Circuit Function",
+ ((extract_bit(regs[TWL6040_REG_DMICBCTL], 7) == 1) ?
+ "Disabled" : "Enabled"));
+
+ fprintf(stream, "|---------------------------------------------------"
+ "-----------|\n");
+ fprintf(stream, "\n");
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_miclsel2string
+ * @BRIEF convert MICLSEL to corresponding string
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in] s: destination string (pre-allocated)
+ * @param[in] miclsel: MICLSEL bitfield
+ * @DESCRIPTION convert MICLSEL to corresponding string
+ *//*------------------------------------------------------------------------ */
+static int twl6040_miclsel2string(char s[30], unsigned char miclsel)
+{
+ if (s == NULL)
+ return OMAPCONF_ERR_ARG;
+
+ switch (miclsel) {
+ case 0:
+ strcpy(s, "Headset Microphone");
+ break;
+ case 1:
+ strcpy(s, "Main Microphone");
+ break;
+ case 2:
+ strcpy(s, "Auxiliary/FM Left");
+ break;
+ case 3:
+ strcpy(s, "None");
+ break;
+ default:
+ strcpy(s, "ERROR!!!");
+ return OMAPCONF_ERR_ARG;
+ }
+
+ return 0;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION twl6040_micrsel2string
+ * @BRIEF convert MICRSEL to corresponding string
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * @param[in] s: destination string (pre-allocated)
+ * @param[in] micrsel: MICRSEL bitfield
+ * @DESCRIPTION convert MICRSEL to corresponding string
+ *//*------------------------------------------------------------------------ */
+static int twl6040_micrsel2string(char s[30], unsigned