/* SPDX-License-Identifier: GPL-2.0 */ /* header file for DIO boards for the HP300 architecture. * Maybe this should handle DIO-II later? * The general structure of this is vaguely based on how * the Amiga port handles Zorro boards. * Copyright (C) Peter Maydell 05/1998 <pmaydell@chiark.greenend.org.uk> * Converted to driver model Jochen Friedrich <jochen@scram.de> * * The board IDs are from the NetBSD kernel, which for once provided * helpful comments... * * This goes with drivers/dio/dio.c
*/
#ifndef _LINUX_DIO_H #define _LINUX_DIO_H
/* The DIO boards in a system are distinguished by 'select codes' which * range from 0-63 (DIO) and 132-255 (DIO-II). * The DIO board with select code sc is located at physical address * 0x600000 + sc * 0x10000 * So DIO cards cover [0x600000-0x800000); the areas [0x200000-0x400000) and * [0x800000-0x1000000) are for additional space required by things * like framebuffers. [0x400000-0x600000) is for miscellaneous internal I/O. * On Linux, this is currently all mapped into the virtual address space * at 0xf0000000 on bootup. * DIO-II boards are at 0x1000000 + (sc - 132) * 0x400000 * which is address range [0x1000000-0x20000000) -- too big to map completely, * so currently we just don't handle DIO-II boards. It wouldn't be hard to * do with ioremap() though.
*/
#include <linux/device.h>
#ifdef __KERNEL__
#include <asm/hp300hw.h>
typedef __u16 dio_id;
/* * DIO devices
*/
struct dio_dev { struct dio_bus *bus;
dio_id id; int scode; struct dio_driver *driver; /* which driver has allocated this device */ struct device dev; /* Generic device interface */
u8 ipl; char name[64]; struct resource resource;
};
struct dio_bus { struct list_head devices; /* list of devices on this bus */ unsignedint num_resources; /* number of resources */ struct resource resources[2]; /* address space routed to this bus */ struct device dev; char name[10];
};
externstruct dio_bus dio_bus; /* Single DIO bus */ externconststruct bus_type dio_bus_type;
/* * DIO device IDs
*/
struct dio_device_id {
dio_id id; /* Device ID or DIO_WILDCARD */ unsignedlong driver_data; /* Data private to the driver */
};
/* * DIO device drivers
*/
struct dio_driver { struct list_head node; char *name; conststruct dio_device_id *id_table; /* NULL if wants all devices */ int (*probe)(struct dio_dev *z, conststruct dio_device_id *id); /* New device inserted */ void (*remove)(struct dio_dev *z); /* Device removed (NULL if not a hot-plug capable driver) */ struct device_driver driver;
};
/* DIO/DIO-II boards all have the following 8bit registers. * These are offsets from the base of the device.
*/ #define DIO_IDOFF 0x01 /* primary device ID */ #define DIO_IPLOFF 0x03 /* interrupt priority level */ #define DIO_SECIDOFF 0x15 /* secondary device ID */ #define DIOII_SIZEOFF 0x101 /* device size, DIO-II only */ #define DIO_VIRADDRBASE 0xf0000000UL /* vir addr where IOspace is mapped */
#define DIO_BASE 0x600000 /* start of DIO space */ #define DIO_END 0x1000000 /* end of DIO space */ #define DIO_DEVSIZE 0x10000 /* size of a DIO device */
#define DIOII_BASE 0x01000000 /* start of DIO-II space */ #define DIOII_END 0x20000000 /* end of DIO-II space */ #define DIOII_DEVSIZE 0x00400000 /* size of a DIO-II device */
/* Highest valid select code. If we add DIO-II support this should become * 256 for everything except HP320, which only has DIO.
*/ #define DIO_SCMAX (hp300_model == HP_320 ? 32 : 256) #define DIOII_SCBASE 132 /* lowest DIO-II select code */ #define DIO_SCINHOLE(scode) (((scode) >= 32) && ((scode) < DIOII_SCBASE)) #define DIO_ISDIOII(scode) ((scode) >= 132 && (scode) < 256)
/* macros to read device IDs, given base address */ #define DIO_ID(baseaddr) in_8((baseaddr) + DIO_IDOFF) #define DIO_SECID(baseaddr) in_8((baseaddr) + DIO_SECIDOFF)
/* find the size of a DIO-II board's address space. * DIO boards are all fixed length.
*/ #define DIOII_SIZE(baseaddr) ((in_8((baseaddr) + DIOII_SIZEOFF) + 1) * 0x100000)
/* general purpose macro for both DIO and DIO-II */ #define DIO_SIZE(scode, base) (DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE)
/* The hardware has primary and secondary IDs; we encode these in a single * int as PRIMARY ID & (SECONDARY ID << 8). * In practice this is only important for framebuffers, * and everybody else just sets ID fields equal to the DIO_ID_FOO value.
*/ #define DIO_ENCODE_ID(pr,sec) ((((int)sec & 0xff) << 8) | ((int)pr & 0xff)) /* macro to determine whether a given primary ID requires a secondary ID byte */ #define DIO_NEEDSSECID(id) ((id) == DIO_ID_FBUFFER) #define DIO_WILDCARD 0xff
/* Similar to the helpers above, these manipulate per-dio_dev * driver-specific data. They are really just a wrapper around * the generic device structure functions of these calls.
*/ staticinlinevoid *dio_get_drvdata (struct dio_dev *d)
{ return dev_get_drvdata(&d->dev);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.