Kernel: Add vc8000d and vc8000e driver

This commit is contained in:
Mingzheng Xing
2023-06-16 21:28:48 +08:00
committed by Han Gao
parent 9c58afc7ad
commit 06b8b8d9f0
74 changed files with 32811 additions and 0 deletions

View File

@@ -38,6 +38,10 @@ source "drivers/staging/media/sunxi/Kconfig"
source "drivers/staging/media/tegra-vde/Kconfig"
source "drivers/staging/media/vpu-vc8000d-kernel/Kconfig"
source "drivers/staging/media/vpu-vc8000e-kernel/Kconfig"
source "drivers/staging/media/zoran/Kconfig"
source "drivers/staging/media/tegra-video/Kconfig"

View File

@@ -12,3 +12,5 @@ obj-$(CONFIG_VIDEO_HANTRO) += hantro/
obj-$(CONFIG_VIDEO_IPU3_IMGU) += ipu3/
obj-$(CONFIG_VIDEO_ROCKCHIP_ISP1) += rkisp1/
obj-$(CONFIG_VIDEO_ZORAN) += zoran/
obj-$(CONFIG_VIDEO_VC8000D) += vpu-vc8000d-kernel/linux/subsys_driver/ vpu-vc8000d-kernel/linux/memalloc/
obj-$(CONFIG_VIDEO_VC8000E) += vpu-vc8000e-kernel/linux/kernel_module/

View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey 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;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
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
state 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 3 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, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU 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 Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@@ -0,0 +1,3 @@
config VIDEO_VC8000D
tristate "VC8000D support"
default m

View File

@@ -0,0 +1,80 @@
##
# Copyright (C) 2020 Alibaba Group Holding Limited
##
DIR_TARGET_KO =bsp/vdec/ko
MODULE_NAME=VDEC
BUILD_LOG_START="\033[47;30m>>> $(MODULE_NAME) $@ begin\033[0m"
BUILD_LOG_END ="\033[47;30m<<< $(MODULE_NAME) $@ end\033[0m"
#
# Do a parallel build with multiple jobs, based on the number of CPUs online
# in this system: 'make -j8' on a 8-CPU system, etc.
#
# (To override it, run 'make JOBS=1' and similar.)
#
ifeq ($(JOBS),)
JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
ifeq ($(JOBS),)
JOBS := 1
endif
endif
all: driver install_local_output
.PHONY: driver install_local_output install_addons install_prepare clean_driver clean_output clean
info:
@echo $(BUILD_LOG_START)
@echo " ====== Build Info from repo project ======"
@echo " BUILDROOT_DIR="$(BUILDROOT_DIR)
@echo " CROSS_COMPILE="$(CROSS_COMPILE)
@echo " LINUX_DIR="$(LINUX_DIR)
@echo " ARCH="$(ARCH)
@echo " BOARD_NAME="$(BOARD_NAME)
@echo " KERNEL_ID="$(KERNELVERSION)
@echo " KERNEL_DIR="$(LINUX_DIR)
@echo " INSTALL_DIR_SDK="$(INSTALL_DIR_SDK)
@echo " ====== Build configuration by settings ======"
@echo " JOBS="$(JOBS)
@echo $(BUILD_LOG_END)
driver:
@echo $(BUILD_LOG_START)
make -C linux/subsys_driver KDIR=$(LINUX_DIR) CROSS=$(CROSS_COMPILE) ARCH=$(ARCH)
make -C linux/memalloc KDIR=$(LINUX_DIR) CROSS=$(CROSS_COMPILE) ARCH=$(ARCH)
@echo $(BUILD_LOG_END)
clean_driver:
@echo $(BUILD_LOG_START)
make -C linux/subsys_driver clean
make -C linux/memalloc clean
@echo $(BUILD_LOG_END)
install_prepare:
mkdir -p ./output/rootfs/$(DIR_TARGET_KO)
install_addons: install_prepare
@if [ -d addons/ko ]; then \
cp -rf addons/ko/* ./output/rootfs/$(DIR_TARGET_KO); \
fi
install_local_output: driver install_prepare install_addons
@echo $(BUILD_LOG_START)
find ./linux -name "*.ko" | xargs -i cp -f {} ./output/rootfs/$(DIR_TARGET_KO)
cp -f ./linux/subsys_driver/driver_load.sh ./output/rootfs/$(DIR_TARGET_KO)
cp -f ./linux/memalloc/memalloc_load.sh ./output/rootfs/$(DIR_TARGET_KO)
chmod +x ./output/rootfs/$(DIR_TARGET_KO)/*.sh
echo "hantrodec" > ./output/rootfs/$(DIR_TARGET_KO)/vc8000d.conf
@if [ `command -v tree` != "" ]; then \
tree ./output/rootfs; \
fi
@echo $(BUILD_LOG_END)
clean_output:
@echo $(BUILD_LOG_START)
rm -rf ./output
@echo $(BUILD_LOG_END)
clean: clean_output clean_driver

View File

@@ -0,0 +1,5 @@
#!/bin/sh
KERNEL_VER=$(uname -r)
BASE_PATH=/lib/modules/${KERNEL_VER}/extra
insmod $BASE_PATH/hantrodec.ko

View File

@@ -0,0 +1,3 @@
#!/bin/sh
rmmod hantrodec

View File

@@ -0,0 +1,142 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef SOFTWARE_LINUX_DWL_DWL_DEFS_H_
#define SOFTWARE_LINUX_DWL_DWL_DEFS_H_
#define DWL_MPEG2_E 31 /* 1 bit */
#define DWL_VC1_E 29 /* 2 bits */
#define DWL_JPEG_E 28 /* 1 bit */
#define DWL_HJPEG_E 17 /* 1 bit */
#define DWL_AV1_E 16 /* 1 bit */
#define DWL_MPEG4_E 26 /* 2 bits */
#define DWL_H264_E 24 /* 2 bits */
#define DWL_H264HIGH10_E 20 /* 1 bits */
#define DWL_AVS2_E 18 /* 2 bits */
#define DWL_VP6_E 23 /* 1 bit */
#define DWL_RV_E 26 /* 2 bits */
#define DWL_VP8_E 23 /* 1 bit */
#define DWL_VP7_E 24 /* 1 bit */
#define DWL_WEBP_E 19 /* 1 bit */
#define DWL_AVS_E 22 /* 1 bit */
#define DWL_G1_PP_E 16 /* 1 bit */
#define DWL_G2_PP_E 31 /* 1 bit */
#define DWL_PP_E 31 /* 1 bit */
#define DWL_HEVC_E 26 /* 3 bits */
#define DWL_VP9_E 29 /* 3 bits */
#define DWL_H264_PIPELINE_E 31 /* 1 bit */
#define DWL_JPEG_PIPELINE_E 30 /* 1 bit */
#define DWL_G2_HEVC_E 0 /* 1 bits */
#define DWL_G2_VP9_E 1 /* 1 bits */
#define DWL_G2_RFC_E 2 /* 1 bits */
#define DWL_RFC_E 17 /* 2 bits */
#define DWL_G2_DS_E 3 /* 1 bits */
#define DWL_DS_E 28 /* 3 bits */
#define DWL_HEVC_VER 8 /* 4 bits */
#define DWL_VP9_PROFILE 12 /* 3 bits */
#define DWL_RING_E 16 /* 1 bits */
#define HANTRODEC_IRQ_STAT_DEC 1
#define HANTRODEC_IRQ_STAT_DEC_OFF (HANTRODEC_IRQ_STAT_DEC * 4)
#define BIGOCEAN_IRQ_STAT_DEC 2
#define BIGOCEAN_IRQ_STAT_DEC_OFF (HANTRODEC_IRQ_STAT_DEC * 4)
#define HANTRODECPP_SYNTH_CFG 60
#define HANTRODECPP_SYNTH_CFG_OFF (HANTRODECPP_SYNTH_CFG * 4)
#define HANTRODEC_SYNTH_CFG 50
#define HANTRODEC_SYNTH_CFG_OFF (HANTRODEC_SYNTH_CFG * 4)
#define HANTRODEC_SYNTH_CFG_2 54
#define HANTRODEC_SYNTH_CFG_2_OFF (HANTRODEC_SYNTH_CFG_2 * 4)
#define HANTRODEC_SYNTH_CFG_3 56
#define HANTRODEC_SYNTH_CFG_3_OFF (HANTRODEC_SYNTH_CFG_3 * 4)
#define HANTRODEC_CFG_STAT 23
#define HANTRODEC_CFG_STAT_OFF (HANTRODEC_CFG_STAT * 4)
#define HANTRODECPP_CFG_STAT 260
#define HANTRODECPP_CFG_STAT_OFF (HANTRODECPP_CFG_STAT * 4)
#define HANTRODEC_DEC_E 0x01
#define HANTRODEC_PP_E 0x01
#define HANTRODEC_DEC_ABORT 0x20
#define HANTRODEC_DEC_IRQ_DISABLE 0x10
#define HANTRODEC_DEC_IRQ 0x100
/* Legacy from G1 */
#define HANTRO_IRQ_STAT_DEC 1
#define HANTRO_IRQ_STAT_DEC_OFF (HANTRO_IRQ_STAT_DEC * 4)
#define HANTRO_IRQ_STAT_PP 60
#define HANTRO_IRQ_STAT_PP_OFF (HANTRO_IRQ_STAT_PP * 4)
#define HANTROPP_SYNTH_CFG 100
#define HANTROPP_SYNTH_CFG_OFF (HANTROPP_SYNTH_CFG * 4)
#define HANTRODEC_SYNTH_CFG 50
#define HANTRODEC_SYNTH_CFG_OFF (HANTRODEC_SYNTH_CFG * 4)
#define HANTRODEC_SYNTH_CFG_2 54
#define HANTRODEC_SYNTH_CFG_2_OFF (HANTRODEC_SYNTH_CFG_2 * 4)
/* VC8000D HW build id */
#define HANTRODEC_HW_BUILD_ID 309
#define HANTRODEC_HW_BUILD_ID_OFF (HANTRODEC_HW_BUILD_ID * 4)
#define HANTRO_DEC_E 0x01
#define HANTRO_PP_E 0x01
#define HANTRO_DEC_ABORT 0x20
#define HANTRO_DEC_IRQ_DISABLE 0x10
#define HANTRO_PP_IRQ_DISABLE 0x10
#define HANTRO_DEC_IRQ 0x100
#define HANTRO_PP_IRQ 0x100
#endif /* SOFTWARE_LINUX_DWL_DWL_DEFS_H_ */

View File

@@ -0,0 +1,88 @@
#############################################################################
#
# The MIT License (MIT)
#
# Copyright (c) 2014 - 2021 VERISILICON
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
#############################################################################
#
# The GPL License (GPL)
#
# Copyright (C) 2014 - 2021 VERISILICON
#
# 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#############################################################################
#
# Note: This software is released under dual MIT and GPL licenses. A
# recipient may use this file under the terms of either the MIT license or
# GPL License. If you wish to use only one license not the other, you can
# indicate your decision by deleting one of the above license notices in your
# version of this file.
#
##############################################################################
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g -DMEMALLOC_DEBUG
else
DEBFLAGS = -O2
endif
# base address and size (MB) for linear memory allocation
HLINA_START := 0x02000000
HLINA_SIZE := 96
EXTRA_CFLAGS += $(DEBFLAGS)
EXTRA_CFLAGS += -DHLINA_START_ADDRESS=$(HLINA_START) -DHLINA_SIZE=$(HLINA_SIZE)
ifneq ($(KERNELRELEASE),)
# recursive call from kernel build system
memalloc-objs :=
obj-m += memalloc.o
else
#KDIR := /export/Testing/Board_Version_Control/SW_Common/SOCLE_MDK-3D/openlinux/2.6.29/v0_5/android_linux-2.6.29
KDIR := /lib/modules/3.2.0-36-generic/build
PWD := $(shell pwd)
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
rm -rf modules.order Module.symvers

View File

@@ -0,0 +1,44 @@
==============================================================================
USAGE
==============================================================================
./memalloc_load.sh
===============================================================================
What is memalloc?
===============================================================================
memalloc is a test environment specific memory allocation kernel driver.
It uses memory left outside linux memory management, divides it into chunks and
gives base addresses to processes for these chunks(= a block of memory).
It has been written for test memory purposes for a very specific test
environment and nothing more.
===============================================================================
Loading the memalloc kernel driver
===============================================================================
1. compile the kernel driver in software/linux/memalloc
> make
2. For testing load kernel driver with:
>./memalloc_load.sh
...or if you want to specify the max size in MB of linear memory:
>./memalloc_load.sh alloc_size=400
...or if you want to specify the base address of linear memory:
>./memalloc_load.sh alloc_base=0x42000000
...or both:
>./memalloc_load.sh alloc_base=0x42000000 alloc_size=400
3. Debugging:
the device node should show up in the the directory /dev
The device should show up in the list /proc/devices
> ls /dev
> cat /proc/devices
Kernel messages can be viewed with
> dmesg
More kernel debug prints can be enabled in the Makefile

View File

@@ -0,0 +1,22 @@
#!/bin/sh
KVER=$(uname -r)
KDIR=/lib/modules/$KVER/build
HLINA_START=0x30000000
HLINA_SIZE=512 #Size in megabytes
HLINA_END=$(($HLINA_START + $HLINA_SIZE*1024*1024))
echo
echo "KDIR=$KDIR"
echo "CROSS=$CROSS"
echo
echo "Linear memory base = $HLINA_START"
printf "Linear top-of-memory = 0x%x\n" $HLINA_END
echo "Linear memory size = ${HLINA_SIZE}MB"
echo
make KDIR=$KDIR CROSS=$CROSS HLINA_START=${HLINA_START}U HLINA_SIZE=${HLINA_SIZE}U $1
exit $?

View File

@@ -0,0 +1,369 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#include <asm/io.h>
#include <linux/uaccess.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/version.h>
#include <linux/vmalloc.h>
#include "memalloc.h"
#ifndef HLINA_START_ADDRESS
#define HLINA_START_ADDRESS 0x1e0000000
#endif
#ifndef HLINA_SIZE
#define HLINA_SIZE 512
#endif
#ifndef HLINA_TRANSL_OFFSET
#define HLINA_TRANSL_OFFSET 0x0
#endif
/* the size of chunk in MEMALLOC_DYNAMIC */
#define CHUNK_SIZE (PAGE_SIZE * 4)
/* memory size in MBs for MEMALLOC_DYNAMIC */
unsigned long alloc_size = HLINA_SIZE;
unsigned long alloc_base = HLINA_START_ADDRESS;
/* user space SW will substract HLINA_TRANSL_OFFSET from the bus address
* and decoder HW will use the result as the address translated base
* address. The SW needs the original host memory bus address for memory
* mapping to virtual address. */
unsigned long addr_transl = HLINA_TRANSL_OFFSET;
static int memalloc_major = 0; /* dynamic */
/* module_param(name, type, perm) */
module_param(alloc_size, ulong, 0);
module_param(alloc_base, ulong, 0);
module_param(addr_transl, ulong, 0);
static DEFINE_SPINLOCK(mem_lock);
typedef struct hlinc {
u64 bus_address;
u32 chunks_reserved;
const struct file *filp; /* Client that allocated this chunk */
} hlina_chunk;
static hlina_chunk *hlina_chunks = NULL;
static size_t chunks = 0;
static int AllocMemory(unsigned long *busaddr, unsigned int size,
const struct file *filp);
static int FreeMemory(unsigned long busaddr, const struct file *filp);
static void ResetMems(void);
static long memalloc_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg) {
int ret = 0;
MemallocParams memparams;
unsigned long busaddr;
PDEBUG("ioctl cmd 0x%08x\n", cmd);
/*
* extract the type and number bitfields, and don't decode
* wrong cmds: return ENOTTY (inappropriate ioctl) before access_ok()
*/
if (_IOC_TYPE(cmd) != MEMALLOC_IOC_MAGIC) return -ENOTTY;
if (_IOC_NR(cmd) > MEMALLOC_IOC_MAXNR) return -ENOTTY;
if (_IOC_DIR(cmd) & _IOC_READ)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)
ret = !access_ok(arg, _IOC_SIZE(cmd));
#else
ret = !access_ok(VERIFY_WRITE, arg, _IOC_SIZE(cmd));
#endif
else if (_IOC_DIR(cmd) & _IOC_WRITE)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)
ret = !access_ok(arg, _IOC_SIZE(cmd));
#else
ret = !access_ok(VERIFY_READ, arg, _IOC_SIZE(cmd));
#endif
if (ret) return -EFAULT;
switch (cmd) {
case MEMALLOC_IOCHARDRESET:
PDEBUG("HARDRESET\n");
ResetMems();
break;
case MEMALLOC_IOCXGETBUFFER:
PDEBUG("GETBUFFER");
ret = copy_from_user(&memparams, (MemallocParams *)arg,
sizeof(MemallocParams));
if (ret) break;
ret = AllocMemory(&memparams.bus_address, memparams.size, filp);
memparams.translation_offset = addr_transl;
ret |= copy_to_user((MemallocParams *)arg, &memparams,
sizeof(MemallocParams));
break;
case MEMALLOC_IOCSFREEBUFFER:
PDEBUG("FREEBUFFER\n");
__get_user(busaddr, (unsigned long *)arg);
ret = FreeMemory(busaddr, filp);
break;
}
return ret ? -EFAULT : 0;
}
static int memalloc_open(struct inode *inode, struct file *filp) {
PDEBUG("dev opened\n");
return 0;
}
static int memalloc_release(struct inode *inode, struct file *filp) {
int i = 0;
spin_lock(&mem_lock);
for (i = 0; i < chunks; i++) {
if (hlina_chunks[i].filp == filp) {
printk(KERN_WARNING "memalloc: Found unfreed memory at release time!\n");
hlina_chunks[i].filp = NULL;
hlina_chunks[i].chunks_reserved = 0;
}
}
spin_unlock(&mem_lock);
PDEBUG("dev closed\n");
return 0;
}
void __exit memalloc_cleanup(void) {
if (hlina_chunks != NULL) vfree(hlina_chunks);
unregister_chrdev(memalloc_major, "memalloc");
PDEBUG("module removed\n");
return;
}
/* VFS methods */
static struct file_operations memalloc_fops = {
.owner = THIS_MODULE,
.open = memalloc_open,
.release = memalloc_release,
.unlocked_ioctl = memalloc_ioctl
};
int __init memalloc_init(void) {
int result;
PDEBUG("module init\n");
printk("memalloc: Linear Memory Allocator\n");
printk("memalloc: Linear memory base = 0x%llx\n", alloc_base);
chunks = (alloc_size * 1024 * 1024) / CHUNK_SIZE;
printk(KERN_INFO
"memalloc: Total size %ld MB; %d chunks"
" of size %lu\n",
alloc_size, (int)chunks, CHUNK_SIZE);
hlina_chunks = (hlina_chunk *)vmalloc(chunks * sizeof(hlina_chunk));
if (hlina_chunks == NULL) {
printk(KERN_ERR "memalloc: cannot allocate hlina_chunks\n");
result = -ENOMEM;
goto err;
}
result = register_chrdev(memalloc_major, "memalloc", &memalloc_fops);
if (result < 0) {
PDEBUG("memalloc: unable to get major %d\n", memalloc_major);
goto err;
} else if (result != 0) {/* this is for dynamic major */
memalloc_major = result;
}
ResetMems();
return 0;
err:
if (hlina_chunks != NULL) vfree(hlina_chunks);
return result;
}
/* Cycle through the buffers we have, give the first free one */
static int AllocMemory(unsigned long *busaddr, unsigned int size,
const struct file *filp) {
int i = 0;
int j = 0;
unsigned int skip_chunks = 0;
/* calculate how many chunks we need; round up to chunk boundary */
unsigned int alloc_chunks = (size + CHUNK_SIZE - 1) / CHUNK_SIZE;
*busaddr = 0;
spin_lock(&mem_lock);
/* run through the chunk table */
for (i = 0; i < chunks;) {
skip_chunks = 0;
/* if this chunk is available */
if (!hlina_chunks[i].chunks_reserved) {
/* check that there is enough memory left */
if (i + alloc_chunks > chunks) break;
/* check that there is enough consecutive chunks available */
for (j = i; j < i + alloc_chunks; j++) {
if (hlina_chunks[j].chunks_reserved) {
skip_chunks = 1;
/* skip the used chunks */
i = j + hlina_chunks[j].chunks_reserved;
break;
}
}
/* if enough free memory found */
if (!skip_chunks) {
*busaddr = hlina_chunks[i].bus_address;
hlina_chunks[i].filp = filp;
hlina_chunks[i].chunks_reserved = alloc_chunks;
break;
}
} else {
/* skip the used chunks */
i += hlina_chunks[i].chunks_reserved;
}
}
spin_unlock(&mem_lock);
if (*busaddr == 0) {
printk("memalloc: Allocation FAILED: size = %ld\n", size);
return -EFAULT;
} else {
PDEBUG("MEMALLOC OK: size: %d, reserved: %ld\n", size,
alloc_chunks * CHUNK_SIZE);
}
return 0;
}
/* Free a buffer based on bus address */
static int FreeMemory(unsigned long busaddr, const struct file *filp) {
int i = 0;
spin_lock(&mem_lock);
for (i = 0; i < chunks; i++) {
/* user space SW has stored the translated bus address, add addr_transl to
* translate back to our address space */
if (hlina_chunks[i].bus_address == busaddr + addr_transl) {
if (hlina_chunks[i].filp == filp) {
hlina_chunks[i].filp = NULL;
hlina_chunks[i].chunks_reserved = 0;
} else {
printk(KERN_WARNING "memalloc: Owner mismatch while freeing memory!\n");
}
break;
}
}
spin_unlock(&mem_lock);
return 0;
}
/* Reset "used" status */
static void ResetMems(void) {
int i = 0;
unsigned long ba = alloc_base;
spin_lock(&mem_lock);
for (i = 0; i < chunks; i++) {
hlina_chunks[i].bus_address = ba;
hlina_chunks[i].filp = NULL;
hlina_chunks[i].chunks_reserved = 0;
ba += CHUNK_SIZE;
}
spin_unlock(&mem_lock);
}
module_init(memalloc_init);
module_exit(memalloc_cleanup);
/* module description */
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Verisilicon");
MODULE_DESCRIPTION("Linear RAM allocation");

View File

@@ -0,0 +1,88 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef MEMALLOC_H
#define MEMALLOC_H
#include <linux/ioctl.h>
#undef PDEBUG
#ifdef MEMALLOC_DEBUG
#ifdef __KERNEL__
#define PDEBUG(fmt, args...) printk(KERN_INFO "memalloc: " fmt, ##args)
#else
#define PDEBUG(fmt, args...) fprintf(stderr, fmt, ##args)
#endif
#else
#define PDEBUG(fmt, args...)
#endif
typedef struct {
unsigned long bus_address;
unsigned int size;
unsigned long translation_offset;
unsigned int mem_type;
int fd;
int flags;
} MemallocParams;
#define MEMALLOC_IOC_MAGIC 'k'
#define MEMALLOC_IOCXGETBUFFER _IOWR(MEMALLOC_IOC_MAGIC, 1, MemallocParams*)
#define MEMALLOC_IOCSFREEBUFFER _IOW(MEMALLOC_IOC_MAGIC, 2, unsigned long*)
#define MEMALLOC_IOCHARDRESET _IO(MEMALLOC_IOC_MAGIC, 15) /* debugging tool */
#define MEMALLOC_IOC_MAXNR 15
#endif /* MEMALLOC_H */

View File

@@ -0,0 +1,99 @@
#!/bin/sh
#############################################################################
#
# The MIT License (MIT)
#
# Copyright (c) 2014 - 2021 VERISILICON
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
#############################################################################
#
# The GPL License (GPL)
#
# Copyright (C) 2014 - 2021 VERISILICON
#
# 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#############################################################################
#
# Note: This software is released under dual MIT and GPL licenses. A
# recipient may use this file under the terms of either the MIT license or
# GPL License. If you wish to use only one license not the other, you can
# indicate your decision by deleting one of the above license notices in your
# version of this file.
#
##############################################################################
#
# Load memalloc
module="memalloc"
device="/dev/memalloc"
mode="666"
echo
if [ ! -e /dev ]
then
mkdir -p /dev/
fi
#insert module
rm_module=`lsmod |grep $module`
if [ ! -z "$rm_module" ]
then
rmmod $module || exit 1
fi
insmod $module.ko $* || exit 1
echo "module $module inserted"
#remove old nod
rm -f $device
#read the major asigned at loading time
major=`cat /proc/devices | grep $module | cut -c1-3`
echo "$module major = $major"
#create dev node
mknod $device c $major 0
echo "node $device created"
#give all 'rw' access
chmod $mode $device
echo "set node access to $mode"
#the end
echo

View File

@@ -0,0 +1,207 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <assert.h>
#include "basetype.h"
#include "memalloc.h"
int main(void) {
i32 memdev_fd = -1;
i32 memdev_fd_2 = -1;
i32 memdev_map = -1;
i32 i = 0, u = 0;
u32 *virtual1 = MAP_FAILED;
u32 *virtual2 = MAP_FAILED;
u32 pgsize = getpagesize();
const char *memdev = "/dev/memalloc";
const char *memmap = "/dev/mem";
u32 bus_address1 = 0, bus_address2 = 0;
u32 size = 4096;
memdev_fd = open(memdev, O_RDWR);
if (memdev_fd == -1) {
printf("Failed to open dev: %s\n", memdev);
goto end1;
}
memdev_fd_2 = open(memdev, O_RDWR);
if (memdev_fd_2 == -1) {
printf("Failed to open dev: %s\n", memdev);
goto end1;
}
memdev_map = open(memmap, O_RDWR);
if (memdev_map == -1) {
printf("Failed to open dev: %s\n", memmap);
goto end1;
}
size = (size + pgsize) & (~(pgsize - 1));
printf("Hard Reset\n", size);
/*ioctl(memdev_fd, MEMALLOC_IOCHARDRESET, 0);*/
for (i = 0; i < 100; i++) {
ioctl(memdev_fd, MEMALLOC_IOCXGETBUFFER, &bus_address1);
printf("bus_address1 0x%08x\n", bus_address1);
ioctl(memdev_fd_2, MEMALLOC_IOCXGETBUFFER, &bus_address2);
printf("bus_address2 0x%08x\n", bus_address2);
/* test write stuff in the mem are*/
if (bus_address1) {
virtual1 = (u32 *)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED,
memdev_map, bus_address1);
printf("Virtual1 %08x\n", virtual1);
}
if (virtual1 != MAP_FAILED) {
for (u = 0; u < size / 4; u++) {
*virtual1 = i + 1;
}
} else {
printf("map failed\n");
}
/* test write stuff in the mem are*/
if (bus_address2) {
virtual2 = (u32 *)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED,
memdev_map, bus_address2);
printf("Virtual2 0x%08x\n", virtual2);
}
if (virtual2 != MAP_FAILED) {
for (u = 0; u < size / 4; u++) {
*virtual2 = i + 2;
}
} else {
printf("map failed\n");
}
if (virtual1 != MAP_FAILED) {
for (u = 0; u < size / 4; u++) {
if (*virtual1 != i + 1) {
printf("MISMATCH1!\n");
break;
}
}
}
if (virtual2 != MAP_FAILED) {
for (u = 0; u < size / 4; u++) {
if (*virtual2 != i + 2) {
printf("MISMATCH2!\n");
break;
}
}
}
if ((i % 30)) {
printf("release %d ", size);
ioctl(memdev_fd, MEMALLOC_IOCSFREEBUFFER, &bus_address1);
printf("address:\t\t0x%08x\n", bus_address1);
}
printf("release %d ", size);
/*ioctl(memdev_fd_2, MEMALLOC_IOCSFREEBUFFER, &bus_address2);
printf("address:\t\t0x%08x\n", bus_address2);
virtual1 = MAP_FAILED;
virtual2 = MAP_FAILED;*/
if (!(i % 30)) {
close(memdev_fd);
memdev_fd = open(memdev, O_RDWR);
if (memdev_fd == -1) {
printf("Failed to open dev: %s\n", memdev);
goto end1;
}
}
close(memdev_fd_2);
memdev_fd_2 = open(memdev, O_RDWR);
if (memdev_fd_2 == -1) {
printf("Failed to open dev: %s\n", memdev);
goto end1;
}
}
end1:
close(memdev_fd);
close(memdev_fd_2);
close(memdev_map);
return 0;
}

View File

@@ -0,0 +1,89 @@
#############################################################################
#
# The MIT License (MIT)
#
# Copyright (c) 2014 - 2021 VERISILICON
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
#############################################################################
#
# The GPL License (GPL)
#
# Copyright (C) 2014 - 2021 VERISILICON
#
# 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#############################################################################
#
# Note: This software is released under dual MIT and GPL licenses. A
# recipient may use this file under the terms of either the MIT license or
# GPL License. If you wish to use only one license not the other, you can
# indicate your decision by deleting one of the above license notices in your
# version of this file.
#
##############################################################################
DEBUG ?= n
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g -DHANTRODEC_DEBUG
DEBFLAGS += -DHANTROMMU_DEBUG
else
DEBFLAGS = -O2
endif
EXTRA_CFLAGS += $(DEBFLAGS)
# EXTRA_CFLAGS += -DDYNAMIC_MALLOC_VCMDNODE
ifneq ($(KERNELRELEASE),)
# recursive call from kernel build system
ccflags-y := -I$(src)/../dwl
hantrodec-objs := hantro_dec.o hantro_mmu.o hantro_axife.o hantro_vcmd.o bidirect_list.o vcmdswhwregisters.o subsys.o kernel_allocator.o
obj-m += hantrodec.o
else
#KDIR := /mnt/export/Testing/Board_Version_Control/SW_Common/SOCLE_MDK-3D/openlinux/2.6.29/v0_5/android_linux-2.6.29
KVER := $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
PWD := $(shell pwd)
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
rm -rf modules.order Module.symvers

View File

@@ -0,0 +1,49 @@
/* Copyright 2013 Google Inc. All Rights Reserved. */
-- BUILD --
You need a fully configured kernel source tree in order to build the
driver. Please set the location of the kernel tree in the Makefile (KDIR).
If you want some extra debug information in the kernel logs, you could
define the HANTRODEC_DEBUG but please be aware that allot of things are traced
with this option.
Also you could set a particular device MAJOR in the 'hantrodec.c' if you don't want
dynamic allocation.
Just run in this dir:
%make
-- USAGE --
The parameters that can be set when loading the driver are the HW IO base
address and the assigned IRQ number.
First of all the module has to be inserted into the kernel with:
(you need a Linux shell cmd line)
%insmod hantrodec.o base_port=<baseaddress> irq=<irq number> pcie=<pcie_enabled>
Set the correct values for the HW IO base address and the IRQ number if
the default values compiled into the module are not valid.
E.g., to disable PCIE mode:
%insmod hantrodec.o pcie=0 base_port=<baseaddress> irq=<irq number>
E.g., to enable vcmd mode:
%insmod hantrodec.o vcmd=1
Second of all a char device file has to be created:
%mknod /dev/hantrodec c <MAJOR> 0
Replace MAJOR with the correct value (i.e. read /proc/devices to found out
the exact values).
Make sure that you have RW rights for the newly created dev file (use 'chmod').
The 'driver_load' script is provided for preparing all the things necessary for
the driver to be usable. The script is using 'awk' to retrieve the device's
major from /proc/devices. Remember to set the driver parameters.

View File

@@ -0,0 +1,220 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifdef __FREERTOS__
#include <string.h>
#include "osal.h"
#elif defined(__linux__)
#include <linux/kernel.h>
#include <linux/module.h>
/* needed for __init,__exit directives */
#include <linux/init.h>
/* needed for remap_page_range
SetPageReserved
ClearPageReserved
*/
#include <linux/mm.h>
/* obviously, for kmalloc */
#include <linux/slab.h>
/* for struct file_operations, register_chrdev() */
#include <linux/fs.h>
/* standard error codes */
#include <linux/errno.h>
#include <linux/moduleparam.h>
/* request_irq(), free_irq() */
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/semaphore.h>
#include <linux/spinlock.h>
/* needed for virt_to_phys() */
#include <asm/io.h>
#include <linux/pci.h>
#include <asm/uaccess.h>
#include <linux/ioport.h>
#include <asm/irq.h>
#include <linux/version.h>
#include <linux/vmalloc.h>
#include <linux/timer.h>
#else //For other os
//TODO...
#endif
#include "bidirect_list.h"
void init_bi_list(bi_list* list)
{
list->head = NULL;
list->tail = NULL;
}
bi_list_node* bi_list_create_node(void)
{
bi_list_node* node=NULL;
node=(bi_list_node*)vmalloc(sizeof(bi_list_node));
if(node==NULL)
{
PDEBUG ("%s\n","vmalloc for node fail!");
return node;
}
memset(node,0,sizeof(bi_list_node));
return node;
}
void bi_list_free_node(bi_list_node* node)
{
//free current node
vfree(node);
return;
}
void bi_list_insert_node_tail(bi_list* list,bi_list_node* current_node)
{
if(current_node==NULL)
{
PDEBUG ("%s\n","insert node tail NULL");
return;
}
if(list->tail)
{
current_node->previous=list->tail;
list->tail->next=current_node;
list->tail=current_node;
list->tail->next=NULL;
}
else
{
list->head=current_node;
list->tail=current_node;
current_node->next=NULL;
current_node->previous=NULL;
}
return;
}
void bi_list_insert_node_before(bi_list* list,bi_list_node* base_node,bi_list_node* new_node)
{
bi_list_node* temp_node_previous=NULL;
if(new_node==NULL)
{
PDEBUG ("%s\n","insert node before new node NULL");
return;
}
if(base_node)
{
if(base_node->previous)
{
//at middle position
temp_node_previous = base_node->previous;
temp_node_previous->next=new_node;
new_node->next = base_node;
base_node->previous = new_node;
new_node->previous=temp_node_previous;
}
else
{
//at head
base_node->previous = new_node;
new_node->next = base_node;
list->head=new_node;
new_node->previous = NULL;
}
}
else
{
//at tail
bi_list_insert_node_tail(list,new_node);
}
return;
}
void bi_list_remove_node(bi_list* list,bi_list_node* current_node)
{
bi_list_node* temp_node_previous=NULL;
bi_list_node* temp_node_next=NULL;
if(current_node==NULL)
{
PDEBUG ("%s\n","remove node NULL");
return;
}
temp_node_next=current_node->next;
temp_node_previous=current_node->previous;
if(temp_node_next==NULL && temp_node_previous==NULL )
{
//there is only one node.
list->head=NULL;
list->tail=NULL;
}
else if(temp_node_next==NULL)
{
//at tail
list->tail=temp_node_previous;
temp_node_previous->next=NULL;
}
else if( temp_node_previous==NULL)
{
//at head
list->head=temp_node_next;
temp_node_next->previous=NULL;
}
else
{
//at middle position
temp_node_previous->next=temp_node_next;
temp_node_next->previous=temp_node_previous;
}
return;
}

View File

@@ -0,0 +1,107 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _BIDIRECT_LIST_H_
#define _BIDIRECT_LIST_H_
#ifdef __FREERTOS__
#include "dev_common_freertos.h" /* needed for the _IOW etc stuff used later */
#elif defined(__linux__)
#include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
#else //For other os
//TODO...
#endif
/*
* Macros to help debugging
*/
#undef PDEBUG /* undef it, just in case */
#ifdef BIDIRECTION_LIST_DEBUG
# ifdef __KERNEL__
/* This one if debugging is on, and kernel space */
# define PDEBUG(fmt, args...) printk( KERN_INFO "hmp4e: " fmt, ## args)
# else
/* This one for user space */
# define PDEBUG(fmt, args...) printf(__FILE__ ":%d: " fmt, __LINE__ , ## args)
# endif
#else
# define PDEBUG(fmt, args...) /* not debugging: nothing */
#endif
/***********************************************************************************************************************************************\
* <Typedefs>
\**********************************************************************************************************************************************/
typedef struct bi_list_node{
void* data;
struct bi_list_node* next;
struct bi_list_node* previous;
}bi_list_node;
typedef struct bi_list{
bi_list_node* head;
bi_list_node* tail;
}bi_list;
void init_bi_list(bi_list* list);
bi_list_node* bi_list_create_node(void);
void bi_list_free_node(bi_list_node* node);
void bi_list_insert_node_tail(bi_list* list,bi_list_node* current_node);
void bi_list_insert_node_before(bi_list* list,bi_list_node* base_node,bi_list_node* new_node);
void bi_list_remove_node(bi_list* list,bi_list_node* current_node);
#endif /* !_BIDIRECT_LIST_H_ */

View File

@@ -0,0 +1,10 @@
#!/bin/sh
KDIR=/mnt/export/Testing/Board_Version_Control/SW_Common/ARM_realview_v6/2.6.28-arm1/v0_1-v6/linux-2.6.28-arm1
echo
echo "KDIR=$KDIR"
echo "CROSS=$CROSS"
make KDIR=$KDIR $1

View File

@@ -0,0 +1,10 @@
#!/bin/sh
KDIR=/mnt/export/Testing/Board_Version_Control/SW_Common/SOCLE_MDK-3D/openlinux/2.6.29/v0_5/android_linux-2.6.29
echo
echo "KDIR=$KDIR"
echo "CROSS=$CROSS"
make KDIR=$KDIR $1

View File

@@ -0,0 +1,10 @@
#!/bin/sh
KDIR=/mnt/export/Testing/Board_Version_Control/SW_Common/VExpress/linux-linaro-3.2-2012.01-0
echo
echo "KDIR=$KDIR"
echo "CROSS=$CROSS"
make KDIR=$KDIR $1

View File

@@ -0,0 +1,43 @@
# Copyright 2013 Google Inc. All Rights Reserved.
module="hantrodec"
device="/dev/hantrodec"
mode="666"
echo
if [ ! -e /dev ]
then
mkdir -p /dev/
fi
#insert module
rm_module=`lsmod |grep $module`
if [ ! -z "$rm_module" ]
then
rmmod $module || exit 1
fi
insmod $module.ko $* || exit 1
echo "module $module inserted"
#remove old nod
rm -f $device
#read the major asigned at loading time
major=`cat /proc/devices | grep $module | cut -c1-3`
echo "$module major = $major"
#create dev node
mknod $device c $major 0
echo "node $device created"
#give all 'rw' access
chmod $mode $device
echo "set node access to $mode"
#the end
echo

View File

@@ -0,0 +1,43 @@
# Copyright 2013 Google Inc. All Rights Reserved.
module="hantrodec"
device="/dev/hantrodec"
mode="666"
echo
if [ ! -e /dev ]
then
mkdir -p /dev/
fi
#insert module
rm_module=`lsmod |grep $module`
if [ ! -z "$rm_module" ]
then
rmmod $module || exit 1
fi
insmod $module.ko $* base_port=0xd0000000 || exit 1
echo "module $module inserted"
#remove old nod
rm -f $device
#read the major asigned at loading time
major=`cat /proc/devices | grep $module | cut -c1-3`
#major='50'
echo "$module major = $major"
#create dev node
mknod $device c $major 0
echo "node $device created"
#give all 'rw' access
chmod $mode $device
echo "set node access to $mode"
#the end
echo

View File

@@ -0,0 +1,255 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _DEV_COMMON_FREERTOS_H_
#define _DEV_COMMON_FREERTOS_H_
/**********Driver for FreeRTOS based on the method of Linux's calling**********/
#define __u8 u8
#define __i8 i8
#define __u32 u32
#define __i32 i32
#define sema_init(s,v) sem_init(s,0,v)
//PCIE
#define pci_get_device(a,b,c) (void *)0
#define pci_enable_device(a) 0
#define pci_disable_device(a) 0
#define pci_resource_start(a,b) 0
#define pci_resource_len(a,b) 0
/*--------------------------------*/
/* IO */
//#define O_RDONLY (1)
//#define O_WRONLY (1 << 1)
//#define O_RDWR (O_RDONLY | O_WRONLY)
//#define O_SYNC (1 << 2)
#undef MAP_FAILED
#define MAP_FAILED NULL
#undef NULL
#define NULL ((void *)0)
#define getpagesize() (1)
#define ioremap_nocache(addr,size) (addr)
#define iounmap(addr)
#define mmap(va, size, access, flag, fd, pa) DirectMemoryMap(pa, size)
#define munmap(pRegs, size)
#define vmalloc(a) pvPortMalloc(a) //malloc(a);
#define vfree(a) vPortFree(a) //free(a);
#define probe(a) Platform_init(a)
#define open(name,flag) freertos_open(name,flag)
#define ioctl(fd,cmd,arg) freertos_ioctl(fd,cmd,arg)
#define close(fd) freertos_close(fd)
#define KERN_INFO
#define KERN_ERR
#define KERN_WARNING
#define KERN_DEBUG
#define printk PDEBUG
#define access_ok(a,b,c) (1)
#define __init
#define __exit
#define msleep(s) osal_usleep(s*1000)
/*
* Let any architecture override either of the following before
* including this file.
*/
#ifndef _IOC_SIZEBITS
# define _IOC_SIZEBITS 14
#endif
#ifndef _IOC_DIRBITS
# define _IOC_DIRBITS 2
#endif
#define _IOC_NRBITS 8
#define _IOC_TYPEBITS 8
#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
#define _IOC_NRSHIFT 0
#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
/*
* Direction bits, which any architecture can choose to override
* before including this file.
*/
#ifndef _IOC_NONE
# define _IOC_NONE 0U
#endif
#ifndef _IOC_WRITE
# define _IOC_WRITE 1U
#endif
#ifndef _IOC_READ
# define _IOC_READ 2U
#endif
#define _IOC(dir,type,nr,size) \
(((dir) << _IOC_DIRSHIFT) | \
((type) << _IOC_TYPESHIFT) | \
((nr) << _IOC_NRSHIFT) | \
((size) << _IOC_SIZESHIFT))
#define _IOC_TYPECHECK(t) (sizeof(t))
/* used to create numbers */
#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
/* used to decode ioctl numbers.. */
#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
/* ...and for the drivers/sound files... */
#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
#define DECLARE_WAIT_QUEUE_HEAD(a)
/* Kernel/User space */
#define copy_from_user(des,src,size) (memcpy(des,src,size),0)
#define copy_to_user(des,src,size) (memcpy(des,src,size),0)
#define raw_copy_from_user(des,src,size) (memcpy(des,src,size),0)
#define raw_copy_to_user(des,src,size) (memcpy(des,src,size),0)
#define __put_user(val,user) (*(user) = (val))
#define __get_user(val,user) ((val) = *user)
/* Interrupt */
/*********************request_irq, disable_irq, enable_irq need to be provided by customer*********************/
#define request_irq(i,isr,flag,name,data) RegisterIRQ(i, isr, flag, name, data)
#define disable_irq(i) IntDisableIRQ(i)
#define enable_irq(i) IntEnableIRQ(i)
#define free_irq(i,data)
#define irqreturn_t void
#define down_interruptible(a) pthread_mutex_lock(a)
#define up(a) pthread_mutex_unlock(a)
#define wait_event_interruptible(a,b) sem_wait(&a)
#define wake_up_interruptible_all(a) sem_post(a)
#define IRQ_RETVAL(a) //(a)
#define IRQ_HANDLED //1
#define IRQ_NONE //0
#define register_chrdev(m,name,op) (0)
#define unregister_chrdev(m,name)
#define IRQF_SHARED 1
#define IRQF_DISABLED 0x00000020
#define request_mem_region(addr,size,name) (1)
#define release_mem_region(addr,size)
#define kill_fasync(queue,sig,flag)
//Timer
//typedef TimerHandle_t struct timer_list; //For FreeRTOS
#define ERR_OS_FAIL (0xffff)
#define ERESTARTSYS ERR_OS_FAIL
#ifdef EFAULT
#undef EFAULT
#endif
#define EFAULT ERR_OS_FAIL
#ifdef ENOTTY
#undef ENOTTY
#endif
#define ENOTTY ERR_OS_FAIL
#ifdef EINVAL
#undef EINVAL
#endif
#define EINVAL ERR_OS_FAIL
#ifdef EBUSY
#undef EBUSY
#endif
#define EBUSY ERR_OS_FAIL
/* kernel sync objects */
/**********the atomic operations need to be provided by customer**********/
//#define atomic_t __attribute__((section("cpu_dram"), aligned(4))) xmp_atomic_int_t//i32
//#define ATOMIC_INIT(a) XMP_ATOMIC_INT_INITIALIZER(a)//a
//#define atomic_inc(a) xmp_atomic_int_increment(a,1)//((*(a))++)
//#define atomic_read(a) xmp_atomic_int_value(a)//(a)
#define atomic_t i32
#define ATOMIC_INIT(a) a
#define atomic_inc(a) ((*(a))++)
#define atomic_read(a) (a)
typedef int sig_atomic_t;
//typedef int sigset_t;
#define sigemptyset(set)
#define sigaddset(set, sig)
#define sigsuspend(set)
#define sigwait(set, signo)
#define spinlock_t pthread_mutex_t
#define spin_lock_init(a) (*a = PTHREAD_MUTEX_INITIALIZER)
#define isr_spin_lock_irqsave(a,b)
#define isr_spin_unlock_irqrestore(a,b)
#define spin_lock_irqsave(a,b) {pthread_mutex_lock(a); \
b = ioread32((void *)SYS_REG_INT_EN) & g_vc8000_int_enable_mask; \
*((volatile uint32_t *)SYS_REG_INT_EN) &= ~(b);}
#define spin_unlock_irqrestore(a,b) {*((volatile uint32_t *)SYS_REG_INT_EN) = \
ioread32((void *)SYS_REG_INT_EN) | (b); \
pthread_mutex_unlock(a); }
#define spin_lock(a) pthread_mutex_lock(a)
#define spin_unlock(a) pthread_mutex_unlock(a)
#define getpid() (int)pthread_self()
#endif /* _DEV_COMMON_FREERTOS_H_ */

View File

@@ -0,0 +1,86 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#include "io_tools.h"
inline u32 ioread32(volatile void* addr) {
return *(volatile u32*)(addr);
}
inline void iowrite32(u32 val,volatile void *addr) {
*(volatile u32*)addr = val;
}
inline u16 ioread16(volatile void* addr) {
return *(volatile u16*)(addr);
}
inline void iowrite16(u16 val,volatile void *addr) {
*(volatile u16*)addr = val;
}
inline u8 ioread8(volatile void* addr) {
return *(volatile u8*)(addr);
}
inline void iowrite8(u8 val,volatile void *addr) {
*(volatile u8*)addr = val;
}
inline u32 readl(volatile void* addr) {
return *(volatile u32*)(addr);
}
inline void writel(unsigned int v, volatile void *addr) {
*(volatile unsigned int *)addr = /*cpu_to_le32*/(v);
}

View File

@@ -0,0 +1,89 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _IO_TOOLS_
#define _IO_TOOLS_
#include "basetype.h"
u32 ioread32(volatile void* addr);
void iowrite32(u32 val,volatile void *addr);
u16 ioread16(volatile void* addr);
u8 ioread8(volatile void* addr);
void iowrite16(u16 val,volatile void *addr);
void iowrite8(u8 val,volatile void *addr);
u32 readl(volatile void* addr);
void writel(unsigned int v, volatile void *addr);
#define read_mreg32(addr) ioread32((void*)(addr))
#define write_mreg32(addr,val) iowrite32(val, (void*)(addr))
#define read_mreg16(addr) ioread16((void*)addr)
#define write_mreg16(addr,val) iowrite16(val, (void*)(addr))
#define read_mreg8(addr) ioread8((void*)addr)
#define write_mreg8(addr,val) iowrite8(val, (void*)(addr))
//Dec
int hantrodec_init(void);
int hantrodec_open(int *inode, int filp);
int hantrodec_release(int *inode, int filp);
long hantrodec_ioctl(int filp, unsigned int cmd, void *arg);
//VCMD interfaces funcs
int hantrovcmd_init(void);
int hantrovcmd_open(int *inode, int filp);
int hantrovcmd_release(int *inode, int filp);
long hantrovcmd_ioctl(int filp, unsigned int cmd, void *arg);
//typedef int (*IRQHandler)(i32 i, void* data);
typedef void (*IRQHandler)(void* data);
#endif //_IO_TOOLS_

View File

@@ -0,0 +1,484 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#include "osal.h"
#include "memalloc_freertos.h"
/* Dev Memory Map for NETNT */
#define DEV_MEM_BANK_0 (0)
#define MEM_BANK0_SIZE (16*1024*1024*1024LL)
#define DEV_MEM_BANK_1 (1)
#define MEM_BANK1_SIZE (16*1024*1024*1024LL)
#if 1
#define SHARED_MEM_DEV_ADDRESS (0x840000000LL) //TOP 29
#define SHARED_MEM_CPU_ADDRESS (0x40000000)
//#define SHARED_MEM_CPU_ADDRESS (0x30000000)
//#define SHARED_MEM_CPU_ADDRESS (0x30000000)
#define SHARED_MEM_SIZE (2*1024*1024*1024LL)
#define SHARED_MEM_BANK (DEV_MEM_BANK_0)
#else
#define SHARED_MEM_DEV_ADDRESS (0x800000000LL) //TOP24
#define SHARED_MEM_CPU_ADDRESS (0x80000000)
#define SHARED_MEM_SIZE (2*1024*1024*1024LL)
#define SHARED_MEM_BANK (DEV_MEM_BANK_0)
#endif
#define MEM_0_DEV_ADDRESS (SHARED_MEM_DEV_ADDRESS + SHARED_MEM_SIZE)
#define MEM_0_CPU_ADDRESS (0)
#define MEM_0_SIZE (MEM_BANK0_SIZE + MEM_BANK1_SIZE - SHARED_MEM_SIZE)
#define MEM_0_BANK (DEV_MEM_BANK_0)
/*
#define MEM_1_DEV_ADDRESS (0xC00000000LL)
#define MEM_1_CPU_ADDRESS (0)
#define MEM_1_SIZE (16*1024*1024*1024LL)
#define MEM_1_BANK (DEV_MEM_BANK_1)
*/
/* the size of chunk in MEMALLOC_DYNAMIC */
#define CHUNK_SIZE (16*1024)
/* DO NOT change below defines, they need to be matched with DWL_MEM_TYPE_xx */
#define _MEM_TYPE_CPU 0U /* CPU RW. non-secure CMA memory */
#define _MEM_TYPE_SLICE 1U /* VPU R, CAAM W */
#define _MEM_TYPE_DPB 2U /* VPU RW, Render R */
#define _MEM_TYPE_VPU_WORKING 3U /* VPU R, CPU W. non-secure memory */
#define _MEM_TYPE_VPU_WORKING_SPECIAL 4U /* VPU R, CPU RW. only for VP9 counter context table */
#define _MEM_TYPE_VPU_ONLY 5U /* VPU RW only. */
/*
memory type enum
*/
typedef enum {
MEM_TYPE_SHARED = 0,
MEM_TYPE_DEVICE,
}_mem_type;
/*
memory region id enum, also as index of array "_regions" and array "hlina_mgr"
*/
typedef enum {
MEM_ID_SHARED = 0,
MEM_ID_0,
/* MEM_ID_1, */
MAX_MEM_REGION
}_mem_region_id;
/*
memory region properties struct
*/
typedef struct __mem_region {
unsigned long long bus_addr; /* Physical address of dev memory region */
char * virt_addr; /* virtual address mapping to CPU, 0 means invisible to CPU */
unsigned long long size; /* size of dev memory region */
unsigned short bank; /* DDR RAM bank id */
_mem_type type;
unsigned long translation_offset; /* user space SW will substract HLINA_TRANSL_OFFSET from the bus address
* and decoder HW will use the result as the address translated base
* address. The SW needs the original host memory bus address for memory
* mapping to virtual address. */
} _mem_region_t;
/*
descriptor for each chunk
*/
typedef struct hlinc {
unsigned short chunks_occupied; /* indicate number of occupied chunks which start from current chunk */
int filp; /* Client that allocated this chunk */
} hlina_chunk_t;
/*
memory region management struct
*/
typedef struct __hlina_mgr {
hlina_chunk_t *hlina_chunks; /* point to descriptor of each chunks */
unsigned long chunks; /* total chunks in this mem region */
unsigned long reserved_chunks; /* number of reserved chunks in this mem rtegion.
* The reserved chunks is located at the beginning of corresponding mem region, application can't use them */
_mem_region_t *mem_prop;
} _hlina_mgr_t;
/*
memory regions perporties, indexed by _mem_region_id.
*/
static _mem_region_t _regions[MAX_MEM_REGION] = {
/*MEM_ID_SHARED*/ { SHARED_MEM_DEV_ADDRESS, (char *)SHARED_MEM_CPU_ADDRESS, SHARED_MEM_SIZE, SHARED_MEM_BANK, MEM_TYPE_SHARED, 0 },
/*MEM_ID_0 */ { MEM_0_DEV_ADDRESS, (char *)MEM_0_CPU_ADDRESS, MEM_0_SIZE, MEM_0_BANK, MEM_TYPE_DEVICE, 0 }
/*MEM_ID_1 { MEM_1_DEV_ADDRESS, (char *)MEM_1_CPU_ADDRESS, MEM_1_SIZE, MEM_1_BANK, MEM_TYPE_DEVICE, 0 } */
};
/*
memory regions hlina manager, indexed by _mem_region_id.
*/
static _hlina_mgr_t hlina_mgr[MAX_MEM_REGION];
int memalloc_major = -1;
//static DEFINE_SPINLOCK(mem_lock);
pthread_mutex_t mem_lock = PTHREAD_MUTEX_INITIALIZER;
/*
Functions declaration
*/
static int AllocMemory(unsigned long long *busaddr, unsigned int size, unsigned int region, const int filp);
static int FreeMemory(unsigned long long busaddr, const int filp);
//static void * DirectMemoryMap(unsigned long long busaddr, unsigned long map_size);
static void CalculateChunks(_mem_region_id id, unsigned long *chunks, unsigned long *chunks_mgr_size);
static void ResetMems(void);
/*
To specified mem region, calculate total chunks number and aligned buffer size to store chunks' descriptors.
*/
static void CalculateChunks(_mem_region_id id, unsigned long *chunks, unsigned long *chunks_mgr_size)
{
*chunks = 0;
*chunks_mgr_size = 0;
if(id < MAX_MEM_REGION) {
*chunks = _regions[id].size / CHUNK_SIZE;
*chunks_mgr_size = (((unsigned int)*chunks) * sizeof(hlina_chunk_t) + CHUNK_SIZE - 1) & (~(CHUNK_SIZE - 1));
}
}
/*
To specified bus address, convert it to virtual (CPU) address according to mem region properties.
*/
void * DirectMemoryMap(unsigned long long busaddr, unsigned long map_size) {
int i;
unsigned long long offset;
void *virtaddr = NULL;
u32 busAddrRight = 0;
if(map_size == 0) {
return NULL;
}
for(i=0; i<MAX_MEM_REGION; i++) {
if((busaddr >= _regions[i].bus_addr) && (busaddr <= _regions[i].bus_addr + _regions[i].size)) {
busAddrRight = 1;
if(_regions[i].virt_addr == NULL) {
continue;
}
else {
offset = busaddr - _regions[i].bus_addr;
if ((offset + map_size) <= _regions[i].size) {
virtaddr = (void *)(_regions[i].virt_addr + offset);
break;
}
}
}
}
if((!busAddrRight) && (virtaddr==NULL)) {
return (void *)(unsigned long)busaddr;
}
return virtaddr;
}
/*
ioctl
*/
long memalloc_ioctl(int filp, unsigned int cmd, void *arg) {
int ret = 0;
MemallocParams memparams;
addr_t busaddr;
unsigned int region;
PDEBUG("memalloc ioctl cmd 0x%08x\n", cmd);
/*
* extract the type and number bitfields, and don't decode
* wrong cmds: return ENOTTY (inappropriate ioctl) before access_ok()
*/
if (_IOC_TYPE(cmd) != MEMALLOC_IOC_MAGIC) return -ENOTTY;
if (_IOC_NR(cmd) > MEMALLOC_IOC_MAXNR) return -ENOTTY;
if (_IOC_DIR(cmd) & _IOC_READ)
ret = !access_ok(VERIFY_WRITE, arg, _IOC_SIZE(cmd));
else if (_IOC_DIR(cmd) & _IOC_WRITE)
ret = !access_ok(VERIFY_READ, arg, _IOC_SIZE(cmd));
if (ret) return -EFAULT;
spin_lock(&mem_lock);
switch (cmd) {
case MEMALLOC_IOCHARDRESET:
PDEBUG("memalloc HARDRESET\n");
ResetMems();
break;
case MEMALLOC_IOCXGETBUFFER:
PDEBUG("memalloc GETBUFFER");
ret = copy_from_user(&memparams, (MemallocParams *)arg,
sizeof(MemallocParams));
if (ret) break;
region = MEM_ID_SHARED;
if(memparams.mem_type == _MEM_TYPE_DPB || memparams.mem_type == _MEM_TYPE_VPU_ONLY)
#ifndef MEM_ONLY_DEV_CHECK
region = MEM_ID_SHARED; //For get output buffer for CPU
#else
region = MEM_ID_0;
#endif
ret = AllocMemory(&memparams.bus_address, memparams.size, region, filp);
memparams.translation_offset = _regions[region].translation_offset;
ret |= copy_to_user((MemallocParams *)arg, &memparams,
sizeof(MemallocParams));
break;
case MEMALLOC_IOCSFREEBUFFER:
PDEBUG("memalloc FREEBUFFER\n");
__get_user(busaddr, (addr_t *)arg);
ret = FreeMemory(busaddr, filp);
break;
}
spin_unlock(&mem_lock);
return ret ? -EFAULT : 0;
}
int memalloc_open(int *inode, int filp) {
PDEBUG("memalloc dev opened\n");
return 0;
}
int memalloc_release(int *inode, int filp) {
int i = 0, j = 0;
hlina_chunk_t *p_hlina;
for (i = 0; i < MAX_MEM_REGION; i++) {
p_hlina = hlina_mgr[i].hlina_chunks;
for (j = hlina_mgr[i].reserved_chunks; j < hlina_mgr[i].chunks; j++) {
spin_lock(&mem_lock);
if (p_hlina[j].filp == filp) {
printk(KERN_WARNING "memalloc: Found unfreed memory at release time!\n");
p_hlina[j].filp = 0;
p_hlina[j].chunks_occupied = 0;
}
spin_unlock(&mem_lock);
}
}
PDEBUG("memalloc dev closed\n");
return 0;
}
int __init memalloc_init(void) {
int result;
int i;
unsigned long chunks, mgr_size, reserved_size;
void *p;
PDEBUG("memalloc module init\n");
printk("memalloc: Linear Memory Allocator\n");
/*
Allocate memory for hlina_mgr
In NETINT platform, there is no big heap memory to store hlina_mgr, so it is put to beginning of shared memory region directly
*/
reserved_size = 0;
for (i=0; i<MAX_MEM_REGION; i++) {
CalculateChunks(i, &chunks, &mgr_size);
/* all hlina_chunks are put to SHARED memory region */
p = DirectMemoryMap(_regions[MEM_ID_SHARED].bus_addr + reserved_size, mgr_size);
hlina_mgr[i].hlina_chunks = (hlina_chunk_t *)p;
hlina_mgr[i].chunks = chunks;
hlina_mgr[i].reserved_chunks = 0;
hlina_mgr[i].mem_prop = &_regions[i];
reserved_size += mgr_size;
printk("memalloc: Linear memory base = 0x%08llx\n", _regions[i].bus_addr);
printk(KERN_INFO
"memalloc: Region[%d] size %lu MB; %lu chunks"
" of size %d\n", i,
(unsigned long)(_regions[i].size/(1024*1024)), chunks, CHUNK_SIZE);
}
hlina_mgr[MEM_ID_SHARED].reserved_chunks = reserved_size / CHUNK_SIZE;
result = register_chrdev(memalloc_major, "memalloc", &memalloc_fops);
if (result < 0) {
PDEBUG("memalloc: unable to get major %d\n", memalloc_major);
goto err;
} else if (result != 0) {/* this is for dynamic major */
memalloc_major = result;
}
ResetMems();
printf("memalloc init successful...\n");
return 0;
err:
#if 0
if (hlina_chunks != NULL) vfree(hlina_chunks);
#endif
return result;
}
/*
Cycle through the buffers in specified region, give the first free one.
TBD: need to check if specifying _mem_type is better than region.
*/
static int AllocMemory(unsigned long long *busaddr, unsigned int size, unsigned int region, const int filp) {
int i = 0;
int j = 0;
unsigned int skip_chunks = 0;
unsigned long total_chunks;
hlina_chunk_t *p_hlina;
/* calculate how many chunks we need; round up to chunk boundary */
unsigned int alloc_chunks = (size + CHUNK_SIZE - 1) / CHUNK_SIZE;
*busaddr = 0;
if(region >= MAX_MEM_REGION) {
printk("memalloc: Allocation FAILED: unknown region = %u\n", region);
return -EFAULT;
}
p_hlina = hlina_mgr[region].hlina_chunks;
total_chunks = hlina_mgr[region].chunks;
/* run through the chunk table */
for (i = hlina_mgr[region].reserved_chunks; i < total_chunks;) {
skip_chunks = 0;
/* if this chunk is available */
if (!p_hlina[i].chunks_occupied) {
/* check that there is enough memory left */
if (i + alloc_chunks > total_chunks) break;
/* check that there is enough consecutive chunks available */
for (j = i; j < i + alloc_chunks; j++) {
if (p_hlina[j].chunks_occupied) {
skip_chunks = 1;
/* skip the used chunks */
i = j + p_hlina[j].chunks_occupied;
break;
}
}
/* if enough free memory found */
if (!skip_chunks) {
*busaddr = hlina_mgr[region].mem_prop->bus_addr + i * CHUNK_SIZE;
p_hlina[i].filp = filp;
p_hlina[i].chunks_occupied = alloc_chunks;
break;
}
} else {
/* skip the used chunks */
i += p_hlina[i].chunks_occupied;
}
}
if (*busaddr == 0) {
printk("memalloc: Allocation FAILED: size = %u\n", size);
return -EFAULT;
} else {
PDEBUG("MEMALLOC OK: size: %d, reserved: %d\n", size,
alloc_chunks * CHUNK_SIZE);
}
return 0;
}
/* Free a buffer based on bus address */
static int FreeMemory(unsigned long long busaddr, const int filp) {
unsigned int i, id;
unsigned long long addr;
hlina_chunk_t *p_hlina;
for(i = 0; i < MAX_MEM_REGION; i++) {
addr = busaddr + _regions[i].translation_offset;
if ((addr >= _regions[i].bus_addr) && (addr < _regions[i].bus_addr + _regions[i].size)) {
id = (addr - _regions[i].bus_addr) / CHUNK_SIZE;
p_hlina = &hlina_mgr[i].hlina_chunks[id];
if ((p_hlina->chunks_occupied) && (p_hlina->filp == filp)) {
p_hlina->filp = 0;
p_hlina->chunks_occupied = 0;
return 0;
}
}
}
printk(KERN_WARNING "memalloc: Owner mismatch while freeing memory!\n");
return -1;
}
/* Reset "used" status */
static void ResetMems(void) {
int i, j = 0;
hlina_chunk_t *p_hlina;
for (i=0; i<MAX_MEM_REGION; i++) {
p_hlina = hlina_mgr[i].hlina_chunks;
for(j=hlina_mgr[i].reserved_chunks; j<hlina_mgr[i].chunks; j++) {
p_hlina[j].filp = 0;
p_hlina[j].chunks_occupied = 0;
}
}
}
//memory type is shared
//return busAddr and virtrulAddr
addr_t GetBusAddrForIODevide(unsigned int size) {
addr_t bus_addr = 0;
AllocMemory(&bus_addr, size, MEM_ID_SHARED , MEM_FD);
return bus_addr;
}

View File

@@ -0,0 +1,104 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _MEMALLOC_FREERTOS_H_
#define _MEMALLOC_FREERTOS_H_
#include "user_freertos.h"
#include "dev_common_freertos.h"
#undef PDEBUG /* undef it, just in case */
#ifdef MEMALLOC_DEBUG
/* This one for user space */
#define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
#else
#define PDEBUG(fmt, args...) /* not debugging: nothing */
#endif
/*
* Ioctl definitions
*/
/* Use 'k' as magic number */
#define MEMALLOC_IOC_MAGIC 'k'
/*
* S means "Set" through a ptr,
* T means "Tell" directly with the argument value
* G means "Get": reply by setting through a pointer
* Q means "Query": response is on the return value
* X means "eXchange": G and S atomically
* H means "sHift": T and Q atomically
*/
#define MEMALLOC_IOCXGETBUFFER _IOWR(MEMALLOC_IOC_MAGIC, 1, MemallocParams*)
#define MEMALLOC_IOCSFREEBUFFER _IOW(MEMALLOC_IOC_MAGIC, 2, unsigned long*)
#define MEMALLOC_IOCGMEMBASE _IOR(MEMALLOC_IOC_MAGIC, 3, unsigned long *)
/* ... more to come */
#define MEMALLOC_IOCHARDRESET _IO(MEMALLOC_IOC_MAGIC, 15) /* debugging tool */
#define MEMALLOC_IOC_MAXNR 15
typedef struct {
unsigned long long bus_address;
unsigned int size;
unsigned long translation_offset;
unsigned int mem_type;
} MemallocParams;
//Mem device
int __init memalloc_init(void);
int memalloc_open(int *inode, int filp);
int memalloc_release(int *inode, int filp);
long memalloc_ioctl(int filp, unsigned int cmd, void *arg);
void * DirectMemoryMap(unsigned long long busaddr, unsigned long map_size);
addr_t GetBusAddrForIODevide(unsigned int size);
#endif /* _MEMALLOC_FREERTOS_H_ */

View File

@@ -0,0 +1,192 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#include "subsys.h"
#include <string.h>
#undef PDEBUG
#ifdef HANTRODEC_DEBUG
# ifdef __KERNEL__
# define PDEBUG(fmt, args...) printk( KERN_INFO "hantrodec: " fmt, ## args)
# else
# define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
# endif
#else
# define PDEBUG(fmt, args...)
#endif
/******************************************************************************/
/* subsystem configuration */
/******************************************************************************/
/* List of subsystems */
static struct SubsysDesc subsys_array[] = {
/* {slice_index, index, base} */
{0, 0, 0x02310000},
// {0, 1, 0x02350000}
};
/* List of all HW cores. */
static struct CoreDesc core_array[] = {
/* {slice, subsys, core_type, offset, iosize, irq, has_apb} */
#if 0
{0, 0, HW_VC8000DJ, 0x600000, 0, 0},
{0, 0, HW_VC8000D, 0x602000, 0, 0},
{0, 0, HW_L2CACHE, 0x604000, 0, 0},
{0, 0, HW_DEC400, 0x606000, 0, 0},
{0, 0, HW_BIGOCEAN, 0x608000, 0, 0},
{0, 0, HW_NOC,0x60a000, 0, 0},
{0, 0, HW_AXIFE, 0x60c000, 0, 0}
#endif
{0, 0, HW_VCMD, 0x0, 27*4, 0, -1},
{0, 0, HW_VC8000D, 0x2000, 503*4, -1, -1},
// {0, 0, HW_MMU, 0x3000, 228*4, -1, 0},
// {0, 0, HW_MMU_WR, 0x4000, 228*4, -1, 0},
{0, 0, HW_DEC400, 0x6000, 1568*4, -1, -1},
{0, 0, HW_L2CACHE, 0x4000, 231*4, -1, -1},
// {0, 0, HW_AXIFE, 0x5000, 64*4, -1, 1},
// {0, 1, HW_VCMD, 0x0, 27*4, -1, 0},
// {0, 1, HW_VC8000D, 0x2000, 503*4, -1, 1},
// {0, 1, HW_MMU, 0x3000, 228*4, -1, 0},
// {0, 1, HW_MMU_WR, 0x4000, 228*4, -1, 0},
// {0, 1, HW_DEC400, 0x6000, 1568*4, -1, 0},
// {0, 1, HW_L2CACHE, 0x4000, 231*4, -1, 0},
// {0, 1, HW_AXIFE, 0x5000, 64*4, -1, 1},
};
extern struct vcmd_config vcmd_core_array[MAX_SUBSYS_NUM];
extern int total_vcmd_core_num;
extern unsigned long multicorebase[];
extern int irq[];
extern unsigned int iosize[];
extern int reg_count[];
/*
If VCMD is used, convert core_array to vcmd_core_array, which are used in
hantor_vcmd_xxx.c.
Otherwise, covnert core_array to multicore_base/irq/iosize, which are used in
hantro_dec_xxx.c
VCMD:
- struct vcmd_config vcmd_core_array[MAX_SUBSYS_NUM]
- total_vcmd_core_num
NON-VCMD:
- multicorebase[HXDEC_MAX_CORES]
- irq[HXDEC_MAX_CORES]
- iosize[HXDEC_MAX_CORES]
*/
void CheckSubsysCoreArray(struct subsys_config *subsys, int *vcmd) {
int num = sizeof(subsys_array)/sizeof(subsys_array[0]);
int i, j;
memset(subsys, 0, sizeof(subsys[0])*MAX_SUBSYS_NUM);
for (i = 0; i < num; i++) {
subsys[i].base_addr = subsys_array[i].base;
subsys[i].irq = -1;
for (j = 0; j < HW_CORE_MAX; j++) {
subsys[i].submodule_offset[j] = 0xffff;
subsys[i].submodule_iosize[j] = 0;
subsys[i].submodule_hwregs[j] = NULL;
}
}
total_vcmd_core_num = 0;
for (i = 0; i < sizeof(core_array)/sizeof(core_array[0]); i++) {
if (!subsys[core_array[i].subsys].base_addr) {
/* undefined subsystem */
continue;
}
subsys[core_array[i].subsys].submodule_offset[core_array[i].core_type]
= core_array[i].offset;
subsys[core_array[i].subsys].submodule_iosize[core_array[i].core_type]
= core_array[i].iosize;
if (core_array[i].irq != -1) {
subsys[core_array[i].subsys].irq = core_array[i].irq;
}
subsys[core_array[i].subsys].has_apbfilter[core_array[i].core_type] = core_array[i].has_apb;
/* vcmd found */
if (core_array[i].core_type == HW_VCMD) {
*vcmd = 1;
total_vcmd_core_num++;
}
}
printk(KERN_INFO "hantrodec: vcmd = %d\n", *vcmd);
/* To plug into hantro_vcmd.c */
if (*vcmd) {
for (i = 0; i < total_vcmd_core_num; i++) {
vcmd_core_array[i].vcmd_base_addr = subsys[i].base_addr;
vcmd_core_array[i].vcmd_iosize = subsys[i].submodule_iosize[HW_VCMD];
vcmd_core_array[i].vcmd_irq = subsys[i].irq;
vcmd_core_array[i].sub_module_type = 2; /* TODO(min): to be fixed */
vcmd_core_array[i].submodule_main_addr = subsys[i].submodule_offset[HW_VC8000D];
vcmd_core_array[i].submodule_dec400_addr = subsys[i].submodule_offset[HW_DEC400];
vcmd_core_array[i].submodule_L2Cache_addr = subsys[i].submodule_offset[HW_L2CACHE];
vcmd_core_array[i].submodule_MMU_addr = subsys[i].submodule_offset[HW_MMU];
}
}
memset(multicorebase, 0, sizeof(multicorebase[0]) * HXDEC_MAX_CORES);
for (i = 0; i < num; i++) {
multicorebase[i] = subsys[i].base_addr + subsys[i].submodule_offset[HW_VC8000D];
irq[i] = subsys[i].irq;
iosize[i] = subsys[i].submodule_iosize[HW_VC8000D];
printk(KERN_INFO "hantrodec: [%d] multicorebase 0x%08lx, iosize %d\n", i, multicorebase[i], iosize[i]);
}
}

View File

@@ -0,0 +1,151 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#include "osal.h"
#include "user_freertos.h"
#include "io_tools.h"
#include "memalloc_freertos.h"
static pthread_mutex_t vcmd_dev_open_count_mutex = PTHREAD_MUTEX_INITIALIZER;
static u32 vcmd_dev_open_count = 0;
extern int vcmd; //it is defined in hantro_dec_freertos.c
/**
* Unify driver for vcmd, the related vcmd interface besides init/open/release/
* ioctl will be called in the hantrdec_init/open/release/ioctl when vcmd is used.
* All drivers's probe should be added and be called by main() explicitly
*/
int Platform_init() {
//Firstly, initialize the mem for IO device
if (memalloc_init() != 0) {
PDEBUG("memalloc_init error\n");
assert(0);
}
//vcmd will modify if exist vcmd device in hantrodec_init
if (hantrodec_init() != 0) {
PDEBUG("hantroenc_init error\n");
assert(0);
}
return 0;
}
int freertos_open(const char* dev_name, int flag) {
//do a hash operator to gain the only dev fd
//int fd = hash(name);
int fd = 0; //the default is error id
if(!strcmp(dev_name, DEC_MODULE_PATH)) {
fd = DEC_FD << 28;
if(vcmd) {
//u32, MSB 4bit for device type, LSB 28bit for reference count
pthread_mutex_lock(&vcmd_dev_open_count_mutex);
vcmd_dev_open_count++;
fd += vcmd_dev_open_count;
pthread_mutex_unlock(&vcmd_dev_open_count_mutex);
}
hantrodec_open(NULL, fd);
}
else if(!strcmp(dev_name, MEMALLOC_MODULE_PATH)) {
fd = MEM_FD << 28;
memalloc_open(NULL, fd);
}
return fd;
}
void freertos_close(int fd) {
//u32, MSB 4bit for device type
u32 fd_tmp = fd;
fd_tmp = fd_tmp >> 28;
switch(fd_tmp) {
case DEC_FD: {
hantrodec_release(NULL, fd);
break;
}
case MEM_FD: {
//so if low in special paltform, could comment it when test, but in normal, it will be opened
//memalloc_release(NULL, fd);
break;
}
case 0: //for /dev/mem, it it not used, so shouldn't go to default
break;
default: {
PDEBUG("freertos_release fd 0x%x error\n", fd);
break;
}
}
}
long freertos_ioctl(int fd, unsigned int cmd, void *arg) {
long ret = -1;
//u32, MSB 4bit for device type
u32 fd_tmp = fd;
fd_tmp = fd_tmp >> 28;
switch(fd_tmp) {
case DEC_FD: {
ret = hantrodec_ioctl(fd, cmd, arg);
break;
}
case MEM_FD: {
ret = memalloc_ioctl(fd, cmd, arg);
break;
}
default: {
PDEBUG("freertos_ioctl fd 0x%x error\n", fd);
break;
}
}
return ret;
}

View File

@@ -0,0 +1,79 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _USER_FREERTOS_H_
#define _USER_FREERTOS_H_
#include "basetype.h"
#include <stddef.h> // size_t
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
//u32, MSB 4bit for device type, LSB 28bit for reference count
enum {
ENC_FD = 0x1,
DEC_FD = 0x2,
MEM_FD = 0x3
//TODO for other device, can exist 15 kinds of evices
};
int Platform_init();
int freertos_open(const char* dev_name, int flag);
void freertos_close(int fd);
long freertos_ioctl(int filp, unsigned int cmd, void *arg);
#endif /* _USER_FREERTOS_H_ */

View File

@@ -0,0 +1,88 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#include <linux/version.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/debugfs.h>
#include <linux/types.h>
#include <linux/device.h>
#include <linux/pagemap.h>
#include <linux/sched.h>
#include <stddef.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0))
#include <linux/dma-map-ops.h>
#else
#include <linux/dma-contiguous.h>
#endif
#include <linux/platform_device.h>
#include <linux/dma-buf.h>
#include "hantroaxife.h"
#define HANTRO_AXIFE_OFFSET 0
void AXIFEEnable (volatile unsigned char *hwregs) {
if (!hwregs) return;
//AXI FE pass through
iowrite32(0x40, (void*)(hwregs + HANTRO_AXIFE_OFFSET + 0x2C));
printk(KERN_INFO "AXI FE: 0x2C = 0x%x\n", ioread32((void*)(hwregs + 0x2C)));
iowrite32(0x2, (void*)(hwregs + HANTRO_AXIFE_OFFSET + 0x28));
printk(KERN_INFO "AXI FE: 0x28 = 0x%x\n", ioread32((void*)(hwregs + 0x28)));
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef __HANTRO_AXIFE_H__
#define __HANTRO_AXIFE_H__
#include <linux/ioctl.h>
#include <linux/types.h>
void AXIFEEnable (volatile unsigned char *hwregs);
#endif

View File

@@ -0,0 +1,199 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _HANTRODEC_H_
#define _HANTRODEC_H_
#ifdef __FREERTOS__
#include "basetype.h"
#include "dev_common_freertos.h"
#elif defined(__linux__)
#include <linux/ioctl.h>
#include <linux/types.h>
#include "hantrommu.h"
#else //For other os
//TODO...
#endif
#include "hantrovcmd.h"
enum CoreType {
/* Decoder */
HW_VC8000D = 0,
HW_VC8000DJ,
HW_BIGOCEAN,
HW_VCMD,
HW_MMU, //if set HW_MMU_WR, then HW_MMU means HW_MMU_RD
HW_MMU_WR,
HW_DEC400,
HW_L2CACHE,
HW_SHAPER,
/* Encoder*/
/* Auxiliary IPs */
HW_NOC,
HW_AXIFE,
HW_APBFILTER,
HW_CORE_MAX /* max number of cores supported */
};
struct core_desc {
__u32 id; /* id of the subsystem */
__u32 type; /* type of core to be written */
__u32 *regs; /* pointer to user registers */
__u32 size; /* size of register space */
__u32 reg_id; /* id of reigster to be read/written */
};
struct regsize_desc {
__u32 slice; /* id of the slice */
__u32 id; /* id of the subsystem */
__u32 type; /* type of core to be written */
__u32 size; /* iosize of the core */
};
struct core_param {
__u32 slice; /* id of the slice */
__u32 id; /* id of the subsystem */
__u32 type; /* type of core to be written */
__u32 size; /* iosize of the core */
__u32 asic_id; /* asic id of the core */
};
struct subsys_desc {
__u32 subsys_num; /* total subsystems count */
__u32 subsys_vcmd_num; /* subsystems with vcmd */
};
struct axife_cfg {
__u8 axi_rd_chn_num;
__u8 axi_wr_chn_num;
__u8 axi_rd_burst_length;
__u8 axi_wr_burst_length;
__u8 fe_mode;
__u32 id;
};
struct apbfilter_cfg {
__u32 nbr_mask_regs;
__u32 mask_reg_offset;
__u32 page_sel_addr;
__u8 num_mode;
__u8 mask_bits_per_reg;
__u32 id; /* id of the subsystem */
__u32 type; /* type of core to be written */
__u32 has_apbfilter;
};
/* Use 'k' as magic number */
#define HANTRODEC_IOC_MAGIC 'k'
/*
* S means "Set" through a ptr,
* T means "Tell" directly with the argument value
* G means "Get": reply by setting through a pointer
* Q means "Query": response is on the return value
* X means "eXchange": G and S atomically
* H means "sHift": T and Q atomically
*/
#define HANTRODEC_PP_INSTANCE _IO(HANTRODEC_IOC_MAGIC, 1)
#define HANTRODEC_HW_PERFORMANCE _IO(HANTRODEC_IOC_MAGIC, 2)
#define HANTRODEC_IOCGHWOFFSET _IOR(HANTRODEC_IOC_MAGIC, 3, unsigned long *)
#define HANTRODEC_IOCGHWIOSIZE _IOR(HANTRODEC_IOC_MAGIC, 4, struct regsize_desc *)
#define HANTRODEC_IOC_CLI _IO(HANTRODEC_IOC_MAGIC, 5)
#define HANTRODEC_IOC_STI _IO(HANTRODEC_IOC_MAGIC, 6)
#define HANTRODEC_IOC_MC_OFFSETS _IOR(HANTRODEC_IOC_MAGIC, 7, unsigned long *)
#define HANTRODEC_IOC_MC_CORES _IOR(HANTRODEC_IOC_MAGIC, 8, unsigned int *)
#define HANTRODEC_IOCS_DEC_PUSH_REG _IOW(HANTRODEC_IOC_MAGIC, 9, struct core_desc *)
#define HANTRODEC_IOCS_PP_PUSH_REG _IOW(HANTRODEC_IOC_MAGIC, 10, struct core_desc *)
#define HANTRODEC_IOCH_DEC_RESERVE _IO(HANTRODEC_IOC_MAGIC, 11)
#define HANTRODEC_IOCT_DEC_RELEASE _IO(HANTRODEC_IOC_MAGIC, 12)
#define HANTRODEC_IOCQ_PP_RESERVE _IO(HANTRODEC_IOC_MAGIC, 13)
#define HANTRODEC_IOCT_PP_RELEASE _IO(HANTRODEC_IOC_MAGIC, 14)
#define HANTRODEC_IOCX_DEC_WAIT _IOWR(HANTRODEC_IOC_MAGIC, 15, struct core_desc *)
#define HANTRODEC_IOCX_PP_WAIT _IOWR(HANTRODEC_IOC_MAGIC, 16, struct core_desc *)
#define HANTRODEC_IOCS_DEC_PULL_REG _IOWR(HANTRODEC_IOC_MAGIC, 17, struct core_desc *)
#define HANTRODEC_IOCS_PP_PULL_REG _IOWR(HANTRODEC_IOC_MAGIC, 18, struct core_desc *)
#define HANTRODEC_IOCG_CORE_WAIT _IOR(HANTRODEC_IOC_MAGIC, 19, int *)
#define HANTRODEC_IOX_ASIC_ID _IOWR(HANTRODEC_IOC_MAGIC, 20, struct core_param *)
#define HANTRODEC_IOCG_CORE_ID _IOR(HANTRODEC_IOC_MAGIC, 21, unsigned long)
#define HANTRODEC_IOCS_DEC_WRITE_REG _IOW(HANTRODEC_IOC_MAGIC, 22, struct core_desc *)
#define HANTRODEC_IOCS_DEC_READ_REG _IOWR(HANTRODEC_IOC_MAGIC, 23, struct core_desc *)
#define HANTRODEC_IOX_ASIC_BUILD_ID _IOWR(HANTRODEC_IOC_MAGIC, 24, __u32 *)
#define HANTRODEC_IOX_SUBSYS _IOWR(HANTRODEC_IOC_MAGIC, 25, struct subsys_desc *)
#define HANTRODEC_IOCX_POLL _IO(HANTRODEC_IOC_MAGIC, 26)
#define HANTRODEC_DEBUG_STATUS _IO(HANTRODEC_IOC_MAGIC, 29)
#define HANTRODEC_IOCS_DEC_WRITE_APBFILTER_REG _IOW(HANTRODEC_IOC_MAGIC, 30, struct core_desc *)
#define HANTRODEC_IOC_APBFILTER_CONFIG _IOR(HANTRODEC_IOC_MAGIC, 31, struct apbfilter_cfg *)
#define HANTRODEC_IOC_AXIFE_CONFIG _IOR(HANTRODEC_IOC_MAGIC, 32, struct axife_cfg *)
#define HANTRODEC_IOC_MAXNR 32
#endif /* !_HANTRODEC_H_ */

View File

@@ -0,0 +1,109 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _HANTROMMU_H_
#define _HANTROMMU_H_
#ifdef __FREERTOS__
#include "basetype.h"
#include "dev_common_freertos.h"
#elif defined(__linux__)
#include <linux/fs.h>
#endif
#define REGION_IN_START 0x0
#define REGION_IN_END 0x0
#define REGION_OUT_START 0x0
#define REGION_OUT_END 0x0
#define REGION_PRIVATE_START 0x0
#define REGION_PRIVATE_END 0x0
#define REGION_IN_MMU_START 0x1000
#define REGION_IN_MMU_END 0x1000
#define REGION_OUT_MMU_START 0x1000
#define REGION_OUT_MMU_END 0x1000
#define REGION_PRIVATE_MMU_START 0x1000
#define REGION_PRIVATE_MMU_END 0x1000
enum MMUStatus {
MMU_STATUS_OK = 0,
MMU_STATUS_FALSE = -1,
MMU_STATUS_INVALID_ARGUMENT = -2,
MMU_STATUS_INVALID_OBJECT = -3,
MMU_STATUS_OUT_OF_MEMORY = -4,
MMU_STATUS_NOT_FOUND = -19,
};
struct addr_desc {
void *virtual_address; /* buffer virtual address */
unsigned int bus_address; /* buffer physical address */
unsigned int size; /* physical size */
};
struct kernel_addr_desc {
unsigned long long bus_address; /* buffer virtual address */
unsigned long long mmu_bus_address; /* buffer physical address in MMU*/
unsigned int size; /* physical size */
};
#define HANTRO_IOC_MMU 'm'
#define HANTRO_IOCS_MMU_MEM_MAP _IOWR(HANTRO_IOC_MMU, 1, struct addr_desc *)
#define HANTRO_IOCS_MMU_MEM_UNMAP _IOWR(HANTRO_IOC_MMU, 2, struct addr_desc *)
#define HANTRO_IOCS_MMU_FLUSH _IOWR(HANTRO_IOC_MMU, 3, unsigned int *)
#define HANTRO_IOC_MMU_MAXNR 3
#endif

View File

@@ -0,0 +1,192 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _VC8000_VCMD_DRIVER_H_
#define _VC8000_VCMD_DRIVER_H_
#ifdef __FREERTOS__
#include "basetype.h"
#include "dev_common_freertos.h"
#elif defined(__linux__)
#include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
#endif
#ifdef __FREERTOS__
//addr_t has been defined in basetype.h //Now the FreeRTOS mem need to support 64bit env
#elif defined(__linux__)
#undef addr_t
#define addr_t ADDR_T_VCMD
typedef size_t addr_t;
#endif
/* Use 'v' as magic number for vcmd */
#define HANTRO_VCMD_IOC_MAGIC 'v'
/*
* S means "Set" through a ptr,
* T means "Tell" directly with the argument value
* G means "Get": reply by setting through a pointer
* Q means "Query": response is on the return value
* X means "eXchange": G and S atomically
* H means "sHift": T and Q atomically
*/
#define HANTRO_VCMD_IOCH_GET_CMDBUF_PARAMETER _IOWR(HANTRO_VCMD_IOC_MAGIC, 20,struct cmdbuf_mem_parameter *)
#define HANTRO_VCMD_IOCH_GET_CMDBUF_POOL_SIZE _IOWR(HANTRO_VCMD_IOC_MAGIC, 21,unsigned long)
#define HANTRO_VCMD_IOCH_SET_CMDBUF_POOL_BASE _IOWR(HANTRO_VCMD_IOC_MAGIC, 22,unsigned long)
#define HANTRO_VCMD_IOCH_GET_VCMD_PARAMETER _IOWR(HANTRO_VCMD_IOC_MAGIC, 24, struct config_parameter *)
#define HANTRO_VCMD_IOCH_RESERVE_CMDBUF _IOWR(HANTRO_VCMD_IOC_MAGIC, 25,struct exchange_parameter *)
#define HANTRO_VCMD_IOCH_LINK_RUN_CMDBUF _IOR(HANTRO_VCMD_IOC_MAGIC, 26,u16 *)
#define HANTRO_VCMD_IOCH_WAIT_CMDBUF _IOR(HANTRO_VCMD_IOC_MAGIC, 27,u16 *)
#define HANTRO_VCMD_IOCH_RELEASE_CMDBUF _IOR(HANTRO_VCMD_IOC_MAGIC, 28,u16 *)
#define HANTRO_VCMD_IOCH_POLLING_CMDBUF _IOR(HANTRO_VCMD_IOC_MAGIC, 40,u16 *)
#define HANTRO_VCMD_IOC_MAXNR 50
/*priority support*/
#define MAX_CMDBUF_PRIORITY_TYPE 2 //0:normal priority,1:high priority
#define CMDBUF_PRIORITY_NORMAL 0
#define CMDBUF_PRIORITY_HIGH 1
#if 0
#define OPCODE_WREG (0x01<<27)
#define OPCODE_END (0x02<<27)
#define OPCODE_NOP (0x03<<27)
#define OPCODE_RREG (0x16<<27)
#define OPCODE_INT (0x18<<27)
#define OPCODE_JMP (0x19<<27)
#define OPCODE_STALL (0x09<<27)
#define OPCODE_CLRINT (0x1a<<27)
#define OPCODE_JMP_RDY0 (0x19<<27)
#define OPCODE_JMP_RDY1 ((0x19<<27)|(1<<26))
#define JMP_IE_1 (1<<25)
#define JMP_RDY_1 (1<<26)
#define CLRINT_OPTYPE_READ_WRITE_1_CLEAR 0
#define CLRINT_OPTYPE_READ_WRITE_0_CLEAR 1
#define CLRINT_OPTYPE_READ_CLEAR 2
#define VC8000E_FRAME_RDY_INT_MASK 0x0001
#define VC8000E_CUTREE_RDY_INT_MASK 0x0002
#define VC8000E_DEC400_INT_MASK 0x0004
#define VC8000E_L2CACHE_INT_MASK 0x0008
#define VC8000E_MMU_INT_MASK 0x0010
#define VC8000D_FRAME_RDY_INT_MASK 0x0100
#define VC8000D_DEC400_INT_MASK 0x0400
#define VC8000D_L2CACHE_INT_MASK 0x0800
#define VC8000D_MMU_INT_MASK 0x1000
#endif
#define HW_ID_1_0_C 0x43421001
#define HW_ID_1_1_2 0x43421102
#define ANY_CMDBUF_ID 0xFFFF
/*module_type support*/
enum vcmd_module_type{
VCMD_TYPE_ENCODER = 0,
VCMD_TYPE_CUTREE,
VCMD_TYPE_DECODER,
VCMD_TYPE_JPEG_ENCODER,
VCMD_TYPE_JPEG_DECODER,
MAX_VCMD_TYPE
};
struct cmdbuf_mem_parameter
{
u32 *virt_cmdbuf_addr;
addr_t phy_cmdbuf_addr; //cmdbuf pool base physical address
u32 mmu_phy_cmdbuf_addr; //cmdbuf pool base mmu mapping address
u32 cmdbuf_total_size; //cmdbuf pool total size in bytes.
u16 cmdbuf_unit_size; //one cmdbuf size in bytes. all cmdbuf have same size.
u32 *virt_status_cmdbuf_addr;
addr_t phy_status_cmdbuf_addr; //status cmdbuf pool base physical address
u32 mmu_phy_status_cmdbuf_addr; //status cmdbuf pool base mmu mapping address
u32 status_cmdbuf_total_size; //status cmdbuf pool total size in bytes.
u16 status_cmdbuf_unit_size; //one status cmdbuf size in bytes. all status cmdbuf have same size.
addr_t base_ddr_addr; //for pcie interface, hw can only access phy_cmdbuf_addr-pcie_base_ddr_addr.
//for other interface, this value should be 0?
};
struct config_parameter
{
u16 module_type; //input vc8000e=0,cutree=1,vc8000d=2,jpege=3, jpegd=4
u16 vcmd_core_num; //output, how many vcmd cores are there with corresponding module_type.
u16 submodule_main_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
u16 submodule_dec400_addr; //output ,if submodule addr == 0xffff, this submodule does not exist.
u16 submodule_L2Cache_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
u16 submodule_MMU_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
u16 submodule_MMUWrite_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
u16 submodule_axife_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
u16 config_status_cmdbuf_id; // output , this status comdbuf save the all register values read in driver init.//used for analyse configuration in cwl.
u32 vcmd_hw_version_id;
};
/*need to consider how many memory should be allocated for status.*/
struct exchange_parameter
{
u32 executing_time; //input ;executing_time=encoded_image_size*(rdoLevel+1)*(rdoq+1);
u16 module_type; //input input vc8000e=0,IM=1,vc8000d=2, jpege=3, jpegd=4
u16 cmdbuf_size; //input, reserve is not used; link and run is input.
u16 priority; //input,normal=0, high/live=1
u16 cmdbuf_id; //output, it is unique in driver.
u16 core_id; //just used for polling.
};
#endif /* !_VC8000_VCMD_DRIVER_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,121 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 Vivante Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 Vivante Corporation
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef __gc_hal_kernel_allocator_h_
#define __gc_hal_kernel_allocator_h_
#include "../memalloc/memalloc.h"
#define IN
#define OUT
#define INOUT
#define OPTIONAL
/* No special needs. */
#define ALLOC_FLAG_NONE 0x00000000
/* Physical contiguous. */
#define ALLOC_FLAG_CONTIGUOUS 0x00000001
/* Physical non contiguous. */
#define ALLOC_FLAG_NON_CONTIGUOUS 0x00000002
/* Need 32bit address. */
#define ALLOC_FLAG_4GB_ADDR 0x00000004
#define MEMORY_IOC_MAGIC 'a'
#define MEMORY_IOC_ALLOCATE _IOWR(MEMORY_IOC_MAGIC, 1, MemallocParams *)
#define MEMORY_IOC_FREE _IOWR(MEMORY_IOC_MAGIC, 2, MemallocParams *)
#define MEMORY_IOC_DMABUF_EXPORT _IOWR(MEMORY_IOC_MAGIC, 3, MemallocParams *)
#define MEMORY_IOC_DMABUF_IMPORT _IOWR(MEMORY_IOC_MAGIC, 4, MemallocParams *)
#define MEMORY_IOC_DMABUF_RELEASE _IOWR(MEMORY_IOC_MAGIC, 5, MemallocParams *)
#define MEMORY_IOC_MAXNR 5
#if 0
int
GFP_Alloc(
INOUT MemallocParams *params,
IN unsigned int Flags,
IN struct device *dev
);
void
GFP_Free(
INOUT MemallocParams *params
);
int
DMABUF_Export(
IN MemallocParams *params,
IN signed int Flags,
OUT signed int *FD
);
int
DMABUF_Import(
IN unsigned int FD,
IN struct device *dev,
OUT MemallocParams *params
);
void
DMABUF_Release(
INOUT MemallocParams *params
);
#endif
#endif

View File

@@ -0,0 +1,203 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#include "subsys.h"
/******************************************************************************/
/* subsystem configuration */
/******************************************************************************/
/* List of subsystems */
struct SubsysDesc subsys_array[] = {
/* {slice_index, index, base} */
{0, 0, 0xffecc00000},
// {0, 1, 0x700000}
};
/* List of all HW cores. */
struct CoreDesc core_array[] = {
/* {slice, subsys, core_type, offset, iosize, irq, has_apbfilter} */
#if 0
{0, 0, HW_VC8000DJ, 0x600000, 0, 0},
{0, 0, HW_VC8000D, 0x602000, 0, 0},
{0, 0, HW_L2CACHE, 0x604000, 0, 0},
{0, 0, HW_DEC400, 0x606000, 0, 0},
{0, 0, HW_BIGOCEAN, 0x608000, 0, 0},
{0, 0, HW_NOC,0x60a000, 0, 0},
{0, 0, HW_AXIFE, 0x60c000, 0, 0}
#endif
{0, 0, HW_VCMD, 0x0, 27*4, 12},
{0, 0, HW_VC8000D, 0x1000, 1023*4, -1, 0},
{0, 0, HW_L2CACHE, 0x2000, 231*4, -1, 0},
{0, 0, HW_MMU, 0x3000, 228*4, -1, 0},
//{0, 0, HW_MMU_WR, 0x4000, 228*4, -1, 0},
//{0, 0, HW_AXIFE, 0x5000, 64*4, -1, 1},
{0, 0, HW_DEC400, 0x6000, 1568*4, -1, 0},
//{0, 1, HW_VCMD, 0x0, 27*4, -1, 0},
//{0, 1, HW_VC8000D, 0x1000, 503*4, -1, 1},
//{0, 1, HW_L2CACHE, 0x2000, 231*4, -1, 0},
//{0, 1, HW_MMU, 0x3000, 228*4, -1, 0},
//{0, 1, HW_MMU_WR, 0x4000, 228*4, -1, 0},
//{0, 1, HW_AXIFE, 0x5000, 64*4, -1, 1},
//{0, 1, HW_DEC400, 0x6000, 1568*4, -1, 0},
};
extern struct vcmd_config vcmd_core_array[MAX_SUBSYS_NUM];
extern int total_vcmd_core_num;
extern unsigned long multicorebase[];
extern int irq[];
extern unsigned int iosize[];
extern int reg_count[];
/*
If VCMD is used, convert core_array to vcmd_core_array, which are used in
hantor_vcmd.c.
Otherwise, covnert core_array to multicore_base/irq/iosize, which are used in
hantro_dec.c
VCMD:
- struct vcmd_config vcmd_core_array[MAX_SUBSYS_NUM]
- total_vcmd_core_num
NON-VCMD:
- multicorebase[HXDEC_MAX_CORES]
- irq[HXDEC_MAX_CORES]
- iosize[HXDEC_MAX_CORES]
*/
void CheckSubsysCoreArray(struct subsys_config *subsys, int *vcmd) {
int num = sizeof(subsys_array)/sizeof(subsys_array[0]);
int i, j;
memset(subsys, 0, sizeof(subsys[0])*MAX_SUBSYS_NUM);
for (i = 0; i < num; i++) {
subsys[i].base_addr = subsys_array[i].base;
subsys[i].irq = -1;
for (j = 0; j < HW_CORE_MAX; j++) {
subsys[i].submodule_offset[j] = 0xffff;
subsys[i].submodule_iosize[j] = 0;
subsys[i].submodule_hwregs[j] = NULL;
}
}
total_vcmd_core_num = 0;
for (i = 0; i < sizeof(core_array)/sizeof(core_array[0]); i++) {
if (!subsys[core_array[i].subsys].base_addr) {
/* undefined subsystem */
continue;
}
subsys[core_array[i].subsys].submodule_offset[core_array[i].core_type]
= core_array[i].offset;
subsys[core_array[i].subsys].submodule_iosize[core_array[i].core_type]
= core_array[i].iosize;
if (subsys[core_array[i].subsys].irq != -1 && core_array[i].irq != -1) {
if (subsys[core_array[i].subsys].irq != core_array[i].irq) {
printk(KERN_INFO "hantrodec: hw core type %d irq %d != subsystem irq %d\n",
core_array[i].core_type,
core_array[i].irq,
subsys[core_array[i].subsys].irq);
printk(KERN_INFO "hantrodec: hw cores of a subsystem should have same irq\n");
}
} else if (core_array[i].irq != -1) {
subsys[core_array[i].subsys].irq = core_array[i].irq;
}
subsys[core_array[i].subsys].has_apbfilter[core_array[i].core_type] = core_array[i].has_apb;
/* vcmd found */
if (core_array[i].core_type == HW_VCMD) {
*vcmd = 1;
total_vcmd_core_num++;
}
}
printk(KERN_INFO "hantrodec: vcmd = %d\n", *vcmd);
/* To plug into hantro_vcmd.c */
if (*vcmd) {
for (i = 0; i < total_vcmd_core_num; i++) {
vcmd_core_array[i].vcmd_base_addr = subsys[i].base_addr;
vcmd_core_array[i].vcmd_iosize = subsys[i].submodule_iosize[HW_VCMD];
vcmd_core_array[i].vcmd_irq = subsys[i].irq;
vcmd_core_array[i].sub_module_type = 2; /* TODO(min): to be fixed */
vcmd_core_array[i].submodule_main_addr = subsys[i].submodule_offset[HW_VC8000D];
vcmd_core_array[i].submodule_dec400_addr = subsys[i].submodule_offset[HW_DEC400];
vcmd_core_array[i].submodule_L2Cache_addr = subsys[i].submodule_offset[HW_L2CACHE];
vcmd_core_array[i].submodule_MMU_addr = subsys[i].submodule_offset[HW_MMU];
vcmd_core_array[i].submodule_MMUWrite_addr = subsys[i].submodule_offset[HW_MMU_WR];
vcmd_core_array[i].submodule_axife_addr = subsys[i].submodule_offset[HW_AXIFE];
}
}
memset(multicorebase, 0, sizeof(multicorebase[0]) * HXDEC_MAX_CORES);
for (i = 0; i < num; i++) {
multicorebase[i] = subsys[i].base_addr + subsys[i].submodule_offset[HW_VC8000D];
irq[i] = subsys[i].irq;
iosize[i] = subsys[i].submodule_iosize[HW_VC8000D];
printk(KERN_INFO "hantrodec: [%d] multicorebase 0x%08lx, iosize %d\n", i, multicorebase[i], iosize[i]);
}
}
void dump_core_array(void)
{
int i;
for (i = 0; i < sizeof(core_array)/sizeof(core_array[0]); i++) {
printk(KERN_INFO "lucz: dumping dump_core_array[%d]\n", i);
printk(KERN_INFO " slice=%d\n", core_array[i].slice);
printk(KERN_INFO " subsys=%d\n", core_array[i].subsys);
printk(KERN_INFO " core_type=%d\n", core_array[i].core_type);
printk(KERN_INFO " offset=%d\n", core_array[i].offset);
printk(KERN_INFO " iosize=%d\n", core_array[i].iosize);
printk(KERN_INFO " irq=%d\n", core_array[i].irq);
printk(KERN_INFO " has_apb=%d\n", core_array[i].has_apb);
}
}

View File

@@ -0,0 +1,204 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _SUBSYS_H_
#define _SUBSYS_H_
#ifdef __FREERTOS__
/* nothing */
#elif defined(__linux__)
#include <linux/fs.h>
#include <linux/platform_device.h>
#endif
#include "hantrodec.h"
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
/* Functions provided by all other subsystem IP - hantrodec_xxx.c */
/******************************************************************************/
/* subsys level */
/******************************************************************************/
#define MAX_SUBSYS_NUM 4 /* up to 4 subsystem (temporary) */
#define HXDEC_MAX_CORES MAX_SUBSYS_NUM /* used in hantro_dec_xxx.c */
/* SubsysDesc & CoreDesc are used for configuration */
struct SubsysDesc {
int slice_index; /* slice this subsys belongs to */
int index; /* subsystem index */
long base;
};
struct CoreDesc {
int slice;
int subsys; /* subsys this core belongs to */
enum CoreType core_type;
int offset; /* offset to subsystem base */
int iosize;
int irq;
int has_apb;
};
/* internal config struct (translated from SubsysDesc & CoreDesc) */
struct subsys_config {
unsigned long base_addr;
int irq;
u32 subsys_type; /* identifier for each subsys vc8000e=0,IM=1,vc8000d=2,jpege=3,jpegd=4 */
u32 submodule_offset[HW_CORE_MAX]; /* in bytes */
u16 submodule_iosize[HW_CORE_MAX]; /* in bytes */
volatile u8 *submodule_hwregs[HW_CORE_MAX]; /* virtual address */
int has_apbfilter[HW_CORE_MAX];
};
void CheckSubsysCoreArray(struct subsys_config *subsys, int *vcmd);
/******************************************************************************/
/* VCMD */
/******************************************************************************/
#define OPCODE_WREG (0x01<<27)
#define OPCODE_END (0x02<<27)
#define OPCODE_NOP (0x03<<27)
#define OPCODE_RREG (0x16<<27)
#define OPCODE_INT (0x18<<27)
#define OPCODE_JMP (0x19<<27)
#define OPCODE_STALL (0x09<<27)
#define OPCODE_CLRINT (0x1a<<27)
#define OPCODE_JMP_RDY0 (0x19<<27)
#define OPCODE_JMP_RDY1 ((0x19<<27)|(1<<26))
#define JMP_IE_1 (1<<25)
#define JMP_RDY_1 (1<<26)
/* Used in vcmd initialization in hantro_vcmd_xxx.c. */
/* May be unified in next step. */
struct vcmd_config {
unsigned long vcmd_base_addr;
u32 vcmd_iosize;
int vcmd_irq;
u32 sub_module_type; /*input vc8000e=0,IM=1,vc8000d=2,jpege=3, jpegd=4*/
u16 submodule_main_addr; // in byte
u16 submodule_dec400_addr; //if submodule addr == 0xffff, this submodule does not exist.// in byte
u16 submodule_L2Cache_addr; // in byte
u16 submodule_MMU_addr; // in byte
u16 submodule_MMUWrite_addr;// in byte
u16 submodule_axife_addr; // in byte
};
#ifdef __FREERTOS__
/* nothing */
#elif defined(__linux__)
int hantrovcmd_open(struct inode *inode, struct file *filp);
int hantrovcmd_release(struct inode *inode, struct file *filp);
long hantrovcmd_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg);
int hantrovcmd_init(struct platform_device *pdev);
void hantrovcmd_cleanup(struct platform_device *pdev);
void hantrovcmd_reset(void);
bool hantro_cmdbuf_range(addr_t addr,size_t size);
/******************************************************************************/
/* MMU */
/******************************************************************************/
/* Init MMU, should be called in driver init function. */
enum MMUStatus MMUInit(volatile unsigned char *hwregs);
/* Clean up all data in MMU, should be called in driver cleanup function
when rmmod driver*/
enum MMUStatus MMUCleanup(volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
/* The function should be called in driver realease function
when driver exit unnormally */
enum MMUStatus MMURelease(void *filp, volatile unsigned char *hwregs);
enum MMUStatus MMUEnable(volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
/* Used in kernel to map buffer */
enum MMUStatus MMUKernelMemNodeMap(struct kernel_addr_desc *addr);
/* Used in kernel to unmap buffer */
enum MMUStatus MMUKernelMemNodeUnmap(struct kernel_addr_desc *addr);
long MMUIoctl(unsigned int cmd, void *filp, unsigned long arg,
volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
void MMURestore(volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
int allocator_init(struct device *dev);
void allocator_remove(void);
int allocator_open(struct inode *inode, struct file *filp);
void allocator_release(struct inode *inode, struct file *filp);
int allocator_ioctl(void *filp, unsigned int cmd, unsigned long arg);
int allocator_mmap(struct file *filp, struct vm_area_struct *vma);
/******************************************************************************/
/* L2Cache */
/******************************************************************************/
/******************************************************************************/
/* DEC400 */
/******************************************************************************/
/******************************************************************************/
/* AXI FE */
/******************************************************************************/
#endif
#endif

View File

@@ -0,0 +1,156 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
/* Register interface based on the document version 1.1.2 */
HWIF_VCMD_HW_ID,
HWIF_VCMD_HW_VERSION,
HWIF_VCMD_HW_BUILD_DATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_MMU,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_L2CACHE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_DEC400,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD,
HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_MMU,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_MMU,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_L2CACHE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_DEC400,
HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_MMU,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_L2CACHE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_DEC400,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD,
HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_MMU,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_MMU,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_L2CACHE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_DEC400,
HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE,
HWIF_VCMD_EXE_CMDBUF_COUNT,
HWIF_VCMD_EXECUTING_CMD,
HWIF_VCMD_EXECUTING_CMD_MSB,
HWIF_VCMD_AXI_TOTAL_AR_LEN,
HWIF_VCMD_AXI_TOTAL_R,
HWIF_VCMD_AXI_TOTAL_AR,
HWIF_VCMD_AXI_TOTAL_R_LAST,
HWIF_VCMD_AXI_TOTAL_AW_LEN,
HWIF_VCMD_AXI_TOTAL_W,
HWIF_VCMD_AXI_TOTAL_AW,
HWIF_VCMD_AXI_TOTAL_W_LAST,
HWIF_VCMD_AXI_TOTAL_B,
HWIF_VCMD_AXI_AR_VALID,
HWIF_VCMD_AXI_AR_READY,
HWIF_VCMD_AXI_R_VALID,
HWIF_VCMD_AXI_R_READY,
HWIF_VCMD_AXI_AW_VALID,
HWIF_VCMD_AXI_AW_READY,
HWIF_VCMD_AXI_W_VALID,
HWIF_VCMD_AXI_W_READY,
HWIF_VCMD_AXI_B_VALID,
HWIF_VCMD_AXI_B_READY,
HWIF_VCMD_WORK_STATE,
HWIF_VCMD_AXI_CLK_GATE_DISABLE,
HWIF_VCMD_MASTER_OUT_CLK_GATE_DISABLE,
HWIF_VCMD_CORE_CLK_GATE_DISABLE,
HWIF_VCMD_ABORT_MODE,
HWIF_VCMD_RESET_CORE,
HWIF_VCMD_RESET_ALL,
HWIF_VCMD_START_TRIGGER,
HWIF_VCMD_IRQ_INTCMD,
HWIF_VCMD_IRQ_JMPP,
HWIF_VCMD_IRQ_JMPD,
HWIF_VCMD_IRQ_RESET,
HWIF_VCMD_IRQ_ABORT,
HWIF_VCMD_IRQ_CMDERR,
HWIF_VCMD_IRQ_TIMEOUT,
HWIF_VCMD_IRQ_BUSERR,
HWIF_VCMD_IRQ_ENDCMD,
HWIF_VCMD_IRQ_INTCMD_EN,
HWIF_VCMD_IRQ_JMPP_EN,
HWIF_VCMD_IRQ_JMPD_EN,
HWIF_VCMD_IRQ_RESET_EN,
HWIF_VCMD_IRQ_ABORT_EN,
HWIF_VCMD_IRQ_CMDERR_EN,
HWIF_VCMD_IRQ_TIMEOUT_EN,
HWIF_VCMD_IRQ_BUSERR_EN,
HWIF_VCMD_IRQ_ENDCMD_EN,
HWIF_VCMD_TIMEOUT_EN,
HWIF_VCMD_TIMEOUT_CYCLES,
HWIF_VCMD_EXECUTING_CMD_ADDR,
HWIF_VCMD_EXECUTING_CMD_ADDR_MSB,
HWIF_VCMD_EXE_CMDBUF_LENGTH,
HWIF_VCMD_CMD_SWAP,
HWIF_VCMD_MAX_BURST_LEN,
HWIF_VCMD_AXI_ID_RD,
HWIF_VCMD_AXI_ID_WR,
HWIF_VCMD_RDY_CMDBUF_COUNT,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_MMU_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_L2CACHE_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_DEC400_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_MMU_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_MMU_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_L2CACHE_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_DEC400_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_MMU_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_L2CACHE_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_DEC400_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_MMU_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_MMU_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_L2CACHE_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_DEC400_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_GATE,
HWIF_VCMD_CMDBUF_EXECUTING_ID,

View File

@@ -0,0 +1,156 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
/* Register interface based on the document version 1.1.2 */
VCMDREG(HWIF_VCMD_HW_ID , 0 ,0xffff0000, 16, 0,RO,"HW ID"),
VCMDREG(HWIF_VCMD_HW_VERSION , 0 ,0x0000ffff, 0, 0,RO,"version of hw(1.0.0).[15:12]-major [11:8]-minor [7:0]-build"),
VCMDREG(HWIF_VCMD_HW_BUILD_DATE , 4 ,0xffffffff, 0, 0,RO,"Hw package generation date in BCD code"),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_MMU , 8 ,0x08000000, 27, 0,RO,"external abnormal interrupt source from mmu of vcd."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_L2CACHE , 8 ,0x04000000, 26, 0,RO,"external abnormal interrupt source from l2cache of vcd."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_DEC400 , 8 ,0x02000000, 25, 0,RO,"external abnormal interrupt source from dec400 of vcd."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD , 8 ,0x01000000, 24, 0,RO,"external abnormal interrupt source from vcd."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_MMU , 8 ,0x00200000, 21, 0,RO,"external abnormal interrupt source from mmu of cutree."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_MMU , 8 ,0x00100000, 20, 0,RO,"external abnormal interrupt source from mmu of vce."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_L2CACHE , 8 ,0x00080000, 19, 0,RO,"external abnormal interrupt source from l2 cache of vce."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_DEC400 , 8 ,0x00040000, 18, 0,RO,"external abnormal interrupt source from dec400 of vce."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE , 8 ,0x00020000, 17, 0,RO,"external abnormal interrupt source from cutree."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE , 8 ,0x00010000, 16, 0,RO,"external abnormal interrupt source from vce."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_MMU , 8 ,0x00000800, 11, 0,RO,"external normal interrupt source from mmu of vcd."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_L2CACHE , 8 ,0x00000400, 10, 0,RO,"external normal interrupt source from l2cache of vcd."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_DEC400 , 8 ,0x00000200, 9, 0,RO,"external normal interrupt source from dec400 of vcd."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD , 8 ,0x00000100, 8, 0,RO,"external normal interrupt source from vcd."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_MMU , 8 ,0x00000020, 5, 0,RO,"external normal interrupt source from mmu of cutree."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_MMU , 8 ,0x00000010, 4, 0,RO,"external normal interrupt source from mmu of vce."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_L2CACHE , 8 ,0x00000008, 3, 0,RO,"external normal interrupt source from l2 cache of vce."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_DEC400 , 8 ,0x00000004, 2, 0,RO,"external normal interrupt source from dec400 of vce."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE , 8 ,0x00000002, 1, 0,RO,"external normal interrupt source from cutree."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE , 8 ,0x00000001, 0, 0,RO,"external normal interrupt source from vce."),
VCMDREG(HWIF_VCMD_EXE_CMDBUF_COUNT , 12 ,0xffffffff, 0, 0,RO,"Hw increases this counter by 1 after one more command buffer has been executed"),
VCMDREG(HWIF_VCMD_EXECUTING_CMD , 16 ,0xffffffff, 0, 0,RO,"the first 32 bits of the executing cmd."),
VCMDREG(HWIF_VCMD_EXECUTING_CMD_MSB , 20 ,0xffffffff, 0, 0,RO,"the second 32 bits of the executing cmd."),
VCMDREG(HWIF_VCMD_AXI_TOTAL_AR_LEN , 24 ,0xffffffff, 0, 0,RO,"axi total ar length"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_R , 28 ,0xffffffff, 0, 0,RO,"axi total r"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_AR , 32 ,0xffffffff, 0, 0,RO,"axi total ar"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_R_LAST , 36 ,0xffffffff, 0, 0,RO,"axi total r last"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_AW_LEN , 40 ,0xffffffff, 0, 0,RO,"axi total aw length"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_W , 44 ,0xffffffff, 0, 0,RO,"axi total w"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_AW , 48 ,0xffffffff, 0, 0,RO,"axi total aw"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_W_LAST , 52 ,0xffffffff, 0, 0,RO,"axi total w last"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_B , 56 ,0xffffffff, 0, 0,RO,"axi total b"),
VCMDREG(HWIF_VCMD_AXI_AR_VALID , 60 ,0x80000000, 31, 0,RO,"axi ar valid"),
VCMDREG(HWIF_VCMD_AXI_AR_READY , 60 ,0x40000000, 30, 0,RO,"axi ar ready"),
VCMDREG(HWIF_VCMD_AXI_R_VALID , 60 ,0x20000000, 29, 0,RO,"axi r valid"),
VCMDREG(HWIF_VCMD_AXI_R_READY , 60 ,0x10000000, 28, 0,RO,"axi r ready"),
VCMDREG(HWIF_VCMD_AXI_AW_VALID , 60 ,0x08000000, 27, 0,RO,"axi aw valid"),
VCMDREG(HWIF_VCMD_AXI_AW_READY , 60 ,0x04000000, 26, 0,RO,"axi aw ready"),
VCMDREG(HWIF_VCMD_AXI_W_VALID , 60 ,0x02000000, 25, 0,RO,"axi w valid"),
VCMDREG(HWIF_VCMD_AXI_W_READY , 60 ,0x01000000, 24, 0,RO,"axi w ready"),
VCMDREG(HWIF_VCMD_AXI_B_VALID , 60 ,0x00800000, 23, 0,RO,"axi b valid"),
VCMDREG(HWIF_VCMD_AXI_B_READY , 60 ,0x00400000, 22, 0,RO,"axi b ready"),
VCMDREG(HWIF_VCMD_WORK_STATE , 60 ,0x00000007, 0, 0,RO,"hw work state. 0-IDLE 1-WORK 2-STALL 3-PEND 4-ABORT"),
VCMDREG(HWIF_VCMD_AXI_CLK_GATE_DISABLE , 64 ,0x00000040, 6, 0,RW,"keep axi_clk always on when this bit is set to 1"),
VCMDREG(HWIF_VCMD_MASTER_OUT_CLK_GATE_DISABLE , 64 ,0x00000020, 5, 0,RW,"keep master_out_clk(APB/AHB master) always on when this bit is set to 1"),
VCMDREG(HWIF_VCMD_CORE_CLK_GATE_DISABLE , 64 ,0x00000010, 4, 0,RW,"keep core_clk always on when this bit is set to 1"),
VCMDREG(HWIF_VCMD_ABORT_MODE , 64 ,0x00000008, 3, 0,RW,"0:abort after finishing current cmdbuf command.1:abort immediately "),
VCMDREG(HWIF_VCMD_RESET_CORE , 64 ,0x00000004, 2, 0,RW,"sw write 1 to this bit will rset HW core logic when AXI/APB bus is idle."),
VCMDREG(HWIF_VCMD_RESET_ALL , 64 ,0x00000002, 1, 0,RW,"sw write 1 to this bit will rset HW immediately including all swregs and AXI/APB bus logic"),
VCMDREG(HWIF_VCMD_START_TRIGGER , 64 ,0x00000001, 0, 0,RW,"0:abort previou task and stop hw. 1:trigger hw to fetch and execute commands."),
VCMDREG(HWIF_VCMD_IRQ_INTCMD , 68 ,0xffff0000, 16, 0,RW,"interrupt sources which are triggered by command buffer id.. Only for version 1.0.c"),
VCMDREG(HWIF_VCMD_IRQ_JMPP , 68 ,0x00000080, 7, 0,RW,"interrupt source which is triggered by JMP command when hw goes to PEND state."),
VCMDREG(HWIF_VCMD_IRQ_JMPD , 68 ,0x00000040, 6, 0,RW,"interrupt source which is triggered by JMP command directly."),
VCMDREG(HWIF_VCMD_IRQ_RESET , 68 ,0x00000020, 5, 0,RW,"interrupt source which is triggered by hw reset or sw_vcmd_reset_all."),
VCMDREG(HWIF_VCMD_IRQ_ABORT , 68 ,0x00000010, 4, 0,RW,"interrupt source which is triggered by abort operation."),
VCMDREG(HWIF_VCMD_IRQ_CMDERR , 68 ,0x00000008, 3, 0,RW,"interrupt source which is triggered when there is illegal command in cmdbuf"),
VCMDREG(HWIF_VCMD_IRQ_TIMEOUT , 68 ,0x00000004, 2, 0,RW,"interrupt source which is triggered when vcmd timeout."),
VCMDREG(HWIF_VCMD_IRQ_BUSERR , 68 ,0x00000002, 1, 0,RW,"interrupt source which is triggered when there is bus error."),
VCMDREG(HWIF_VCMD_IRQ_ENDCMD , 68 ,0x00000001, 0, 0,RW,"interrupt source which is triggered by END command."),
VCMDREG(HWIF_VCMD_IRQ_INTCMD_EN , 72 ,0xffff0000, 16, 0,RW,"interrupt sources which are triggered by command buffer id. Only for version 1.0.c"),
VCMDREG(HWIF_VCMD_IRQ_JMPP_EN , 72 ,0x00000080, 7, 0,RW,"interrupt enable for sw_vcmd_irq_jmpp"),
VCMDREG(HWIF_VCMD_IRQ_JMPD_EN , 72 ,0x00000040, 6, 0,RW,"interrupt enable for sw_vcmd_irq_jmpd"),
VCMDREG(HWIF_VCMD_IRQ_RESET_EN , 72 ,0x00000020, 5, 0,RW,"interrupt enable for sw_vcmd_irq_reset"),
VCMDREG(HWIF_VCMD_IRQ_ABORT_EN , 72 ,0x00000010, 4, 0,RW,"interrupt enable for sw_vcmd_irq_abort"),
VCMDREG(HWIF_VCMD_IRQ_CMDERR_EN , 72 ,0x00000008, 3, 0,RW,"interrupt enable for sw_vcmd_irq_cmderr"),
VCMDREG(HWIF_VCMD_IRQ_TIMEOUT_EN , 72 ,0x00000004, 2, 0,RW,"interrupt enable for sw_vcmd_irq_timeout"),
VCMDREG(HWIF_VCMD_IRQ_BUSERR_EN , 72 ,0x00000002, 1, 0,RW,"interrupt enable for sw_vcmd_irq_buserr"),
VCMDREG(HWIF_VCMD_IRQ_ENDCMD_EN , 72 ,0x00000001, 0, 0,RW,"interrupt enable for sw_vcmd_irq_endcmd"),
VCMDREG(HWIF_VCMD_TIMEOUT_EN , 76 ,0x80000000, 31, 0,RW,"1:timeout work. 0: timeout do not work"),
VCMDREG(HWIF_VCMD_TIMEOUT_CYCLES , 76 ,0x7fffffff, 0, 0,RW,"sw_vcmd_irq_timeout will be generated when timeout counter is equal to this value."),
VCMDREG(HWIF_VCMD_EXECUTING_CMD_ADDR , 80 ,0xffffffff, 0, 0,RW,"the least 32 bits address of the executing command"),
VCMDREG(HWIF_VCMD_EXECUTING_CMD_ADDR_MSB , 84 ,0xffffffff, 0, 0,RW,"the most 32 bits address of the executing command"),
VCMDREG(HWIF_VCMD_EXE_CMDBUF_LENGTH , 88 ,0x0000ffff, 0, 0,RW,"the length of current command buffer in unit of 64bits."),
VCMDREG(HWIF_VCMD_CMD_SWAP , 92 ,0xf0000000, 28, 0,RW,"axi data swapping"),
VCMDREG(HWIF_VCMD_MAX_BURST_LEN , 92 ,0x00ff0000, 16, 0,RW,"max burst length which will be sent to axi bus"),
VCMDREG(HWIF_VCMD_AXI_ID_RD , 92 ,0x0000ff00, 8, 0,RW,"the arid which will be used on axi bus reading"),
VCMDREG(HWIF_VCMD_AXI_ID_WR , 92 ,0x000000ff, 0, 0,RW,"the awid which will be used on axi bus writing"),
VCMDREG(HWIF_VCMD_RDY_CMDBUF_COUNT , 96 ,0xffffffff, 0, 0,RW,"sw increases this counter by 1 after one more command buffer was ready."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_MMU_GATE , 100,0x10000000, 28, 0,RW,"external abnormal interrupt source from mmu of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_L2CACHE_GATE, 100,0x08000000, 27, 0,RW,"external abnormal interrupt source from l2cache of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_DEC400_GATE, 100,0x04000000, 26, 0,RW,"external abnormal interrupt source from dec400 of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_GATE , 100,0x01000000, 24, 0,RW,"external abnormal interrupt source from vcd gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_MMU_GATE, 100,0x00200000, 21, 0,RW,"external abnormal interrupt source from mmu of cutree gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_MMU_GATE , 100,0x00100000, 20, 0,RW,"external abnormal interrupt source from mmu of vce gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_L2CACHE_GATE, 100,0x00080000, 19, 0,RW,"external abnormal interrupt source from l2 cache of vce gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_DEC400_GATE, 100,0x00040000, 18, 0,RW,"external abnormal interrupt source from dec400 of vce gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_GATE , 100,0x00020000, 17, 0,RW,"external abnormal interrupt source from cutree gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_GATE , 100,0x00010000, 16, 0,RW,"external abnormal interrupt source from vce gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_MMU_GATE , 100,0x00000800, 11, 0,RW,"external normal interrupt source from mmu of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_L2CACHE_GATE, 100,0x00000400, 10, 0,RW,"external normal interrupt source from l2cache of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_DEC400_GATE, 100,0x00000200, 9, 0,RW,"external normal interrupt source from dec400 of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_GATE , 100,0x00000100, 8, 0,RW,"external normal interrupt source from vcd gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_MMU_GATE, 100,0x00000020, 5, 0,RW,"external normal interrupt source from mmu of cutree gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_MMU_GATE , 100,0x00000010, 4, 0,RW,"external normal interrupt source from mmu of vce gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_L2CACHE_GATE, 100,0x00000008, 3, 0,RW,"external normal interrupt source from l2 cache of vce gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_DEC400_GATE, 100,0x00000004, 2, 0,RW,"external normal interrupt source from dec400 of vce gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_GATE , 100,0x00000002, 1, 0,RW,"external normal interrupt source from cutree gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_GATE , 100,0x00000001, 0, 0,RW,"external normal interrupt source from vce gate."),
VCMDREG(HWIF_VCMD_CMDBUF_EXECUTING_ID , 104,0xffffffff, 0, 0,RW,"The ID of current executing command buffer.used after version 1.1.2."),

View File

@@ -0,0 +1,148 @@
/*
* Hantro Decoder device driver (kernel module)
*
* Copyright (C) 2020 VeriSilicon Microelectronics Co., Ltd.
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. External compiler flags
3. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include <linux/io.h> /* for ioread32 and iowrite32 ... */
#include "vcmdswhwregisters.h"
/* NOTE: Don't use ',' in descriptions, because it is used as separator in csv
* parsing. */
const regVcmdField_s asicVcmdRegisterDesc[] =
{
#include "vcmdregistertable.h"
};
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/* Define this to print debug info for every register write.
#define DEBUG_PRINT_REGS */
/*******************************************************************************
Function name : vcmd_read_reg
Description : Retrive the content of a hadware register
Note: The status register will be read after every MB
so it may be needed to buffer it's content if reading
the HW register is slow.
Return type : u32
Argument : u32 offset
*******************************************************************************/
u32 vcmd_read_reg(const void *hwregs, u32 offset)
{
u32 val;
val =(u32) ioread32((void*)hwregs + offset);
PDEBUG("vcmd_read_reg 0x%02x --> %08x\n", offset, val);
return val;
}
/*******************************************************************************
Function name : vcmd_write_reg
Description : Set the content of a hadware register
Return type : void
Argument : u32 offset
Argument : u32 val
*******************************************************************************/
void vcmd_write_reg(const void *hwregs, u32 offset, u32 val)
{
iowrite32(val,(void*)hwregs + offset);
PDEBUG("vcmd_write_reg 0x%02x with value %08x\n", offset, val);
}
/*------------------------------------------------------------------------------
vcmd_write_register_value
Write a value into a defined register field (write will happens actually).
------------------------------------------------------------------------------*/
void vcmd_write_register_value(const void *hwregs,u32* reg_mirror,regVcmdName name, u32 value)
{
const regVcmdField_s *field;
u32 regVal;
field = &asicVcmdRegisterDesc[name];
#ifdef DEBUG_PRINT_REGS
PDEBUG("vcmd_write_register_value 0x%2x 0x%08x Value: %10d %s\n",
field->base, field->mask, value, field->description);
#endif
/* Check that value fits in field */
PDEBUG("field->name == name=%d\n",field->name == name);
PDEBUG("((field->mask >> field->lsb) << field->lsb) == field->mask=%d\n",((field->mask >> field->lsb) << field->lsb) == field->mask);
PDEBUG("(field->mask >> field->lsb) >= value=%d\n",(field->mask >> field->lsb) >= value);
PDEBUG("field->base < ASIC_VCMD_SWREG_AMOUNT*4=%d\n",field->base < ASIC_VCMD_SWREG_AMOUNT*4);
/* Clear previous value of field in register */
regVal = reg_mirror[field->base/4] & ~(field->mask);
/* Put new value of field in register */
reg_mirror[field->base/4] = regVal | ((value << field->lsb) & field->mask);
/* write it into HW registers */
vcmd_write_reg(hwregs, field->base,reg_mirror[field->base/4]);
}
/*------------------------------------------------------------------------------
vcmd_get_register_value
Get an unsigned value from the ASIC registers
------------------------------------------------------------------------------*/
u32 vcmd_get_register_value(const void *hwregs, u32* reg_mirror,regVcmdName name)
{
const regVcmdField_s *field;
u32 value;
field = &asicVcmdRegisterDesc[name];
PDEBUG("field->base < ASIC_VCMD_SWREG_AMOUNT * 4=%d\n",field->base < ASIC_VCMD_SWREG_AMOUNT * 4);
value = reg_mirror[field->base / 4] = vcmd_read_reg(hwregs, field->base);
value = (value & field->mask) >> field->lsb;
return value;
}

View File

@@ -0,0 +1,233 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. External compiler flags
3. Module defines
------------------------------------------------------------------------------*/
#ifndef VCMD_SWHWREGISTERS_H
#define VCMD_SWHWREGISTERS_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#ifdef __FREERTOS__
#include "basetype.h"
#include "io_tools.h"
#elif defined(__linux__)
#ifndef MODEL_SIMULATION
#include <linux/ioctl.h>
#include <linux/kernel.h>
#include <linux/module.h>
#endif
#endif
#ifdef __FREERTOS__
//addr_t has been defined in basetype.h //Now the FreeRTOS mem need to support 64bit env
#elif defined(__linux__)
typedef size_t addr_t;
#endif
typedef addr_t ptr_t;
#undef PDEBUG /* undef it, just in case */
#ifdef REGISTER_DEBUG
# ifdef __KERNEL__
/* This one if debugging is on, and kernel space */
# define PDEBUG(fmt, args...) printk( KERN_INFO "memalloc: " fmt, ## args)
# else
/* This one for user space */
# define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
# endif
#else
# define PDEBUG(fmt, ...) /* not debugging: nothing */
#endif
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
#define ASIC_VCMD_SWREG_AMOUNT 27
#define VCMD_REGISTER_CONTROL_OFFSET 0X40
#define VCMD_REGISTER_INT_STATUS_OFFSET 0X44
#define VCMD_REGISTER_INT_CTL_OFFSET 0X48
#define VCMD_REGISTER_EXT_INT_GATE_OFFSET 0X64
/* HW Register field names */
typedef enum
{
#include "vcmdregisterenum.h"
VcmdRegisterAmount
} regVcmdName;
/* HW Register field descriptions */
typedef struct
{
u32 name; /* Register name and index */
int base; /* Register base address */
u32 mask; /* Bitmask for this field */
int lsb; /* LSB for this field [31..0] */
int trace; /* Enable/disable writing in swreg_params.trc */
int rw; /* 1=Read-only 2=Write-only 3=Read-Write */
char *description; /* Field description */
} regVcmdField_s;
/* Flags for read-only, write-only and read-write */
#define RO 1
#define WO 2
#define RW 3
#define REGBASE(reg) (asicVcmdRegisterDesc[reg].base)
/* Description field only needed for system model build. */
#ifdef TEST_DATA
#define VCMDREG(name, base, mask, lsb, trace, rw, desc) \
{name, base, mask, lsb, trace, rw, desc}
#else
#define VCMDREG(name, base, mask, lsb, trace, rw, desc) \
{name, base, mask, lsb, trace, rw, ""}
#endif
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
extern const regVcmdField_s asicVcmdRegisterDesc[];
/*------------------------------------------------------------------------------
EncAsicSetRegisterValue
Set a value into a defined register field
------------------------------------------------------------------------------*/
static inline void vcmd_set_register_mirror_value(u32 *reg_mirror, regVcmdName name, u32 value)
{
const regVcmdField_s *field;
u32 regVal;
field = &asicVcmdRegisterDesc[name];
#ifdef DEBUG_PRINT_REGS
printf("vcmd_set_register_mirror_value 0x%2x 0x%08x Value: %10d %s\n",
field->base, field->mask, value, field->description);
#endif
/* Check that value fits in field */
PDEBUG("field->name == name=%d\n",field->name == name);
PDEBUG("((field->mask >> field->lsb) << field->lsb) == field->mask=%d\n",((field->mask >> field->lsb) << field->lsb) == field->mask);
PDEBUG("(field->mask >> field->lsb) >= value=%d\n",(field->mask >> field->lsb) >= value);
PDEBUG("field->base < ASIC_VCMD_SWREG_AMOUNT * 4=%d\n",field->base < ASIC_VCMD_SWREG_AMOUNT * 4);
/* Clear previous value of field in register */
regVal = reg_mirror[field->base / 4] & ~(field->mask);
/* Put new value of field in register */
reg_mirror[field->base / 4] = regVal | ((value << field->lsb) & field->mask);
}
static inline u32 vcmd_get_register_mirror_value(u32 *reg_mirror, regVcmdName name)
{
const regVcmdField_s *field;
u32 regVal;
field = &asicVcmdRegisterDesc[name];
/* Check that value fits in field */
PDEBUG("field->name == name=%d\n",field->name == name);
PDEBUG("((field->mask >> field->lsb) << field->lsb) == field->mask=%d\n",((field->mask >> field->lsb) << field->lsb) == field->mask);
PDEBUG("field->base < ASIC_VCMD_SWREG_AMOUNT * 4=%d\n",field->base < ASIC_VCMD_SWREG_AMOUNT * 4);
regVal = reg_mirror[field->base / 4];
regVal = (regVal & field->mask) >> field->lsb;
#ifdef DEBUG_PRINT_REGS
PDEBUG("vcmd_get_register_mirror_value 0x%2x 0x%08x Value: %10d %s\n",
field->base, field->mask, regVal, field->description);
#endif
return regVal;
}
u32 vcmd_read_reg(const void *hwregs, u32 offset);
void vcmd_write_reg(const void *hwregs, u32 offset, u32 val);
void vcmd_write_register_value(const void *hwregs,u32* reg_mirror,regVcmdName name, u32 value);
u32 vcmd_get_register_value(const void *hwregs, u32* reg_mirror,regVcmdName name);
#define vcmd_set_addr_register_value(reg_base, reg_mirror, name, value) do {\
if(sizeof(addr_t) == 8) {\
vcmd_write_register_value((reg_base), (reg_mirror),name, (u32)((addr_t)value)); \
vcmd_write_register_value((reg_base), (reg_mirror),name##_MSB, (u32)(((addr_t)value) >> 32));\
} else {\
vcmd_write_register_value((reg_base),(reg_mirror), name, (u32)((addr_t)value));\
}\
}while (0)
#define VCMDGetAddrRegisterValue(reg_base, reg_mirror,name) \
((sizeof(addr_t) == 8) ? (\
(((addr_t)vcmd_get_register_value((reg_base),(reg_mirror), name)) | \
(((addr_t)vcmd_get_register_value((reg_base), (reg_mirror),name##_MSB)) << 32))\
) : ((addr_t)vcmd_get_register_value((reg_base),(reg_mirror), (name))))
#endif /* VCMD_SWHWREGISTERS_H */

View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey 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;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
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
state 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 3 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, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU 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 Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@@ -0,0 +1,3 @@
config VIDEO_VC8000E
tristate "VC8000E support"
default m

View File

@@ -0,0 +1,90 @@
##
# Copyright (C) 2020 Alibaba Group Holding Limited
##
ifneq ($(wildcard ../.param),)
include ../.param
endif
#CONFIG_DEBUG_MODE=1
CONFIG_OUT_ENV=hwlinux
CONFIG_BUILD_DRV_EXTRA_PARAM:=""
DIR_TARGET_BASE=bsp/venc
DIR_TARGET_KO =bsp/venc/ko
MODULE_NAME=VENC
BUILD_LOG_START="\033[47;30m>>> $(MODULE_NAME) $@ begin\033[0m"
BUILD_LOG_END ="\033[47;30m<<< $(MODULE_NAME) $@ end\033[0m"
#
# Do a parallel build with multiple jobs, based on the number of CPUs online
# in this system: 'make -j8' on a 8-CPU system, etc.
#
# (To override it, run 'make JOBS=1' and similar.)
#
ifeq ($(JOBS),)
JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
ifeq ($(JOBS),)
JOBS := 1
endif
endif
all: info driver install_local_output
.PHONY: info driver install_local_output install_addons install_prepare clean_driver clean_output clean
info:
@echo $(BUILD_LOG_START)
@echo " ====== Build Info from repo project ======"
@echo " BUILDROOT_DIR="$(BUILDROOT_DIR)
@echo " CROSS_COMPILE="$(CROSS_COMPILE)
@echo " LINUX_DIR="$(LINUX_DIR)
@echo " ARCH="$(ARCH)
@echo " BOARD_NAME="$(BOARD_NAME)
@echo " KERNEL_ID="$(KERNELVERSION)
@echo " KERNEL_DIR="$(LINUX_DIR)
@echo " INSTALL_DIR_ROOTFS="$(INSTALL_DIR_ROOTFS)
@echo " INSTALL_DIR_SDK="$(INSTALL_DIR_SDK)
@echo " ====== Build configuration by settings ======"
# @echo " CONFIG_DEBUG_MODE="$(CONFIG_DEBUG_MODE)
@echo " CONFIG_OUT_ENV="$(CONFIG_OUT_ENV)
@echo " JOBS="$(JOBS)
@echo $(BUILD_LOG_END)
driver:
@echo $(BUILD_LOG_START)
make -C linux/kernel_module KDIR=$(LINUX_DIR) ARCH=$(ARCH)
@echo $(BUILD_LOG_END)
clean_driver:
@echo $(BUILD_LOG_START)
make -C linux/kernel_module KDIR=$(LINUX_DIR) clean
@echo $(BUILD_LOG_END)
install_prepare:
mkdir -p ./output/rootfs/$(DIR_TARGET_KO)
install_addons: install_prepare
@if [ -d addons/ko ]; then \
cp -rf addons/ko/* ./output/rootfs/$(DIR_TARGET_KO); \
fi
install_local_output: install_addons install_prepare driver
@echo $(BUILD_LOG_START)
find ./linux -name "*.ko" | xargs -i cp -f {} ./output/rootfs/$(DIR_TARGET_KO)
cp -f ./linux/kernel_module/driver_load.sh ./output/rootfs/$(DIR_TARGET_KO)
chmod +x ./output/rootfs/$(DIR_TARGET_KO)/*.sh
echo "vc8000" > ./output/rootfs/$(DIR_TARGET_KO)/vc8000e.conf
@if [ `command -v tree` != "" ]; then \
tree ./output/rootfs; \
fi
@echo $(BUILD_LOG_END)
clean_output:
@echo $(BUILD_LOG_START)
rm -rf ./output
@echo $(BUILD_LOG_END)
clean: clean_output clean_driver

View File

@@ -0,0 +1,5 @@
#!/bin/sh
KERNEL_VER=$(uname -r)
BASE_PATH=/lib/modules/${KERNEL_VER}/extra
insmod $BASE_PATH/vc8000.ko

View File

@@ -0,0 +1,3 @@
#!/bin/sh
rmmod vc8000

View File

@@ -0,0 +1,204 @@
#############################################################################
#
# The MIT License (MIT)
#
# Copyright (c) 2014 - 2021 VERISILICON
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
#############################################################################
#
# The GPL License (GPL)
#
# Copyright (C) 2014 - 2021 VERISILICON
#
# 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#############################################################################
#
# Note: This software is released under dual MIT and GPL licenses. A
# recipient may use this file under the terms of either the MIT license or
# GPL License. If you wish to use only one license not the other, you can
# indicate your decision by deleting one of the above license notices in your
# version of this file.
#
##############################################################################
ARM_CROSS_COMPILE ?= n
ifeq ($(ARM_CROSS_COMPILE),y)
export ARCH=arm64
export CROSS_COMPILE=/opt/kmb/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-
KDIR := /home/vsi/kmb-evm/kernel/mainline-tracking
endif
SUPPORT_MMU = y
SUPPORT_AXIFE = n
SUPPORT_VCMD_ENABLE_IP = n
ifeq ($(obj),)
obj = .
endif
#################################################
# configuration
MDIR := hantro
# drivers objects
# list-multi := hantro_mmu.o
# # what to build
vc8000-objs := vc8000_driver.o vc8000_vcmd_driver.o bidirect_list.o vcmdswhwregisters.o vc8000_normal_driver.o
obj-m += vc8000.o
ifeq ($(strip $(SUPPORT_MMU)),y)
vc8000-objs += hantro_mmu.o
endif
ifeq ($(strip $(SUPPORT_AXIFE)),y)
vc8000-objs += vc8000_axife.o
endif
tardest := .
#################################################
# compile modules
ifneq ($(KERNELRELEASE),)
# recursive call from kernel build system
dummy := $(shell echo $(KERNELRELEASE) > $(obj)/.version)
ifeq ($(VERSION).$(PATCHLEVEL),2.6)
export-objs :=
list-multi :=
else
multi-m := $(filter $(list-multi), $(obj-m))
int-m := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs)))
export-objs := $(filter $(int-m) $(obj-m),$(export-objs))
endif
CC += -I$(obj)
EXTRA_CFLAGS += -g
# Print debugging messages from the device
#EXTRA_CFLAGS += -DHANTRO_DRIVER_DEBUG
#EXTRA_CFLAGS += -DHANTROMMU_DEBUG
#EXTRA_CFLAGS += -DDYNAMIC_MALLOC_VCMDNODE
snapshot := $(wildcard $(obj)/.snapshot)
ifneq ($(snapshot),)
SNAPSHOT_CFLAGS := -DSNAPSHOT='$(shell cat $(snapshot))'
EXTRA_CFLAGS += $(SNAPSHOT_CFLAGS)
endif
ifeq ($(strip $(SUPPORT_MMU)),y)
EXTRA_CFLAGS += -DHANTROMMU_SUPPORT
endif
ifeq ($(strip $(SUPPORT_AXIFE)),y)
EXTRA_CFLAGS += -DHANTROAXIFE_SUPPORT
endif
ifeq ($(strip $(SUPPORT_VCMD_ENABLE_IP)),y)
EXTRA_CFLAGS += -DHANTROVCMD_ENABLE_IP_SUPPORT
endif
-include $(TOPDIR)/Rules.make
else
# take version info from last module build if available
KERNELRELEASE := $(shell cat $(obj)/.version 2>/dev/null || uname -r)
endif
ifneq ($(ARM_CROSS_COMPILE),y)
KDIR_BASE := /afs/hantro.com/projects/Testing/Board_Version_Control
#KDIR := $(KDIR_BASE)/Realview_EB/SW/Linux/v0_0/linux-2.6.19-arm2
#KDIR := $(KDIR_BASE)/Realview_EB/SW/Linux/linux-2.6.21-arm1/v0_0/linux-2.6.21-arm1
#KDIR := $(KDIR_BASE)/Realview_PB/PB926EJS/SW/Linux/linux-2.6.24-arm2-spnlck/v0_1/linux-2.6.24-arm2-spnlck
#KDIR := $(KDIR_BASE)/Realview_PB/PB926EJS/SW/Linux/linux-2.6.28-arm1/v0_1/linux-2.6.28-arm1
#KDIR := $(KDIR_BASE)/SW_Common/ARM_realview_v6/2.6.28-arm1/v0_1-v6/linux-2.6.28-arm1
KVER := $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
endif
PWD := $(shell pwd)
DEST := /lib/modules/$(KERNELRELEASE)/$(MDIR)
# which files to install?
inst-m := $(wildcard *.ko)
ifeq ($(inst-m),)
inst-m := $(obj-m)
endif
# locales seem to cause trouble sometimes.
LC_ALL = POSIX
export LC_ALL
default::
$(MAKE) -C $(KDIR) M=$(PWD) modules
install::
strip --strip-debug $(inst-m)
-su -c "mkdir -p $(DEST); cp -v $(inst-m) $(DEST); depmod -a"
clean::
$(MAKE) -C $(KDIR) M=$(PWD) clean
-rm -f .version
#################################################
# build tarballs
thisdir := $(notdir $(PWD))
name := $(shell echo $(thisdir) | sed 's/-.*//')
ver := $(shell echo $(thisdir) | sed 's/.*-//')
date := $(shell date +%Y%m%d)
tardest ?= .
snapdir := $(HOME)/snapshot
snap ?= $(name)
release: clean
rm -f .snapshot
(cd ..; tar cvzf $(tardest)/$(name)-$(ver).tar.gz $(thisdir))
snapshot snap tarball: clean
echo $(date) > .snapshot
(cd ..; tar czf $(snapdir)/$(snap)-$(date).tar.gz $(thisdir))
$(MAKE) -C $(snapdir)
#################################################
# other stuff
%.asm: %.o
objdump -S $< > $@

View File

@@ -0,0 +1,42 @@
-- BUILD --
You need a fully configured kernel source tree in order to build the
driver. Please set the location of the kernel tree in the Makefile (KDIR).
If you want some extra debug information in the kernel logs, you could
define the HANTRO_DRIVER_DEBUG but please be aware that allot of things are traced
with this option.
Also you could set a particular device MAJOR in the 'vc8000_normal_driver.c' and 'vc8000_vcmd_driver.c'
if you don't want dynamic allocation.
Just run in this dir:
%make
If you want to install the modules please check first the install destination
in the Makefile (MDIR, DEST) and run:
%make install
-- USAGE --
Run script driver_load.sh to do all the things described below.
> sh driver_load.sh vcmd=0
First of all the module has to be inserted into the kernel with:
(you need a Linux shell cmd line)
%insmod vc8000.ko vcmd_supported=1
Second of all a char device file has to be created:
%mknod /dev/vc8000 c $MAJOR 0
Replace MAJOR = 254 with the correct value (i.e. read /proc/devices to find out
the exact value).
Make sure that you have RW rights for the newly created dev file (use 'chmod').
The 'driver_load' script is provided for preparing all the things necessary for
the driver to be usable. The script is using 'cat' to retrieve the device's
major from /proc/devices. Remember to set the driver parameters.

View File

@@ -0,0 +1,222 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifdef __FREERTOS__
#include <string.h>
#include "osal.h"
#elif defined(__linux__)
#include <linux/kernel.h>
#include <linux/module.h>
/* needed for __init,__exit directives */
#include <linux/init.h>
/* needed for remap_page_range
SetPageReserved
ClearPageReserved
*/
#include <linux/mm.h>
/* obviously, for kmalloc */
#include <linux/slab.h>
/* for struct file_operations, register_chrdev() */
#include <linux/fs.h>
/* standard error codes */
#include <linux/errno.h>
#include <linux/moduleparam.h>
/* request_irq(), free_irq() */
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/semaphore.h>
#include <linux/spinlock.h>
/* needed for virt_to_phys() */
#include <asm/io.h>
#include <linux/pci.h>
#include <asm/uaccess.h>
#include <linux/ioport.h>
#include <asm/irq.h>
#include <linux/version.h>
#include <linux/vmalloc.h>
#include <linux/timer.h>
#else //For other os
//TODO...
#endif
#include "bidirect_list.h"
void init_bi_list(bi_list* list)
{
list->head = NULL;
list->tail = NULL;
}
bi_list_node* bi_list_create_node(void)
{
bi_list_node* node=NULL;
node=(bi_list_node*)vmalloc(sizeof(bi_list_node));
if(node==NULL)
{
PDEBUG ("%s\n","vmalloc for node fail!");
return node;
}
memset(node,0,sizeof(bi_list_node));
return node;
}
void bi_list_free_node(bi_list_node* node)
{
//free current node
vfree(node);
return;
}
void bi_list_insert_node_tail(bi_list* list,bi_list_node* current_node)
{
if(current_node==NULL)
{
PDEBUG ("%s\n","insert node tail NULL");
return;
}
if(list->tail)
{
current_node->previous=list->tail;
list->tail->next=current_node;
list->tail=current_node;
list->tail->next=NULL;
}
else
{
list->head=current_node;
list->tail=current_node;
current_node->next=NULL;
current_node->previous=NULL;
}
return;
}
void bi_list_insert_node_before(bi_list* list,bi_list_node* base_node,bi_list_node* new_node)
{
bi_list_node* temp_node_previous=NULL;
if(new_node==NULL)
{
PDEBUG ("%s\n","insert node before new node NULL");
return;
}
if(base_node)
{
if(base_node->previous)
{
//at middle position
temp_node_previous = base_node->previous;
temp_node_previous->next=new_node;
new_node->next = base_node;
base_node->previous = new_node;
new_node->previous=temp_node_previous;
}
else
{
//at head
base_node->previous = new_node;
new_node->next = base_node;
list->head=new_node;
new_node->previous = NULL;
}
}
else
{
//at tail
bi_list_insert_node_tail(list,new_node);
}
return;
}
void bi_list_remove_node(bi_list* list,bi_list_node* current_node)
{
bi_list_node* temp_node_previous=NULL;
bi_list_node* temp_node_next=NULL;
if(current_node==NULL)
{
PDEBUG ("%s\n","remove node NULL");
return;
}
temp_node_next=current_node->next;
temp_node_previous=current_node->previous;
if(temp_node_next==NULL && temp_node_previous==NULL )
{
//there is only one node.
list->head=NULL;
list->tail=NULL;
}
else if(temp_node_next==NULL)
{
//at tail
list->tail=temp_node_previous;
temp_node_previous->next=NULL;
}
else if( temp_node_previous==NULL)
{
//at head
list->head=temp_node_next;
temp_node_next->previous=NULL;
}
else
{
//at middle position
temp_node_previous->next=temp_node_next;
temp_node_next->previous=temp_node_previous;
}
return;
}

View File

@@ -0,0 +1,116 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _BIDIRECT_LIST_H_
#define _BIDIRECT_LIST_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __FREERTOS__
#include "dev_common_freertos.h" /* needed for the _IOW etc stuff used later */
#elif defined(__linux__)
#include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
#else //For other os
//TODO...
#endif
/*
* Macros to help debugging
*/
#undef PDEBUG /* undef it, just in case */
#ifdef BIDIRECTION_LIST_DEBUG
# ifdef __KERNEL__
/* This one if debugging is on, and kernel space */
# define PDEBUG(fmt, args...) printk( KERN_INFO "hmp4e: " fmt, ## args)
# else
/* This one for user space */
# define PDEBUG(fmt, args...) printf(__FILE__ ":%d: " fmt, __LINE__ , ## args)
# endif
#else
# define PDEBUG(fmt, args...) /* not debugging: nothing */
#endif
/***********************************************************************************************************************************************\
* <Typedefs>
\**********************************************************************************************************************************************/
typedef struct bi_list_node{
void* data;
struct bi_list_node* next;
struct bi_list_node* previous;
}bi_list_node;
typedef struct bi_list{
bi_list_node* head;
bi_list_node* tail;
}bi_list;
void init_bi_list(bi_list* list);
bi_list_node* bi_list_create_node(void);
void bi_list_free_node(bi_list_node* node);
void bi_list_insert_node_tail(bi_list* list,bi_list_node* current_node);
void bi_list_insert_node_before(bi_list* list,bi_list_node* base_node,bi_list_node* new_node);
void bi_list_remove_node(bi_list* list,bi_list_node* current_node);
#ifdef __cplusplus
}
#endif
#endif /* !_BIDIRECT_LIST_H_ */

View File

@@ -0,0 +1,61 @@
#!/bin/sh
#dmesg -C
module="vc8000"
device="/dev/vc8000"
mode="666"
#Used to setup default parameters
DefaultParameter(){
vcmd=1
#default value can be added to here
}
echo
if [ ! -e /dev ]
then
mkdir /dev/
fi
echo "Help information:"
echo "Input format should be like as below"
echo "./driver_load.sh vcmd=0(default) or (1)"
if [ $# -eq 0 ]
then
DefaultParameter
echo " Default vcmd_supported value = $vcmd"
else
para_1="$1"
vcmd_input=${para_1##*=}
vcmd=$vcmd_input
if [ $vcmd -ne 0 ] && [ $vcmd -ne 1 ]
then
echo "Invalid vcmd_supported value, which = $vcmd"
echo "vcmd_supported should be 0 or 1"
fi
echo "vcmd_supported = $vcmd"
fi
#vcmd_supported = 0(default) or 1
#insert module
insmod $module.ko vcmd_supported=$vcmd || exit 1
#insmod $module.ko vcmd_supported=1 || exit 1
echo "module $module inserted"
#remove old nod
rm -f $device
#read the major asigned at loading time
major=`cat /proc/devices | grep $module | cut -c1-3`
echo "$module major = $major"
#create dev node
mknod $device c $major 0
echo "node $device created"
#give all 'rw' access
chmod $mode $device
echo "set node access to $mode"
#the end
echo

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,155 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _HANTROMMU_H_
#define _HANTROMMU_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __FREERTOS__
#elif defined(__linux__)
#include <linux/fs.h>
#endif
#define REGION_IN_START 0x0
#define REGION_IN_END 0x0
#define REGION_OUT_START 0x0
#define REGION_OUT_END 0x0
#define REGION_PRIVATE_START 0x0
#define REGION_PRIVATE_END 0x0
#define REGION_IN_MMU_START 0x1000
#define REGION_IN_MMU_END 0x40002000
#define REGION_OUT_MMU_START 0x40002000
#define REGION_OUT_MMU_END 0x40002000
#define REGION_PRIVATE_MMU_START 0x40002000
#define REGION_PRIVATE_MMU_END 0x40002000
#define MMU_REG_OFFSET 0
#define MMU_REG_HW_ID (MMU_REG_OFFSET + 6*4)
#define MMU_REG_FLUSH (MMU_REG_OFFSET + 97*4)
#define MMU_REG_PAGE_TABLE_ID (MMU_REG_OFFSET + 107*4)
#define MMU_REG_CONTROL (MMU_REG_OFFSET + 226*4)
#define MMU_REG_ADDRESS (MMU_REG_OFFSET + 227*4)
#define MMU_REG_ADDRESS_MSB (MMU_REG_OFFSET + 228*4)
#define MTLB_PCIE_START_ADDRESS 0x00100000
#define PAGE_PCIE_START_ADDRESS 0x00200000 /* page_table_entry start address */
#define STLB_PCIE_START_ADDRESS 0x00300000
#define PAGE_TABLE_ENTRY_SIZE 64
enum MMUStatus {
MMU_STATUS_OK = 0,
MMU_STATUS_FALSE = -1,
MMU_STATUS_INVALID_ARGUMENT = -2,
MMU_STATUS_INVALID_OBJECT = -3,
MMU_STATUS_OUT_OF_MEMORY = -4,
MMU_STATUS_NOT_FOUND = -19,
};
struct addr_desc {
void *virtual_address; /* buffer virtual address */
unsigned int bus_address; /* buffer physical address */
unsigned int size; /* physical size */
};
struct kernel_addr_desc {
unsigned long long bus_address; /* buffer virtual address */
unsigned int mmu_bus_address; /* buffer physical address in MMU*/
unsigned int size; /* physical size */
};
#define HANTRO_IOC_MMU 'm'
#define HANTRO_IOCS_MMU_MEM_MAP _IOWR(HANTRO_IOC_MMU, 1, struct addr_desc *)
#define HANTRO_IOCS_MMU_MEM_UNMAP _IOWR(HANTRO_IOC_MMU, 2, struct addr_desc *)
#define HANTRO_IOCS_MMU_ENABLE _IOWR(HANTRO_IOC_MMU, 3, unsigned int *)
#define HANTRO_IOCS_MMU_FLUSH _IOWR(HANTRO_IOC_MMU, 4, unsigned int *)
#define HANTRO_IOC_MMU_MAXNR 4
#define MAX_SUBSYS_NUM 4 /* up to 4 subsystem (temporary) */
#define HXDEC_MAX_CORES MAX_SUBSYS_NUM /* used in hantro_dec.c */
/* Init MMU, should be called in driver init function. */
enum MMUStatus MMUInit(volatile unsigned char *hwregs);
/* Clean up all data in MMU, should be called in driver cleanup function
when rmmod driver*/
enum MMUStatus MMUCleanup(volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
/* The function should be called in driver realease function
when driver exit unnormally */
enum MMUStatus MMURelease(void *filp, volatile unsigned char *hwregs);
enum MMUStatus MMUEnable(volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
/* Used in kernel to map buffer */
enum MMUStatus MMUKernelMemNodeMap(struct kernel_addr_desc *addr);
/* Used in kernel to unmap buffer */
enum MMUStatus MMUKernelMemNodeUnmap(struct kernel_addr_desc *addr);
unsigned long long GetMMUAddress(void);
long MMUIoctl(unsigned int cmd, void *filp, unsigned long arg,
volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
void MMURestore(volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,99 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#include <linux/version.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/debugfs.h>
#include <linux/types.h>
#include <linux/device.h>
#include <linux/pagemap.h>
#include <linux/sched.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0))
#include <linux/dma-map-ops.h>
#else
#include <linux/dma-contiguous.h>
#endif
#include <linux/platform_device.h>
#include <linux/dma-buf.h>
#include <stddef.h>
#include "vc8000_axife.h"
/* mode description
* 1: OYB normal(enable)
* 2: bypass
*/
u32 AXIFEEnable(volatile u8 *hwregs, u32 mode) {
#ifndef HANTROVCMD_ENABLE_IP_SUPPORT
if (!hwregs) return -1;
//AXI FE pass through
if(mode == 1)
{
iowrite32(0x02, (void *)(hwregs+AXI_REG10_SW_FRONTEND_EN));
iowrite32(0x00, (void *)(hwregs+AXI_REG11_SW_WORK_MODE));
}
else if(mode == 2)
{
iowrite32(0x02, (void *)(hwregs+AXI_REG10_SW_FRONTEND_EN));
iowrite32(0x40, (void *)(hwregs+AXI_REG11_SW_WORK_MODE));
}
printk(KERN_INFO "AXIFEEnable: axife_reg10_addr=0x%p, *axife_reg10_addr=0x%08x\n", hwregs + 10*4, ioread32((void *)(hwregs + 10*4)));
printk(KERN_INFO "AXIFEEnable: axife_reg11_addr=0x%p, *axife_reg11_addr=0x%08x\n", hwregs + 11*4, ioread32((void *)(hwregs + 11*4)));
#endif
return 0;
}

View File

@@ -0,0 +1,77 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef __VC8000_AXIFE_H__
#define __VC8000_AXIFE_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __FREERTOS__
#elif defined(__linux__)
#include <linux/ioctl.h>
#include <linux/types.h>
#endif
#define AXI_REG10_SW_FRONTEND_EN 10*4 //0x28
#define AXI_REG11_SW_WORK_MODE 11*4 //0x2c
u32 AXIFEEnable(volatile u8 *hwregs, u32 mode);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,102 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/version.h>
#include "vc8000_driver.h"
static u32 vcmd_supported = 1;
int __init hantroenc_normal_init(void);
int __init hantroenc_vcmd_init(void);
void __exit hantroenc_normal_cleanup(void);
void __exit hantroenc_vcmd_cleanup(void);
int __init hantroenc_init(void)
{
if(vcmd_supported==0)
{
return hantroenc_normal_init();
}
else
{
return hantroenc_vcmd_init();
}
}
void __exit hantroenc_cleanup(void)
{
if(vcmd_supported==0)
{
hantroenc_normal_cleanup();
}
else
{
hantroenc_vcmd_cleanup();
}
return;
}
module_init(hantroenc_init);
module_exit(hantroenc_cleanup);
module_param(vcmd_supported,uint,0);
/* module description */
/*MODULE_LICENSE("Proprietary");*/
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Verisilicon");
MODULE_DESCRIPTION("VC8000 Vcmd driver");

View File

@@ -0,0 +1,331 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
#ifndef _VC8000_VCMD_DRIVER_H_
#define _VC8000_VCMD_DRIVER_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __FREERTOS__
/* needed for the _IOW etc stuff used later */
#include "base_type.h"
#include "osal.h"
#include "dev_common_freertos.h"
#elif defined(__linux__)
#include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
#else //For other os
//TODO...
#endif
#ifdef HANTROMMU_SUPPORT
#include "hantrommu.h"
#endif
#ifdef HANTROAXIFE_SUPPORT
#include "vc8000_axife.h"
#endif
#ifdef __FREERTOS__
//ptr_t has been defined in base_type.h //Now the FreeRTOS mem need to support 64bit env
#elif defined(__linux__)
#undef ptr_t
#define ptr_t PTR_T_KERNEL
typedef size_t ptr_t;
#endif
/*
* Macros to help debugging
*/
#undef PDEBUG /* undef it, just in case */
#ifdef HANTRO_DRIVER_DEBUG
# ifdef __KERNEL__
/* This one if debugging is on, and kernel space */
# define PDEBUG(fmt, args...) printk( KERN_INFO "vc8000: " fmt, ## args)
# else
/* This one for user space */
# define PDEBUG(fmt, args...) printf(__FILE__ ":%d: " fmt, __LINE__ , ## args)
# endif
#else
# define PDEBUG(fmt, args...) /* not debugging: nothing */
#endif
#define ENC_HW_ID1 0x48320100
#define ENC_HW_ID2 0x80006000
#define CORE_INFO_MODE_OFFSET 31
#define CORE_INFO_AMOUNT_OFFSET 28
/* Use 'k' as magic number */
#define HANTRO_IOC_MAGIC 'k'
/*
* S means "Set" through a ptr,
* T means "Tell" directly with the argument value
* G means "Get": reply by setting through a pointer
* Q means "Query": response is on the return value
* X means "eXchange": G and S atomically
* H means "sHift": T and Q atomically
*/
#define HANTRO_IOCG_HWOFFSET _IOR(HANTRO_IOC_MAGIC, 3, unsigned long *)
#define HANTRO_IOCG_HWIOSIZE _IOR(HANTRO_IOC_MAGIC, 4, unsigned int *)
#define HANTRO_IOC_CLI _IO(HANTRO_IOC_MAGIC, 5)
#define HANTRO_IOC_STI _IO(HANTRO_IOC_MAGIC, 6)
#define HANTRO_IOCX_VIRT2BUS _IOWR(HANTRO_IOC_MAGIC, 7, unsigned long *)
#define HANTRO_IOCH_ARDRESET _IO(HANTRO_IOC_MAGIC, 8) /* debugging tool */
#define HANTRO_IOCG_SRAMOFFSET _IOR(HANTRO_IOC_MAGIC, 9, unsigned long *)
#define HANTRO_IOCG_SRAMEIOSIZE _IOR(HANTRO_IOC_MAGIC, 10, unsigned int *)
#define HANTRO_IOCH_ENC_RESERVE _IOR(HANTRO_IOC_MAGIC, 11,unsigned int *)
#define HANTRO_IOCH_ENC_RELEASE _IOR(HANTRO_IOC_MAGIC, 12,unsigned int *)
#define HANTRO_IOCG_CORE_NUM _IOR(HANTRO_IOC_MAGIC, 13,unsigned int *)
#define HANTRO_IOCG_CORE_INFO _IOR(HANTRO_IOC_MAGIC, 14,SUBSYS_CORE_INFO *)
#define HANTRO_IOCG_CORE_WAIT _IOR(HANTRO_IOC_MAGIC, 15, unsigned int *)
#define HANTRO_IOCG_ANYCORE_WAIT _IOR(HANTRO_IOC_MAGIC, 16, CORE_WAIT_OUT *)
#define HANTRO_IOCH_GET_CMDBUF_PARAMETER _IOWR(HANTRO_IOC_MAGIC, 25,struct cmdbuf_mem_parameter *)
#define HANTRO_IOCH_GET_CMDBUF_POOL_SIZE _IOWR(HANTRO_IOC_MAGIC, 26,unsigned long)
#define HANTRO_IOCH_SET_CMDBUF_POOL_BASE _IOWR(HANTRO_IOC_MAGIC, 27,unsigned long)
#define HANTRO_IOCH_GET_VCMD_PARAMETER _IOWR(HANTRO_IOC_MAGIC, 28, struct config_parameter *)
#define HANTRO_IOCH_RESERVE_CMDBUF _IOWR(HANTRO_IOC_MAGIC, 29,struct exchange_parameter *)
#define HANTRO_IOCH_LINK_RUN_CMDBUF _IOR(HANTRO_IOC_MAGIC, 30,u16 *)
#define HANTRO_IOCH_WAIT_CMDBUF _IOR(HANTRO_IOC_MAGIC, 31,u16 *)
#define HANTRO_IOCH_RELEASE_CMDBUF _IOR(HANTRO_IOC_MAGIC, 32,u16 *)
#define HANTRO_IOCH_POLLING_CMDBUF _IOR(HANTRO_IOC_MAGIC, 33,u16 *)
#define HANTRO_IOCH_GET_VCMD_ENABLE _IOWR(HANTRO_IOC_MAGIC, 50,unsigned long)
#define GET_ENCODER_IDX(type_info) (CORE_VC8000E);
#define CORETYPE(core) (1 << core)
#define HANTRO_IOC_MAXNR 60
/*priority support*/
#define MAX_CMDBUF_PRIORITY_TYPE 2 //0:normal priority,1:high priority
#define CMDBUF_PRIORITY_NORMAL 0
#define CMDBUF_PRIORITY_HIGH 1
#define OPCODE_WREG (0x01<<27)
#define OPCODE_END (0x02<<27)
#define OPCODE_NOP (0x03<<27)
#define OPCODE_RREG (0x16<<27)
#define OPCODE_INT (0x18<<27)
#define OPCODE_JMP (0x19<<27)
#define OPCODE_STALL (0x09<<27)
#define OPCODE_CLRINT (0x1a<<27)
#define OPCODE_JMP_RDY0 (0x19<<27)
#define OPCODE_JMP_RDY1 ((0x19<<27)|(1<<26))
#define JMP_IE_1 (1<<25)
#define JMP_RDY_1 (1<<26)
#define CLRINT_OPTYPE_READ_WRITE_1_CLEAR 0
#define CLRINT_OPTYPE_READ_WRITE_0_CLEAR 1
#define CLRINT_OPTYPE_READ_CLEAR 2
#define VC8000E_FRAME_RDY_INT_MASK 0x0001
#define VC8000E_CUTREE_RDY_INT_MASK 0x0002
#define VC8000E_DEC400_INT_MASK 0x0004
#define VC8000E_L2CACHE_INT_MASK 0x0008
#define VC8000E_MMU_INT_MASK 0x0010
#define CUTREE_MMU_INT_MASK 0x0020
#define VC8000D_FRAME_RDY_INT_MASK 0x0100
#define VC8000D_DEC400_INT_MASK 0x0400
#define VC8000D_L2CACHE_INT_MASK 0x0800
#define VC8000D_MMU_INT_MASK 0x1000
#define VC8000D_DEC400_INT_MASK_1_1_1 0x0200
#define VC8000D_L2CACHE_INT_MASK_1_1_1 0x0400
#define VC8000D_MMU_INT_MASK_1_1_1 0x0800
#define HW_ID_1_0_C 0x43421001
#define HW_ID_1_1_2 0x43421102
#define ASIC_STATUS_SEGMENT_READY 0x1000
#define ASIC_STATUS_FUSE_ERROR 0x200
#define ASIC_STATUS_SLICE_READY 0x100
#define ASIC_STATUS_LINE_BUFFER_DONE 0x080 /* low latency */
#define ASIC_STATUS_HW_TIMEOUT 0x040
#define ASIC_STATUS_BUFF_FULL 0x020
#define ASIC_STATUS_HW_RESET 0x010
#define ASIC_STATUS_ERROR 0x008
#define ASIC_STATUS_FRAME_READY 0x004
#define ASIC_IRQ_LINE 0x001
#define ASIC_STATUS_ALL (ASIC_STATUS_SEGMENT_READY |\
ASIC_STATUS_FUSE_ERROR |\
ASIC_STATUS_SLICE_READY |\
ASIC_STATUS_LINE_BUFFER_DONE |\
ASIC_STATUS_HW_TIMEOUT |\
ASIC_STATUS_BUFF_FULL |\
ASIC_STATUS_HW_RESET |\
ASIC_STATUS_ERROR |\
ASIC_STATUS_FRAME_READY)
enum
{
CORE_VC8000E = 0,
CORE_VC8000EJ = 1,
CORE_CUTREE = 2,
CORE_DEC400 = 3,
CORE_MMU = 4,
CORE_L2CACHE = 5,
CORE_AXIFE = 6,
CORE_APBFT = 7,
CORE_MMU_1 = 8,
CORE_AXIFE_1 = 9,
CORE_MAX
};
//#define CORE_MAX (CORE_MMU)
/*module_type support*/
enum vcmd_module_type{
VCMD_TYPE_ENCODER = 0,
VCMD_TYPE_CUTREE,
VCMD_TYPE_DECODER,
VCMD_TYPE_JPEG_ENCODER,
VCMD_TYPE_JPEG_DECODER,
MAX_VCMD_TYPE
};
struct cmdbuf_mem_parameter
{
u32 *virt_cmdbuf_addr;
ptr_t phy_cmdbuf_addr; //cmdbuf pool base physical address
u32 mmu_phy_cmdbuf_addr; //cmdbuf pool base mmu mapping address
u32 cmdbuf_total_size; //cmdbuf pool total size in bytes.
u16 cmdbuf_unit_size; //one cmdbuf size in bytes. all cmdbuf have same size.
u32 *virt_status_cmdbuf_addr;
ptr_t phy_status_cmdbuf_addr; //status cmdbuf pool base physical address
u32 mmu_phy_status_cmdbuf_addr; //status cmdbuf pool base mmu mapping address
u32 status_cmdbuf_total_size; //status cmdbuf pool total size in bytes.
u16 status_cmdbuf_unit_size; //one status cmdbuf size in bytes. all status cmdbuf have same size.
ptr_t base_ddr_addr; //for pcie interface, hw can only access phy_cmdbuf_addr-pcie_base_ddr_addr.
//for other interface, this value should be 0?
};
struct config_parameter
{
u16 module_type; //input vc8000e=0,cutree=1,vc8000d=2jpege=3, jpegd=4
u16 vcmd_core_num; //output, how many vcmd cores are there with corresponding module_type.
u16 submodule_main_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
u16 submodule_dec400_addr; //output ,if submodule addr == 0xffff, this submodule does not exist.
u16 submodule_L2Cache_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
u16 submodule_MMU_addr[2]; //output,if submodule addr == 0xffff, this submodule does not exist.
u16 submodule_axife_addr[2]; //output,if submodule addr == 0xffff, this submodule does not exist.
u16 config_status_cmdbuf_id; // output , this status comdbuf save the all register values read in driver init.//used for analyse configuration in cwl.
u32 vcmd_hw_version_id;
};
/*need to consider how many memory should be allocated for status.*/
struct exchange_parameter
{
u32 executing_time; //input ;executing_time=encoded_image_size*(rdoLevel+1)*(rdoq+1);
u16 module_type; //input input vc8000e=0,IM=1,vc8000d=2jpege=3, jpegd=4
u16 cmdbuf_size; //input, reserve is not used; link and run is input.
u16 priority; //input,normal=0, high/live=1
u16 cmdbuf_id; //output ,it is unique in driver.
u16 core_id; //just used for polling.
};
typedef struct CoreWaitOut
{
u32 job_id[4];
u32 irq_status[4];
u32 irq_num;
} CORE_WAIT_OUT;
typedef struct
{
u32 subsys_idx;
u32 core_type;
unsigned long offset;
u32 reg_size;
int irq;
}CORE_CONFIG;
typedef struct
{
unsigned long base_addr;
u32 iosize;
u32 resouce_shared; //indicate the core share resources with other cores or not.If 1, means cores can not work at the same time.
}SUBSYS_CONFIG;
typedef struct
{
u32 type_info; //indicate which IP is contained in this subsystem and each uses one bit of this variable
unsigned long offset[CORE_MAX];
unsigned long regSize[CORE_MAX];
int irq[CORE_MAX];
}SUBSYS_CORE_INFO;
typedef struct
{
SUBSYS_CONFIG cfg;
SUBSYS_CORE_INFO core_info;
}SUBSYS_DATA;
#ifdef __cplusplus
}
#endif
#endif /* !_VC8000_VCMD_DRIVER_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,157 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
/* Register interface based on the document version 1.1.2 */
HWIF_VCMD_HW_ID,
HWIF_VCMD_HW_VERSION,
HWIF_VCMD_HW_BUILD_DATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_MMU,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_L2CACHE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_DEC400,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD,
HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_MMU,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_MMU,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_L2CACHE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_DEC400,
HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_MMU,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_L2CACHE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_DEC400,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD,
HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_MMU,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_MMU,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_L2CACHE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_DEC400,
HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE,
HWIF_VCMD_EXE_CMDBUF_COUNT,
HWIF_VCMD_EXECUTING_CMD,
HWIF_VCMD_EXECUTING_CMD_MSB,
HWIF_VCMD_AXI_TOTAL_AR_LEN,
HWIF_VCMD_AXI_TOTAL_R,
HWIF_VCMD_AXI_TOTAL_AR,
HWIF_VCMD_AXI_TOTAL_R_LAST,
HWIF_VCMD_AXI_TOTAL_AW_LEN,
HWIF_VCMD_AXI_TOTAL_W,
HWIF_VCMD_AXI_TOTAL_AW,
HWIF_VCMD_AXI_TOTAL_W_LAST,
HWIF_VCMD_AXI_TOTAL_B,
HWIF_VCMD_AXI_AR_VALID,
HWIF_VCMD_AXI_AR_READY,
HWIF_VCMD_AXI_R_VALID,
HWIF_VCMD_AXI_R_READY,
HWIF_VCMD_AXI_AW_VALID,
HWIF_VCMD_AXI_AW_READY,
HWIF_VCMD_AXI_W_VALID,
HWIF_VCMD_AXI_W_READY,
HWIF_VCMD_AXI_B_VALID,
HWIF_VCMD_AXI_B_READY,
HWIF_VCMD_WORK_STATE,
HWIF_VCMD_INIT_MODE,
HWIF_VCMD_AXI_CLK_GATE_DISABLE,
HWIF_VCMD_MASTER_OUT_CLK_GATE_DISABLE,
HWIF_VCMD_CORE_CLK_GATE_DISABLE,
HWIF_VCMD_ABORT_MODE,
HWIF_VCMD_RESET_CORE,
HWIF_VCMD_RESET_ALL,
HWIF_VCMD_START_TRIGGER,
HWIF_VCMD_IRQ_INTCMD,
HWIF_VCMD_IRQ_JMPP,
HWIF_VCMD_IRQ_JMPD,
HWIF_VCMD_IRQ_RESET,
HWIF_VCMD_IRQ_ABORT,
HWIF_VCMD_IRQ_CMDERR,
HWIF_VCMD_IRQ_TIMEOUT,
HWIF_VCMD_IRQ_BUSERR,
HWIF_VCMD_IRQ_ENDCMD,
HWIF_VCMD_IRQ_INTCMD_EN,
HWIF_VCMD_IRQ_JMPP_EN,
HWIF_VCMD_IRQ_JMPD_EN,
HWIF_VCMD_IRQ_RESET_EN,
HWIF_VCMD_IRQ_ABORT_EN,
HWIF_VCMD_IRQ_CMDERR_EN,
HWIF_VCMD_IRQ_TIMEOUT_EN,
HWIF_VCMD_IRQ_BUSERR_EN,
HWIF_VCMD_IRQ_ENDCMD_EN,
HWIF_VCMD_TIMEOUT_EN,
HWIF_VCMD_TIMEOUT_CYCLES,
HWIF_VCMD_EXECUTING_CMD_ADDR,
HWIF_VCMD_EXECUTING_CMD_ADDR_MSB,
HWIF_VCMD_EXE_CMDBUF_LENGTH,
HWIF_VCMD_CMD_SWAP,
HWIF_VCMD_MAX_BURST_LEN,
HWIF_VCMD_AXI_ID_RD,
HWIF_VCMD_AXI_ID_WR,
HWIF_VCMD_RDY_CMDBUF_COUNT,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_MMU_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_L2CACHE_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_DEC400_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCD_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_MMU_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_MMU_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_L2CACHE_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_DEC400_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_GATE,
HWIF_VCMD_EXT_ABN_INT_SRC_VCE_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_MMU_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_L2CACHE_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_DEC400_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCD_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_MMU_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_MMU_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_L2CACHE_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_DEC400_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_GATE,
HWIF_VCMD_EXT_NORM_INT_SRC_VCE_GATE,
HWIF_VCMD_CMDBUF_EXECUTING_ID,

View File

@@ -0,0 +1,157 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
/* Register interface based on the document version 1.1.2 */
VCMDREG(HWIF_VCMD_HW_ID , 0 ,0xffff0000, 16, 0,RO,"HW ID"),
VCMDREG(HWIF_VCMD_HW_VERSION , 0 ,0x0000ffff, 0, 0,RO,"version of hw(1.0.0).[15:12]-major [11:8]-minor [7:0]-build"),
VCMDREG(HWIF_VCMD_HW_BUILD_DATE , 4 ,0xffffffff, 0, 0,RO,"Hw package generation date in BCD code"),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_MMU , 8 ,0x08000000, 27, 0,RO,"external abnormal interrupt source from mmu of vcd."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_L2CACHE , 8 ,0x04000000, 26, 0,RO,"external abnormal interrupt source from l2cache of vcd."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_DEC400 , 8 ,0x02000000, 25, 0,RO,"external abnormal interrupt source from dec400 of vcd."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD , 8 ,0x01000000, 24, 0,RO,"external abnormal interrupt source from vcd."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_MMU , 8 ,0x00200000, 21, 0,RO,"external abnormal interrupt source from mmu of cutree."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_MMU , 8 ,0x00100000, 20, 0,RO,"external abnormal interrupt source from mmu of vce."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_L2CACHE , 8 ,0x00080000, 19, 0,RO,"external abnormal interrupt source from l2 cache of vce."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_DEC400 , 8 ,0x00040000, 18, 0,RO,"external abnormal interrupt source from dec400 of vce."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE , 8 ,0x00020000, 17, 0,RO,"external abnormal interrupt source from cutree."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE , 8 ,0x00010000, 16, 0,RO,"external abnormal interrupt source from vce."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_MMU , 8 ,0x00000800, 11, 0,RO,"external normal interrupt source from mmu of vcd."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_L2CACHE , 8 ,0x00000400, 10, 0,RO,"external normal interrupt source from l2cache of vcd."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_DEC400 , 8 ,0x00000200, 9, 0,RO,"external normal interrupt source from dec400 of vcd."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD , 8 ,0x00000100, 8, 0,RO,"external normal interrupt source from vcd."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_MMU , 8 ,0x00000020, 5, 0,RO,"external normal interrupt source from mmu of cutree."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_MMU , 8 ,0x00000010, 4, 0,RO,"external normal interrupt source from mmu of vce."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_L2CACHE , 8 ,0x00000008, 3, 0,RO,"external normal interrupt source from l2 cache of vce."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_DEC400 , 8 ,0x00000004, 2, 0,RO,"external normal interrupt source from dec400 of vce."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE , 8 ,0x00000002, 1, 0,RO,"external normal interrupt source from cutree."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE , 8 ,0x00000001, 0, 0,RO,"external normal interrupt source from vce."),
VCMDREG(HWIF_VCMD_EXE_CMDBUF_COUNT , 12 ,0xffffffff, 0, 0,RO,"Hw increases this counter by 1 after one more command buffer has been executed"),
VCMDREG(HWIF_VCMD_EXECUTING_CMD , 16 ,0xffffffff, 0, 0,RO,"the first 32 bits of the executing cmd."),
VCMDREG(HWIF_VCMD_EXECUTING_CMD_MSB , 20 ,0xffffffff, 0, 0,RO,"the second 32 bits of the executing cmd."),
VCMDREG(HWIF_VCMD_AXI_TOTAL_AR_LEN , 24 ,0xffffffff, 0, 0,RO,"axi total ar length"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_R , 28 ,0xffffffff, 0, 0,RO,"axi total r"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_AR , 32 ,0xffffffff, 0, 0,RO,"axi total ar"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_R_LAST , 36 ,0xffffffff, 0, 0,RO,"axi total r last"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_AW_LEN , 40 ,0xffffffff, 0, 0,RO,"axi total aw length"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_W , 44 ,0xffffffff, 0, 0,RO,"axi total w"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_AW , 48 ,0xffffffff, 0, 0,RO,"axi total aw"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_W_LAST , 52 ,0xffffffff, 0, 0,RO,"axi total w last"),
VCMDREG(HWIF_VCMD_AXI_TOTAL_B , 56 ,0xffffffff, 0, 0,RO,"axi total b"),
VCMDREG(HWIF_VCMD_AXI_AR_VALID , 60 ,0x80000000, 31, 0,RO,"axi ar valid"),
VCMDREG(HWIF_VCMD_AXI_AR_READY , 60 ,0x40000000, 30, 0,RO,"axi ar ready"),
VCMDREG(HWIF_VCMD_AXI_R_VALID , 60 ,0x20000000, 29, 0,RO,"axi r valid"),
VCMDREG(HWIF_VCMD_AXI_R_READY , 60 ,0x10000000, 28, 0,RO,"axi r ready"),
VCMDREG(HWIF_VCMD_AXI_AW_VALID , 60 ,0x08000000, 27, 0,RO,"axi aw valid"),
VCMDREG(HWIF_VCMD_AXI_AW_READY , 60 ,0x04000000, 26, 0,RO,"axi aw ready"),
VCMDREG(HWIF_VCMD_AXI_W_VALID , 60 ,0x02000000, 25, 0,RO,"axi w valid"),
VCMDREG(HWIF_VCMD_AXI_W_READY , 60 ,0x01000000, 24, 0,RO,"axi w ready"),
VCMDREG(HWIF_VCMD_AXI_B_VALID , 60 ,0x00800000, 23, 0,RO,"axi b valid"),
VCMDREG(HWIF_VCMD_AXI_B_READY , 60 ,0x00400000, 22, 0,RO,"axi b ready"),
VCMDREG(HWIF_VCMD_WORK_STATE , 60 ,0x00000007, 0, 0,RO,"hw work state. 0-IDLE 1-WORK 2-STALL 3-PEND 4-ABORT"),
VCMDREG(HWIF_VCMD_INIT_MODE , 64 ,0x00000080, 7, 0,RW,"After executed a END command in init mode, VCMD will get back to normal mode"),
VCMDREG(HWIF_VCMD_AXI_CLK_GATE_DISABLE , 64 ,0x00000040, 6, 0,RW,"keep axi_clk always on when this bit is set to 1"),
VCMDREG(HWIF_VCMD_MASTER_OUT_CLK_GATE_DISABLE , 64 ,0x00000020, 5, 0,RW,"keep master_out_clk(APB/AHB master) always on when this bit is set to 1"),
VCMDREG(HWIF_VCMD_CORE_CLK_GATE_DISABLE , 64 ,0x00000010, 4, 0,RW,"keep core_clk always on when this bit is set to 1"),
VCMDREG(HWIF_VCMD_ABORT_MODE , 64 ,0x00000008, 3, 0,RW,"0:abort after finishing current cmdbuf command.1:abort immediately "),
VCMDREG(HWIF_VCMD_RESET_CORE , 64 ,0x00000004, 2, 0,RW,"sw write 1 to this bit will rset HW core logic when AXI/APB bus is idle."),
VCMDREG(HWIF_VCMD_RESET_ALL , 64 ,0x00000002, 1, 0,RW,"sw write 1 to this bit will rset HW immediately including all swregs and AXI/APB bus logic"),
VCMDREG(HWIF_VCMD_START_TRIGGER , 64 ,0x00000001, 0, 0,RW,"0:abort previou task and stop hw. 1:trigger hw to fetch and execute commands."),
VCMDREG(HWIF_VCMD_IRQ_INTCMD , 68 ,0xffff0000, 16, 0,RW,"interrupt sources which are triggered by command buffer id.. Only for version 1.0.c"),
VCMDREG(HWIF_VCMD_IRQ_JMPP , 68 ,0x00000080, 7, 0,RW,"interrupt source which is triggered by JMP command when hw goes to PEND state."),
VCMDREG(HWIF_VCMD_IRQ_JMPD , 68 ,0x00000040, 6, 0,RW,"interrupt source which is triggered by JMP command directly."),
VCMDREG(HWIF_VCMD_IRQ_RESET , 68 ,0x00000020, 5, 0,RW,"interrupt source which is triggered by hw reset or sw_vcmd_reset_all."),
VCMDREG(HWIF_VCMD_IRQ_ABORT , 68 ,0x00000010, 4, 0,RW,"interrupt source which is triggered by abort operation."),
VCMDREG(HWIF_VCMD_IRQ_CMDERR , 68 ,0x00000008, 3, 0,RW,"interrupt source which is triggered when there is illegal command in cmdbuf"),
VCMDREG(HWIF_VCMD_IRQ_TIMEOUT , 68 ,0x00000004, 2, 0,RW,"interrupt source which is triggered when vcmd timeout."),
VCMDREG(HWIF_VCMD_IRQ_BUSERR , 68 ,0x00000002, 1, 0,RW,"interrupt source which is triggered when there is bus error."),
VCMDREG(HWIF_VCMD_IRQ_ENDCMD , 68 ,0x00000001, 0, 0,RW,"interrupt source which is triggered by END command."),
VCMDREG(HWIF_VCMD_IRQ_INTCMD_EN , 72 ,0xffff0000, 16, 0,RW,"interrupt sources which are triggered by command buffer id. Only for version 1.0.c"),
VCMDREG(HWIF_VCMD_IRQ_JMPP_EN , 72 ,0x00000080, 7, 0,RW,"interrupt enable for sw_vcmd_irq_jmpp"),
VCMDREG(HWIF_VCMD_IRQ_JMPD_EN , 72 ,0x00000040, 6, 0,RW,"interrupt enable for sw_vcmd_irq_jmpd"),
VCMDREG(HWIF_VCMD_IRQ_RESET_EN , 72 ,0x00000020, 5, 0,RW,"interrupt enable for sw_vcmd_irq_reset"),
VCMDREG(HWIF_VCMD_IRQ_ABORT_EN , 72 ,0x00000010, 4, 0,RW,"interrupt enable for sw_vcmd_irq_abort"),
VCMDREG(HWIF_VCMD_IRQ_CMDERR_EN , 72 ,0x00000008, 3, 0,RW,"interrupt enable for sw_vcmd_irq_cmderr"),
VCMDREG(HWIF_VCMD_IRQ_TIMEOUT_EN , 72 ,0x00000004, 2, 0,RW,"interrupt enable for sw_vcmd_irq_timeout"),
VCMDREG(HWIF_VCMD_IRQ_BUSERR_EN , 72 ,0x00000002, 1, 0,RW,"interrupt enable for sw_vcmd_irq_buserr"),
VCMDREG(HWIF_VCMD_IRQ_ENDCMD_EN , 72 ,0x00000001, 0, 0,RW,"interrupt enable for sw_vcmd_irq_endcmd"),
VCMDREG(HWIF_VCMD_TIMEOUT_EN , 76 ,0x80000000, 31, 0,RW,"1:timeout work. 0: timeout do not work"),
VCMDREG(HWIF_VCMD_TIMEOUT_CYCLES , 76 ,0x7fffffff, 0, 0,RW,"sw_vcmd_irq_timeout will be generated when timeout counter is equal to this value."),
VCMDREG(HWIF_VCMD_EXECUTING_CMD_ADDR , 80 ,0xffffffff, 0, 0,RW,"the least 32 bits address of the executing command"),
VCMDREG(HWIF_VCMD_EXECUTING_CMD_ADDR_MSB , 84 ,0xffffffff, 0, 0,RW,"the most 32 bits address of the executing command"),
VCMDREG(HWIF_VCMD_EXE_CMDBUF_LENGTH , 88 ,0x0000ffff, 0, 0,RW,"the length of current command buffer in unit of 64bits."),
VCMDREG(HWIF_VCMD_CMD_SWAP , 92 ,0xf0000000, 28, 0,RW,"axi data swapping"),
VCMDREG(HWIF_VCMD_MAX_BURST_LEN , 92 ,0x00ff0000, 16, 0,RW,"max burst length which will be sent to axi bus"),
VCMDREG(HWIF_VCMD_AXI_ID_RD , 92 ,0x0000ff00, 8, 0,RW,"the arid which will be used on axi bus reading"),
VCMDREG(HWIF_VCMD_AXI_ID_WR , 92 ,0x000000ff, 0, 0,RW,"the awid which will be used on axi bus writing"),
VCMDREG(HWIF_VCMD_RDY_CMDBUF_COUNT , 96 ,0xffffffff, 0, 0,RW,"sw increases this counter by 1 after one more command buffer was ready."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_MMU_GATE , 100,0x10000000, 28, 0,RW,"external abnormal interrupt source from mmu of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_L2CACHE_GATE, 100,0x08000000, 27, 0,RW,"external abnormal interrupt source from l2cache of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_DEC400_GATE, 100,0x04000000, 26, 0,RW,"external abnormal interrupt source from dec400 of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCD_GATE , 100,0x01000000, 24, 0,RW,"external abnormal interrupt source from vcd gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_MMU_GATE, 100,0x00200000, 21, 0,RW,"external abnormal interrupt source from mmu of cutree gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_MMU_GATE , 100,0x00100000, 20, 0,RW,"external abnormal interrupt source from mmu of vce gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_L2CACHE_GATE, 100,0x00080000, 19, 0,RW,"external abnormal interrupt source from l2 cache of vce gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_DEC400_GATE, 100,0x00040000, 18, 0,RW,"external abnormal interrupt source from dec400 of vce gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_CUTREE_GATE , 100,0x00020000, 17, 0,RW,"external abnormal interrupt source from cutree gate."),
VCMDREG(HWIF_VCMD_EXT_ABN_INT_SRC_VCE_GATE , 100,0x00010000, 16, 0,RW,"external abnormal interrupt source from vce gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_MMU_GATE , 100,0x00000800, 11, 0,RW,"external normal interrupt source from mmu of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_L2CACHE_GATE, 100,0x00000400, 10, 0,RW,"external normal interrupt source from l2cache of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_DEC400_GATE, 100,0x00000200, 9, 0,RW,"external normal interrupt source from dec400 of vcd gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCD_GATE , 100,0x00000100, 8, 0,RW,"external normal interrupt source from vcd gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_MMU_GATE, 100,0x00000020, 5, 0,RW,"external normal interrupt source from mmu of cutree gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_MMU_GATE , 100,0x00000010, 4, 0,RW,"external normal interrupt source from mmu of vce gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_L2CACHE_GATE, 100,0x00000008, 3, 0,RW,"external normal interrupt source from l2 cache of vce gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_DEC400_GATE, 100,0x00000004, 2, 0,RW,"external normal interrupt source from dec400 of vce gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_CUTREE_GATE , 100,0x00000002, 1, 0,RW,"external normal interrupt source from cutree gate."),
VCMDREG(HWIF_VCMD_EXT_NORM_INT_SRC_VCE_GATE , 100,0x00000001, 0, 0,RW,"external normal interrupt source from vce gate."),
VCMDREG(HWIF_VCMD_CMDBUF_EXECUTING_ID , 104,0xffffffff, 0, 0,RW,"The ID of current executing command buffer.used after version 1.1.2."),

View File

@@ -0,0 +1,180 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. External compiler flags
3. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include <asm/io.h>
#include "vcmdswhwregisters.h"
/* NOTE: Don't use ',' in descriptions, because it is used as separator in csv
* parsing. */
const regVcmdField_s asicVcmdRegisterDesc[] =
{
#include "vcmdregistertable.h"
};
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/* Define this to print debug info for every register write.
#define DEBUG_PRINT_REGS */
/*******************************************************************************
Function name : vcmd_read_reg
Description : Retrive the content of a hadware register
Note: The status register will be read after every MB
so it may be needed to buffer it's content if reading
the HW register is slow.
Return type : u32
Argument : u32 offset
*******************************************************************************/
u32 vcmd_read_reg(const void *hwregs, u32 offset)
{
u32 val;
val =(u32) ioread32((void*)hwregs + offset);
PDEBUG("vcmd_read_reg 0x%02x --> %08x\n", offset, val);
return val;
}
/*******************************************************************************
Function name : vcmd_write_reg
Description : Set the content of a hadware register
Return type : void
Argument : u32 offset
Argument : u32 val
*******************************************************************************/
void vcmd_write_reg(const void *hwregs, u32 offset, u32 val)
{
iowrite32(val,(void*)hwregs + offset);
PDEBUG("vcmd_write_reg 0x%02x with value %08x\n", offset, val);
}
/*------------------------------------------------------------------------------
vcmd_write_register_value
Write a value into a defined register field (write will happens actually).
------------------------------------------------------------------------------*/
void vcmd_write_register_value(const void *hwregs,u32* reg_mirror,regVcmdName name, u32 value)
{
const regVcmdField_s *field;
u32 regVal;
field = &asicVcmdRegisterDesc[name];
#ifdef DEBUG_PRINT_REGS
PDEBUG("vcmd_write_register_value 0x%2x 0x%08x Value: %10d %s\n",
field->base, field->mask, value, field->description);
#endif
/* Check that value fits in field */
PDEBUG("field->name == name=%d\n",field->name == name);
PDEBUG("((field->mask >> field->lsb) << field->lsb) == field->mask=%d\n",((field->mask >> field->lsb) << field->lsb) == field->mask);
PDEBUG("(field->mask >> field->lsb) >= value=%d\n",(field->mask >> field->lsb) >= value);
PDEBUG("field->base < ASIC_VCMD_SWREG_AMOUNT*4=%d\n",field->base < ASIC_VCMD_SWREG_AMOUNT*4);
/* Clear previous value of field in register */
regVal = reg_mirror[field->base/4] & ~(field->mask);
/* Put new value of field in register */
reg_mirror[field->base/4] = regVal | ((value << field->lsb) & field->mask);
/* write it into HW registers */
vcmd_write_reg(hwregs, field->base,reg_mirror[field->base/4]);
}
/*------------------------------------------------------------------------------
vcmd_get_register_value
Get an unsigned value from the ASIC registers
------------------------------------------------------------------------------*/
u32 vcmd_get_register_value(const void *hwregs, u32* reg_mirror,regVcmdName name)
{
const regVcmdField_s *field;
u32 value;
field = &asicVcmdRegisterDesc[name];
PDEBUG("field->base < ASIC_VCMD_SWREG_AMOUNT * 4=%d\n",field->base < ASIC_VCMD_SWREG_AMOUNT * 4);
value = reg_mirror[field->base / 4] = vcmd_read_reg(hwregs, field->base);
value = (value & field->mask) >> field->lsb;
return value;
}

View File

@@ -0,0 +1,244 @@
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 - 2021 VERISILICON
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************
*
* The GPL License (GPL)
*
* Copyright (C) 2014 - 2021 VERISILICON
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*****************************************************************************
*
* Note: This software is released under dual MIT and GPL licenses. A
* recipient may use this file under the terms of either the MIT license or
* GPL License. If you wish to use only one license not the other, you can
* indicate your decision by deleting one of the above license notices in your
* version of this file.
*
*****************************************************************************/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. External compiler flags
3. Module defines
------------------------------------------------------------------------------*/
#ifndef VCMD_SWHWREGISTERS_H
#define VCMD_SWHWREGISTERS_H
#ifdef __cplusplus
extern "C" {
#endif
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#ifdef __FREERTOS__
#include "base_type.h"
#include "io_tools.h"
#elif defined(__linux__)
#include <linux/ioctl.h>
#include <linux/kernel.h>
#include <linux/module.h>
#endif
#ifdef __FREERTOS__
//ptr_t has been defined in base_type.h //Now the FreeRTOS mem need to support 64bit env
#elif defined(__linux__)
typedef int i32;
typedef size_t ptr_t;
#endif
#undef PDEBUG /* undef it, just in case */
#ifdef REGISTER_DEBUG
# ifdef __KERNEL__
/* This one if debugging is on, and kernel space */
# define PDEBUG(fmt, args...) printk( KERN_INFO "memalloc: " fmt, ## args)
# else
/* This one for user space */
# define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
# endif
#else
# define PDEBUG(fmt, args...) /* not debugging: nothing */
#endif
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
#ifdef HANTROVCMD_ENABLE_IP_SUPPORT
#define VCMD_REGISTER_INDEX_SW_INIT_CMD0 32
#define ASIC_VCMD_SWREG_AMOUNT 64
#else
#define ASIC_VCMD_SWREG_AMOUNT 27
#endif
#define VCMD_REGISTER_CONTROL_OFFSET 0X40
#define VCMD_REGISTER_INT_STATUS_OFFSET 0X44
#define VCMD_REGISTER_INT_CTL_OFFSET 0X48
#define VCMD_REGISTER_EXT_INT_GATE_OFFSET 0X64
/* HW Register field names */
typedef enum
{
#include "vcmdregisterenum.h"
VcmdRegisterAmount
} regVcmdName;
/* HW Register field descriptions */
typedef struct
{
u32 name; /* Register name and index */
i32 base; /* Register base address */
u32 mask; /* Bitmask for this field */
i32 lsb; /* LSB for this field [31..0] */
i32 trace; /* Enable/disable writing in swreg_params.trc */
i32 rw; /* 1=Read-only 2=Write-only 3=Read-Write */
char *description; /* Field description */
} regVcmdField_s;
/* Flags for read-only, write-only and read-write */
#define RO 1
#define WO 2
#define RW 3
#define REGBASE(reg) (asicVcmdRegisterDesc[reg].base)
/* Description field only needed for system model build. */
#ifdef TEST_DATA
#define VCMDREG(name, base, mask, lsb, trace, rw, desc) \
{name, base, mask, lsb, trace, rw, desc}
#else
#define VCMDREG(name, base, mask, lsb, trace, rw, desc) \
{name, base, mask, lsb, trace, rw, ""}
#endif
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
extern const regVcmdField_s asicVcmdRegisterDesc[];
/*------------------------------------------------------------------------------
EncAsicSetRegisterValue
Set a value into a defined register field
------------------------------------------------------------------------------*/
static inline void vcmd_set_register_mirror_value(u32 *reg_mirror, regVcmdName name, u32 value)
{
const regVcmdField_s *field;
u32 regVal;
field = &asicVcmdRegisterDesc[name];
#ifdef DEBUG_PRINT_REGS
printf("vcmd_set_register_mirror_value 0x%2x 0x%08x Value: %10d %s\n",
field->base, field->mask, value, field->description);
#endif
/* Check that value fits in field */
PDEBUG("field->name == name=%d\n",field->name == name);
PDEBUG("((field->mask >> field->lsb) << field->lsb) == field->mask=%d\n",((field->mask >> field->lsb) << field->lsb) == field->mask);
PDEBUG("(field->mask >> field->lsb) >= value=%d\n",(field->mask >> field->lsb) >= value);
PDEBUG("field->base < ASIC_VCMD_SWREG_AMOUNT * 4=%d\n",field->base < ASIC_VCMD_SWREG_AMOUNT * 4);
/* Clear previous value of field in register */
regVal = reg_mirror[field->base / 4] & ~(field->mask);
/* Put new value of field in register */
reg_mirror[field->base / 4] = regVal | ((value << field->lsb) & field->mask);
}
static inline u32 vcmd_get_register_mirror_value(u32 *reg_mirror, regVcmdName name)
{
const regVcmdField_s *field;
u32 regVal;
field = &asicVcmdRegisterDesc[name];
/* Check that value fits in field */
PDEBUG("field->name == name=%d\n",field->name == name);
PDEBUG("((field->mask >> field->lsb) << field->lsb) == field->mask=%d\n",((field->mask >> field->lsb) << field->lsb) == field->mask);
PDEBUG("field->base < ASIC_VCMD_SWREG_AMOUNT * 4=%d\n",field->base < ASIC_VCMD_SWREG_AMOUNT * 4);
regVal = reg_mirror[field->base / 4];
regVal = (regVal & field->mask) >> field->lsb;
#ifdef DEBUG_PRINT_REGS
PDEBUG("vcmd_get_register_mirror_value 0x%2x 0x%08x Value: %10d %s\n",
field->base, field->mask, regVal, field->description);
#endif
return regVal;
}
u32 vcmd_read_reg(const void *hwregs, u32 offset);
void vcmd_write_reg(const void *hwregs, u32 offset, u32 val);
void vcmd_write_register_value(const void *hwregs,u32* reg_mirror,regVcmdName name, u32 value);
u32 vcmd_get_register_value(const void *hwregs, u32* reg_mirror,regVcmdName name);
#define vcmd_set_addr_register_value(reg_base, reg_mirror, name, value) do {\
if(sizeof(ptr_t) == 8) {\
vcmd_write_register_value((reg_base), (reg_mirror),name, (u32)((ptr_t)value)); \
vcmd_write_register_value((reg_base), (reg_mirror),name##_MSB, (u32)(((ptr_t)value) >> 32));\
} else {\
vcmd_write_register_value((reg_base),(reg_mirror), name, (u32)((ptr_t)value));\
}\
}while (0)
#define VCMDGetAddrRegisterValue(reg_base, reg_mirror,name) \
((sizeof(ptr_t) == 8) ? (\
(((ptr_t)vcmd_get_register_value((reg_base),(reg_mirror), name)) | \
(((ptr_t)vcmd_get_register_value((reg_base), (reg_mirror),name##_MSB)) << 32))\
) : ((ptr_t)vcmd_get_register_value((reg_base),(reg_mirror), (name))))
#ifdef __cplusplus
}
#endif
#endif /* VCMD_SWHWREGISTERS_H */