dns320l-setup.c
changeset 2 459c75093fd1
child 3 f2f1be1cc4ba
equal deleted inserted replaced
1:3b0d3467d641 2:459c75093fd1
       
     1 /*
       
     2  * arch/arm/mach-kirkwood/dns320l-setup.c
       
     3  *
       
     4  * D-Link DNS-320L Setup File
       
     5  *
       
     6  * This file is licensed under the terms of the GNU General Public
       
     7  * License version 2.  This program is licensed "as is" without any
       
     8  * warranty of any kind, whether express or implied.
       
     9  */
       
    10 
       
    11 #include <linux/kernel.h>
       
    12 #include <linux/init.h>
       
    13 #include <linux/platform_device.h>
       
    14 #include <linux/ata_platform.h>
       
    15 #include <linux/mtd/partitions.h>
       
    16 #include <linux/mv643xx_eth.h>
       
    17 #include <linux/gpio.h>
       
    18 #include <linux/leds.h>
       
    19 #include <asm/mach-types.h>
       
    20 #include <asm/mach/arch.h>
       
    21 #include <mach/kirkwood.h>
       
    22 #include "common.h"
       
    23 #include "mpp.h"
       
    24 #include <linux/sysfs.h>
       
    25 #include <linux/kobject.h>
       
    26 #include <linux/mtd/nand.h>
       
    27 #include <linux/i2c.h>
       
    28 #include <linux/gpio_keys.h>
       
    29 #include <linux/gpio-fan.h>
       
    30 #include <linux/input.h>
       
    31 
       
    32 #define DNS320L_GPIO_LED_SATA1          20
       
    33 #define DNS320L_GPIO_LED_SATA0          21
       
    34 #define DNS320L_GPIO_POWER_SATA         24
       
    35 #define DNS320L_GPIO_LED_USB_BLUE       25
       
    36 #define DNS320L_GPIO_LED_USB_ORANGE     26
       
    37 #define DNS320L_GPIO_BUTTON_USB         27
       
    38 
       
    39 static struct mtd_partition dns320l_nand_parts[] = {
       
    40 	{
       
    41 		.name = "u-boot",
       
    42 		.offset = 0,
       
    43 		.size = SZ_1M
       
    44 	}, {
       
    45 		.name = "uImage",
       
    46 		.offset = MTDPART_OFS_NXTBLK,
       
    47 		.size = 5 * SZ_1M
       
    48 	}, {
       
    49 		.name = "ramdisk",
       
    50 		.offset = MTDPART_OFS_NXTBLK,
       
    51 		.size = 5 * SZ_1M
       
    52 	}, {
       
    53 		.name = "image",
       
    54 		.offset = MTDPART_OFS_NXTBLK,
       
    55 		.size = 100 * SZ_1M
       
    56 	}, {
       
    57 	    .name = "rescue firmware",
       
    58 	    .offset = MTDPART_OFS_NXTBLK,
       
    59 	    .size = 10 * SZ_1M
       
    60 	}, {
       
    61 	    .name = "config",
       
    62 	    .offset = MTDPART_OFS_NXTBLK,
       
    63 	    .size = 5 * SZ_1M
       
    64 	}, {
       
    65 	    .name = "my-dlink",
       
    66 	    .offset = MTDPART_OFS_NXTBLK,
       
    67 	    .size = 2 * SZ_1M
       
    68 	},
       
    69 };
       
    70 
       
    71 
       
    72 static struct mv643xx_eth_platform_data dns320l_ge00_data = {
       
    73 	.phy_addr	= MV643XX_ETH_PHY_ADDR(0),
       
    74 };
       
    75 
       
    76 static struct mv_sata_platform_data dns320l_sata_data = {
       
    77 	.n_ports	= 2,
       
    78 };
       
    79 
       
    80 static void __init dns320l_gpio_register(unsigned gpio, char *name, int def)
       
    81 {
       
    82 	if (gpio_request(gpio, name) == 0 &&
       
    83 	    gpio_direction_output(gpio, 0) == 0) {
       
    84 		gpio_set_value(gpio, def);
       
    85 		if (gpio_export(gpio, 0) != 0)
       
    86 			pr_err("dns320l: Failed to export GPIO %s\n", name);
       
    87 	} else
       
    88 		pr_err("dns320l: Failed to register %s\n", name);
       
    89 }
       
    90 
       
    91 /*****************************************************************************
       
    92  * Buttons
       
    93  ****************************************************************************/
       
    94 
       
    95 static struct gpio_keys_button dns320l_button_pins[] = {
       
    96 	{
       
    97 		.code		= KEY_EJECTCD,
       
    98 		.gpio		= DNS320L_GPIO_BUTTON_USB,
       
    99 		.desc		= "USB unmount button",
       
   100 		.active_low	= 1,
       
   101 	}
       
   102 };
       
   103 
       
   104 static struct gpio_keys_platform_data dns320l_button_data = {
       
   105 	.buttons	= dns320l_button_pins,
       
   106 	.nbuttons	= ARRAY_SIZE(dns320l_button_pins),
       
   107 };
       
   108 
       
   109 static struct platform_device dns320l_button_device = {
       
   110 	.name		= "gpio-keys",
       
   111 	.id		= -1,
       
   112 	.num_resources	= 0,
       
   113 	.dev		= {
       
   114 		.platform_data	= &dns320l_button_data,
       
   115 	}
       
   116 };
       
   117 
       
   118 /*****************************************************************************
       
   119  * LEDs
       
   120  ****************************************************************************/
       
   121 
       
   122 static struct gpio_led dns320l_led_pins[] = {
       
   123 	{
       
   124 		.name	= "dns320l:blue:usb",
       
   125 		.gpio	= DNS320L_GPIO_LED_USB_BLUE,
       
   126 		.default_trigger = "default-on",
       
   127 	},
       
   128 	{
       
   129 		.name	= "dns320l:orange:usb",
       
   130 		.gpio	= DNS320L_GPIO_LED_USB_ORANGE,
       
   131 	},
       
   132 	{
       
   133 	    .name   = "dns320l:blue:sata0",
       
   134 	    .gpio   = DNS320L_GPIO_LED_SATA0,
       
   135 	    .default_trigger = "ide-disk"
       
   136 	},
       
   137 	{
       
   138 	    .name   = "dns320l:blue:sata1",
       
   139 	    .gpio   = DNS320L_GPIO_LED_SATA1,
       
   140 	    .default_trigger = "ide-disk"
       
   141 	},
       
   142 //	{
       
   143 //	    .name   = "dns320l:blue:power",
       
   144 //	    .gpio   = DNS320L_GPIO_LED_POWER,
       
   145 //	},
       
   146 	
       
   147 };
       
   148 
       
   149 static struct gpio_led_platform_data dns320l_led_data = {
       
   150 	.num_leds	= ARRAY_SIZE(dns320l_led_pins),
       
   151 	.leds		= dns320l_led_pins,
       
   152 };
       
   153 
       
   154 static struct platform_device dns320l_led_device = {
       
   155 	.name		= "leds-gpio",
       
   156 	.id		= -1,
       
   157 	.dev		= {
       
   158 		.platform_data	= &dns320l_led_data,
       
   159 	},
       
   160 };
       
   161 
       
   162 /*****************************************************************************
       
   163  * Fan
       
   164  ****************************************************************************/
       
   165 
       
   166 static unsigned int dns320l_mpp_config[] __initdata = {
       
   167     MPP13_UART1_TXD,
       
   168 	MPP14_UART1_RXD,
       
   169 	MPP16_GPIO,
       
   170 	MPP17_GPIO,
       
   171 	MPP18_GPO,
       
   172 	MPP19_GPO,
       
   173 	MPP20_GPIO,    // SATA LED
       
   174 	MPP21_GPIO,    // SATA LED
       
   175 	MPP24_GPIO,    // SATA Power
       
   176 	MPP25_GPIO,    // USB LED Blue
       
   177 	MPP26_GPIO,	   // USB LED Orange
       
   178 	MPP27_GPIO,	   // Button USB Copy
       
   179 	MPP28_GPIO,	
       
   180 	MPP29_GPIO,	 
       
   181 	MPP30_GPIO,
       
   182 	MPP31_GPIO,
       
   183 	MPP32_GPIO,
       
   184 	MPP33_GPO,
       
   185 	MPP34_GPIO,	
       
   186 	MPP35_GPIO,	
       
   187 	MPP36_GPIO,	
       
   188 	MPP37_GPIO,	
       
   189 	MPP38_GPIO,
       
   190 	MPP39_GPIO,	
       
   191 	MPP40_GPIO,	
       
   192 	MPP41_GPIO,
       
   193 	MPP42_GPIO,
       
   194 	MPP43_GPIO,	
       
   195 	MPP44_GPIO,	
       
   196 	MPP45_GPIO,	
       
   197 	MPP46_GPIO,	
       
   198 	MPP47_GPIO,	
       
   199 	MPP48_GPIO,	
       
   200 	MPP49_GPIO,
       
   201 	0
       
   202 };
       
   203 
       
   204 static void __init dns320l_init(void)
       
   205 {
       
   206     /*
       
   207      * Basic setup. Needs to be called early.
       
   208      */
       
   209     
       
   210     kirkwood_init();
       
   211     /* setup gpio pin select */
       
   212     kirkwood_mpp_conf(dns320l_mpp_config);
       
   213     kirkwood_uart0_init();
       
   214     kirkwood_uart1_init();
       
   215     kirkwood_nand_init(ARRAY_AND_SIZE(dns320l_nand_parts), 60);
       
   216 
       
   217     kirkwood_ehci_init();
       
   218     kirkwood_i2c_init();
       
   219     kirkwood_ge00_init(&dns320l_ge00_data);
       
   220     platform_device_register(&dns320l_led_device);
       
   221 	dns320l_gpio_register(DNS320L_GPIO_POWER_SATA, "dns320l:power:sata", 1);
       
   222     kirkwood_sata_init(&dns320l_sata_data);
       
   223     
       
   224     platform_device_register(&dns320l_button_device);
       
   225 }
       
   226 
       
   227 MACHINE_START(DNS320L, "DNS-320L")
       
   228 	/* Maintainer: Andreas Boehler <andreas@aboehler.at> */
       
   229 	.boot_params	= 0x00000100,
       
   230 	.init_machine	= dns320l_init,
       
   231 	.map_io		= kirkwood_map_io,
       
   232 	.init_early	= kirkwood_init_early,
       
   233 	.init_irq	= kirkwood_init_irq,
       
   234 	.timer		= &kirkwood_timer,
       
   235 MACHINE_END
       
   236