AccessBus_Linux_5536_01.00.0401/0000755011205700000240000000000010337204131015677 5ustar pmccumbedialoutAccessBus_Linux_5536_01.00.0401/README0000644011205700000240000001200410337203761016564 0ustar pmccumbedialoutAMD Geode(TM) LX Processor and AMD Geode(TM) CS5536 Companion Device Linux ACCESS.bus Controller Driver - Release Notes Version: 01.00.0401, General Release Release Date: June 2, 2005 -------------------------------------------------------------------------------- PRODUCT INFORMATION -------------------------------------------------------------------------------- This driver provides basic support for the AMD Geode(TM) CS5536 companion device ACCESS.bus controller for Linux kernel version 2.6.11. - build_num.h - configure.ac - lx_acb.c - Makefile.in - README.AccessBus.txt (this file) Features -------- The driver provides an acb_adapter driver for the CS5536 companion device ACCESS.bus controller Dependencies ------------ - Linux Kernel 2.6.11 - (recommended) Linux 2.6.11 Kernel Patch for Geode LX/GX processors Patches_Linux2.6.11_Common_02.02.0102.patch Functional Changes ------------------ None Defects Corrected ----------------- None Known Errata ------------ None -------------------------------------------------------------------------------- VALIDATION ENVIRONMENT -------------------------------------------------------------------------------- Validated on AMD Geode(TM) Norwich Development Board - Rev 2 Rework H and Rev 3 Rework E with: Processor: AMD Geode LX processor, silicon rev. C1 @ 433 MHz Chipset: AMD Geode CS5536 companion device, silicon rev. B1 PCI Bus Speed: 66 MHz Memory: 256 MB PC3200 RAM CRT: NEC MultiSync FP2141SB Flat Panel: Samsung LTM213U3-L07 1600x1200 2-channel LVDS, Keyboard/Mouse: PS/2 on Moray 1.1 BIOS: GeodeROM 1.06.06 Operating System: Gentoo 2005.0 Kernel: v2.6.11 Kernel Patch: LX Kernel Patch v02.02.0100 Graphics Driver: LX Xorg Graphics driver v03.00.0100 Audio Driver: CS5536 ALSA Audio driver v01.00.0500 AES Driver: LX AES driver v02.01.0100 ACCESS.bus Driver: LX ACB Driver v01.00.0401 Video4Linux2 Driver: LX Video4Linux2 driver v03.02.0100 Other Software: N/A -------------------------------------------------------------------------------- INSTALLATION INSTRUCTIONS -------------------------------------------------------------------------------- Note that your usage and path names may vary. It is recommmended that users first apply and build the Geode LX processor Linux 2.6.11 Kernel Patch. This requires that the /usr/src/linux is a symbolic link to the patched target kernel. The instructions assume the build is performed on the target system, and that the patched kernel is installed. to build: autoconf ./configure make -C /usr/src/linux SUBDIRS=`pwd` modules make install mknod /dev/i2c-0 c 89 0 on udev systems: mknod /etc/udev/devices/i2c-0 c 89 0 to install (on target platform) modprobe i2c-dev insmod lx_acb.o -------------------------------------------------------------------------------- RELEASE HISTORY (Previous Release) -------------------------------------------------------------------------------- Version: 01.00.0300 Release Date: May 26, 2005 Dependencies ------------ - Linux 2.6.11 from kernel.org - Geode LX processor Linux 2.6.11 Kernel Patch Patches_Linux2.6.11_LX_1.00.0201.patch Functional Changes ------------------ - First release Defects Corrected ----------------- - First release Known Errata ------------ - First release ================================================================================ Copyright --------- Copyright 2005 Advanced Micro Devices, Inc. All rights reserved. The contents of this document are provided in connection with Advanced Micro Devices, Inc. ("AMD") products. AMD makes no representations or warranties with respect to the accuracy or completeness of the contents of this publication and reserves the right to make changes to specifications and product descriptions at any time without notice. No license, whether express, implied, arising by estoppel or otherwise, to any intellectual property rights is granted by this publication. Except as set forth in AMD's Standard Terms and Conditions of Sale, AMD assumes no liability whatsoever, and disclaims any express or implied warranty, relating to its products including, but not limited to, the implied warranty of merchantability, fitness for a particular purpose, or infringement of any intellectual property right. AMD's products are not designed, intended, authorized or warranted for use as components in systems intended for surgical implant into the body, or in other applications intended to support or sustain life, or in any other application in which the failure of AMD's product could create a situation where personal injury, death, or severe property or environmental damage may occur. AMD reserves the right to discontinue or make changes to its products at any time without notice. Trademarks ---------- AMD, the AMD Arrow logo, and combinations thereof, and Geode are trademarks of Advanced Micro Devices, Inc. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies. ================================================================================ AccessBus_Linux_5536_01.00.0401/configure.ac0000444011205700000240000000066210337203761020177 0ustar pmccumbedialoutAC_INIT(configure.ac) AC_PROG_CC AC_CHECK_TOOL(LD, ld, :) AC_ARG_WITH(kernel-path, [ --with-kernel-path Specify the kernel path], KERNEL_SRC=$withval, KERNEL_SRC="/usr/src/linux") AC_ARG_WITH(module-path, [ --with-module-path Specify where to install the modules], INSTALL_MOD_PATH=$withval, INSTALL_MOD_PATH=/lib/modules) CFLAGS="$CFLAGS -Wall" AC_SUBST(KERNEL_SRC) AC_SUBST(INSTALL_MOD_PATH) AC_OUTPUT([ ./Makefile ]) AccessBus_Linux_5536_01.00.0401/AccessBus_Linux_5536_01.00.04010000644011205700000240000000000010337203761022435 0ustar pmccumbedialoutAccessBus_Linux_5536_01.00.0401/build_num.h0000444011205700000240000000340010337203761020031 0ustar pmccumbedialout#ifndef BUILD_NUM_H #define BUILD_NUM_H /* * Copyright (c) 2003-2005 Advanced Micro Devices, Inc. * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * The full GNU General Public License is included in this distribution in the * file called COPYING * */ /* * */ /* * */ #ifdef AMD_BUILDNUM_DEFINED #error "Caution: You have muliple version files in your path. Please correct this." #endif #define AMD_BUILDNUM_DEFINED /* Define the following for your driver */ #define _NAME "AMD Linux Access.Bus driver" #define _MAJOR 01 #define _MINOR 00 /* This defines the current buildlevel and revision of the code */ #define _BL 04 #define _BLREV 01 #ifdef _BLREV #define _BUILDLEVEL _x(_BL)_x(_BLREV) #else #define _BUILDLEVEL _x(_BL) #endif /* Use this macro to get the version string */ #define _VERSION_NUMBER _x(_MAJOR) "." _x(_MINOR) "." _BUILDLEVEL #define AMD_VERSION _NAME " " _VERSION_NUMBER /* Syntatic sugar for use above - you probably don't have to touch this */ #define _x(s) _s(s) #define _s(s) #s #endif AccessBus_Linux_5536_01.00.0401/Makefile.in0000444011205700000240000000313610337203761017755 0ustar pmccumbedialoutCC=@CC@ LD=@LD@ KERNEL_SRC=@KERNEL_SRC@ # Grab the kernel version right out of the tree KERNEL_VERSION = $(shell sed -ne 's/"//g;s/^\#define UTS_RELEASE //p' \ $(KERNEL_SRC)/include/linux/version.h) # This is borrowed from the Orinoco drivers. Thanks fellas... OLDMAKE = $(filter 2.4%, $(KERNEL_VERSION)) DOT_CONFIG = $(wildcard $(KERNEL_SRC)/.config) ifeq (,$(DOT_CONFIG)) $(error The kernel source is not configured) endif include $(DOT_CONFIG) CURDIR=$(shell pwd) ifeq (,$(OLDMAKE)) MODULES=lx_acb.o obj-m += lx_acb.o all: modules modules: $(MAKE) -C $(KERNEL_SRC) M=$(CURDIR) modules install: modules install -d $(DESTDIR)/lib/modules/$(KERNEL_VERSION)/kernel/drivers/i2c install -m 0644 $(MODULES:%.o=%.ko) $(DESTDIR)/lib/modules/$(KERNEL_VERSION)/kernel/drivers/i2c clean: rm -f *.o *.ko *.mod.c .*.cmd else MODULES=lx_acb.o KERNEL_HEADERS = -I$(KERNEL_SRC)/include CPPFLAGS = -D__KERNEL__ -DMODULE -I. $(KERNEL_HEADERS) CFLAGS=-O2 -g -Wall -Wstrict-prototypes -fno-strict-aliasing -fno-common -pipe ifdef CONFIG_MODVERSIONS MFLAG = -DMODVERSIONS -include $(KERNEL_SRC)/include/linux/modversions.h endif SRCS=lc_acb.c all: $(MODULES) clean: @ rm -f *.o *.ko *.mod.c .*.cmd install: $(MODULES) @ install -d $(DESTDIR)/lib/modules/$(KERNEL_VERSION)/kernel/drivers/i2c @ install -m 0644 $(MODULES) $(DESTDIR)/lib/modules/$(KERNEL_VERSION)/kernel/drivers/i2c %.o: %.c $(CC) -MD $(CFLAGS) $(CPPFLAGS) $(MFLAG) -c $< %.s: %.c $(CC) -MD $(CFLAGS) $(CPPFLAGS) -S $< %.i: %.c $(CC) -MD $(CPPFLAGS) -E $< -o $@ -include $(SRCS:%.c=%.d) endif distclean: clean @ rm Makefile clean AccessBus_Linux_5536_01.00.0401/AUTHORS0000644011205700000240000000022210337203761016753 0ustar pmccumbedialoutFor bugs, patches, and info requests, please subscribe to info-linux@geode.amd.com. Send a blank message to: info-linux-subscribe@geode.amd.com AccessBus_Linux_5536_01.00.0401/COPYING0000644011205700000240000004313110337203761016744 0ustar pmccumbedialout GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 Library General Public License instead of this License. AccessBus_Linux_5536_01.00.0401/lx_acb.c0000444011205700000240000004004010337203761017277 0ustar pmccumbedialout/* * Copyright (c) 2003-2005 Advanced Micro Devices, Inc. * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * The full GNU General Public License is included in this distribution in the * file called COPYING * */ /* * */ /* * */ #include #include #include #include #include #include #include #include #include #include #include #include "build_num.h" MODULE_AUTHOR("William Morrow (william.morrow@amd.com)"); MODULE_DESCRIPTION("AMD LX ACCESS.bus Driver"); MODULE_LICENSE("GPL"); #define NAME "lx_acb" #define LENGTH(n) (sizeof(n)/sizeof(n[0])) #define ACBSDA (dev->io+0) #define ACBST (dev->io+1) #define ACBST_SDAST 0x40 /* SDA Status */ #define ACBST_BER 0x20 #define ACBST_NEGACK 0x10 /* Negative Acknowledge */ #define ACBST_STASTR 0x08 /* Stall After Start */ #define ACBST_MASTER 0x02 #define ACBST_XMIT 0x01 #define ACBCST (dev->io+2) #define ACBCST_BB 0x02 #define ACBCST_TSDA 0x10 #define ACBCST_TGSCL 0x20 #define ACBCTL1 (dev->io+3) #define ACBCTL1_STASTRE 0x80 #define ACBCTL1_NMINTE 0x40 #define ACBCTL1_ACK 0x10 #define ACBCTL1_INTEN 0x04 #define ACBCTL1_STOP 0x02 #define ACBCTL1_START 0x01 #define ACBADDR (dev->io+4) #define ACBCTL2 (dev->io+5) #define ACBCTL2_CLK 0x70 #define ACBCTL2_ENABLE 0x01 #define MAX_DEVICES 4 static int debug = 0; MODULE_PARM(debug,"i"); #define DEBUG(n,s...) do { if( debug >= (n) ) printk(KERN_INFO NAME ":" s); } while(0) #define POLLED_MODE 1 #define POLL_TIMEOUT (HZ) enum amd_acb_state { state_idle, state_address, state_read, state_write, state_next, state_stop, state_error, }; #define STATE_ACTIVE ((1<index, inz(ACBST), inz(ACBCST), inz(ACBCTL1), inz(ACBCTL2)); } static void acb_start(struct acb_dev *dev) { DEBUG(3,"ACB%d START\n",dev->index); outz( (inz(ACBCTL1) | ACBCTL1_START), ACBCTL1 ); } static void acb_stop(struct acb_dev *dev) { DEBUG(3,"ACB%d STOP\n",dev->index); outz( (inz(ACBCTL1) | ACBCTL1_STOP), ACBCTL1 ); } static void acb_snak(struct acb_dev *dev) { DEBUG(3,"ACB%d SNAK\n",dev->index); outz( inz(ACBCTL1) | ACBCTL1_ACK, ACBCTL1 ); } static void acb_bbusy(struct acb_dev *dev) { int retries = 100; while( (inz(ACBCST)&ACBCST_BB) != 0 && --retries >= 0 ) { if( (inz(ACBST) & ACBST_MASTER) != 0 ) outz( ACBCTL1_STOP, ACBCTL1 ); else if( (inz(ACBCST) & (ACBCST_TSDA|ACBCST_TGSCL)) == 0 ) outz( ACBCST_TGSCL, ACBCST ); udelay(1000); } if( retries < 0 ) { DEBUG(0,"ACB%d BUS BUSY\n",dev->index); acb_dump(dev); } } static void acb_reenable(struct acb_dev *dev) { DEBUG(3,"ACB%d REENABLE\n",dev->index); outz( (ACBCTL2_CLK & ~ACBCTL2_ENABLE), ACBCTL2 ); // Configure no interrupt mode (polling) and // Disable global call address outz( 0x00, ACBCTL1 ); // Disable slave address outz( 0x00, ACBADDR ); // Enable the ACCESS.bus device outz( inz(ACBCTL2) | ACBCTL2_ENABLE, ACBCTL2); } static void acb_reset(struct acb_dev *dev) { DEBUG(3,"ACB%d RESET\n",dev->index); // Clear NEGACK, STASTR and BER bits outz( ACBST_BER|ACBST_NEGACK|ACBST_STASTR, ACBST ); outz( 0, ACBST ); // Status Reg bug workaround // Clear BB (BUS BUSY) bit acb_bbusy(dev); // toggle enable ACB acb_reenable(dev); } static int acb_probe(struct acb_dev *dev) { DEBUG(0,"%s\n",AMD_VERSION); DEBUG(3,"ACB%d PROBE\n",dev->index); acb_reset(dev); //probe with reset outz( (ACBCTL2_CLK & ~ACBCTL2_ENABLE), ACBCTL2 ); if( inz(ACBCTL2) != (ACBCTL2_CLK & ~ACBCTL2_ENABLE)) { DEBUG(2,"ACB%d readback failed\n",dev->index); return -ENXIO; } outz( 0x00, ACBCTL1 ); outz( 0x00, ACBADDR ); outz( inz(ACBCTL2) | ACBCTL2_ENABLE, ACBCTL2 ); if( inz(ACBCTL1) ) { DEBUG(2,"ACB%d disabled, but ACBCTL1!=0\n",dev->index); return -ENXIO; } outz( ACBST_BER|ACBST_NEGACK|ACBST_STASTR, ACBST ); outz( 0, ACBST ); // Status Reg bug workaround acb_bbusy(dev); return 0; } static int amd_acb_machine(struct acb_dev *dev,int status) { unsigned char addr, ch; unsigned short flags; if( (status&ACBST_MASTER) == 0 ) { DEBUG(1,"ACB%d NOT MASTER\n",dev->index); dev->state = state_error; } if( (status&ACBST_BER) != 0 ) { DEBUG(1,"ACB%d BUS ERROR\n",dev->index); outz( ACBST_BER, ACBST ); outz( 0, ACBST ); // Status Reg bug workaround dev->state = state_error; } if( (status&ACBST_STASTR) != 0 ) { DEBUG(5,"ACB%d STALLED\n",dev->index); outz( ACBST_STASTR, ACBST ); outz( 0, ACBST ); // Status Reg bug workaround return 0; } switch( dev->state ) { case state_error: break; case state_address: addr = dev->addr << 1; flags = dev->flags; if( dev->len > 0 ) { if( (flags&I2C_M_RD) != 0 ) { addr |= 1; dev->state = state_read; if( dev->len == 1 ) acb_snak(dev); } else dev->state = state_write; } else dev->state = state_next; if( (flags&I2C_M_REV_DIR_ADDR) != 0 ) addr ^= 1; DEBUG(5,"ACB%d SEND ADDR %02x\n",dev->index,addr); outz( addr, ACBSDA ); break; case state_read: if( (status&ACBST_XMIT) != 0 ) { acb_dump(dev); return 0; } if( --dev->len <= 0 ) { if( dev->last == 0 ) { acb_start(dev); dev->state = state_next; } else { acb_stop(dev); dev->state = state_idle; } } else if( dev->len == 1 ) acb_snak(dev); ch = inz(ACBSDA); DEBUG(5,"ACB%d RECV DATA %02x %d\n",dev->index,ch,dev->len); *dev->bp++ = ch; break; case state_write: if( (status&ACBST_XMIT) == 0 ) { acb_dump(dev); return 0; } if( (status&ACBST_NEGACK) != 0 ) { DEBUG(5,"ACB%d NAK\n",dev->index); if( dev->last == 0 ) acb_start(dev); outz( ACBST_NEGACK, ACBST ); outz( 0, ACBST ); // Status Reg bug workaround dev->state = state_next; break; } if( dev->len <= 0 ) { dev->state = state_next; break; } ch = *dev->bp++; DEBUG(5,"ACB%d SEND DATA %02x %d\n",dev->index,ch,dev->len); outz( ch, ACBSDA ); if( --dev->len <= 0 ) { if( dev->last == 0 ) acb_start(dev); } break; case state_stop: acb_stop(dev); dev->state = state_idle; break; default: DEBUG(0,"ACB%d, Interrupt in state %d\n",dev->index,dev->state); return 0; } if( dev->state == state_next && dev->last != 0 ) dev->state = state_stop; return 1; } #ifdef POLLED_MODE static void amd_acb_poll(struct acb_dev *dev) { int status, ret; unsigned long tmo; for(;;) { tmo = jiffies + POLL_TIMEOUT; while( jiffies < tmo ) { status = inz(ACBST); while( (status&(ACBST_BER|ACBST_SDAST|ACBST_NEGACK)) != 0 ) { ret = amd_acb_machine(dev, status); if( ret == 0 ) break; return; } yield(); } acb_reset(dev); if( dev->msgn != 0 || dev->state != state_address ) break; if( --dev->retries < 0 ) break; DEBUG(3,"ACB%d RETRY %d\n",dev->index,dev->retries); acb_start(dev); } DEBUG(0,"ACB%d TIMEOUT\n",dev->index); dev->state = state_error; } #endif /* POLLED_MODE */ static int amd_acb_master_xfer(struct i2c_adapter *adp, struct i2c_msg *msg, int num) { struct acb_dev *dev = adp->algo_data; DEBUG(2,"ACB%d XFER %d MSGS\n",dev->index,num); if( num <= 0 ) return 0; down(&dev->sem); acb_start(dev); dev->last = 0; dev->result = 0; dev->state = state_address; dev->count = num; dev->msgn = 0; for(;;) { if( (dev->msgn+1) >= dev->count ) dev->last = 1; dev->flags = msg->flags; if( (dev->flags & I2C_M_TEN) != 0 ) { DEBUG(0,"ACB%d ten bit addresses not supported\n",dev->index); dev->result = -EIO; break; } dev->bp = msg->buf; dev->len = msg->len; dev->addr = msg->addr; dev->retries = adp->retries; dev->state = state_address; DEBUG(2,"ACB%d MSG %d %s %d bytes\n",dev->index,dev->msgn, (dev->flags&I2C_M_RD)!=0 ? "rd" : "wr", dev->len); #ifdef POLLED_MODE while( ((1<state) & STATE_ACTIVE) != 0 ) { amd_acb_poll(dev); } #else /* POLLED_MODE */ #error Interrupt driven mode not implemented #endif /* POLLED_MODE */ if( dev->state == state_idle ) break; if( dev->state != state_next ) { if( dev->result == 0 ) dev->result = -EIO; acb_dump(dev); acb_reset(dev); break; } ++dev->msgn; ++msg; } up(&dev->sem); return dev->result != 0 ? dev->result : num; } #ifdef MOD_INC_USE_COUNT void amd_acb_inc_use(struct i2c_adapter *adapter) { #ifdef MODULE MOD_INC_USE_COUNT; #endif } #endif #ifdef MOD_DEC_USE_COUNT void amd_acb_dec_use(struct i2c_adapter *adapter) { #ifdef MODULE MOD_DEC_USE_COUNT; #endif } #endif static u32 amd_acb_functionality(struct i2c_adapter *adp) { return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; } #ifdef IO_SIOCFG_IN_10 #define CFG_INDEX 0x002E #define CFG_DATA 0x002F #else #define CFG_INDEX 0x015C /* Cygnus/Krill... */ #define CFG_DATA 0x015D #endif #define CFG_IDX_LDN 7 #define CFG_IDX_ACBH 60 #define CFG_IDX_ACBL 61 #define LDN_ACB1 5 /* ACB1 (LDN 5) */ #define LDN_ACB2 6 /* ACB2 (LDN 6) */ static int detect_addr_ldn(struct amd_acb_driver *s) { int i, addr, ldn, io[MAX_DEVICES]; unsigned long flags; ldn = LDN_ACB1; s->n_dev = 2; /* probe addresses */ spin_lock_irqsave(&s->lock, flags); for( i=0; in_dev; ++i ) { outz(CFG_IDX_LDN,CFG_INDEX); outz(ldn,CFG_DATA); outz(CFG_IDX_ACBH,CFG_INDEX); addr = inz(CFG_DATA) << 8; outz(CFG_IDX_ACBL,CFG_INDEX); addr |= inz(CFG_DATA); if( addr == 0 ) break; io[i] = addr; ++ldn; } spin_unlock_irqrestore(&s->lock, flags); /* check addresses */ for( i=0; in_dev; ++i ) { DEBUG(1,"bus %d addr %04x\n",i,io[i]); if( io[i] == 0 ) return -ENODEV; } /* load algo_data */ for( i=0; in_dev; ++i ) { struct acb_dev *dev = &s->dev[i]; dev->io = io[i]; } return 0; } static int detect_addr_bar(struct amd_acb_driver *s) { unsigned long addr; struct acb_dev *dev; /* check addresses */ if( s->pci == NULL ) return -ENODEV; addr = pci_resource_start(s->pci,0); if( addr == 0 ) return -ENODEV; s->n_dev = 1; /* load algo_data */ dev = &s->dev[0]; dev->io = addr; DEBUG(1,"bus addr %04lx\n",addr); return 0; } /* pci vendor and device id for pci to isa bridge */ #define PCI_DEVICE_ID_CYRIX_SC1400_BRIDGE 0x0405 #define PCI_DEVICE_ID_NS_SC1200_BRIDGE 0x0505 #define PCI_DEVICE_ID_NS_LX_BRIDGE 0x002b #define PCI_DEVICE_ID_AMD_LX_BRIDGE 0x2090 #ifndef I2C_HW_ACB_SC1200 #define I2C_HW_ACB_SC1200 (I2C_ALGO_ACB | 0) #endif #ifndef I2C_HW_ACB_SC1400 #define I2C_HW_ACB_SC1400 (I2C_ALGO_ACB | 1) #endif #ifndef I2C_HW_ACB_LX #define I2C_HW_ACB_LX (I2C_ALGO_ACB | 2) #endif #define MODEL(vendor,name,model,probe,n) { \ #name, I2C_HW_ACB_##name, 0x##model, detect_addr_##probe, n, \ PCI_VENDOR_ID_##vendor, PCI_DEVICE_ID_##vendor##_##name##_BRIDGE } static struct pci_id { char *name; int id; int model; int (*probe)(struct amd_acb_driver *s); int n_dev; int vendor; int devid; } pci_isa_devids[] = { MODEL(AMD , LX , 5536, bar, 1), MODEL(NS , LX , 5535, bar, 1), MODEL(NS , SC1200, 1200, ldn, 2), MODEL(CYRIX, SC1400, 1400, ldn, 1), }; static int detect_addr(struct amd_acb_driver *s) { int i, rc; struct acb_dev *dev; struct i2c_adapter *adp; struct i2c_algorithm *algo; struct pci_dev *dp; struct pci_id *idp = &pci_isa_devids[0]; rc = 0; for( i=LENGTH(pci_isa_devids); --i>=0; ++idp ) { dp = pci_find_device(idp->vendor,idp->devid,NULL); if( dp != NULL ) break; } if( i < 0 ) { rc = -ENODEV; goto xit; } if( (rc=pci_request_region(dp,0,"amd_acb")) != 0 ) goto xit; s->pci = dp; s->model = idp->model; DEBUG(0,"model %04x/id %08x\n",idp->model,idp->id); rc = idp->probe(s); if( rc != 0 ) goto xit; s->n_dev = idp->n_dev; spin_lock_init(&s->lock); for( i=0; in_dev; ++i ) { dev = &s->dev[i]; dev->index = i; init_MUTEX(&dev->sem); algo = &dev->algo; strcpy(&algo->name[0],"ACCESS.bus (ACB) algorithm"); algo->id = I2C_ALGO_ACB; algo->master_xfer = amd_acb_master_xfer; algo->functionality = amd_acb_functionality; adp = &dev->adp; sprintf(&adp->name[0],"%s (ACB%d)",idp->name,i+1); adp->id = idp->id; adp->algo = algo; adp->algo_data = dev; #ifdef MOD_IEC_USE_COUNT adp->inc_use = amd_acb_inc_use; #endif #ifdef MOD_DEC_USE_COUNT adp->dec_use = amd_acb_dec_use; #endif DEBUG(3,"ACB%d ADD %08lx\n",dev->index,(unsigned long)adp); rc = i2c_add_adapter(adp); if( rc != 0 ) { DEBUG(0,"Adapter %d registration failed: %d\n",i+1,rc); rc = -ENODEV; goto xit; } rc = acb_probe(dev); if( rc != 0 ) goto xit; } return 0; xit: if( s->pci != NULL ) pci_release_region(s->pci,0); return rc; } static int __init amd_acb_init(void) { int rc; DEBUG(0,"AMD ACCESS.bus Driver\n"); s = kmalloc(sizeof(*s),GFP_KERNEL); if( s == NULL ) return -ENOMEM; memset(s,0,sizeof(*s)); rc = detect_addr(s); if( rc != 0 ) { kfree(s); s = NULL; } return rc; } static void __exit amd_acb_cleanup(void) { int i; struct acb_dev *dev; struct i2c_adapter *adp; DEBUG(0,"removing ACCESS.bus Driver\n"); if( s == NULL ) return; for( i=0; in_dev; ++i ) { dev = &s->dev[i]; adp = &dev->adp; DEBUG(3,"ACB%d DELETE %08lx\n",dev->index,(unsigned long)adp); i2c_del_adapter(adp); pci_release_region(s->pci,0); } kfree(s); s = NULL; } #ifdef EXPORT_NO_SYMBOLS EXPORT_NO_SYMBOLS; #endif module_init(amd_acb_init); module_exit(amd_acb_cleanup);