| 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) 2010 John Crispin <blogic@openwrt.org> |
| 7 | */ |
| 8 | |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/platform_device.h> |
| 11 | #include <linux/leds.h> |
| 12 | #include <linux/gpio.h> |
| 13 | #include <linux/gpio_buttons.h> |
| 14 | #include <linux/mtd/mtd.h> |
| 15 | #include <linux/mtd/partitions.h> |
| 16 | #include <linux/mtd/physmap.h> |
| 17 | #include <linux/input.h> |
| 18 | |
| 19 | #include <lantiq_soc.h> |
| 20 | #include <irq.h> |
| 21 | |
| 22 | #include "../machtypes.h" |
| 23 | #include "../dev-leds-gpio.h" |
| 24 | #include "../dev-gpio-buttons.h" |
| 25 | #include "devices.h" |
| 26 | #include "dev-dwc_otg.h" |
| 27 | |
| 28 | static struct mtd_partition wbmr_partitions[] = |
| 29 | { |
| 30 | { |
| 31 | .name = "uboot", |
| 32 | .offset = 0x0, |
| 33 | .size = 0x40000, |
| 34 | }, |
| 35 | { |
| 36 | .name = "uboot-env", |
| 37 | .offset = 0x40000, |
| 38 | .size = 0x20000, |
| 39 | }, |
| 40 | { |
| 41 | .name = "linux", |
| 42 | .offset = 0x60000, |
| 43 | .size = 0x1f20000, |
| 44 | }, |
| 45 | { |
| 46 | .name = "calibration", |
| 47 | .offset = 0x1fe0000, |
| 48 | .size = 0x20000, |
| 49 | }, |
| 50 | }; |
| 51 | |
| 52 | static struct physmap_flash_data wbmr_flash_data = { |
| 53 | .nr_parts = ARRAY_SIZE(wbmr_partitions), |
| 54 | .parts = wbmr_partitions, |
| 55 | }; |
| 56 | |
| 57 | static struct gpio_led |
| 58 | wbmr_leds_gpio[] __initdata = { |
| 59 | { .name = "soc:blue:movie", .gpio = 20, .active_low = 1, }, |
| 60 | { .name = "soc:red:internet", .gpio = 18, .active_low = 1, }, |
| 61 | { .name = "soc:green:internet", .gpio = 17, .active_low = 1, }, |
| 62 | { .name = "soc:green:adsl", .gpio = 16, .active_low = 1, }, |
| 63 | { .name = "soc:green:wlan", .gpio = 15, .active_low = 1, }, |
| 64 | { .name = "soc:red:security", .gpio = 14, .active_low = 1, }, |
| 65 | { .name = "soc:green:power", .gpio = 1, .active_low = 1, }, |
| 66 | { .name = "soc:red:power", .gpio = 5, .active_low = 1, }, |
| 67 | { .name = "soc:green:usb", .gpio = 28, .active_low = 1, }, |
| 68 | }; |
| 69 | |
| 70 | static struct gpio_keys_button |
| 71 | wbmr_gpio_keys[] __initdata = { |
| 72 | { |
| 73 | .desc = "aoss", |
| 74 | .type = EV_KEY, |
| 75 | .code = BTN_0, |
| 76 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 77 | .gpio = 0, |
| 78 | .active_low = 1, |
| 79 | }, |
| 80 | { |
| 81 | .desc = "reset", |
| 82 | .type = EV_KEY, |
| 83 | .code = BTN_1, |
| 84 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 85 | .gpio = 37, |
| 86 | .active_low = 1, |
| 87 | }, |
| 88 | }; |
| 89 | |
| 90 | static struct ltq_pci_data ltq_pci_data = { |
| 91 | .clock = PCI_CLOCK_INT, |
| 92 | .gpio = PCI_GNT1 | PCI_REQ1, |
| 93 | .irq = { |
| 94 | [14] = INT_NUM_IM0_IRL0 + 22, |
| 95 | }, |
| 96 | }; |
| 97 | |
| 98 | static struct ltq_eth_data ltq_eth_data = { |
| 99 | .mii_mode = PHY_INTERFACE_MODE_RGMII, |
| 100 | }; |
| 101 | |
| 102 | static void __init |
| 103 | wbmr_init(void) |
| 104 | { |
| 105 | #define WMBR_BRN_MAC 0x1fd0024 |
| 106 | |
| 107 | ltq_add_device_leds_gpio(-1, ARRAY_SIZE(wbmr_leds_gpio), wbmr_leds_gpio); |
| 108 | ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL, ARRAY_SIZE(wbmr_gpio_keys), wbmr_gpio_keys); |
| 109 | ltq_register_nor(&wbmr_flash_data); |
| 110 | ltq_register_pci(<q_pci_data); |
| 111 | memcpy_fromio(<q_eth_data.mac.sa_data, |
| 112 | (void *)KSEG1ADDR(LTQ_FLASH_START + WMBR_BRN_MAC), 6); |
| 113 | ltq_register_etop(<q_eth_data); |
| 114 | xway_register_dwc(36); |
| 115 | } |
| 116 | |
| 117 | MIPS_MACHINE(LANTIQ_MACH_WBMR, |
| 118 | "WBMR", |
| 119 | "WBMR", |
| 120 | wbmr_init); |
| 121 | |