linux-3.1/dns320l-setup.c
changeset 4 1b9d05c730cb
equal deleted inserted replaced
3:f2f1be1cc4ba 4:1b9d05c730cb
       
     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_BLUE     20
       
    33 #define DNS320L_GPIO_LED_SATA0_BLUE     21
       
    34 #define DNS320L_GPIO_LED_SATA1_RED      22
       
    35 #define DNS320L_GPIO_LED_SATA0_RED      23
       
    36 #define DNS320L_GPIO_POWER_SATA         24
       
    37 #define DNS320L_GPIO_LED_USB_BLUE       25
       
    38 #define DNS320L_GPIO_LED_USB_ORANGE     26
       
    39 #define DNS320L_GPIO_BUTTON_USB         27
       
    40 #define DNS320L_GPIO_BUTTON_RESET       28
       
    41 #define DNS320L_GPIO_BUTTON_POWER       29
       
    42 
       
    43 static struct mtd_partition dns320l_nand_parts[] = {
       
    44 	{
       
    45 		.name = "u-boot",
       
    46 		.offset = 0,
       
    47 		.size = SZ_1M
       
    48 	}, {
       
    49 		.name = "uImage",
       
    50 		.offset = MTDPART_OFS_NXTBLK,
       
    51 		.size = 5 * SZ_1M
       
    52 	}, {
       
    53 		.name = "ramdisk",
       
    54 		.offset = MTDPART_OFS_NXTBLK,
       
    55 		.size = 5 * SZ_1M
       
    56 	}, {
       
    57 		.name = "image",
       
    58 		.offset = MTDPART_OFS_NXTBLK,
       
    59 		.size = 100 * SZ_1M
       
    60 	}, {
       
    61 	    .name = "rescue firmware",
       
    62 	    .offset = MTDPART_OFS_NXTBLK,
       
    63 	    .size = 10 * SZ_1M
       
    64 	}, {
       
    65 	    .name = "config",
       
    66 	    .offset = MTDPART_OFS_NXTBLK,
       
    67 	    .size = 5 * SZ_1M
       
    68 	}, {
       
    69 	    .name = "my-dlink",
       
    70 	    .offset = MTDPART_OFS_NXTBLK,
       
    71 	    .size = 2 * SZ_1M
       
    72 	},
       
    73 };
       
    74 
       
    75 
       
    76 static struct mv643xx_eth_platform_data dns320l_ge00_data = {
       
    77 	.phy_addr	= MV643XX_ETH_PHY_ADDR(0),
       
    78 };
       
    79 
       
    80 static struct mv_sata_platform_data dns320l_sata_data = {
       
    81 	.n_ports	= 2,
       
    82 };
       
    83 
       
    84 static void __init dns320l_gpio_register(unsigned gpio, char *name, int def)
       
    85 {
       
    86 	if (gpio_request(gpio, name) == 0 &&
       
    87 	    gpio_direction_output(gpio, 0) == 0) {
       
    88 		gpio_set_value(gpio, def);
       
    89 		if (gpio_export(gpio, 0) != 0)
       
    90 			pr_err("dns320l: Failed to export GPIO %s\n", name);
       
    91 	} else
       
    92 		pr_err("dns320l: Failed to register %s\n", name);
       
    93 }
       
    94 
       
    95 /*****************************************************************************
       
    96  * Buttons
       
    97  ****************************************************************************/
       
    98 
       
    99 static struct gpio_keys_button dns320l_button_pins[] = {
       
   100 	{
       
   101 		.code		= KEY_COPY,
       
   102 		.type       = EV_KEY,
       
   103 		.gpio		= DNS320L_GPIO_BUTTON_USB,
       
   104 		.desc		= "USB Copy button",
       
   105 		.active_low	= 1,
       
   106 		.debounce_interval = 1000,
       
   107 	},
       
   108 	{ // This button does not (yet) work...
       
   109 	    .code       = KEY_POWER,
       
   110         .type       = EV_KEY,
       
   111 	    .gpio       = DNS320L_GPIO_BUTTON_POWER,
       
   112 	    .desc       = "Power Button",
       
   113         .active_low = 1,
       
   114         .debounce_interval = 1000,
       
   115 	},
       
   116 	{
       
   117 	    .code       = KEY_OPTION,
       
   118 	    .type       = EV_KEY,
       
   119 	    .gpio       = DNS320L_GPIO_BUTTON_RESET,
       
   120 	    .desc       = "Reset Button",
       
   121 	    .active_low = 1,
       
   122 	    .debounce_interval = 1000,
       
   123 	},
       
   124 };
       
   125 
       
   126 static struct gpio_keys_platform_data dns320l_button_data = {
       
   127 	.buttons	= dns320l_button_pins,
       
   128 	.nbuttons	= ARRAY_SIZE(dns320l_button_pins),
       
   129 };
       
   130 
       
   131 static struct platform_device dns320l_button_device = {
       
   132 	.name		= "gpio-keys",
       
   133 	.id		= -1,
       
   134 	.dev		= {
       
   135 		.platform_data	= &dns320l_button_data,
       
   136 	}
       
   137 };
       
   138 
       
   139 /*****************************************************************************
       
   140  * LEDs
       
   141  ****************************************************************************/
       
   142 
       
   143 static struct gpio_led dns320l_led_pins[] = {
       
   144 	{
       
   145 		.name	= "dns320l:blue:usb",
       
   146 		.gpio	= DNS320L_GPIO_LED_USB_BLUE,
       
   147 		.default_trigger = "default-on",
       
   148 	},
       
   149 	{
       
   150 		.name	= "dns320l:orange:usb",
       
   151 		.gpio	= DNS320L_GPIO_LED_USB_ORANGE,
       
   152 	},
       
   153 	{
       
   154 	    .name   = "dns320l:blue:sata0",
       
   155 	    .gpio   = DNS320L_GPIO_LED_SATA0_BLUE,
       
   156 	    .default_trigger = "ide-disk"
       
   157 	},
       
   158 	{
       
   159 	    .name   = "dns320l:blue:sata1",
       
   160 	    .gpio   = DNS320L_GPIO_LED_SATA1_BLUE,
       
   161 	    .default_trigger = "ide-disk"
       
   162 	},
       
   163 	{
       
   164 	    .name   = "dns320l:red:sata0",
       
   165 	    .gpio   = DNS320L_GPIO_LED_SATA0_RED,
       
   166 	},
       
   167 	{
       
   168 	    .name   = "dns320l:red:sata1",
       
   169 	    .gpio   = DNS320L_GPIO_LED_SATA1_RED,
       
   170 	},
       
   171 };
       
   172 
       
   173 static struct gpio_led_platform_data dns320l_led_data = {
       
   174 	.num_leds	= ARRAY_SIZE(dns320l_led_pins),
       
   175 	.leds		= dns320l_led_pins,
       
   176 };
       
   177 
       
   178 static struct platform_device dns320l_led_device = {
       
   179 	.name		= "leds-gpio",
       
   180 	.id		= -1,
       
   181 	.dev		= {
       
   182 		.platform_data	= &dns320l_led_data,
       
   183 	},
       
   184 };
       
   185 
       
   186 /*****************************************************************************
       
   187  * Fan
       
   188  ****************************************************************************/
       
   189 
       
   190 static unsigned int dns320l_mpp_config[] __initdata = {
       
   191     MPP13_UART1_TXD,
       
   192 	MPP14_UART1_RXD,
       
   193 	MPP20_GPIO,    // SATA LED BLUE
       
   194 	MPP21_GPIO,    // SATA LED BLUE
       
   195 	MPP22_GPIO,    // SATA LED RED
       
   196 	MPP23_GPIO,    // SATA LED RED
       
   197 	MPP24_GPIO,    // SATA Power
       
   198 	MPP25_GPIO,    // USB LED Blue
       
   199 	MPP26_GPIO,	   // USB LED Orange
       
   200 	MPP27_GPIO,	   // Button USB Copy
       
   201 	MPP28_GPIO,	   // Button Reset
       
   202 	MPP29_GPIO,	   // Button Power
       
   203 	MPP30_GPIO,
       
   204 	MPP31_GPIO,
       
   205 	MPP32_GPIO,
       
   206 	MPP33_GPO,
       
   207 	MPP34_GPIO,	
       
   208 	MPP35_GPIO,	
       
   209 	MPP36_GPIO,	
       
   210 	MPP37_GPIO,	
       
   211 	MPP38_GPIO,
       
   212 	MPP39_GPIO,	
       
   213 	MPP40_GPIO,	
       
   214 	MPP41_GPIO,
       
   215 	MPP42_GPIO,
       
   216 	MPP43_GPIO,	
       
   217 	MPP44_GPIO,	
       
   218 	MPP45_GPIO,	
       
   219 	MPP46_GPIO,	
       
   220 	MPP47_GPIO,	
       
   221 	MPP48_GPIO,	
       
   222 	MPP49_GPIO,
       
   223 	0
       
   224 };
       
   225 
       
   226 static void __init dns320l_init(void)
       
   227 {
       
   228     /*
       
   229      * Basic setup. Needs to be called early.
       
   230      */
       
   231     
       
   232     kirkwood_init();
       
   233     /* setup gpio pin select */
       
   234     kirkwood_mpp_conf(dns320l_mpp_config);
       
   235     kirkwood_uart0_init();
       
   236     kirkwood_uart1_init();
       
   237     kirkwood_nand_init(ARRAY_AND_SIZE(dns320l_nand_parts), 40);
       
   238 
       
   239     kirkwood_ehci_init();
       
   240     kirkwood_i2c_init();
       
   241     kirkwood_ge00_init(&dns320l_ge00_data);
       
   242     platform_device_register(&dns320l_led_device);
       
   243 	dns320l_gpio_register(DNS320L_GPIO_POWER_SATA, "dns320l:power:sata", 1);
       
   244     kirkwood_sata_init(&dns320l_sata_data);
       
   245     
       
   246     platform_device_register(&dns320l_button_device);
       
   247 }
       
   248 
       
   249 MACHINE_START(DNS320L, "DNS-320L")
       
   250 	/* Maintainer: Andreas Boehler <andreas@aboehler.at> */
       
   251 	.boot_params	= 0x00000100,
       
   252 	.init_machine	= dns320l_init,
       
   253 	.map_io		= kirkwood_map_io,
       
   254 	.init_early	= kirkwood_init_early,
       
   255 	.init_irq	= kirkwood_init_irq,
       
   256 	.timer		= &kirkwood_timer,
       
   257 MACHINE_END
       
   258