/*
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
*
* This software may be used, modified, copied, distributed, and sold, in
* both source and binary form provided that the above copyright, these
* terms and the following disclaimer are retained. The name of the author
* and/or the contributor may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTOR BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION.
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Portions copyright (C) 1993, David Greenman. This software may be used,
* modified, copied, distributed, and sold, in both source and binary form
* provided that the above copyright and these terms are retained. Under no
* circumstances is the author responsible for the proper functioning of this
* software, nor does the author assume any responsibility for damages
* incurred with its use.
*/
struct fe_simple_probe_struct {
uint8_t port; /* Offset from the base I/O address. */
uint8_t mask; /* Bits to be checked. */
uint8_t bits; /* Values to be compared against. */
};
static inline int fe_simple_probe(bus_space_tag_t, bus_space_handle_t,
struct fe_simple_probe_struct const *);
static int fmv_find(bus_space_tag_t, bus_space_handle_t, int *, int *);
/*
* See if the sepcified address is valid for FMV-180 series.
*/
for (i = 0; i < NFMV_IOMAP; i++)
if (fmv_iomap[i] == ia->ia_io[0].ir_addr)
break;
if (i == NFMV_IOMAP) {
DPRINTF("%s: unknown iobase 0x%x\n",
__func__, ia->ia_io[0].ir_addr);
return 0;
}
/*
* Check for specific bits in specific registers have specific values.
*/
static inline int
fe_simple_probe(bus_space_tag_t iot, bus_space_handle_t ioh,
const struct fe_simple_probe_struct *sp)
{
uint8_t val;
const struct fe_simple_probe_struct *p;
/*
* Hardware (vendor) specific probe routines.
*/
/*
* Probe Fujitsu FMV-180 series boards and get iobase and irq from
* board.
*/
static int
fmv_find(bus_space_tag_t iot, bus_space_handle_t ioh, int *iobase, int *irq)
{
uint8_t config;
static const int fmv_irqmap[4] = { 3, 7, 10, 15 };
static const struct fe_simple_probe_struct probe_table[] = {
{ FE_DLCR2, 0x70, 0x00 },
{ FE_DLCR4, 0x08, 0x00 },
/* { FE_DLCR5, 0x80, 0x00 }, Doesn't work. */
{ FE_FMV0, FE_FMV0_MAGIC_MASK, FE_FMV0_MAGIC_VALUE },
{ FE_FMV1, FE_FMV1_MAGIC_MASK, FE_FMV1_MAGIC_VALUE },
{ FE_FMV3, FE_FMV3_EXTRA_MASK, FE_FMV3_EXTRA_VALUE },
#if 1
/*
* Test *vendor* part of the station address for Fujitsu.
* The test will gain reliability of probe process, but
* it rejects FMV-180 clone boards manufactured by other vendors.
* We have to turn the test off when such cards are made available.
*/
{ FE_FMV4, 0xFF, 0x00 },
{ FE_FMV5, 0xFF, 0x00 },
{ FE_FMV6, 0xFF, 0x0E },
#else
/*
* We can always verify the *first* 2 bits (in Ehternet
* bit order) are "no multicast" and "no local" even for
* unknown vendors.
*/
{ FE_FMV4, 0x03, 0x00 },
#endif
{ 0, 0x00, 0x00 },
};
/* Check if our I/O address matches config info on EEPROM. */
config = bus_space_read_1(iot, ioh, FE_FMV2);
*iobase = fmv_iomap[(config & FE_FMV2_ADDR) >> FE_FMV2_ADDR_SHIFT];
/*
* Determine which IRQ to be used.
*
* In this version, we always get an IRQ assignment from the
* FMV-180's configuration EEPROM, ignoring that specified in
* config file.
*/
*irq = fmv_irqmap[(config & FE_FMV2_IRQ) >> FE_FMV2_IRQ_SHIFT];