aboutsummaryrefslogblamecommitdiffstats
path: root/COPYING
blob: ca442d313d86dc67e0a2e5d584b465bd382cbf5c (plain) (tree)



















                                                                        
                                                                               













































































































































































































































































































                                                                            
                                                                              































                                                                             

   NOTE! This copyright does *not* cover user programs that use kernel
 services by normal system calls - this is merely considered normal use
 of the kernel, and does *not* fall under the heading of "derived work".
 Also note that the GPL below is copyrighted by the Free Software
 Foundation, but the instance of code that it refers to (the Linux
 kernel) is copyrighted by me and others who actually wrote it.

 Also note that the only valid version of the GPL as far as the kernel
 is concerned is _this_ particular version of the license (ie v2, not
 v2.2 or v3.x or whatever), unless explicitly otherwise stated.

			Linus Torvalds

----------------------------------------

		    GNU GENERAL PUBLIC LICENSE
		       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
                       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

			    Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

		    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

			    NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

		     END OF TERMS AND CONDITIONS

	    How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) year name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.
n class="hl opt">; case 5: /* FD_DATA */ return sbus_readb(&sun_fdc->data_82077); case 7: /* FD_DIR */ /* XXX: Is DCL on 0x80 in sun4m? */ return sbus_readb(&sun_fdc->dir_82077); }; panic("sun_82072_fd_inb: How did I get here?"); } static void sun_82077_fd_outb(unsigned char value, unsigned long port) { udelay(5); switch(port & 7) { default: printk("floppy: Asked to write to unknown port %lx\n", port); panic("floppy: Port bolixed."); case 2: /* FD_DOR */ /* Happily, the 82077 has a real DOR register. */ sbus_writeb(value, &sun_fdc->dor_82077); break; case 5: /* FD_DATA */ sbus_writeb(value, &sun_fdc->data_82077); break; case 7: /* FD_DCR */ sbus_writeb(value, &sun_fdc->dcr_82077); break; case 4: /* FD_STATUS */ sbus_writeb(value, &sun_fdc->status_82077); break; }; return; } /* For pseudo-dma (Sun floppy drives have no real DMA available to * them so we must eat the data fifo bytes directly ourselves) we have * three state variables. doing_pdma tells our inline low-level * assembly floppy interrupt entry point whether it should sit and eat * bytes from the fifo or just transfer control up to the higher level * floppy interrupt c-code. I tried very hard but I could not get the * pseudo-dma to work in c-code without getting many overruns and * underruns. If non-zero, doing_pdma encodes the direction of * the transfer for debugging. 1=read 2=write */ unsigned char *pdma_vaddr; unsigned long pdma_size; volatile int doing_pdma = 0; /* This is software state */ char *pdma_base = NULL; unsigned long pdma_areasize; /* Common routines to all controller types on the Sparc. */ static void sun_fd_disable_dma(void) { doing_pdma = 0; if (pdma_base) { mmu_unlockarea(pdma_base, pdma_areasize); pdma_base = NULL; } } static void sun_fd_set_dma_mode(int mode) { switch(mode) { case DMA_MODE_READ: doing_pdma = 1; break; case DMA_MODE_WRITE: doing_pdma = 2; break; default: printk("Unknown dma mode %d\n", mode); panic("floppy: Giving up..."); } } static void sun_fd_set_dma_addr(char *buffer) { pdma_vaddr = buffer; } static void sun_fd_set_dma_count(int length) { pdma_size = length; } static void sun_fd_enable_dma(void) { pdma_vaddr = mmu_lockarea(pdma_vaddr, pdma_size); pdma_base = pdma_vaddr; pdma_areasize = pdma_size; } irqreturn_t sparc_floppy_irq(int irq, void *dev_cookie) { if (likely(doing_pdma)) { void __iomem *stat = (void __iomem *) fdc_status; unsigned char *vaddr = pdma_vaddr; unsigned long size = pdma_size; u8 val; while (size) { val = readb(stat); if (unlikely(!(val & 0x80))) { pdma_vaddr = vaddr; pdma_size = size; return IRQ_HANDLED; } if (unlikely(!(val & 0x20))) { pdma_vaddr = vaddr; pdma_size = size; doing_pdma = 0; goto main_interrupt; } if (val & 0x40) { /* read */ *vaddr++ = readb(stat + 1); } else { unsigned char data = *vaddr++; /* write */ writeb(data, stat + 1); } size--; } pdma_vaddr = vaddr; pdma_size = size; /* Send Terminal Count pulse to floppy controller. */ val = readb(auxio_register); val |= AUXIO_AUX1_FTCNT; writeb(val, auxio_register); val &= ~AUXIO_AUX1_FTCNT; writeb(val, auxio_register); doing_pdma = 0; } main_interrupt: return floppy_interrupt(irq, dev_cookie); } static int sun_fd_request_irq(void) { static int once = 0; int error; if(!once) { once = 1; error = request_irq(FLOPPY_IRQ, sparc_floppy_irq, IRQF_DISABLED, "floppy", NULL); return ((error == 0) ? 0 : -1); } return 0; } static void sun_fd_free_irq(void) { } static unsigned int sun_get_dma_residue(void) { /* XXX This isn't really correct. XXX */ return 0; } static int sun_fd_eject(int drive) { set_dor(0x00, 0xff, 0x90); udelay(500); set_dor(0x00, 0x6f, 0x00); udelay(500); return 0; } #ifdef CONFIG_PCI #include <asm/ebus.h> #include <asm/isa.h> #include <asm/ns87303.h> static struct ebus_dma_info sun_pci_fd_ebus_dma; static struct pci_dev *sun_pci_ebus_dev; static int sun_pci_broken_drive = -1; struct sun_pci_dma_op { unsigned int addr; int len; int direction; char *buf; }; static struct sun_pci_dma_op sun_pci_dma_current = { -1U, 0, 0, NULL}; static struct sun_pci_dma_op sun_pci_dma_pending = { -1U, 0, 0, NULL}; extern irqreturn_t floppy_interrupt(int irq, void *dev_id); static unsigned char sun_pci_fd_inb(unsigned long port) { udelay(5); return inb(port); } static void sun_pci_fd_outb(unsigned char val, unsigned long port) { udelay(5); outb(val, port); } static void sun_pci_fd_broken_outb(unsigned char val, unsigned long port) { udelay(5); /* * XXX: Due to SUN's broken floppy connector on AX and AXi * we need to turn on MOTOR_0 also, if the floppy is * jumpered to DS1 (like most PC floppies are). I hope * this does not hurt correct hardware like the AXmp. * (Eddie, Sep 12 1998). */ if (port == ((unsigned long)sun_fdc) + 2) { if (((val & 0x03) == sun_pci_broken_drive) && (val & 0x20)) { val |= 0x10; } } outb(val, port); } #ifdef PCI_FDC_SWAP_DRIVES static void sun_pci_fd_lde_broken_outb(unsigned char val, unsigned long port) { udelay(5); /* * XXX: Due to SUN's broken floppy connector on AX and AXi * we need to turn on MOTOR_0 also, if the floppy is * jumpered to DS1 (like most PC floppies are). I hope * this does not hurt correct hardware like the AXmp. * (Eddie, Sep 12 1998). */ if (port == ((unsigned long)sun_fdc) + 2) { if (((val & 0x03) == sun_pci_broken_drive) && (val & 0x10)) { val &= ~(0x03); val |= 0x21; } } outb(val, port); } #endif /* PCI_FDC_SWAP_DRIVES */ static void sun_pci_fd_enable_dma(void) { BUG_ON((NULL == sun_pci_dma_pending.buf) || (0 == sun_pci_dma_pending.len) || (0 == sun_pci_dma_pending.direction)); sun_pci_dma_current.buf = sun_pci_dma_pending.buf; sun_pci_dma_current.len = sun_pci_dma_pending.len; sun_pci_dma_current.direction = sun_pci_dma_pending.direction; sun_pci_dma_pending.buf = NULL; sun_pci_dma_pending.len = 0; sun_pci_dma_pending.direction = 0; sun_pci_dma_pending.addr = -1U; sun_pci_dma_current.addr = pci_map_single(sun_pci_ebus_dev, sun_pci_dma_current.buf, sun_pci_dma_current.len, sun_pci_dma_current.direction); ebus_dma_enable(&sun_pci_fd_ebus_dma, 1); if (ebus_dma_request(&sun_pci_fd_ebus_dma, sun_pci_dma_current.addr, sun_pci_dma_current.len)) BUG(); } static void sun_pci_fd_disable_dma(void) { ebus_dma_enable(&sun_pci_fd_ebus_dma, 0); if (sun_pci_dma_current.addr != -1U) pci_unmap_single(sun_pci_ebus_dev, sun_pci_dma_current.addr, sun_pci_dma_current.len, sun_pci_dma_current.direction); sun_pci_dma_current.addr = -1U; } static void sun_pci_fd_set_dma_mode(int mode) { if (mode == DMA_MODE_WRITE) sun_pci_dma_pending.direction = PCI_DMA_TODEVICE; else sun_pci_dma_pending.direction = PCI_DMA_FROMDEVICE; ebus_dma_prepare(&sun_pci_fd_ebus_dma, mode != DMA_MODE_WRITE); } static void sun_pci_fd_set_dma_count(int length) { sun_pci_dma_pending.len = length; } static void sun_pci_fd_set_dma_addr(char *buffer) { sun_pci_dma_pending.buf = buffer; } static unsigned int sun_pci_get_dma_residue(void) { return ebus_dma_residue(&sun_pci_fd_ebus_dma); } static int sun_pci_fd_request_irq(void) { return ebus_dma_irq_enable(&sun_pci_fd_ebus_dma, 1); } static void sun_pci_fd_free_irq(void) { ebus_dma_irq_enable(&sun_pci_fd_ebus_dma, 0); } static int sun_pci_fd_eject(int drive) { return -EINVAL; } void sun_pci_fd_dma_callback(struct ebus_dma_info *p, int event, void *cookie) { floppy_interrupt(0, NULL); } /* * Floppy probing, we'd like to use /dev/fd0 for a single Floppy on PCI, * even if this is configured using DS1, thus looks like /dev/fd1 with * the cabling used in Ultras. */ #define DOR (port + 2) #define MSR (port + 4) #define FIFO (port + 5) static void sun_pci_fd_out_byte(unsigned long port, unsigned char val, unsigned long reg) { unsigned char status; int timeout = 1000; while (!((status = inb(MSR)) & 0x80) && --timeout) udelay(100); outb(val, reg); } static unsigned char sun_pci_fd_sensei(unsigned long port) { unsigned char result[2] = { 0x70, 0x00 }; unsigned char status; int i = 0; sun_pci_fd_out_byte(port, 0x08, FIFO); do { int timeout = 1000; while (!((status = inb(MSR)) & 0x80) && --timeout) udelay(100); if (!timeout) break; if ((status & 0xf0) == 0xd0) result[i++] = inb(FIFO); else break; } while (i < 2); return result[0]; } static void sun_pci_fd_reset(unsigned long port) { unsigned char mask = 0x00; unsigned char status; int timeout = 10000; outb(0x80, MSR); do { status = sun_pci_fd_sensei(port); if ((status & 0xc0) == 0xc0) mask |= 1 << (status & 0x03); else udelay(100); } while ((mask != 0x0f) && --timeout); } static int sun_pci_fd_test_drive(unsigned long port, int drive) { unsigned char status, data; int timeout = 1000; int ready; sun_pci_fd_reset(port); data = (0x10 << drive) | 0x0c | drive; sun_pci_fd_out_byte(port, data, DOR); sun_pci_fd_out_byte(port, 0x07, FIFO); sun_pci_fd_out_byte(port, drive & 0x03, FIFO); do { udelay(100); status = sun_pci_fd_sensei(port); } while (((status & 0xc0) == 0x80) && --timeout); if (!timeout) ready = 0; else ready = (status & 0x10) ? 0 : 1; sun_pci_fd_reset(port); return ready; } #undef FIFO #undef MSR #undef DOR #endif /* CONFIG_PCI */ #ifdef CONFIG_PCI static int __init ebus_fdthree_p(struct linux_ebus_device *edev) { if (!strcmp(edev->prom_node->name, "fdthree")) return 1; if (!strcmp(edev->prom_node->name, "floppy")) { const char *compat; compat = of_get_property(edev->prom_node, "compatible", NULL); if (compat && !strcmp(compat, "fdthree")) return 1; } return 0; } #endif #ifdef CONFIG_PCI #undef ISA_FLOPPY_WORKS #ifdef ISA_FLOPPY_WORKS static unsigned long __init isa_floppy_init(void) { struct sparc_isa_bridge *isa_br; struct sparc_isa_device *isa_dev = NULL; for_each_isa(isa_br) { for_each_isadev(isa_dev, isa_br) { if (!strcmp(isa_dev->prom_node->name, "dma")) { struct sparc_isa_device *child = isa_dev->child; while (child) { if (!strcmp(child->prom_node->name, "floppy")) { isa_dev = child; goto isa_done; } child = child->next; } } } } isa_done: if (!isa_dev) return 0; /* We could use DMA on devices behind the ISA bridge, but... * * There is a slight problem. Normally on x86 kit the x86 processor * delays I/O port instructions when the ISA bus "dma in progress" * signal is active. Well, sparc64 systems do not monitor this * signal thus we would need to block all I/O port accesses in software * when a dma transfer is active for some device. */ sun_fdc = (struct sun_flpy_controller *)isa_dev->resource.start; FLOPPY_IRQ = isa_dev->irq; sun_fdops.fd_inb = sun_pci_fd_inb; sun_fdops.fd_outb = sun_pci_fd_outb; can_use_virtual_dma = use_virtual_dma = 1; sun_fdops.fd_enable_dma = sun_fd_enable_dma; sun_fdops.fd_disable_dma = sun_fd_disable_dma; sun_fdops.fd_set_dma_mode = sun_fd_set_dma_mode; sun_fdops.fd_set_dma_addr = sun_fd_set_dma_addr; sun_fdops.fd_set_dma_count = sun_fd_set_dma_count; sun_fdops.get_dma_residue = sun_get_dma_residue; sun_fdops.fd_request_irq = sun_fd_request_irq; sun_fdops.fd_free_irq = sun_fd_free_irq; /* Floppy eject is manual. Actually, could determine this * via presence of 'manual' property in OBP node. */ sun_fdops.fd_eject = sun_pci_fd_eject; fdc_status = (unsigned long) &sun_fdc->status_82077; FLOPPY_MOTOR_MASK = 0xf0; allowed_drive_mask = 0; sun_floppy_types[0] = 0; sun_floppy_types[1] = 4; sun_pci_broken_drive = 1; sun_fdops.fd_outb = sun_pci_fd_broken_outb; return sun_floppy_types[0]; } #endif /* ISA_FLOPPY_WORKS */ #endif static unsigned long __init sun_floppy_init(void) { char state[128]; struct sbus_bus *bus; struct sbus_dev *sdev = NULL; static int initialized = 0; if (initialized) return sun_floppy_types[0]; initialized = 1; for_all_sbusdev (sdev, bus) { if (!strcmp(sdev->prom_name, "SUNW,fdtwo")) break; } if(sdev) { floppy_sdev = sdev; FLOPPY_IRQ = sdev->irqs[0]; } else { #ifdef CONFIG_PCI struct linux_ebus *ebus; struct linux_ebus_device *edev = NULL; unsigned long config = 0; void __iomem *auxio_reg; const char *state_prop; for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { if (ebus_fdthree_p(edev)) goto ebus_done; } } ebus_done: if (!edev) { #ifdef ISA_FLOPPY_WORKS return isa_floppy_init(); #else return 0; #endif } state_prop = of_get_property(edev->prom_node, "status", NULL); if (state_prop && !strncmp(state_prop, "disabled", 8)) return 0; FLOPPY_IRQ = edev->irqs[0]; /* Make sure the high density bit is set, some systems * (most notably Ultra5/Ultra10) come up with it clear. */ auxio_reg = (void __iomem *) edev->resource[2].start; writel(readl(auxio_reg)|0x2, auxio_reg); sun_pci_ebus_dev = ebus->self; spin_lock_init(&sun_pci_fd_ebus_dma.lock); /* XXX ioremap */ sun_pci_fd_ebus_dma.regs = (void __iomem *) edev->resource[1].start; if (!sun_pci_fd_ebus_dma.regs) return 0; sun_pci_fd_ebus_dma.flags = (EBUS_DMA_FLAG_USE_EBDMA_HANDLER | EBUS_DMA_FLAG_TCI_DISABLE); sun_pci_fd_ebus_dma.callback = sun_pci_fd_dma_callback; sun_pci_fd_ebus_dma.client_cookie = NULL; sun_pci_fd_ebus_dma.irq = FLOPPY_IRQ; strcpy(sun_pci_fd_ebus_dma.name, "floppy"); if (ebus_dma_register(&sun_pci_fd_ebus_dma)) return 0; /* XXX ioremap */ sun_fdc = (struct sun_flpy_controller *)edev->resource[0].start; sun_fdops.fd_inb = sun_pci_fd_inb; sun_fdops.fd_outb = sun_pci_fd_outb; can_use_virtual_dma = use_virtual_dma = 0; sun_fdops.fd_enable_dma = sun_pci_fd_enable_dma; sun_fdops.fd_disable_dma = sun_pci_fd_disable_dma; sun_fdops.fd_set_dma_mode = sun_pci_fd_set_dma_mode; sun_fdops.fd_set_dma_addr = sun_pci_fd_set_dma_addr; sun_fdops.fd_set_dma_count = sun_pci_fd_set_dma_count; sun_fdops.get_dma_residue = sun_pci_get_dma_residue; sun_fdops.fd_request_irq = sun_pci_fd_request_irq; sun_fdops.fd_free_irq = sun_pci_fd_free_irq; sun_fdops.fd_eject = sun_pci_fd_eject; fdc_status = (unsigned long) &sun_fdc->status_82077; FLOPPY_MOTOR_MASK = 0xf0; /* * XXX: Find out on which machines this is really needed. */ if (1) { sun_pci_broken_drive = 1; sun_fdops.fd_outb = sun_pci_fd_broken_outb; } allowed_drive_mask = 0; if (sun_pci_fd_test_drive((unsigned long)sun_fdc, 0)) sun_floppy_types[0] = 4; if (sun_pci_fd_test_drive((unsigned long)sun_fdc, 1)) sun_floppy_types[1] = 4; /* * Find NS87303 SuperIO config registers (through ecpp). */ for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { if (!strcmp(edev->prom_node->name, "ecpp")) { config = edev->resource[1].start; goto config_done; } } } config_done: /* * Sanity check, is this really the NS87303? */ switch (config & 0x3ff) { case 0x02e: case 0x15c: case 0x26e: case 0x398: break; default: config = 0; } if (!config) return sun_floppy_types[0]; /* Enable PC-AT mode. */ ns87303_modify(config, ASC, 0, 0xc0); #ifdef PCI_FDC_SWAP_DRIVES /* * If only Floppy 1 is present, swap drives. */ if (!sun_floppy_types[0] && sun_floppy_types[1]) { /* * Set the drive exchange bit in FCR on NS87303, * make sure other bits are sane before doing so. */ ns87303_modify(config, FER, FER_EDM, 0); ns87303_modify(config, ASC, ASC_DRV2_SEL, 0); ns87303_modify(config, FCR, 0, FCR_LDE); config = sun_floppy_types[0]; sun_floppy_types[0] = sun_floppy_types[1]; sun_floppy_types[1] = config; if (sun_pci_broken_drive != -1) { sun_pci_broken_drive = 1 - sun_pci_broken_drive; sun_fdops.fd_outb = sun_pci_fd_lde_broken_outb; } } #endif /* PCI_FDC_SWAP_DRIVES */ return sun_floppy_types[0]; #else return 0; #endif } prom_getproperty(sdev->prom_node, "status", state, sizeof(state)); if(!strncmp(state, "disabled", 8)) return 0; /* * We cannot do sbus_ioremap here: it does request_region, * which the generic floppy driver tries to do once again. * But we must use the sdev resource values as they have * had parent ranges applied. */ sun_fdc = (struct sun_flpy_controller *) (sdev->resource[0].start + ((sdev->resource[0].flags & 0x1ffUL) << 32UL)); /* Last minute sanity check... */ if(sbus_readb(&sun_fdc->status1_82077) == 0xff) { sun_fdc = (struct sun_flpy_controller *)-1; return 0; } sun_fdops.fd_inb = sun_82077_fd_inb; sun_fdops.fd_outb = sun_82077_fd_outb; can_use_virtual_dma = use_virtual_dma = 1; sun_fdops.fd_enable_dma = sun_fd_enable_dma; sun_fdops.fd_disable_dma = sun_fd_disable_dma; sun_fdops.fd_set_dma_mode = sun_fd_set_dma_mode; sun_fdops.fd_set_dma_addr = sun_fd_set_dma_addr; sun_fdops.fd_set_dma_count = sun_fd_set_dma_count; sun_fdops.get_dma_residue = sun_get_dma_residue; sun_fdops.fd_request_irq = sun_fd_request_irq; sun_fdops.fd_free_irq = sun_fd_free_irq; sun_fdops.fd_eject = sun_fd_eject; fdc_status = (unsigned long) &sun_fdc->status_82077; /* Success... */ allowed_drive_mask = 0x01; sun_floppy_types[0] = 4; sun_floppy_types[1] = 0; return sun_floppy_types[0]; } #define EXTRA_FLOPPY_PARAMS static DEFINE_SPINLOCK(dma_spin_lock); #define claim_dma_lock() \ ({ unsigned long flags; \ spin_lock_irqsave(&dma_spin_lock, flags); \ flags; \ }) #define release_dma_lock(__flags) \ spin_unlock_irqrestore(&dma_spin_lock, __flags); #endif /* !(__ASM_SPARC64_FLOPPY_H) */