Merge tag 'multiplatform' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[deliverable/linux.git] / arch / mips / loongson1 / common / platform.c
CommitLineData
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>
afe046be 16#include <linux/usb/ehci_pdriver.h>
ca585cf9
KC
17#include <asm-generic/sizes.h>
18
19#include <loongson1.h>
20
21#define LS1X_UART(_id) \
22 { \
23 .mapbase = LS1X_UART ## _id ## _BASE, \
24 .irq = LS1X_UART ## _id ## _IRQ, \
25 .iotype = UPIO_MEM, \
26 .flags = UPF_IOREMAP | UPF_FIXED_TYPE, \
27 .type = PORT_16550A, \
28 }
29
30static struct plat_serial8250_port ls1x_serial8250_port[] = {
31 LS1X_UART(0),
32 LS1X_UART(1),
33 LS1X_UART(2),
34 LS1X_UART(3),
35 {},
36};
37
38struct platform_device ls1x_uart_device = {
39 .name = "serial8250",
40 .id = PLAT8250_DEV_PLATFORM,
41 .dev = {
42 .platform_data = ls1x_serial8250_port,
43 },
44};
45
46void __init ls1x_serial_setup(void)
47{
48 struct clk *clk;
49 struct plat_serial8250_port *p;
50
51 clk = clk_get(NULL, "dc");
52 if (IS_ERR(clk))
53 panic("unable to get dc clock, err=%ld", PTR_ERR(clk));
54
55 for (p = ls1x_serial8250_port; p->flags != 0; ++p)
56 p->uartclk = clk_get_rate(clk);
57}
58
59/* Synopsys Ethernet GMAC */
60static struct resource ls1x_eth0_resources[] = {
61 [0] = {
62 .start = LS1X_GMAC0_BASE,
63 .end = LS1X_GMAC0_BASE + SZ_64K - 1,
64 .flags = IORESOURCE_MEM,
65 },
66 [1] = {
67 .name = "macirq",
68 .start = LS1X_GMAC0_IRQ,
69 .flags = IORESOURCE_IRQ,
70 },
71};
72
73static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = {
74 .bus_id = 0,
75 .phy_mask = 0,
76};
77
78static struct plat_stmmacenet_data ls1x_eth_data = {
79 .bus_id = 0,
80 .phy_addr = -1,
81 .mdio_bus_data = &ls1x_mdio_bus_data,
82 .has_gmac = 1,
83 .tx_coe = 1,
84};
85
86struct platform_device ls1x_eth0_device = {
87 .name = "stmmaceth",
88 .id = 0,
89 .num_resources = ARRAY_SIZE(ls1x_eth0_resources),
90 .resource = ls1x_eth0_resources,
91 .dev = {
92 .platform_data = &ls1x_eth_data,
93 },
94};
95
96/* USB EHCI */
97static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32);
98
99static struct resource ls1x_ehci_resources[] = {
100 [0] = {
101 .start = LS1X_EHCI_BASE,
102 .end = LS1X_EHCI_BASE + SZ_32K - 1,
103 .flags = IORESOURCE_MEM,
104 },
105 [1] = {
106 .start = LS1X_EHCI_IRQ,
107 .flags = IORESOURCE_IRQ,
108 },
109};
110
afe046be 111static struct usb_ehci_pdata ls1x_ehci_pdata = {
afe046be
FF
112};
113
ca585cf9 114struct platform_device ls1x_ehci_device = {
afe046be 115 .name = "ehci-platform",
ca585cf9
KC
116 .id = -1,
117 .num_resources = ARRAY_SIZE(ls1x_ehci_resources),
118 .resource = ls1x_ehci_resources,
119 .dev = {
120 .dma_mask = &ls1x_ehci_dmamask,
afe046be 121 .platform_data = &ls1x_ehci_pdata,
ca585cf9
KC
122 },
123};
124
125/* Real Time Clock */
126struct platform_device ls1x_rtc_device = {
127 .name = "ls1x-rtc",
128 .id = -1,
129};
This page took 0.049004 seconds and 5 git commands to generate.