]>
Commit | Line | Data |
---|---|---|
ca585cf9 KC |
1 | /* |
2 | * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License as published by the | |
6 | * Free Software Foundation; either version 2 of the License, or (at your | |
7 | * option) any later version. | |
8 | */ | |
9 | ||
10 | #include <linux/clk.h> | |
11 | #include <linux/dma-mapping.h> | |
12 | #include <linux/err.h> | |
13 | #include <linux/phy.h> | |
14 | #include <linux/serial_8250.h> | |
15 | #include <linux/stmmac.h> | |
16 | #include <asm-generic/sizes.h> | |
17 | ||
18 | #include <loongson1.h> | |
19 | ||
20 | #define LS1X_UART(_id) \ | |
21 | { \ | |
22 | .mapbase = LS1X_UART ## _id ## _BASE, \ | |
23 | .irq = LS1X_UART ## _id ## _IRQ, \ | |
24 | .iotype = UPIO_MEM, \ | |
25 | .flags = UPF_IOREMAP | UPF_FIXED_TYPE, \ | |
26 | .type = PORT_16550A, \ | |
27 | } | |
28 | ||
29 | static struct plat_serial8250_port ls1x_serial8250_port[] = { | |
30 | LS1X_UART(0), | |
31 | LS1X_UART(1), | |
32 | LS1X_UART(2), | |
33 | LS1X_UART(3), | |
34 | {}, | |
35 | }; | |
36 | ||
37 | struct platform_device ls1x_uart_device = { | |
38 | .name = "serial8250", | |
39 | .id = PLAT8250_DEV_PLATFORM, | |
40 | .dev = { | |
41 | .platform_data = ls1x_serial8250_port, | |
42 | }, | |
43 | }; | |
44 | ||
45 | void __init ls1x_serial_setup(void) | |
46 | { | |
47 | struct clk *clk; | |
48 | struct plat_serial8250_port *p; | |
49 | ||
50 | clk = clk_get(NULL, "dc"); | |
51 | if (IS_ERR(clk)) | |
52 | panic("unable to get dc clock, err=%ld", PTR_ERR(clk)); | |
53 | ||
54 | for (p = ls1x_serial8250_port; p->flags != 0; ++p) | |
55 | p->uartclk = clk_get_rate(clk); | |
56 | } | |
57 | ||
58 | /* Synopsys Ethernet GMAC */ | |
59 | static struct resource ls1x_eth0_resources[] = { | |
60 | [0] = { | |
61 | .start = LS1X_GMAC0_BASE, | |
62 | .end = LS1X_GMAC0_BASE + SZ_64K - 1, | |
63 | .flags = IORESOURCE_MEM, | |
64 | }, | |
65 | [1] = { | |
66 | .name = "macirq", | |
67 | .start = LS1X_GMAC0_IRQ, | |
68 | .flags = IORESOURCE_IRQ, | |
69 | }, | |
70 | }; | |
71 | ||
72 | static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = { | |
73 | .bus_id = 0, | |
74 | .phy_mask = 0, | |
75 | }; | |
76 | ||
77 | static struct plat_stmmacenet_data ls1x_eth_data = { | |
78 | .bus_id = 0, | |
79 | .phy_addr = -1, | |
80 | .mdio_bus_data = &ls1x_mdio_bus_data, | |
81 | .has_gmac = 1, | |
82 | .tx_coe = 1, | |
83 | }; | |
84 | ||
85 | struct platform_device ls1x_eth0_device = { | |
86 | .name = "stmmaceth", | |
87 | .id = 0, | |
88 | .num_resources = ARRAY_SIZE(ls1x_eth0_resources), | |
89 | .resource = ls1x_eth0_resources, | |
90 | .dev = { | |
91 | .platform_data = &ls1x_eth_data, | |
92 | }, | |
93 | }; | |
94 | ||
95 | /* USB EHCI */ | |
96 | static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32); | |
97 | ||
98 | static struct resource ls1x_ehci_resources[] = { | |
99 | [0] = { | |
100 | .start = LS1X_EHCI_BASE, | |
101 | .end = LS1X_EHCI_BASE + SZ_32K - 1, | |
102 | .flags = IORESOURCE_MEM, | |
103 | }, | |
104 | [1] = { | |
105 | .start = LS1X_EHCI_IRQ, | |
106 | .flags = IORESOURCE_IRQ, | |
107 | }, | |
108 | }; | |
109 | ||
110 | struct platform_device ls1x_ehci_device = { | |
111 | .name = "ls1x-ehci", | |
112 | .id = -1, | |
113 | .num_resources = ARRAY_SIZE(ls1x_ehci_resources), | |
114 | .resource = ls1x_ehci_resources, | |
115 | .dev = { | |
116 | .dma_mask = &ls1x_ehci_dmamask, | |
117 | }, | |
118 | }; | |
119 | ||
120 | /* Real Time Clock */ | |
121 | struct platform_device ls1x_rtc_device = { | |
122 | .name = "ls1x-rtc", | |
123 | .id = -1, | |
124 | }; |