pax_global_header00006660000000000000000000000064146555142230014521gustar00rootroot0000000000000052 comment=70c524c5475646588a0a946951305e3da180658c usbio-drivers-0~git202408092230.70c524c5/000077500000000000000000000000001465551422300171345ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/.github/000077500000000000000000000000001465551422300204745ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/.github/workflows/000077500000000000000000000000001465551422300225315ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/.github/workflows/scorecard.yml000066400000000000000000000060731465551422300252270ustar00rootroot00000000000000# This workflow uses actions that are not certified by GitHub. They are provided # by a third-party and are governed by separate terms of service, privacy # policy, and support documentation. name: Scorecard supply-chain security on: # For Branch-Protection check. Only the default branch is supported. See # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection branch_protection_rule: # To guarantee Maintained check is occasionally updated. See # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained schedule: - cron: '45 22 * * 5' push: branches: [ "main" ] # Declare default permissions as read only. permissions: read-all jobs: analysis: name: Scorecard analysis runs-on: ubuntu-latest permissions: # Needed to upload the results to code-scanning dashboard. security-events: write # Needed to publish results and get a badge (see publish_results below). id-token: write # Uncomment the permissions below if installing in a private repository. # contents: read # actions: read steps: - name: "Checkout code" uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: persist-credentials: false - name: "Run analysis" uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1 with: results_file: results.sarif results_format: sarif # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: # - you want to enable the Branch-Protection check on a *public* repository, or # - you are installing Scorecard on a *private* repository # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional. # repo_token: ${{ secrets.SCORECARD_TOKEN }} # Public repositories: # - Publish results to OpenSSF REST API for easy access by consumers # - Allows the repository to include the Scorecard badge. # - See https://github.com/ossf/scorecard-action#publishing-results. # For private repositories: # - `publish_results` will always be set to `false`, regardless # of the value entered here. publish_results: true # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" uses: actions/upload-artifact@97a0fba1372883ab732affbe8f94b823f91727db # v3.pre.node20 with: name: SARIF file path: results.sarif retention-days: 5 # Upload the results to GitHub's code scanning dashboard (optional). # Commenting out will disable upload of results to your repo's Code Scanning dashboard - name: "Upload to code-scanning" uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9 with: sarif_file: results.sarif usbio-drivers-0~git202408092230.70c524c5/CODE_OF_CONDUCT.md000066400000000000000000000124761465551422300217450ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at CommunityCodeOfConduct AT intel DOT com. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. [homepage]: https://www.contributor-covenant.org [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html [Mozilla CoC]: https://github.com/mozilla/diversity [FAQ]: https://www.contributor-covenant.org/faq usbio-drivers-0~git202408092230.70c524c5/CONTRIBUTING.md000066400000000000000000000043621465551422300213720ustar00rootroot00000000000000# Contributing ### License USBIO is licensed under the terms in [GPL-2.0 license](./GPL-2.0 license) file. By contributing to the project, you agree to the license and copyright terms therein and release your contribution under these terms. ### Sign your work Please use the sign-off line at the end of the patch. Your signature certifies that you wrote the patch or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: if you can certify the below (from [developercertificate.org](http://developercertificate.org/)): ``` Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 660 York Street, Suite 102, San Francisco, CA 94110 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ``` Then you just add a line to every git commit message: Signed-off-by: Joe Smith Use your real name (sorry, no pseudonyms or anonymous contributions.) If you set your `user.name` and `user.email` git configs, you can sign your commit automatically with `git commit -s`. usbio-drivers-0~git202408092230.70c524c5/LICENSE.txt000066400000000000000000000432541465551422300207670ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. usbio-drivers-0~git202408092230.70c524c5/Makefile000066400000000000000000000011131465551422300205700ustar00rootroot00000000000000# SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2023 Intel Corporation. obj-m += usbio.o usbio-y := drivers/mfd/usbio.o obj-m += gpio-usbio.o gpio-usbio-y := drivers/gpio/gpio-usbio.o obj-m += i2c-usbio.o i2c-usbio-y := drivers/i2c/busses/i2c-usbio.o KERNELRELEASE ?= $(shell uname -r) KERNEL_SRC ?= /lib/modules/$(KERNELRELEASE)/build PWD := $(shell pwd) ccflags-y += -I$(src)/include/ all: $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules modules_install: $(MAKE) INSTALL_MOD_DIR=/updates -C $(KERNEL_SRC) M=$(PWD) modules_install clean: $(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean usbio-drivers-0~git202408092230.70c524c5/README.md000066400000000000000000000053711465551422300204210ustar00rootroot00000000000000# usbio driver stack This repository supports USBIO Extension drivers on Intel Alder Lake, Raptor Lake, Meteor Lake and Lunar Lake platforms. ## Build instructions: Three ways are available: 1. build with kernel source tree 2. build out of kernel source tree 3. build with dkms ### build with kernel source tree * Tested with kernel 6.8 * Check out kernel * Copy repo content to kernel source * Modify related Kconfig and Makefile * Add to drivers/mfd/Kconfig ``` config MFD_USBIO tristate "Intel USBIO extension support" select MFD_CORE depends on USB help This adds support for Intel USBIO (I2C/SPI/GPIO) Extension. Additional drivers such as GPIO_USBIO, I2C_USBIO, etc. must be enabled in order to use the functionality of the device. ``` * add to drivers/mfd/Makefile ``` obj-$(CONFIG_MFD_USBIO) += usbio.o ``` * Add to drivers/gpio/Kconfig ``` config GPIO_USBIO tristate "INTEL USBIO GPIO Extension support" depends on MFD_USBIO help Select this option to enable GPIO driver for the INTEL USBIO GPIO Extension. This driver can also be built as a module. If so, the module will be called gpio-usbio. ``` * Add to drivers/gpio/Makefile ``` obj-$(CONFIG_GPIO_USBIO) += gpio-usbio.o ``` * Add to drivers/i2c/busses/Kconfig ``` config I2C_USBIO tristate "INTEL USBIO I2C Extension support" depends on MFD_USBIO help If you say yes to this option, I2C functionality support of INTEL USBIO I2C Extension will be included. This driver can also be built as a module. If so, the module will be called i2c-usbio. ``` * Add to drivers/i2c/busses/Makefile ``` obj-$(CONFIG_I2C_USBIO) += i2c-usbio.o ``` * Add to drivers/spi/Kconfig ``` config SPI_LJCA tristate "INTEL La Jolla Cove Adapter SPI support" depends on MFD_LJCA help Select this option to enable SPI driver for the INTEL La Jolla Cove Adapter (LJCA) board. This driver can also be built as a module. If so, the module will be called spi-ljca. ``` * Add to drivers/spi/Makefile ``` obj-$(CONFIG_SPI_LJCA) += spi-ljca.o ``` * Enable the following settings in .config ``` CONFIG_MFD_USBIO=m CONFIG_GPIO_USBIO=m CONFIG_I2C_USBIO=m CONFIG_SPI_LJCA=m ``` ### build out of kernel source tree * Requires 5.13 or later kernel header installed on compiling machine * To compile: ``` $cd linux-usbio $make -j`nproc` ``` * To install and use modules ``` $sudo make modules_install $sudo depmod -a ``` ### Build with dkms a dkms.conf file is also provided as an example for building with dkms which can be used by ```dkms``` ```add```, ```build``` and ```install```. ## Deployment: TBD usbio-drivers-0~git202408092230.70c524c5/SECURITY.md000066400000000000000000000006251465551422300207300ustar00rootroot00000000000000# Security Policy Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. ## Reporting a Vulnerability Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). usbio-drivers-0~git202408092230.70c524c5/dkms.conf000066400000000000000000000006421465551422300207430ustar00rootroot00000000000000PACKAGE_NAME="usbio-drivers" PACKAGE_VERSION="0.0.1" MAKE="make KERNELRELEASE=$kernelver KERNEL_SRC=$kernel_source_dir" CLEAN="make KERNELRELEASE=$kernelver KERNEL_SRC=$kernel_source_dir clean" BUILT_MODULE_NAME[0]="usbio" DEST_MODULE_LOCATION[0]="/updates" BUILT_MODULE_NAME[1]="gpio-usbio" DEST_MODULE_LOCATION[1]="/updates" BUILT_MODULE_NAME[2]="i2c-usbio" DEST_MODULE_LOCATION[2]="/updates" AUTOINSTALL="yes" usbio-drivers-0~git202408092230.70c524c5/drivers/000077500000000000000000000000001465551422300206125ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/drivers/gpio/000077500000000000000000000000001465551422300215505ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/drivers/gpio/gpio-usbio.c000066400000000000000000000323741465551422300240020ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-only /* * * Copyright (c) 2023, Intel Corporation. */ #include #include #include #include #include #include #include #include #include #include #include #include #define GPIO_PAYLOAD_LEN(packet, pin) (sizeof(*packet)) /* GPIO commands */ #define GPIO_DEINIT 0 #define GPIO_INIT 1 #define GPIO_READ 2 #define GPIO_WRITE 3 /* Deprecated */ #define GPIO_INT_EVENT 4 #define GPIO_INT_MASK 5 #define GPIO_INT_UNMASK 6 /* PinMode */ #define GPIO_CONF_DISABLED 0 #define GPIO_CONF_INPUT 1 #define GPIO_CONF_OUTPUT 2 /* PinConfig */ #define GPIO_CONF_DEFAULT (0<<2) #define GPIO_CONF_PULLUP (1<<2) #define GPIO_CONF_PULLDOWN (2<<2) #define GPIO_CONF_NONE (3<<2) /* Deprecated */ #define GPIO_CONF_INTERRUPT BIT(6) #define GPIO_INT_TYPE BIT(7) #define GPIO_CONF_EDGE (1 << 7) #define GPIO_CONF_LEVEL (0 << 7) #define IRQ_SUPPORT 0 struct gpio_cfg_packet { u8 bankid; u8 config; u8 pincount; u8 pins; } __packed; struct gpio_rw_packet { u8 bankid; u8 pincount; u8 pins; u32 value; } __packed; struct usbio_gpio_dev { struct platform_device *pdev; struct gpio_chip gc; struct usbio_gpio_info *ctr_info; DECLARE_BITMAP(unmasked_irqs, MAX_GPIO_NUM); DECLARE_BITMAP(enabled_irqs, MAX_GPIO_NUM); DECLARE_BITMAP(reenable_irqs, MAX_GPIO_NUM); u8 *connect_mode; struct mutex irq_lock; struct work_struct work; struct mutex trans_lock; u8 obuf[256]; u8 ibuf[256]; }; static bool usbio_gpio_valid(struct usbio_gpio_dev *usbio_gpio, int gpio_id) { if (gpio_id >= usbio_gpio->ctr_info->num || !test_bit(gpio_id, usbio_gpio->ctr_info->valid_pin_map)) { dev_err(&usbio_gpio->pdev->dev, "invalid gpio_id:%d\n", gpio_id); return false; } return true; } static int gpio_config(struct usbio_gpio_dev *usbio_gpio, u8 gpio_id, u8 config) { struct gpio_cfg_packet *packet = (struct gpio_cfg_packet *)usbio_gpio->obuf; int ret; if (!usbio_gpio_valid(usbio_gpio, gpio_id)) return -EINVAL; mutex_lock(&usbio_gpio->trans_lock); packet->bankid = gpio_id / GPIO_PER_BANK; packet->config = config | usbio_gpio->connect_mode[gpio_id]; packet->pincount = 1; packet->pins = gpio_id % GPIO_PER_BANK; ret = usbio_transfer(usbio_gpio->pdev, GPIO_INIT, packet, GPIO_PAYLOAD_LEN(packet, packet->pins), NULL, NULL); mutex_unlock(&usbio_gpio->trans_lock); return ret; } static int usbio_gpio_read(struct usbio_gpio_dev *usbio_gpio, u8 gpio_id) { struct gpio_rw_packet *packet = (struct gpio_rw_packet *)usbio_gpio->obuf; struct gpio_rw_packet *ack_packet; int ret; int ibuf_len; if (!usbio_gpio_valid(usbio_gpio, gpio_id)) return -EINVAL; mutex_lock(&usbio_gpio->trans_lock); packet->bankid = gpio_id / GPIO_PER_BANK; packet->pincount = 1; packet->pins = gpio_id % GPIO_PER_BANK; ret = usbio_transfer(usbio_gpio->pdev, GPIO_READ, packet, GPIO_PAYLOAD_LEN(packet, packet->pins), usbio_gpio->ibuf, &ibuf_len); ack_packet = (struct gpio_rw_packet *)usbio_gpio->ibuf; if (ret || !ibuf_len || ack_packet->pins != packet->pins) { dev_err(&usbio_gpio->pdev->dev, "%s failed gpio_id:%d ret %d %d", __func__, gpio_id, ret, ack_packet->pins); mutex_unlock(&usbio_gpio->trans_lock); return -EIO; } mutex_unlock(&usbio_gpio->trans_lock); return (ack_packet->value & (1 << ack_packet->pins) ? 1 : 0); } static int usbio_gpio_write(struct usbio_gpio_dev *usbio_gpio, u8 gpio_id, int value) { struct gpio_rw_packet *packet = (struct gpio_rw_packet *)usbio_gpio->obuf; int ret; mutex_lock(&usbio_gpio->trans_lock); packet->bankid = gpio_id / GPIO_PER_BANK; packet->pincount = 1; packet->pins = gpio_id % GPIO_PER_BANK; packet->value = value << packet->pins; ret = usbio_transfer(usbio_gpio->pdev, GPIO_WRITE, packet, GPIO_PAYLOAD_LEN(packet, packet->pins), NULL, NULL); if (ret) { dev_err(&usbio_gpio->pdev->dev, "%s failed gpio_id:%d ret %d\n", __func__, gpio_id, ret); mutex_unlock(&usbio_gpio->trans_lock); return -EIO; } mutex_unlock(&usbio_gpio->trans_lock); return ret; } static int usbio_gpio_get_value(struct gpio_chip *chip, unsigned int offset) { struct usbio_gpio_dev *usbio_gpio = gpiochip_get_data(chip); return usbio_gpio_read(usbio_gpio, offset); } static void usbio_gpio_set_value(struct gpio_chip *chip, unsigned int offset, int val) { struct usbio_gpio_dev *usbio_gpio = gpiochip_get_data(chip); int ret; ret = usbio_gpio_write(usbio_gpio, offset, val); if (ret) dev_err(chip->parent, "%s offset:%d val:%d set value failed %d\n", __func__, offset, val, ret); } static int usbio_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) { struct usbio_gpio_dev *usbio_gpio = gpiochip_get_data(chip); u8 config = GPIO_CONF_INPUT; return gpio_config(usbio_gpio, offset, config); } static int usbio_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, int val) { struct usbio_gpio_dev *usbio_gpio = gpiochip_get_data(chip); u8 config = GPIO_CONF_OUTPUT; int ret; ret = gpio_config(usbio_gpio, offset, config); if (ret) return ret; usbio_gpio_set_value(chip, offset, val); return 0; } static int usbio_gpio_set_config(struct gpio_chip *chip, unsigned int offset, unsigned long config) { struct usbio_gpio_dev *usbio_gpio = gpiochip_get_data(chip); if (!usbio_gpio_valid(usbio_gpio, offset)) return -EINVAL; usbio_gpio->connect_mode[offset] = 0; switch (pinconf_to_config_param(config)) { case PIN_CONFIG_BIAS_PULL_UP: usbio_gpio->connect_mode[offset] |= GPIO_CONF_PULLUP; break; case PIN_CONFIG_BIAS_PULL_DOWN: usbio_gpio->connect_mode[offset] |= GPIO_CONF_PULLDOWN; break; case PIN_CONFIG_DRIVE_PUSH_PULL: case PIN_CONFIG_PERSIST_STATE: usbio_gpio->connect_mode[offset] |= GPIO_CONF_NONE; break; default: usbio_gpio->connect_mode[offset] |= GPIO_CONF_DEFAULT; break; } return 0; } #if IRQ_SUPPORT static int usbio_enable_irq(struct usbio_gpio_dev *usbio_gpio, int gpio_id, bool enable) { struct gpio_packet *packet = (struct gpio_packet *)usbio_gpio->obuf; int ret; mutex_lock(&usbio_gpio->trans_lock); packet->num = 1; packet->item[0].index = gpio_id; packet->item[0].value = 0; dev_dbg(usbio_gpio->gc.parent, "%s %d", __func__, gpio_id); ret = usbio_transfer(usbio_gpio->pdev, enable == true ? GPIO_INT_UNMASK : GPIO_INT_MASK, packet, GPIO_PAYLOAD_LEN(packet, packet->pins), NULL, NULL); mutex_unlock(&usbio_gpio->trans_lock); return ret; } static void usbio_gpio_async(struct work_struct *work) { struct usbio_gpio_dev *usbio_gpio = container_of(work, struct usbio_gpio_dev, work); int gpio_id; int unmasked; for_each_set_bit (gpio_id, usbio_gpio->reenable_irqs, usbio_gpio->gc.ngpio) { clear_bit(gpio_id, usbio_gpio->reenable_irqs); unmasked = test_bit(gpio_id, usbio_gpio->unmasked_irqs); if (unmasked) usbio_enable_irq(usbio_gpio, gpio_id, true); } } void usbio_gpio_event_cb(struct platform_device *pdev, u8 cmd, const void *evt_data, int len) { const struct gpio_packet *packet = evt_data; struct usbio_gpio_dev *usbio_gpio = platform_get_drvdata(pdev); int i; int irq; if (cmd != GPIO_INT_EVENT) return; for (i = 0; i < packet->num; i++) { irq = irq_find_mapping(usbio_gpio->gc.irq.domain, packet->item[i].index); if (!irq) { dev_err(usbio_gpio->gc.parent, "gpio_id %d not mapped to IRQ\n", packet->item[i].index); return; } generic_handle_irq(irq); set_bit(packet->item[i].index, usbio_gpio->reenable_irqs); dev_dbg(usbio_gpio->gc.parent, "%s got one interrupt %d %d %d\n", __func__, i, packet->item[i].index, packet->item[i].value); } schedule_work(&usbio_gpio->work); } static void usbio_irq_unmask(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); struct usbio_gpio_dev *usbio_gpio = gpiochip_get_data(gc); int gpio_id = irqd_to_hwirq(irqd); dev_dbg(usbio_gpio->gc.parent, "%s %d", __func__, gpio_id); set_bit(gpio_id, usbio_gpio->unmasked_irqs); } static void usbio_irq_mask(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); struct usbio_gpio_dev *usbio_gpio = gpiochip_get_data(gc); int gpio_id = irqd_to_hwirq(irqd); dev_dbg(usbio_gpio->gc.parent, "%s %d", __func__, gpio_id); clear_bit(gpio_id, usbio_gpio->unmasked_irqs); } static int usbio_irq_set_type(struct irq_data *irqd, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); struct usbio_gpio_dev *usbio_gpio = gpiochip_get_data(gc); int gpio_id = irqd_to_hwirq(irqd); usbio_gpio->connect_mode[gpio_id] = GPIO_CONF_INTERRUPT; switch (type) { case IRQ_TYPE_LEVEL_HIGH: usbio_gpio->connect_mode[gpio_id] |= GPIO_CONF_LEVEL | GPIO_CONF_PULLUP; break; case IRQ_TYPE_LEVEL_LOW: usbio_gpio->connect_mode[gpio_id] |= GPIO_CONF_LEVEL | GPIO_CONF_PULLDOWN; break; case IRQ_TYPE_EDGE_BOTH: break; case IRQ_TYPE_EDGE_RISING: usbio_gpio->connect_mode[gpio_id] |= GPIO_CONF_EDGE | GPIO_CONF_PULLUP; break; case IRQ_TYPE_EDGE_FALLING: usbio_gpio->connect_mode[gpio_id] |= GPIO_CONF_EDGE | GPIO_CONF_PULLDOWN; break; default: return -EINVAL; } dev_dbg(usbio_gpio->gc.parent, "%s %d %x\n", __func__, gpio_id, usbio_gpio->connect_mode[gpio_id]); return 0; } static void usbio_irq_bus_lock(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); struct usbio_gpio_dev *usbio_gpio = gpiochip_get_data(gc); mutex_lock(&usbio_gpio->irq_lock); } static void usbio_irq_bus_unlock(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); struct usbio_gpio_dev *usbio_gpio = gpiochip_get_data(gc); int gpio_id = irqd_to_hwirq(irqd); int enabled; int unmasked; enabled = test_bit(gpio_id, usbio_gpio->enabled_irqs); unmasked = test_bit(gpio_id, usbio_gpio->unmasked_irqs); dev_dbg(usbio_gpio->gc.parent, "%s %d %d %d\n", __func__, gpio_id, enabled, unmasked); if (enabled != unmasked) { if (unmasked) { gpio_config(usbio_gpio, gpio_id, 0); usbio_enable_irq(usbio_gpio, gpio_id, true); set_bit(gpio_id, usbio_gpio->enabled_irqs); } else { usbio_enable_irq(usbio_gpio, gpio_id, false); clear_bit(gpio_id, usbio_gpio->enabled_irqs); } } mutex_unlock(&usbio_gpio->irq_lock); } static unsigned int usbio_irq_startup(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); return gpiochip_lock_as_irq(gc, irqd_to_hwirq(irqd)); } static void usbio_irq_shutdown(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); gpiochip_unlock_as_irq(gc, irqd_to_hwirq(irqd)); } static struct irq_chip usbio_gpio_irqchip = { .name = "ljca-irq", .irq_mask = usbio_irq_mask, .irq_unmask = usbio_irq_unmask, .irq_set_type = usbio_irq_set_type, .irq_bus_lock = usbio_irq_bus_lock, .irq_bus_sync_unlock = usbio_irq_bus_unlock, .irq_startup = usbio_irq_startup, .irq_shutdown = usbio_irq_shutdown, }; #endif static int usbio_gpio_probe(struct platform_device *pdev) { struct usbio_gpio_dev *usbio_gpio; struct usbio_platform_data *pdata = dev_get_platdata(&pdev->dev); #if IRQ_SUPPORT struct gpio_irq_chip *girq = NULL; #endif usbio_gpio = devm_kzalloc(&pdev->dev, sizeof(*usbio_gpio), GFP_KERNEL); if (!usbio_gpio) return -ENOMEM; usbio_gpio->ctr_info = &pdata->gpio_info; usbio_gpio->connect_mode = devm_kcalloc(&pdev->dev, usbio_gpio->ctr_info->num, sizeof(*usbio_gpio->connect_mode), GFP_KERNEL); if (!usbio_gpio->connect_mode) return -ENOMEM; mutex_init(&usbio_gpio->irq_lock); mutex_init(&usbio_gpio->trans_lock); usbio_gpio->pdev = pdev; usbio_gpio->gc.direction_input = usbio_gpio_direction_input; usbio_gpio->gc.direction_output = usbio_gpio_direction_output; usbio_gpio->gc.get = usbio_gpio_get_value; usbio_gpio->gc.set = usbio_gpio_set_value; usbio_gpio->gc.set_config = usbio_gpio_set_config; usbio_gpio->gc.can_sleep = true; usbio_gpio->gc.parent = &pdev->dev; usbio_gpio->gc.base = -1; usbio_gpio->gc.ngpio = usbio_gpio->ctr_info->num; usbio_gpio->gc.label = ACPI_COMPANION(&pdev->dev) ? acpi_dev_name(ACPI_COMPANION(&pdev->dev)) : "usbio-gpio"; usbio_gpio->gc.owner = THIS_MODULE; platform_set_drvdata(pdev, usbio_gpio); #if IRQ_SUPPORT usbio_register_event_cb(pdev, usbio_gpio_event_cb); girq = &usbio_gpio->gc.irq; girq->chip = &usbio_gpio_irqchip; girq->parent_handler = NULL; girq->num_parents = 0; girq->parents = NULL; girq->default_type = IRQ_TYPE_NONE; girq->handler = handle_simple_irq; INIT_WORK(&usbio_gpio->work, usbio_gpio_async); #endif return devm_gpiochip_add_data(&pdev->dev, &usbio_gpio->gc, usbio_gpio); } #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0) static int usbio_gpio_remove(struct platform_device *pdev) #else static void usbio_gpio_remove(struct platform_device *pdev) #endif { #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0) return 0; #endif } static struct platform_driver usbio_gpio_driver = { .driver.name = "usbio-gpio", .probe = usbio_gpio_probe, .remove = usbio_gpio_remove, }; module_platform_driver(usbio_gpio_driver); MODULE_AUTHOR("Zhang Lixu "); MODULE_AUTHOR("Israel Cepeda "); MODULE_AUTHOR("Lifu Wang "); MODULE_DESCRIPTION("Intel USBIO-GPIO driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:usb-gpio"); usbio-drivers-0~git202408092230.70c524c5/drivers/i2c/000077500000000000000000000000001465551422300212675ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/drivers/i2c/busses/000077500000000000000000000000001465551422300225735ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/drivers/i2c/busses/i2c-usbio.c000066400000000000000000000244351465551422300245430ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-only /* * * Copyright (c) 2023, Intel Corporation. */ #include #include #include #include #include #include /* I2C commands */ enum i2c_cmd { I2C_DEINIT, I2C_INIT, I2C_READ, I2C_WRITE, I2C_XFER }; enum i2c_address_mode { I2C_ADDRESS_MODE_7BIT, I2C_ADDRESS_MODE_10BIT, }; /* Speeds */ #define I2C_400KHZ 400000 /* i2c init flags */ #define I2C_INIT_FLAG_MODE_MASK (0x1 << 0) #define I2C_INIT_FLAG_MODE_POLLING (0x0 << 0) #define I2C_INIT_FLAG_MODE_INTERRUPT (0x1 << 0) #define I2C_FLAG_ADDR_16BIT (0x1 << 0) #define I2C_INIT_FLAG_FREQ_MASK (0x3 << 1) #define I2C_FLAG_FREQ_100K (0x0 << 1) #define I2C_FLAG_FREQ_400K (0x1 << 1) #define I2C_FLAG_FREQ_1M (0x2 << 1) /* I2C init commands: Init/Deinit */ struct i2c_init_packet { u8 id; u16 config; u32 speed; } __packed; /* I2C RW commands: Read/Write */ struct i2c_rw_packet { u8 id; u16 config; u16 len; u8 data[]; } __packed; /* I2C Transfer */ struct i2c_xfer { u8 id; u16 config; u16 wlen; u16 rlen; u8 data[]; } __packed; #define USBIO_I2C_MAX_XFER_SIZE 256 #define USBIO_I2C_BUF_SIZE \ (USBIO_I2C_MAX_XFER_SIZE + sizeof(struct i2c_rw_packet)) struct usbio_i2c_dev { struct platform_device *pdev; struct usbio_i2c_info *ctr_info; struct i2c_adapter adap; u8 obuf[USBIO_I2C_BUF_SIZE]; u8 ibuf[USBIO_I2C_BUF_SIZE]; }; static u16 usbio_i2c_format_slave_addr(u8 slave_addr, enum i2c_address_mode mode) { if (mode == I2C_ADDRESS_MODE_7BIT) return (u16)slave_addr; return 0xFF; } static int usbio_i2c_start(struct usbio_i2c_dev *usbio_i2c, u8 slave_addr) { struct i2c_init_packet *w_packet = (struct i2c_init_packet *)usbio_i2c->obuf; int ret; memset(w_packet, 0, sizeof(*w_packet)); w_packet->id = usbio_i2c->ctr_info->id; /* TODO: Add support for 10Bit address and multiple speeds */ w_packet->config = usbio_i2c_format_slave_addr(slave_addr, I2C_ADDRESS_MODE_7BIT); w_packet->speed = I2C_400KHZ; ret = usbio_transfer_noack(usbio_i2c->pdev, I2C_INIT, w_packet, sizeof(*w_packet)); if (ret) { dev_err(&usbio_i2c->adap.dev, "i2c start failed ret:%d\n", ret); return -EIO; } return 0; } static int usbio_i2c_stop(struct usbio_i2c_dev *usbio_i2c, u8 slave_addr) { struct i2c_init_packet *w_packet = (struct i2c_init_packet *)usbio_i2c->obuf; int ret; memset(w_packet, 0, sizeof(*w_packet)); w_packet->id = usbio_i2c->ctr_info->id; /* TODO: Add support for 10Bit address */ w_packet->config = usbio_i2c_format_slave_addr(slave_addr, I2C_ADDRESS_MODE_7BIT); ret = usbio_transfer_noack(usbio_i2c->pdev, I2C_DEINIT, w_packet, sizeof(*w_packet)); if (ret) { dev_err(&usbio_i2c->adap.dev, "i2c stop failed ret:%d\n", ret); return -EIO; } return 0; } static int usbio_i2c_pure_read(struct usbio_i2c_dev *usbio_i2c, u8 slave_addr, u8 *data, int len) { struct i2c_rw_packet *w_packet = (struct i2c_rw_packet *)usbio_i2c->obuf; struct i2c_rw_packet *r_packet = (struct i2c_rw_packet *)usbio_i2c->ibuf; int ibuf_len; int ret; if (len > USBIO_I2C_MAX_XFER_SIZE) return -EINVAL; memset(w_packet, 0, sizeof(*w_packet)); w_packet->id = usbio_i2c->ctr_info->id; /* TODO: Add support for 10Bit address */ w_packet->config = usbio_i2c_format_slave_addr(slave_addr, I2C_ADDRESS_MODE_7BIT); w_packet->len = cpu_to_le16(len); ret = usbio_transfer(usbio_i2c->pdev, I2C_READ, w_packet, sizeof(*w_packet) + 1, r_packet, &ibuf_len); if (ret) { dev_err(&usbio_i2c->adap.dev, "I2C_READ failed ret:%d\n", ret); return ret; } if (ibuf_len < sizeof(*r_packet)) return -EIO; if ((s16)le16_to_cpu(r_packet->len) != len || r_packet->id != w_packet->id) { dev_err(&usbio_i2c->adap.dev, "i2c raw read failed len:%d id:%d %d\n", (s16)le16_to_cpu(r_packet->len), r_packet->id, w_packet->id); return -EIO; } memcpy(data, r_packet->data, len); return 0; } static int usbio_i2c_read(struct usbio_i2c_dev *usbio_i2c, u8 slave_addr, u8 *data, u8 len) { int ret; ret = usbio_i2c_start(usbio_i2c, slave_addr); if (ret) return ret; ret = usbio_i2c_pure_read(usbio_i2c, slave_addr, data, len); if (ret) { dev_err(&usbio_i2c->adap.dev, "i2c raw read failed ret:%d\n", ret); return ret; } return usbio_i2c_stop(usbio_i2c, slave_addr); } static int usbio_i2c_pure_write(struct usbio_i2c_dev *usbio_i2c, u8 slave_addr, u8 *data, u8 len) { struct i2c_rw_packet *w_packet = (struct i2c_rw_packet *)usbio_i2c->obuf; struct i2c_rw_packet *r_packet = (struct i2c_rw_packet *)usbio_i2c->ibuf; int ret; int ibuf_len; if (len > USBIO_I2C_MAX_XFER_SIZE) return -EINVAL; memset(w_packet, 0, sizeof(*w_packet)); w_packet->id = usbio_i2c->ctr_info->id; /* TODO: Add support for 10Bit address */ w_packet->config = usbio_i2c_format_slave_addr(slave_addr, I2C_ADDRESS_MODE_7BIT); w_packet->len = cpu_to_le16(len); memcpy(w_packet->data, data, len); ret = usbio_transfer(usbio_i2c->pdev, I2C_WRITE, w_packet, sizeof(*w_packet) + w_packet->len, r_packet, &ibuf_len); if (ret || ibuf_len < sizeof(*r_packet)) return -EIO; if ((s16)le16_to_cpu(r_packet->len) != len || r_packet->id != w_packet->id) { dev_err(&usbio_i2c->adap.dev, "i2c write failed len:%d id:%d/%d\n", (s16)le16_to_cpu(r_packet->len), r_packet->id, w_packet->id); return -EIO; } return 0; } static int usbio_i2c_write(struct usbio_i2c_dev *usbio_i2c, u8 slave_addr, u8 *data, u8 len) { int ret; if (!data) return -EINVAL; ret = usbio_i2c_start(usbio_i2c, slave_addr); if (ret) return ret; ret = usbio_i2c_pure_write(usbio_i2c, slave_addr, data, len); if (ret) return ret; return usbio_i2c_stop(usbio_i2c, slave_addr); } static int usbio_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msg, int num) { struct usbio_i2c_dev *usbio_i2c; struct i2c_msg *cur_msg; int i, ret; usbio_i2c = i2c_get_adapdata(adapter); if (!usbio_i2c) return -EINVAL; for (i = 0; i < num; i++) { cur_msg = &msg[i]; dev_dbg(&adapter->dev, "i:%d msg:(%d %d)\n", i, cur_msg->flags, cur_msg->len); if (cur_msg->flags & I2C_M_RD) ret = usbio_i2c_read(usbio_i2c, cur_msg->addr, cur_msg->buf, cur_msg->len); else ret = usbio_i2c_write(usbio_i2c, cur_msg->addr, cur_msg->buf, cur_msg->len); if (ret) return ret; } return num; } static u32 usbio_i2c_func(struct i2c_adapter *adap) { return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; } static const struct i2c_adapter_quirks usbio_i2c_quirks = { .max_read_len = USBIO_I2C_MAX_XFER_SIZE, .max_write_len = USBIO_I2C_MAX_XFER_SIZE, }; static const struct i2c_algorithm usbio_i2c_algo = { .master_xfer = usbio_i2c_xfer, .functionality = usbio_i2c_func, }; struct match_ids_walk_data { struct acpi_device *adev; const char *hid1; const char *uid2; const char *uid2_v2; }; static int match_device_ids(struct acpi_device *adev, void *data) { struct match_ids_walk_data *wd = data; if (acpi_dev_hid_uid_match(adev, wd->hid1, wd->uid2) || acpi_dev_hid_uid_match(adev, wd->hid1, wd->uid2_v2)) { wd->adev = adev; return 1; } return 0; } static void try_bind_acpi(struct platform_device *pdev, struct usbio_i2c_dev *usbio_i2c) { struct acpi_device *parent; struct acpi_device *cur = ACPI_COMPANION(&pdev->dev); const char *hid1; const char *uid1; char uid2[2] = { 0 }; char uid2_v2[5] = { 0 }; struct match_ids_walk_data wd = { 0 }; if (!cur) return; hid1 = acpi_device_hid(cur); uid1 = acpi_device_uid(cur); snprintf(uid2, sizeof(uid2), "%d", usbio_i2c->ctr_info->id); snprintf(uid2_v2, sizeof(uid2_v2), "VIC%d", usbio_i2c->ctr_info->id); /* * If the pdev is bound to the right acpi device, just forward it to the * adapter. Otherwise, we find that of current adapter manually. */ if (!uid1 || !strcmp(uid1, uid2) || !strcmp(uid1, uid2_v2)) { ACPI_COMPANION_SET(&usbio_i2c->adap.dev, cur); return; } dev_info(&pdev->dev, "hid %s uid %s new uid%s\n", hid1, uid1, uid2); parent = ACPI_COMPANION(pdev->dev.parent); if (!parent) return; wd.hid1 = hid1; wd.uid2 = uid2; wd.uid2_v2 = uid2_v2; #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) acpi_dev_for_each_child(parent, match_device_ids, &wd); ACPI_COMPANION_SET(&usbio_i2c->adap.dev, wd.adev); #else list_for_each_entry(wd.adev, &parent->children, node) { if (match_device_ids(wd.adev, &wd)) { ACPI_COMPANION_SET(&usbio_i2c->adap.dev, wd.adev); return; } } #endif } static int usbio_i2c_probe(struct platform_device *pdev) { struct usbio_i2c_dev *usbio_i2c; struct usbio_platform_data *pdata = dev_get_platdata(&pdev->dev); int ret; usbio_i2c = devm_kzalloc(&pdev->dev, sizeof(*usbio_i2c), GFP_KERNEL); if (!usbio_i2c) return -ENOMEM; usbio_i2c->pdev = pdev; usbio_i2c->ctr_info = &pdata->i2c_info; usbio_i2c->adap.owner = THIS_MODULE; usbio_i2c->adap.class = I2C_CLASS_HWMON; usbio_i2c->adap.algo = &usbio_i2c_algo; usbio_i2c->adap.dev.parent = &pdev->dev; try_bind_acpi(pdev, usbio_i2c); usbio_i2c->adap.dev.of_node = pdev->dev.of_node; i2c_set_adapdata(&usbio_i2c->adap, usbio_i2c); snprintf(usbio_i2c->adap.name, sizeof(usbio_i2c->adap.name), "%s-%s-%d", "usbio-i2c", dev_name(pdev->dev.parent), usbio_i2c->ctr_info->id); platform_set_drvdata(pdev, usbio_i2c); ret = i2c_add_adapter(&usbio_i2c->adap); if (ret) return ret; #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) if (has_acpi_companion(&usbio_i2c->adap.dev)) acpi_dev_clear_dependencies(ACPI_COMPANION(&usbio_i2c->adap.dev)); #endif return 0; } #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0) static int usbio_i2c_remove(struct platform_device *pdev) #else static void usbio_i2c_remove(struct platform_device *pdev) #endif { struct usbio_i2c_dev *usbio_i2c = platform_get_drvdata(pdev); i2c_del_adapter(&usbio_i2c->adap); #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0) return 0; #endif } static struct platform_driver usbio_i2c_driver = { .driver.name = "usbio-i2c", .probe = usbio_i2c_probe, .remove = usbio_i2c_remove, }; module_platform_driver(usbio_i2c_driver); MODULE_AUTHOR("Ye Xiang "); MODULE_AUTHOR("Zhang Lixu "); MODULE_AUTHOR("Israel Cepeda "); MODULE_AUTHOR("Lifu Wang "); MODULE_DESCRIPTION("Intel USBIO-I2C driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:usb-i2c"); usbio-drivers-0~git202408092230.70c524c5/drivers/mfd/000077500000000000000000000000001465551422300213605ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/drivers/mfd/bridge.h000066400000000000000000000060441465551422300227710ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-only #ifndef __USB_IO_BRIDGE_H #define __USB_IO_BRIDGE_H /* stub types */ enum stub_type { CTRL_STUB = 1, DIAG_STUB, GPIO_STUB, I2C_STUB, SPI_STUB, }; /* CTRL stub commands */ enum usbio_mng_cmd { CTRL_PROT_VERSION = 0, CTRL_FW_VERSION, CTRL_RESET_NOTIFY, CTRL_RESET, CTRL_POWER_STATE_CHANGE, CTRL_SET_DFU_MODE, CTRL_ENUM_GPIO = 0x10, CTRL_ENUM_I2C, CTRL_ENUM_SPI, }; /* DIAG commands */ enum diag_cmd { DIAG_GET_STATE = 1, DIAG_GET_STATISTIC, DIAG_SET_TRACE_LEVEL, DIAG_SET_ECHO_MODE, DIAG_GET_FW_LOG, DIAG_GET_FW_COREDUMP, DIAG_TRIGGER_WDT, DIAG_TRIGGER_FAULT, DIAG_FEED_WDT, DIAG_GET_SECURE_STATE, }; /* command Flags */ #define ACK_FLAG BIT(0) #define RESP_FLAG BIT(1) #define CMPL_FLAG BIT(2) #define ERR_FLAG BIT(3) /* Control Transfer Message */ struct usbio_msg { u8 type; u8 cmd; u8 flags; u8 len; u8 data[]; } __packed; /* Bulk Transfer Message */ struct usbio_bmsg { u8 type; u8 cmd; u8 flags; u16 len; u8 data[]; } __packed; struct fw_version { u8 major; u8 minor; u16 patch; u16 build; } __packed; struct usbio_i2c_descriptor { u8 num; struct usbio_i2c_info info[]; } __packed; struct usbio_spi_ctr_info { u8 id; u8 capacity; } __packed; struct usbio_spi_descriptor { u8 num; struct usbio_spi_ctr_info info[]; } __packed; struct usbio_bank_descriptor { u8 bank_id; u8 pin_num; /* 1 bit for each gpio, 1 means valid */ u32 valid_pins; } __packed; struct usbio_gpio_descriptor { u8 pins_per_bank; u8 banks; struct usbio_bank_descriptor bank_desc[]; } __packed; #define MAX_PACKET_SIZE 64 #define MAX_PAYLOAD_SIZE (MAX_PACKET_SIZE - sizeof(struct usbio_msg)) #define USB_WRITE_TIMEOUT 200 #define USB_WRITE_ACK_TIMEOUT 500 #define USB_ENUM_STUB_TIMEOUT 20 struct usbio_event_cb_entry { struct platform_device *pdev; usbio_event_cb_t notify; }; struct usbio_stub_packet { u8 *ibuf; u32 ibuf_len; }; struct usbio_stub { struct list_head list; u8 type; struct usb_interface *intf; spinlock_t event_cb_lock; struct usbio_stub_packet ipacket; /* for identify ack */ bool acked; int cur_cmd; struct usbio_event_cb_entry event_entry; }; static inline void *usbio_priv(const struct usbio_stub *stub) { return (char *)stub + sizeof(struct usbio_stub); } enum bridge_state { BRIDGE_STOPPED, BRIDGE_INITED, BRIDGE_RESET_HANDSHAKE, BRIDGE_RESET_SYNCED, BRIDGE_ENUM_GPIO_COMPLETE, BRIDGE_ENUM_I2C_COMPLETE, BRIDGE_ENUM_SPI_COMPLETE, BRIDGE_SUSPEND, BRIDGE_STARTED, BRIDGE_FAILED, }; struct usbio_dev { struct usb_device *udev; struct usb_interface *intf; u8 ep0; /* the address of the control endpoint */ u8 in_ep; /* the address of the bulk in endpoint */ u8 out_ep; /* the address of the bulk out endpoint */ /* control buffer for xfer */ u16 cbuf_len; unsigned char *cbuf; /* the urb/buffer for read */ u16 ibuf_len; struct urb *in_urb; unsigned char *ibuf; enum bridge_state state; struct list_head stubs_list; /* to wait for an ongoing write ack */ wait_queue_head_t ack_wq; struct mfd_cell *cells; int cell_count; struct mutex mutex; }; #endif usbio-drivers-0~git202408092230.70c524c5/drivers/mfd/usbio.c000066400000000000000000000672101465551422300226530ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-only /* * * Copyright (c) 2023, Intel Corporation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include "bridge.h" static char *gpio_hids[] = { "INTC1074", /* TGL */ "INTC1096", /* ADL */ "INTC100B", /* RPL */ "INTC10D1", /* MTL-CVF */ "INTC1007", /* MTL */ "INTC10B5", /* LNL */ }; static struct mfd_cell_acpi_match usbio_acpi_match_gpio; static char *i2c_hids[] = { "INTC1075", /* TGL */ "INTC1097", /* ADL */ "INTC100C", /* RPL */ "INTC10D2", /* MTL-CVF */ "INTC1008", /* MTL */ "INTC10B6", /* LNL */ }; static struct mfd_cell_acpi_match usbio_acpi_match_i2cs; static char *spi_hids[] = { "INTC1091", /* TGL */ "INTC1098", /* ADL */ "INTC100D", /* RPL */ "INTC10D3", /* MTL */ }; static struct mfd_cell_acpi_match usbio_acpi_match_spis; static int try_match_acpi_hid(struct acpi_device *child, struct mfd_cell_acpi_match *match, char **hids, int hids_num) { struct acpi_device_id ids[2] = {}; int i; for (i = 0; i < hids_num; i++) { strscpy(ids[0].id, hids[i], sizeof(ids[0].id)); if (!acpi_match_device_ids(child, ids)) { match->pnpid = hids[i]; break; } } return 0; } static int match_device_ids(struct acpi_device *adev, void *data) { (void)data; try_match_acpi_hid(adev, &usbio_acpi_match_gpio, gpio_hids, ARRAY_SIZE(gpio_hids)); try_match_acpi_hid(adev, &usbio_acpi_match_i2cs, i2c_hids, ARRAY_SIZE(i2c_hids)); try_match_acpi_hid(adev, &usbio_acpi_match_spis, spi_hids, ARRAY_SIZE(spi_hids)); return 0; } static int precheck_acpi_hid(struct usb_interface *intf) { struct acpi_device *parent; #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0) struct acpi_device *child; #endif parent = ACPI_COMPANION(&intf->dev); if (!parent) return -ENODEV; #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) acpi_dev_for_each_child(parent, match_device_ids, NULL); #else list_for_each_entry (child, &parent->children, node) { match_device_ids(child, NULL); } #endif return 0; } static bool usbio_validate(void *data, u32 data_len) { struct usbio_bmsg *header = (struct usbio_bmsg *)data; return (header->len + sizeof(*header) == data_len); } static void usbio_dump(struct usbio_dev *bridge, void *buf, int len) { int i; u8 tmp[256] = { 0 }; int n = 0; if (!len) return; for (i = 0; i < len; i++) n += scnprintf(tmp + n, sizeof(tmp) - n - 1, "%02x ", ((u8 *)buf)[i]); dev_dbg(&bridge->intf->dev, "%s\n", tmp); } static struct usbio_stub *usbio_stub_alloc(struct usbio_dev *bridge, int priv_size) { struct usbio_stub *stub; stub = kzalloc(sizeof(*stub) + priv_size, GFP_KERNEL); if (!stub) return ERR_PTR(-ENOMEM); spin_lock_init(&stub->event_cb_lock); INIT_LIST_HEAD(&stub->list); list_add_tail(&stub->list, &bridge->stubs_list); dev_dbg(&bridge->intf->dev, "enuming a stub success\n"); return stub; } static struct usbio_stub *usbio_stub_find(struct usbio_dev *bridge, u8 type) { struct usbio_stub *stub; list_for_each_entry (stub, &bridge->stubs_list, list) { if (stub->type == type) return stub; } dev_err(&bridge->intf->dev, "usb stub not find, type: %d", type); return ERR_PTR(-ENODEV); } static void usbio_stub_notify(struct usbio_stub *stub, u8 cmd, const void *evt_data, int len) { unsigned long flags; spin_lock_irqsave(&stub->event_cb_lock, flags); if (stub->event_entry.notify && stub->event_entry.pdev) stub->event_entry.notify(stub->event_entry.pdev, cmd, evt_data, len); spin_unlock_irqrestore(&stub->event_cb_lock, flags); } static int usbio_parse(struct usbio_dev *bridge, struct usbio_bmsg *header) { struct usbio_stub *stub; stub = usbio_stub_find(bridge, header->type); if (IS_ERR(stub)) return PTR_ERR(stub); if (!(header->flags & RESP_FLAG)) { usbio_stub_notify(stub, header->cmd, header->data, header->len); return 0; } if (stub->cur_cmd != header->cmd) { dev_err(&bridge->intf->dev, "header->cmd:%x != stub->cur_cmd:%x", header->cmd, stub->cur_cmd); return -EINVAL; } stub->ipacket.ibuf_len = header->len; if (stub->ipacket.ibuf) memcpy(stub->ipacket.ibuf, header->data, header->len); stub->acked = true; wake_up(&bridge->ack_wq); return 0; } static int usbio_control_xfer(struct usbio_stub *stub, u8 cmd, const void *obuf, int obuf_len, void *ibuf, int *ibuf_len, bool wait_ack, int timeout) { struct usbio_msg *header; struct usbio_dev *bridge = usb_get_intfdata(stub->intf); int actual, ret; u8 flags = CMPL_FLAG; if (bridge->state == BRIDGE_STOPPED) return -ENODEV; if (obuf_len > bridge->cbuf_len) return -EINVAL; if (wait_ack) flags |= ACK_FLAG; stub->ipacket.ibuf_len = 0; actual = sizeof(header) + obuf_len; header = kmalloc(actual, GFP_KERNEL); if (!header) return -ENOMEM; header->type = stub->type; header->cmd = cmd; header->flags = flags; header->len = obuf_len; memcpy(header->data, obuf, obuf_len); dev_dbg(&bridge->intf->dev, "send: type:0x%x cmd:0x%x flags:0x%x len:%d\n", header->type, header->cmd, header->flags, header->len); usbio_dump(bridge, header->data, header->len); mutex_lock(&bridge->mutex); stub->cur_cmd = cmd; stub->ipacket.ibuf = ibuf; stub->acked = false; usb_autopm_get_interface(bridge->intf); ret = usb_control_msg_send(bridge->udev, bridge->ep0, 0, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 0, 0, header, actual, timeout, GFP_KERNEL); if (ret) { dev_err(&bridge->intf->dev, "bridge write failed ret:%d total_len:%d\n ", ret, actual); goto error; } kfree(header); if (wait_ack) { actual = bridge->cbuf_len; header = kmalloc(actual, GFP_KERNEL); if (!header) { ret = -ENOMEM; goto error; } ret = usb_control_msg_recv(bridge->udev, bridge->ep0, 0, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 0, 0, header, actual, timeout, GFP_KERNEL); if (ret) { dev_err(&bridge->intf->dev, "bridge read failed ret:%d total_len:%d\n ", ret, actual); goto error; } } if (ibuf_len && header) { *ibuf_len = header->len; memcpy(ibuf, header->data, *ibuf_len); } stub->ipacket.ibuf = NULL; stub->ipacket.ibuf_len = 0; error: kfree(header); usb_autopm_put_interface(bridge->intf); mutex_unlock(&bridge->mutex); return ret; } static int usbio_bulk_write(struct usbio_stub *stub, u8 cmd, const void *obuf, int obuf_len, void *ibuf, int *ibuf_len, bool wait_ack, int timeout) { struct usbio_bmsg *header; struct usbio_dev *bridge = usb_get_intfdata(stub->intf); int ret; u8 flags = CMPL_FLAG; int actual; if (bridge->state == BRIDGE_STOPPED) return -ENODEV; if (obuf_len > MAX_PAYLOAD_SIZE) return -EINVAL; if (wait_ack) flags |= ACK_FLAG; stub->ipacket.ibuf_len = 0; header = kmalloc(sizeof(*header) + obuf_len, GFP_KERNEL); if (!header) return -ENOMEM; header->type = stub->type; header->cmd = cmd; header->flags = flags; header->len = obuf_len; memcpy(header->data, obuf, obuf_len); dev_dbg(&bridge->intf->dev, "send: type:0x%x cmd:0x%x flags:0x%x len:%d\n", header->type, header->cmd, header->flags, header->len); usbio_dump(bridge, header->data, header->len); mutex_lock(&bridge->mutex); stub->cur_cmd = cmd; stub->ipacket.ibuf = ibuf; stub->acked = false; usb_autopm_get_interface(bridge->intf); ret = usb_bulk_msg(bridge->udev, usb_sndbulkpipe(bridge->udev, bridge->out_ep), header, sizeof(*header) + obuf_len, &actual, USB_WRITE_TIMEOUT); kfree(header); if (ret || actual != sizeof(*header) + obuf_len) { dev_err(&bridge->intf->dev, "bridge write failed ret:%d total_len:%d\n ", ret, actual); goto error; } if (wait_ack) { ret = wait_event_timeout(bridge->ack_wq, stub->acked, msecs_to_jiffies(timeout)); if (!ret || !stub->acked) { dev_err(&bridge->intf->dev, "acked wait timed out ret:%d timeout:%d ack:%d\n", ret, timeout, stub->acked); ret = -ETIMEDOUT; goto error; } } if (ibuf_len) *ibuf_len = stub->ipacket.ibuf_len; stub->ipacket.ibuf = NULL; stub->ipacket.ibuf_len = 0; ret = 0; error: usb_autopm_put_interface(bridge->intf); mutex_unlock(&bridge->mutex); return ret; } static int usbio_transfer_internal(struct platform_device *pdev, u8 cmd, const void *obuf, int obuf_len, void *ibuf, int *ibuf_len, bool wait_ack) { struct usbio_platform_data *usbio_pdata; struct usbio_dev *bridge; struct usbio_stub *stub; if (!pdev) return -EINVAL; bridge = dev_get_drvdata(pdev->dev.parent); usbio_pdata = dev_get_platdata(&pdev->dev); stub = usbio_stub_find(bridge, usbio_pdata->type); if (IS_ERR(stub)) return PTR_ERR(stub); if (stub->type <= GPIO_STUB) return usbio_control_xfer(stub, cmd, obuf, obuf_len, ibuf, ibuf_len, wait_ack, USB_WRITE_ACK_TIMEOUT); else return usbio_bulk_write(stub, cmd, obuf, obuf_len, ibuf, ibuf_len, wait_ack, USB_WRITE_ACK_TIMEOUT); } int usbio_transfer(struct platform_device *pdev, u8 cmd, const void *obuf, int obuf_len, void *ibuf, int *ibuf_len) { return usbio_transfer_internal(pdev, cmd, obuf, obuf_len, ibuf, ibuf_len, true); } EXPORT_SYMBOL_GPL(usbio_transfer); int usbio_transfer_noack(struct platform_device *pdev, u8 cmd, const void *obuf, int obuf_len) { return usbio_transfer_internal(pdev, cmd, obuf, obuf_len, NULL, NULL, false); } EXPORT_SYMBOL_GPL(usbio_transfer_noack); int usbio_register_event_cb(struct platform_device *pdev, usbio_event_cb_t event_cb) { struct usbio_platform_data *usbio_pdata; struct usbio_dev *bridge; struct usbio_stub *stub; unsigned long flags; if (!pdev) return -EINVAL; bridge = dev_get_drvdata(pdev->dev.parent); usbio_pdata = dev_get_platdata(&pdev->dev); stub = usbio_stub_find(bridge, usbio_pdata->type); if (IS_ERR(stub)) return PTR_ERR(stub); spin_lock_irqsave(&stub->event_cb_lock, flags); stub->event_entry.notify = event_cb; stub->event_entry.pdev = pdev; spin_unlock_irqrestore(&stub->event_cb_lock, flags); return 0; } EXPORT_SYMBOL_GPL(usbio_register_event_cb); void usbio_unregister_event_cb(struct platform_device *pdev) { struct usbio_platform_data *usbio_pdata; struct usbio_dev *bridge; struct usbio_stub *stub; unsigned long flags; bridge = dev_get_drvdata(pdev->dev.parent); usbio_pdata = dev_get_platdata(&pdev->dev); stub = usbio_stub_find(bridge, usbio_pdata->type); if (IS_ERR(stub)) return; spin_lock_irqsave(&stub->event_cb_lock, flags); stub->event_entry.notify = NULL; stub->event_entry.pdev = NULL; spin_unlock_irqrestore(&stub->event_cb_lock, flags); } EXPORT_SYMBOL_GPL(usbio_unregister_event_cb); static void usbio_stub_cleanup(struct usbio_dev *bridge) { struct usbio_stub *stub; struct usbio_stub *next; list_for_each_entry_safe (stub, next, &bridge->stubs_list, list) { list_del_init(&stub->list); kfree(stub); } } static void usbio_read_complete(struct urb *urb) { struct usbio_dev *bridge = urb->context; struct usbio_bmsg *header = urb->transfer_buffer; int len = urb->actual_length; int ret; dev_dbg(&bridge->intf->dev, "bulk read urb got message from fw, status:%d data_len:%d\n", urb->status, urb->actual_length); BUG_ON(!bridge); BUG_ON(!header); if (urb->status) { /* sync/async unlink faults aren't errors */ if (urb->status == -ENOENT || urb->status == -ECONNRESET || urb->status == -ESHUTDOWN) return; dev_err(&bridge->intf->dev, "read bulk urb transfer failed: %d\n", urb->status); goto resubmit; } dev_dbg(&bridge->intf->dev, "receive: type:%d cmd:%d flags:%d len:%d\n", header->type, header->cmd, header->flags, header->len); usbio_dump(bridge, header->data, header->len); if (!usbio_validate(header, len)) { dev_err(&bridge->intf->dev, "data not correct header->len:%d payload_len:%d\n ", header->len, len); goto resubmit; } ret = usbio_parse(bridge, header); if (ret) dev_err(&bridge->intf->dev, "failed to parse data: ret:%d type:%d len: %d", ret, header->type, header->len); resubmit: ret = usb_submit_urb(urb, GFP_ATOMIC); if (ret) dev_err(&bridge->intf->dev, "failed submitting read urb, error %d\n", ret); } static int usbio_start(struct usbio_dev *bridge) { int ret; usb_fill_bulk_urb(bridge->in_urb, bridge->udev, usb_rcvbulkpipe(bridge->udev, bridge->in_ep), bridge->ibuf, bridge->ibuf_len, usbio_read_complete, bridge); ret = usb_submit_urb(bridge->in_urb, GFP_KERNEL); if (ret) { dev_err(&bridge->intf->dev, "failed submitting read urb, error %d\n", ret); } return ret; } struct usbio_mng_priv { long reset_id; }; static int usbio_mng_reset_handshake(struct usbio_stub *stub) { int ret; int ilen; ret = usbio_control_xfer(stub, CTRL_RESET_NOTIFY, 0, 0, 0, &ilen, true, USB_WRITE_ACK_TIMEOUT); if (ret) { dev_err(&stub->intf->dev, "CTRL_RESET_NOTIFY failed ret:%d\n", ret); return -EIO; } return 0; } static inline int usbio_mng_reset(struct usbio_stub *stub) { return usbio_control_xfer(stub, CTRL_RESET, NULL, 0, NULL, NULL, true, USB_WRITE_ACK_TIMEOUT); } static int usbio_add_mfd_cell(struct usbio_dev *bridge, struct mfd_cell *cell) { struct mfd_cell *new_cells; /* Enumerate the device even if it does not appear in DSDT */ if (!cell->acpi_match->pnpid) dev_warn(&bridge->intf->dev, "The HID of cell %s does not exist in DSDT\n", cell->name); new_cells = krealloc_array(bridge->cells, (bridge->cell_count + 1), sizeof(struct mfd_cell), GFP_KERNEL); if (!new_cells) return -ENOMEM; memcpy(&new_cells[bridge->cell_count], cell, sizeof(*cell)); bridge->cells = new_cells; bridge->cell_count++; return 0; } static int usbio_gpio_stub_init(struct usbio_dev *bridge, struct usbio_gpio_descriptor *desc) { struct usbio_stub *stub; struct mfd_cell cell = { 0 }; struct usbio_platform_data *pdata; int gpio_num = desc->pins_per_bank * desc->banks; int i; u32 valid_pin[MAX_GPIO_NUM / (sizeof(u32) * BITS_PER_BYTE)]; if (gpio_num > MAX_GPIO_NUM) return -EINVAL; stub = usbio_stub_alloc(bridge, sizeof(*pdata)); if (IS_ERR(stub)) return PTR_ERR(stub); stub->type = GPIO_STUB; stub->intf = bridge->intf; pdata = usbio_priv(stub); pdata->type = stub->type; pdata->gpio_info.num = gpio_num; for (i = 0; i < desc->banks; i++) { valid_pin[i] = desc->bank_desc[i].valid_pins; dev_info(&bridge->intf->dev, "bank:%d map:0x%08x\n", i, valid_pin[i]); } bitmap_from_arr32(pdata->gpio_info.valid_pin_map, valid_pin, gpio_num); cell.name = "usbio-gpio"; cell.platform_data = pdata; cell.pdata_size = sizeof(*pdata); cell.acpi_match = &usbio_acpi_match_gpio; return usbio_add_mfd_cell(bridge, &cell); } static int usbio_mng_enum_gpio(struct usbio_stub *stub) { struct usbio_dev *bridge = usb_get_intfdata(stub->intf); struct usbio_gpio_descriptor *desc; int ret; int len; desc = kzalloc(MAX_PAYLOAD_SIZE, GFP_KERNEL); if (!desc) return -ENOMEM; ret = usbio_control_xfer(stub, CTRL_ENUM_GPIO, NULL, 0, desc->bank_desc, &len, true, USB_ENUM_STUB_TIMEOUT); if (ret || !len || (len % sizeof(*desc->bank_desc))) { dev_err(&stub->intf->dev, "enum gpio failed ret:%d len:%d bank_desc:%ld\n", ret, len, sizeof(*desc->bank_desc)); kfree(desc); return -EIO; } desc->pins_per_bank = GPIO_PER_BANK; desc->banks = len / sizeof(*desc->bank_desc); ret = usbio_gpio_stub_init(bridge, desc); kfree(desc); if (ret) dev_err(&stub->intf->dev, "enum gpio failed ret:%d\n", ret); return ret; } static int usbio_i2c_stub_init(struct usbio_dev *bridge, struct usbio_i2c_descriptor *desc) { struct usbio_stub *stub; struct usbio_platform_data *pdata; int i; int ret; stub = usbio_stub_alloc(bridge, desc->num * sizeof(*pdata)); if (IS_ERR(stub)) return PTR_ERR(stub); stub->type = I2C_STUB; stub->intf = bridge->intf; pdata = usbio_priv(stub); for (i = 0; i < desc->num; i++) { struct mfd_cell cell = { 0 }; pdata[i].type = stub->type; pdata[i].i2c_info.id = desc->info[i].id; pdata[i].i2c_info.capacity = desc->info[i].capacity; cell.name = "usbio-i2c"; cell.platform_data = &pdata[i]; cell.pdata_size = sizeof(pdata[i]); cell.acpi_match = &usbio_acpi_match_i2cs; ret = usbio_add_mfd_cell(bridge, &cell); if (ret) return ret; } return 0; } static int usbio_mng_enum_i2c(struct usbio_stub *stub) { struct usbio_dev *bridge = usb_get_intfdata(stub->intf); struct usbio_i2c_descriptor *desc; int ret; int len; desc = kzalloc(MAX_PAYLOAD_SIZE, GFP_KERNEL); if (!desc) return -ENOMEM; ret = usbio_control_xfer(stub, CTRL_ENUM_I2C, NULL, 0, desc->info, &len, true, USB_ENUM_STUB_TIMEOUT); if (ret || !len || (len % sizeof(*desc->info))) { dev_err(&stub->intf->dev, "CTRL_ENUM_I2C failed ret:%d len:%d num:%d\n", ret, len, desc->num); kfree(desc); return -EIO; } desc->num = len / sizeof(*desc->info); ret = usbio_i2c_stub_init(bridge, desc); kfree(desc); return ret; } static int usbio_spi_stub_init(struct usbio_dev *bridge, struct usbio_spi_descriptor *desc) { struct usbio_stub *stub; struct usbio_platform_data *pdata; int i; int ret; stub = usbio_stub_alloc(bridge, desc->num * sizeof(*pdata)); if (IS_ERR(stub)) return PTR_ERR(stub); stub->type = SPI_STUB; stub->intf = bridge->intf; pdata = usbio_priv(stub); for (i = 0; i < desc->num; i++) { struct mfd_cell cell = { 0 }; pdata[i].type = stub->type; pdata[i].spi_info.id = desc->info[i].id; pdata[i].spi_info.capacity = desc->info[i].capacity; cell.name = "usbio-spi"; cell.platform_data = &pdata[i]; cell.pdata_size = sizeof(pdata[i]); cell.acpi_match = &usbio_acpi_match_spis; ret = usbio_add_mfd_cell(bridge, &cell); if (ret) return ret; } return 0; } static int usbio_mng_enum_spi(struct usbio_stub *stub) { struct usbio_dev *bridge = usb_get_intfdata(stub->intf); struct usbio_spi_descriptor *desc; int ret; int len; desc = kzalloc(MAX_PAYLOAD_SIZE, GFP_KERNEL); if (!desc) return -ENOMEM; ret = usbio_control_xfer(stub, CTRL_ENUM_SPI, NULL, 0, desc, &len, true, USB_ENUM_STUB_TIMEOUT); if (ret) { dev_err(&stub->intf->dev, "CTRL_ENUM_SPI failed ret:%d len:%d num:%d\n", ret, len, desc->num); kfree(desc); return -EIO; } ret = usbio_spi_stub_init(bridge, desc); kfree(desc); return ret; } static int usbio_mng_get_version(struct usbio_stub *stub, char *buf) { struct fw_version version = { 0 }; int ret; int len; if (!buf) return -EINVAL; ret = usbio_control_xfer(stub, CTRL_FW_VERSION, NULL, 0, &version, &len, true, USB_WRITE_ACK_TIMEOUT); if (ret || len < sizeof(struct fw_version)) { dev_err(&stub->intf->dev, "CTRL_GET_VERSION failed ret:%d len:%d\n", ret, len); return ret; } return sysfs_emit(buf, "%d.%d.%d.%d\n", version.major, version.minor, le16_to_cpu(version.patch), le16_to_cpu(version.build)); } static inline int usbio_mng_set_dfu_mode(struct usbio_stub *stub) { return usbio_control_xfer(stub, CTRL_SET_DFU_MODE, NULL, 0, NULL, NULL, true, USB_WRITE_ACK_TIMEOUT); } static int usbio_mng_link(struct usbio_dev *bridge, struct usbio_stub *stub) { int ret; ret = usbio_mng_reset_handshake(stub); if (ret) return ret; bridge->state = BRIDGE_RESET_SYNCED; /* workaround for FW limitation, ignore return value of enum result */ usbio_mng_enum_gpio(stub); bridge->state = BRIDGE_ENUM_GPIO_COMPLETE; usbio_mng_enum_i2c(stub); bridge->state = BRIDGE_ENUM_I2C_COMPLETE; usbio_mng_enum_spi(stub); bridge->state = BRIDGE_ENUM_SPI_COMPLETE; return 0; } static int usbio_mng_init(struct usbio_dev *bridge) { struct usbio_stub *stub; struct usbio_mng_priv *priv; int ret; stub = usbio_stub_alloc(bridge, sizeof(*priv)); if (IS_ERR(stub)) return PTR_ERR(stub); priv = usbio_priv(stub); if (!priv) return -ENOMEM; priv->reset_id = 0; stub->type = CTRL_STUB; stub->intf = bridge->intf; ret = usbio_mng_link(bridge, stub); if (ret) dev_err(&bridge->intf->dev, "mng stub link done ret:%d state:%d\n", ret, bridge->state); return ret; } static inline int usbio_diag_get_fw_log(struct usbio_stub *stub, void *buf) { int ret; int len; if (!buf) return -EINVAL; ret = usbio_control_xfer(stub, DIAG_GET_FW_LOG, NULL, 0, buf, &len, true, USB_WRITE_ACK_TIMEOUT); if (ret) return ret; return len; } static inline int usbio_diag_get_coredump(struct usbio_stub *stub, void *buf) { int ret; int len; if (!buf) return -EINVAL; ret = usbio_control_xfer(stub, DIAG_GET_FW_COREDUMP, NULL, 0, buf, &len, true, USB_WRITE_ACK_TIMEOUT); if (ret) return ret; return len; } static inline int usbio_diag_set_trace_level(struct usbio_stub *stub, u8 level) { return usbio_control_xfer(stub, DIAG_SET_TRACE_LEVEL, &level, sizeof(level), NULL, NULL, true, USB_WRITE_ACK_TIMEOUT); } static int usbio_diag_init(struct usbio_dev *bridge) { struct usbio_stub *stub; stub = usbio_stub_alloc(bridge, 0); if (IS_ERR(stub)) return PTR_ERR(stub); stub->type = DIAG_STUB; stub->intf = bridge->intf; return 0; } static void usbio_delete(struct usbio_dev *bridge) { mutex_destroy(&bridge->mutex); usb_free_urb(bridge->in_urb); usb_put_intf(bridge->intf); usb_put_dev(bridge->udev); kfree(bridge->ibuf); kfree(bridge->cells); kfree(bridge); } static int usbio_init(struct usbio_dev *bridge) { mutex_init(&bridge->mutex); init_waitqueue_head(&bridge->ack_wq); INIT_LIST_HEAD(&bridge->stubs_list); bridge->state = BRIDGE_INITED; return 0; } static void usbio_stop(struct usbio_dev *bridge) { usb_kill_urb(bridge->in_urb); } static ssize_t cmd_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); struct usbio_dev *bridge = usb_get_intfdata(intf); struct usbio_stub *mng_stub = usbio_stub_find(bridge, CTRL_STUB); struct usbio_stub *diag_stub = usbio_stub_find(bridge, DIAG_STUB); if (sysfs_streq(buf, "dfu")) usbio_mng_set_dfu_mode(mng_stub); else if (sysfs_streq(buf, "reset")) usbio_mng_reset(mng_stub); else if (sysfs_streq(buf, "debug")) usbio_diag_set_trace_level(diag_stub, 3); return count; } static ssize_t cmd_show(struct device *dev, struct device_attribute *attr, char *buf) { return sysfs_emit(buf, "%s\n", "supported cmd: [dfu, reset, debug]"); } static DEVICE_ATTR_RW(cmd); static ssize_t version_show(struct device *dev, struct device_attribute *attr, char *buf) { struct usb_interface *intf = to_usb_interface(dev); struct usbio_dev *bridge = usb_get_intfdata(intf); struct usbio_stub *stub = usbio_stub_find(bridge, CTRL_STUB); return usbio_mng_get_version(stub, buf); } static DEVICE_ATTR_RO(version); static ssize_t log_show(struct device *dev, struct device_attribute *attr, char *buf) { struct usb_interface *intf = to_usb_interface(dev); struct usbio_dev *bridge = usb_get_intfdata(intf); struct usbio_stub *diag_stub = usbio_stub_find(bridge, DIAG_STUB); return usbio_diag_get_fw_log(diag_stub, buf); } static DEVICE_ATTR_RO(log); static ssize_t coredump_show(struct device *dev, struct device_attribute *attr, char *buf) { struct usb_interface *intf = to_usb_interface(dev); struct usbio_dev *bridge = usb_get_intfdata(intf); struct usbio_stub *diag_stub = usbio_stub_find(bridge, DIAG_STUB); return usbio_diag_get_coredump(diag_stub, buf); } static DEVICE_ATTR_RO(coredump); static struct attribute *usbio_attrs[] = { &dev_attr_version.attr, &dev_attr_cmd.attr, &dev_attr_log.attr, &dev_attr_coredump.attr, NULL, }; ATTRIBUTE_GROUPS(usbio); static int usbio_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usbio_dev *bridge; struct usb_endpoint_descriptor *ep0, *bulk_in, *bulk_out; int ret; ret = precheck_acpi_hid(intf); if (ret) return ret; /* allocate memory for our device state and initialize it */ bridge = kzalloc(sizeof(*bridge), GFP_KERNEL); if (!bridge) return -ENOMEM; usbio_init(bridge); bridge->udev = usb_get_dev(interface_to_usbdev(intf)); bridge->intf = usb_get_intf(intf); if (!bridge->udev) { dev_err(&intf->dev, "Could not find usb device\n"); goto error; } /* control transfer enpoint information */ ep0 = &bridge->udev->ep0.desc; if (!ep0) { dev_err(&intf->dev, "Could not find control endpoint descriptor\n"); goto error; } bridge->ep0 = ep0->bEndpointAddress; bridge->cbuf_len = usb_endpoint_maxp(ep0); bridge->cbuf = kzalloc(bridge->cbuf_len, GFP_KERNEL); if (!bridge->cbuf) { ret = -ENOMEM; goto error; } dev_dbg(&intf->dev, "ep0 addr:%d size:%u\n", bridge->ep0, bridge->cbuf_len); /* set up the endpoint information use only the first bulk-in and bulk-out endpoints */ ret = usb_find_common_endpoints(intf->cur_altsetting, &bulk_in, &bulk_out, NULL, NULL); if (ret) { dev_err(&intf->dev, "Could not find both bulk-in and bulk-out endpoints\n"); goto error; } bridge->in_ep = bulk_in->bEndpointAddress; bridge->ibuf_len = usb_endpoint_maxp(bulk_in); bridge->ibuf = kzalloc(bridge->ibuf_len, GFP_KERNEL); if (!bridge->ibuf) { ret = -ENOMEM; goto error; } bridge->in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!bridge->in_urb) { ret = -ENOMEM; goto error; } bridge->out_ep = bulk_out->bEndpointAddress; dev_dbg(&intf->dev, "bulk_in addr:%d bulk_out addr:%d size:%u\n", bridge->in_ep, bridge->out_ep, bridge->ibuf_len); /* save our data pointer in this intf device */ usb_set_intfdata(intf, bridge); ret = usbio_start(bridge); if (ret) { dev_err(&intf->dev, "bridge read start failed ret %d\n", ret); goto error; } ret = usbio_mng_init(bridge); if (ret) { dev_err(&intf->dev, "register mng stub failed ret %d\n", ret); goto error_stop; } ret = usbio_diag_init(bridge); if (ret) { dev_err(&intf->dev, "register diag stub failed ret %d\n", ret); goto error_stop; } ret = mfd_add_hotplug_devices(&intf->dev, bridge->cells, bridge->cell_count); if (ret) { dev_err(&intf->dev, "failed to add mfd devices to core %d\n", bridge->cell_count); goto error_stop; } bridge->state = BRIDGE_STARTED; dev_info(&intf->dev, "USB Bridge device init success\n"); return 0; error_stop: usbio_stop(bridge); error: dev_err(&intf->dev, "USB Bridge device init failed\n"); /* this frees allocated memory */ usbio_stub_cleanup(bridge); usbio_delete(bridge); return ret; } static void usbio_disconnect(struct usb_interface *intf) { struct usbio_dev *bridge; bridge = usb_get_intfdata(intf); usbio_stop(bridge); bridge->state = BRIDGE_STOPPED; mfd_remove_devices(&intf->dev); usbio_stub_cleanup(bridge); usb_set_intfdata(intf, NULL); usbio_delete(bridge); dev_info(&intf->dev, "USB Bridge disconnected\n"); } static int usbio_suspend(struct usb_interface *intf, pm_message_t message) { struct usbio_dev *bridge = usb_get_intfdata(intf); usbio_stop(bridge); bridge->state = BRIDGE_SUSPEND; dev_dbg(&intf->dev, "USB Bridge suspend\n"); return 0; } static int usbio_resume(struct usb_interface *intf) { struct usbio_dev *bridge = usb_get_intfdata(intf); bridge->state = BRIDGE_STARTED; dev_dbg(&intf->dev, "USB Bridge resume\n"); return usbio_start(bridge); } static const struct usb_device_id usbio_table[] = { {USB_DEVICE(0x2AC1, 0x20C1)}, /* Lattice NX40 */ {USB_DEVICE(0x2AC1, 0x20C9)}, /* Lattice NX33 */ {USB_DEVICE(0x2AC1, 0x20CB)}, /* Lattice NX33U */ {} }; MODULE_DEVICE_TABLE(usb, usbio_table); static struct usb_driver usbbridge_driver = { .name = "usbio-bridge", .probe = usbio_probe, .disconnect = usbio_disconnect, .suspend = usbio_suspend, .resume = usbio_resume, .id_table = usbio_table, .dev_groups = usbio_groups, .supports_autosuspend = 1, }; module_usb_driver(usbbridge_driver); MODULE_AUTHOR("Ye Xiang "); MODULE_AUTHOR("Zhang Lixu "); MODULE_AUTHOR("Israel Cepeda "); MODULE_AUTHOR("Lifu Wang "); MODULE_DESCRIPTION("Intel USBIO Bridge driver"); MODULE_LICENSE("GPL v2"); usbio-drivers-0~git202408092230.70c524c5/include/000077500000000000000000000000001465551422300205575ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/include/linux/000077500000000000000000000000001465551422300217165ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/include/linux/mfd/000077500000000000000000000000001465551422300224645ustar00rootroot00000000000000usbio-drivers-0~git202408092230.70c524c5/include/linux/mfd/usbio.h000066400000000000000000000021341465551422300237560ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-only #ifndef __LINUX_USB_IO_H #define __LINUX_USB_IO_H #include #include #include #define MAX_BANK_NUM 5 #define GPIO_PER_BANK 32 #define MAX_GPIO_NUM (MAX_BANK_NUM * GPIO_PER_BANK) struct usbio_gpio_info { int num; DECLARE_BITMAP(valid_pin_map, MAX_GPIO_NUM); }; struct usbio_i2c_info { u8 id; u8 capacity; }; struct usbio_spi_info { u8 id; u8 capacity; }; struct usbio_platform_data { int type; union { struct usbio_gpio_info gpio_info; struct usbio_i2c_info i2c_info; struct usbio_spi_info spi_info; }; }; typedef void (*usbio_event_cb_t)(struct platform_device *pdev, u8 cmd, const void *evt_data, int len); int usbio_register_event_cb(struct platform_device *pdev, usbio_event_cb_t event_cb); void usbi_unregister_event_cb(struct platform_device *pdev); int usbio_transfer(struct platform_device *pdev, u8 cmd, const void *obuf, int obuf_len, void *ibuf, int *ibuf_len); int usbio_transfer_noack(struct platform_device *pdev, u8 cmd, const void *obuf, int obuf_len); #endif usbio-drivers-0~git202408092230.70c524c5/security.md000066400000000000000000000006261465551422300213310ustar00rootroot00000000000000# Security Policy Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. ## Reporting a Vulnerability Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html).