#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <machine/autoconf.h>
#include <loongson/dev/leiocreg.h>
#include <loongson/dev/leiocvar.h>
int leioc_match(struct device *, void *, void*);
void leioc_attach(struct device *, struct device *, void *);
const struct cfattach leioc_ca = {
sizeof(struct device), leioc_match, leioc_attach
};
struct cfdriver leioc_cd = {
NULL, "leioc", DV_DULL
};
struct mips_bus_space leioc_io_space_tag = {
.bus_base = PHYS_TO_XKPHYS(0, CCA_NC),
._space_read_1 = generic_space_read_1,
._space_write_1 = generic_space_write_1,
._space_map = generic_space_map,
._space_unmap = generic_space_unmap
};
int
leioc_match(struct device *parent, void *cfg, void *aux)
{
struct mainbus_attach_args *maa = aux;
if (loongson_ver != 0x3a && loongson_ver != 0x3b)
return 0;
if (strcmp(maa->maa_name, leioc_cd.cd_name) != 0)
return 0;
return 1;
}
void
leioc_attach(struct device *parent, struct device *self, void *aux)
{
struct leioc_attach_args laa;
printf("\n");
laa.laa_name = "com";
laa.laa_iot = &leioc_io_space_tag;
laa.laa_base = LEIOC_UART0_BASE;
config_found(self, &laa, NULL);
laa.laa_base = LEIOC_UART1_BASE;
config_found(self, &laa, NULL);
}