File: [local] / prex-old / dev / arm / cats / hostio.c (download)
Revision 1.1, Fri Aug 8 13:18:16 2008 UTC (15 years, 9 months ago) by nbrk
Branch: MAIN
CVS Tags: HEAD
Start implementing basic hardware support for CATS, based on new autoconfiguration
mechanism. This effectively uses bus_space to abstract children of parents.
Some info about these drivers:
hostio is a host memory-mapped i/o - one and only child of 'root';
footbridge is just a proxy for now;
fuart is a DC21285 UART driver which fills uart_attach_args and attaches
com, which is machine independent driver;
This all is not finished yet (just quick hacks), but commit it so i could work at home.
|
/*
* $Id: hostio.c,v 1.1 2008/08/08 13:18:16 nbrk Exp $
*/
#include <driver.h>
#include <bus.h>
#include "hostiovar.h"
/*
* Autoconf glue.
*/
int hostio_match(struct device *parent, void *aux);
int hostio_attach(struct device *parent, struct device *self, void *aux);
struct driver hostio_drv = {
"hostio", /* name */
sizeof(struct hostio_softc),/* datasize */
hostio_match, /* match */
hostio_attach, /* attach */
NULL, /* detach */
-1 /* nunits XXX */
};
int
hostio_match(struct device *parent, void *aux)
{
return(1);
}
int
hostio_attach(struct device *parent, struct device *self, void *aux)
{
struct hostio_softc *sc = self->dv_data;
printk("\n");
sc->sc_iot = &hostio_bs_tag;
/*
* Nothing to do. Just pass our bus_space_tag_t to upper layers.
*/
config_search_children(self, sc->sc_iot);
return(0);
}
int
hostio_map(void *cookie, bus_addr_t addr, bus_size_t size, int flags, bus_space_handle_t *ioh)
{
/* XXX */
/* *ioh = kmem_map(addr, size); */
*ioh = addr;
return(0);
}
uint8_t
hostio_read_1(void *cookie, bus_space_handle_t ioh, bus_size_t off)
{
uint8_t d;
d = *(volatile uint32_t *)(ioh + off);
return(d);
}
uint16_t
hostio_read_2(void *cookie, bus_space_handle_t ioh, bus_size_t off)
{
uint16_t d;
d = *(volatile uint32_t *)(ioh + off);
return(d);
}
uint32_t
hostio_read_4(void *cookie, bus_space_handle_t ioh, bus_size_t off)
{
uint32_t d;
d = *(volatile uint32_t *)(ioh + off);
return(d);
}
void
hostio_write_1(void *cookie, bus_space_handle_t ioh, bus_size_t off, uint8_t data)
{
*(volatile uint32_t *)(ioh + off) = data;
}
void
hostio_write_2(void *cookie, bus_space_handle_t ioh, bus_size_t off, uint16_t data)
{
*(volatile uint32_t *)(ioh + off) = data;
}
void
hostio_write_4(void *cookie, bus_space_handle_t ioh, bus_size_t off, uint32_t data)
{
*(volatile uint32_t *)(ioh + off) = data;
}