Path: blob/master/arch/mips/alchemy/gpr/platform.c
10818 views
/*1* GPR board platform device registration2*3* Copyright (C) 2010 Wolfgang Grandegger <[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/mtd/partitions.h>23#include <linux/mtd/physmap.h>24#include <linux/leds.h>25#include <linux/gpio.h>26#include <linux/i2c.h>27#include <linux/i2c-gpio.h>2829#include <asm/mach-au1x00/au1000.h>3031/*32* Watchdog33*/34static struct resource gpr_wdt_resource[] = {35[0] = {36.start = 1,37.end = 1,38.name = "gpr-adm6320-wdt",39.flags = IORESOURCE_IRQ,40}41};4243static struct platform_device gpr_wdt_device = {44.name = "adm6320-wdt",45.id = 0,46.num_resources = ARRAY_SIZE(gpr_wdt_resource),47.resource = gpr_wdt_resource,48};4950/*51* FLASH52*53* 0x00000000-0x00200000 : "kernel"54* 0x00200000-0x00a00000 : "rootfs"55* 0x01d00000-0x01f00000 : "config"56* 0x01c00000-0x01d00000 : "yamon"57* 0x01d00000-0x01d40000 : "yamon env vars"58* 0x00000000-0x00a00000 : "kernel+rootfs"59*/60static struct mtd_partition gpr_mtd_partitions[] = {61{62.name = "kernel",63.size = 0x00200000,64.offset = 0,65},66{67.name = "rootfs",68.size = 0x00800000,69.offset = MTDPART_OFS_APPEND,70.mask_flags = MTD_WRITEABLE,71},72{73.name = "config",74.size = 0x00200000,75.offset = 0x01d00000,76},77{78.name = "yamon",79.size = 0x00100000,80.offset = 0x01c00000,81},82{83.name = "yamon env vars",84.size = 0x00040000,85.offset = MTDPART_OFS_APPEND,86},87{88.name = "kernel+rootfs",89.size = 0x00a00000,90.offset = 0,91},92};9394static struct physmap_flash_data gpr_flash_data = {95.width = 4,96.nr_parts = ARRAY_SIZE(gpr_mtd_partitions),97.parts = gpr_mtd_partitions,98};99100static struct resource gpr_mtd_resource = {101.start = 0x1e000000,102.end = 0x1fffffff,103.flags = IORESOURCE_MEM,104};105106static struct platform_device gpr_mtd_device = {107.name = "physmap-flash",108.dev = {109.platform_data = &gpr_flash_data,110},111.num_resources = 1,112.resource = &gpr_mtd_resource,113};114115/*116* LEDs117*/118static struct gpio_led gpr_gpio_leds[] = {119{ /* green */120.name = "gpr:green",121.gpio = 4,122.active_low = 1,123},124{ /* red */125.name = "gpr:red",126.gpio = 5,127.active_low = 1,128}129};130131static struct gpio_led_platform_data gpr_led_data = {132.num_leds = ARRAY_SIZE(gpr_gpio_leds),133.leds = gpr_gpio_leds,134};135136static struct platform_device gpr_led_devices = {137.name = "leds-gpio",138.id = -1,139.dev = {140.platform_data = &gpr_led_data,141}142};143144/*145* I2C146*/147static struct i2c_gpio_platform_data gpr_i2c_data = {148.sda_pin = 209,149.sda_is_open_drain = 1,150.scl_pin = 210,151.scl_is_open_drain = 1,152.udelay = 2, /* ~100 kHz */153.timeout = HZ,154};155156static struct platform_device gpr_i2c_device = {157.name = "i2c-gpio",158.id = -1,159.dev.platform_data = &gpr_i2c_data,160};161162static struct i2c_board_info gpr_i2c_info[] __initdata = {163{164I2C_BOARD_INFO("lm83", 0x18),165.type = "lm83"166}167};168169static struct platform_device *gpr_devices[] __initdata = {170&gpr_wdt_device,171&gpr_mtd_device,172&gpr_i2c_device,173&gpr_led_devices,174};175176static int __init gpr_dev_init(void)177{178i2c_register_board_info(0, gpr_i2c_info, ARRAY_SIZE(gpr_i2c_info));179180return platform_add_devices(gpr_devices, ARRAY_SIZE(gpr_devices));181}182device_initcall(gpr_dev_init);183184185