1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/* $OpenBSD: leioc.c,v 1.1 2016/11/17 14:41:21 visa Exp $ */
/*
* Copyright (c) 2016 Visa Hankala
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Driver for the Loongson 3A low-end IO controller.
*
* Each Loongson 3A CPU package has a built-in `low-end' IO controller.
* The controller provides GPIO, LPCI, PCI, SPI, and UART interfaces.
*/
#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);
}
|