Skip to content

Commit 85af253

Browse files
committed
imx: add glue to make imx devices attach to fdtbus
This is the first commit of probably a few that will make the imx drivers attach to our new fdtbus. The goal is to have nearly everything taken from FDT.
1 parent fdf430a commit 85af253

File tree

20 files changed

+638
-190
lines changed

20 files changed

+638
-190
lines changed

sys/arch/armv7/armv7/platform.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ platform_init()
4343
extern struct armv7_platform omap_platform;
4444
extern struct armv7_platform sunxi_platform;
4545

46+
if (fdt_next_node(0)) {
47+
platform = &fdt_platform;
48+
return;
49+
}
50+
4651
switch (board_id) {
4752
#if NEXYNOS > 0
4853
case BOARD_ID_EXYNOS5_CHROMEBOOK:
@@ -75,9 +80,7 @@ platform_init()
7580
break;
7681
#endif
7782
default:
78-
if (fdt_next_node(0) == NULL)
79-
printf("%s: board type 0x%x unknown", __func__, board_id);
80-
platform = &fdt_platform;
83+
panic("%s: board type 0x%x unknown", __func__, board_id);
8184
break;
8285
}
8386
}

sys/arch/armv7/conf/generic.imx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,34 @@ imx0 at mainbus?
33

44
# iMX on-chip devices
55
imxccm* at imx? # clock control module
6+
imxccm* at fdt? # clock control module
67
imxtemp* at imx? # temperature sensor
78
imxiomuxc* at imx? # iomux controller
9+
imxiomuxc* at fdt? # iomux controller
810
imxdog* at imx? # watchdog timer
11+
imxdog* at fdt? # watchdog timer
912
imxocotp* at imx? # on-chip otp controller
13+
imxocotp* at fdt? # on-chip otp controller
1014
imxgpio* at imx? # user-visible GPIO pins?
15+
imxgpio* at fdt? # user-visible GPIO pins?
1116
imxesdhc* at imx? # SDHC controller
17+
#imxesdhc* at fdt? # SDHC controller
1218
imxenet* at imx? # ethernet
19+
#imxenet* at fdt? # ethernet
1320
imxuart* at imx? # onboard uarts
21+
imxuart* at fdt? # onboard uarts
1422
imxiic* at imx? # i2c
23+
imxiic* at fdt? # i2c
1524

1625
#imxpcibr* at imx? # PCIe controller host bridge
1726
#pci* at imxpcibr?
1827

19-
ahci* at imx? # AHCI/SATA
28+
imxahci* at imx? # AHCI/SATA
29+
ahci* at imxahci? # AHCI/SATA
2030

21-
ehci* at imx? # EHCI (shim)
31+
imxehci* at imx? # EHCI
32+
imxehci* at fdt? # EHCI
33+
ehci* at imxehci? # EHCI (shim)
2234

2335
sdmmc* at imxesdhc? # SD/MMC bus
2436

sys/arch/armv7/exynos/exynos.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@
2020
#include <sys/systm.h>
2121

2222
#include <machine/bus.h>
23+
#include <machine/fdt.h>
2324

2425
#include <armv7/armv7/armv7var.h>
2526

2627
static int
2728
exynos_match(struct device *parent, void *cfdata, void *aux)
2829
{
30+
/* If we're running with fdt, do not attach. */
31+
/* XXX: Find a better way. */
32+
if (fdt_next_node(0))
33+
return (0);
34+
2935
switch (board_id)
3036
{
3137
case BOARD_ID_EXYNOS5_CHROMEBOOK:

sys/arch/armv7/fdt/fdt_machdep.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <armv7/armv7/armv7var.h>
3131
#include <armv7/armv7/armv7_machdep.h>
3232
#include <armv7/virt/pl011var.h>
33+
#include <armv7/imx/imxuartvar.h>
3334

3435
extern int comcnspeed;
3536
extern int comcnmode;
@@ -45,12 +46,24 @@ static void
4546
fdt_platform_init_cons(void)
4647
{
4748
void *node;
49+
char *stdout_path;
4850
struct fdt_memory mem;
4951

5052
if ((node = fdt_find_compatible("arm,pl011")) != NULL &&
5153
!fdt_get_memory_address(node, 0, &mem))
5254
pl011cnattach(&armv7_bs_tag, mem.addr, comcnspeed, comcnmode);
5355

56+
if ((node = fdt_find_node("/chosen")) == NULL ||
57+
!fdt_node_property(node, "stdout-path", &stdout_path))
58+
return;
59+
60+
if ((node = fdt_find_node(stdout_path)) == NULL)
61+
return;
62+
63+
if (fdt_node_compatible("fsl,imx6q-uart", node) &&
64+
!fdt_get_memory_address(node, 0, &mem))
65+
imxuartcnattach(&armv7_bs_tag, mem.addr, comcnspeed, comcnmode);
66+
5467
comdefaultrate = comcnspeed;
5568
}
5669

sys/arch/armv7/imx/files.imx

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,67 @@ file arch/armv7/imx/imx_machdep.c imx needs-flag
77
file arch/armv7/imx/imx.c imx
88
file arch/armv7/imx/imx6.c imx
99

10-
# serial ports
11-
device imxuart
12-
attach imxuart at imx
13-
file arch/armv7/imx/imxuart.c imxuart
10+
device imxocotp
11+
attach imxocotp at imx
12+
attach imxocotp at fdt with imxocotp_fdt
13+
file arch/armv7/imx/imxocotp.c imxocotp | imxocotp_fdt
1414

1515
device imxccm
1616
attach imxccm at imx
17-
file arch/armv7/imx/imxccm.c imxccm
17+
attach imxccm at fdt with imxccm_fdt
18+
file arch/armv7/imx/imxccm.c imxccm | imxccm_fdt
1819

1920
device imxtemp
2021
attach imxtemp at imx
2122
file arch/armv7/imx/imxtemp.c imxtemp
2223

2324
device imxiomuxc
2425
attach imxiomuxc at imx
25-
file arch/armv7/imx/imxiomuxc.c imxiomuxc
26+
attach imxiomuxc at fdt with imxiomuxc_fdt
27+
file arch/armv7/imx/imxiomuxc.c imxiomuxc | imxiomuxc_fdt
2628

2729
device imxdog
2830
attach imxdog at imx
29-
file arch/armv7/imx/imxdog.c imxdog
31+
attach imxdog at fdt with imxdog_fdt
32+
file arch/armv7/imx/imxdog.c imxdog | imxdog_fdt
3033

31-
device imxocotp
32-
attach imxocotp at imx
33-
file arch/armv7/imx/imxocotp.c imxocotp
34+
# serial ports
35+
device imxuart
36+
attach imxuart at imx
37+
attach imxuart at fdt with imxuart_fdt
38+
file arch/armv7/imx/imxuart.c imxuart | imxuart_fdt
3439

3540
device imxgpio
3641
attach imxgpio at imx
37-
file arch/armv7/imx/imxgpio.c imxgpio
42+
attach imxgpio at fdt with imxgpio_fdt
43+
file arch/armv7/imx/imxgpio.c imxgpio | imxgpio_fdt
3844

3945
device imxiic: i2cbus
4046
attach imxiic at imx
41-
file arch/armv7/imx/imxiic.c imxiic
47+
attach imxiic at fdt with imxiic_fdt
48+
file arch/armv7/imx/imxiic.c imxiic | imxiic_fdt
49+
50+
device imxesdhc: sdmmcbus
51+
attach imxesdhc at imx
52+
#attach imxesdhc at fdt with imxesdhc_fdt
53+
file arch/armv7/imx/imxesdhc.c imxesdhc | imxesdhc_fdt
54+
55+
device imxehci {}
56+
attach imxehci at imx
57+
attach imxehci at fdt with imxehci_fdt
58+
attach ehci at imxehci with ehci_imx
59+
file arch/armv7/imx/imxehci.c imxehci | imxehci_fdt
4260

4361
device imxenet: ether, ifnet, mii, ifmedia
4462
attach imxenet at imx
45-
file arch/armv7/imx/imxenet.c imxenet
63+
#attach imxenet at fdt with imxenet_fdt
64+
file arch/armv7/imx/imxenet.c imxenet | imxenet_fdt
4665

47-
attach ehci at imx with imxehci
48-
file arch/armv7/imx/imxehci.c imxehci
49-
50-
device imxesdhc: sdmmcbus
51-
attach imxesdhc at imx
52-
file arch/armv7/imx/imxesdhc.c imxesdhc
66+
device imxahci {}
67+
attach imxahci at imx
68+
attach imxahci at fdt with imxahci_fdt
69+
attach ahci at imxahci with ahci_imx
70+
file arch/armv7/imx/imxahci.c imxahci | imxahci_fdt
5371

5472
device imxpchb
5573
attach imxpchb at imx
@@ -71,6 +89,3 @@ file arch/armv7/imx/maxim7301.c maxgpio
7189
#device imxpcibr {} : pcibus
7290
#attach imxpcibr at imx
7391
#file arch/armv7/imx/imxpcibr.c imxpcibr
74-
75-
attach ahci at imx with imxahci
76-
file arch/armv7/imx/imxahci.c imxahci

sys/arch/armv7/imx/imx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@
2020
#include <sys/systm.h>
2121

2222
#include <machine/bus.h>
23+
#include <machine/fdt.h>
2324

2425
#include <armv7/armv7/armv7var.h>
2526

2627
static int
2728
imx_match(struct device *parent, void *cfdata, void *aux)
2829
{
30+
/* If we're running with fdt, do not attach. */
31+
/* XXX: Find a better way. */
32+
if (fdt_next_node(0))
33+
return (0);
34+
2935
switch (board_id)
3036
{
3137
case BOARD_ID_IMX6_CUBOXI:

sys/arch/armv7/imx/imx6.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,11 @@
6363
#define USBPHY1_ADDR 0x020c9000
6464
#define USBPHY2_ADDR 0x020ca000
6565
#define USBOTG_ADDR 0x02184000
66-
#define USBOTG_EHCI_ADDR 0x02184100
6766
#define USBUH1_ADDR 0x02184200
68-
#define USBUH1_EHCI_ADDR 0x02184300
6967
#define USBUH2_ADDR 0x02184400
70-
#define USBUH2_EHCI_ADDR 0x02184500
7168
#define USBUH3_ADDR 0x02184600
72-
#define USBUH3_EHCI_ADDR 0x02184700
7369
#define USBNC_ADDR 0x02184800
74-
#define USBx_SIZE 0x100
70+
#define USBx_SIZE 0x200
7571

7672
#define USBH1_IRQ 40
7773
#define USBH2_IRQ 41
@@ -313,7 +309,6 @@ struct armv7_dev imx6_devs[] = {
313309
{ .name = "ehci",
314310
.unit = 0,
315311
.mem = {
316-
{ USBUH1_EHCI_ADDR, USBx_SIZE },
317312
{ USBUH1_ADDR, USBx_SIZE },
318313
{ USBPHY2_ADDR, USBPHYx_SIZE },
319314
{ USBNC_ADDR, USBx_SIZE },
@@ -324,7 +319,6 @@ struct armv7_dev imx6_devs[] = {
324319
{ .name = "ehci",
325320
.unit = 1,
326321
.mem = {
327-
{ USBOTG_EHCI_ADDR, USBx_SIZE },
328322
{ USBOTG_ADDR, USBx_SIZE },
329323
{ USBPHY1_ADDR, USBPHYx_SIZE },
330324
{ USBNC_ADDR, USBx_SIZE },

0 commit comments

Comments
 (0)