Root/target/linux/lantiq/files/arch/mips/lantiq/xway/mach-gigasx76x.c

1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License version 2 as published
4 * by the Free Software Foundation.
5 *
6 * Copyright (C) 2011 Andrej Vlašić
7 * Copyright (C) 2011 Luka Perkov
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/platform_device.h>
14#include <linux/leds.h>
15#include <linux/gpio.h>
16#include <linux/mtd/mtd.h>
17#include <linux/mtd/partitions.h>
18#include <linux/mtd/physmap.h>
19#include <linux/input.h>
20#include <linux/pci.h>
21#include <linux/phy.h>
22#include <linux/io.h>
23#include <linux/if_ether.h>
24#include <linux/etherdevice.h>
25#include <linux/string.h>
26
27#include <irq.h>
28#include <lantiq_soc.h>
29#include <lantiq_platform.h>
30#include <dev-gpio-leds.h>
31#include <dev-gpio-buttons.h>
32
33#include "../machtypes.h"
34#include "dev-wifi-athxk.h"
35#include "devices.h"
36#include "dev-dwc_otg.h"
37
38#include "mach-gigasx76x.h"
39
40static u8 ltq_ethaddr[6] = { 0 };
41
42static int __init
43setup_ethaddr(char *str)
44{
45    if (!mac_pton(str, ltq_ethaddr))
46        memset(ltq_ethaddr, 0, 6);
47    return 0;
48}
49__setup("ethaddr=", setup_ethaddr);
50
51
52enum {
53    UNKNOWN = 0,
54    SX761,
55    SX762,
56    SX763,
57};
58static u8 board __initdata = SX763;
59
60static int __init
61setup_board(char *str)
62{
63    if (!strcmp(str, "sx761"))
64        board = SX761;
65    else if (!strcmp(str, "sx762"))
66        board = SX762;
67    else if (!strcmp(str, "sx763"))
68        board = SX763;
69    else
70        board = UNKNOWN;
71    return 0;
72}
73__setup("board=", setup_board);
74
75static struct mtd_partition gigasx76x_partitions[] =
76{
77    {
78        .name = "uboot",
79        .offset = 0x0,
80        .size = 0x10000,
81    },
82    {
83        .name = "uboot_env",
84        .offset = 0x10000,
85        .size = 0x10000,
86    },
87    {
88        .name = "linux",
89        .offset = 0x20000,
90        .size = 0x7e0000,
91    },
92};
93
94static struct gpio_led
95gigasx76x_gpio_leds[] __initdata = {
96    { .name = "soc:green:voip", .gpio = 216, },
97    { .name = "soc:green:adsl", .gpio = 217, },
98    { .name = "soc:green:usb", .gpio = 218, },
99    { .name = "soc:green:wifi", .gpio = 219, },
100    { .name = "soc:green:phone2", .gpio = 220, },
101    { .name = "soc:green:phone1", .gpio = 221, },
102    { .name = "soc:green:line", .gpio = 222, },
103    { .name = "soc:green:online", .gpio = 223, },
104};
105
106static struct gpio_keys_button
107gigasx76x_gpio_keys[] __initdata = {
108    {
109        .desc = "wps",
110        .type = EV_KEY,
111        .code = KEY_WPS_BUTTON,
112        .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
113        .gpio = 22,
114        .active_low = 1,
115    },
116    {
117        .desc = "reset",
118        .type = EV_KEY,
119        .code = BTN_0,
120        .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
121        .gpio = 14,
122        .active_low = 0,
123    },
124};
125
126static struct physmap_flash_data gigasx76x_flash_data = {
127    .nr_parts = ARRAY_SIZE(gigasx76x_partitions),
128    .parts = gigasx76x_partitions,
129};
130
131static struct ltq_pci_data ltq_pci_data = {
132    .clock = PCI_CLOCK_INT,
133    .gpio = PCI_GNT1 | PCI_REQ1,
134    .irq = { [14] = INT_NUM_IM0_IRL0 + 22, },
135};
136
137static struct ltq_eth_data ltq_eth_data = {
138    .mii_mode = PHY_INTERFACE_MODE_MII,
139};
140
141static void __init
142gigasx76x_init(void)
143{
144#define GIGASX76X_USB 29
145
146    ltq_register_gpio_stp();
147    ltq_register_nor(&gigasx76x_flash_data);
148    ltq_register_pci(&ltq_pci_data);
149    ltq_register_tapi();
150    ltq_add_device_gpio_leds(-1, ARRAY_SIZE(gigasx76x_gpio_leds), gigasx76x_gpio_leds);
151    ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL, ARRAY_SIZE(gigasx76x_gpio_keys), gigasx76x_gpio_keys);
152    xway_register_dwc(GIGASX76X_USB);
153
154    if (!is_valid_ether_addr(ltq_ethaddr))
155        random_ether_addr(ltq_ethaddr);
156
157    memcpy(&ltq_eth_data.mac.sa_data, ltq_ethaddr, 6);
158    ltq_register_etop(&ltq_eth_data);
159    if (board == SX762)
160        ltq_register_ath5k(sx762_eeprom_data, ltq_ethaddr);
161    else
162        ltq_register_ath5k(sx763_eeprom_data, ltq_ethaddr);
163}
164
165MIPS_MACHINE(LANTIQ_MACH_GIGASX76X,
166            "GIGASX76X",
167            "GIGASX76X - Gigaset SX761,SX762,SX763",
168            gigasx76x_init);
169

Archive Download this file



interactive