Path: blob/master/arch/mips/alchemy/mtx-1/platform.c
10818 views
/*1* MTX-1 platform devices registration2*3* Copyright (C) 2007-2009, Florian Fainelli <[email protected]>4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA18*/1920#include <linux/init.h>21#include <linux/platform_device.h>22#include <linux/leds.h>23#include <linux/gpio.h>24#include <linux/gpio_keys.h>25#include <linux/input.h>26#include <linux/mtd/partitions.h>27#include <linux/mtd/physmap.h>28#include <mtd/mtd-abi.h>2930#include <asm/mach-au1x00/au1xxx_eth.h>3132static struct gpio_keys_button mtx1_gpio_button[] = {33{34.gpio = 207,35.code = BTN_0,36.desc = "System button",37}38};3940static struct gpio_keys_platform_data mtx1_buttons_data = {41.buttons = mtx1_gpio_button,42.nbuttons = ARRAY_SIZE(mtx1_gpio_button),43};4445static struct platform_device mtx1_button = {46.name = "gpio-keys",47.id = -1,48.dev = {49.platform_data = &mtx1_buttons_data,50}51};5253static struct resource mtx1_wdt_res[] = {54[0] = {55.start = 215,56.end = 215,57.name = "mtx1-wdt-gpio",58.flags = IORESOURCE_IRQ,59}60};6162static struct platform_device mtx1_wdt = {63.name = "mtx1-wdt",64.id = 0,65.num_resources = ARRAY_SIZE(mtx1_wdt_res),66.resource = mtx1_wdt_res,67};6869static struct gpio_led default_leds[] = {70{71.name = "mtx1:green",72.gpio = 211,73}, {74.name = "mtx1:red",75.gpio = 212,76},77};7879static struct gpio_led_platform_data mtx1_led_data = {80.num_leds = ARRAY_SIZE(default_leds),81.leds = default_leds,82};8384static struct platform_device mtx1_gpio_leds = {85.name = "leds-gpio",86.id = -1,87.dev = {88.platform_data = &mtx1_led_data,89}90};9192static struct mtd_partition mtx1_mtd_partitions[] = {93{94.name = "filesystem",95.size = 0x01C00000,96.offset = 0,97},98{99.name = "yamon",100.size = 0x00100000,101.offset = MTDPART_OFS_APPEND,102.mask_flags = MTD_WRITEABLE,103},104{105.name = "kernel",106.size = 0x002c0000,107.offset = MTDPART_OFS_APPEND,108},109{110.name = "yamon env",111.size = 0x00040000,112.offset = MTDPART_OFS_APPEND,113},114};115116static struct physmap_flash_data mtx1_flash_data = {117.width = 4,118.nr_parts = 4,119.parts = mtx1_mtd_partitions,120};121122static struct resource mtx1_mtd_resource = {123.start = 0x1e000000,124.end = 0x1fffffff,125.flags = IORESOURCE_MEM,126};127128static struct platform_device mtx1_mtd = {129.name = "physmap-flash",130.dev = {131.platform_data = &mtx1_flash_data,132},133.num_resources = 1,134.resource = &mtx1_mtd_resource,135};136137static struct __initdata platform_device * mtx1_devs[] = {138&mtx1_gpio_leds,139&mtx1_wdt,140&mtx1_button,141&mtx1_mtd,142};143144static struct au1000_eth_platform_data mtx1_au1000_eth0_pdata = {145.phy_search_highest_addr = 1,146.phy1_search_mac0 = 1,147};148149static int __init mtx1_register_devices(void)150{151int rc;152153au1xxx_override_eth_cfg(0, &mtx1_au1000_eth0_pdata);154155rc = gpio_request(mtx1_gpio_button[0].gpio,156mtx1_gpio_button[0].desc);157if (rc < 0) {158printk(KERN_INFO "mtx1: failed to request %d\n",159mtx1_gpio_button[0].gpio);160goto out;161}162gpio_direction_input(mtx1_gpio_button[0].gpio);163out:164return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs));165}166167arch_initcall(mtx1_register_devices);168169170