blob: a1aa87f09180f91215a3d2c95c3c6153f82f87f2 [file] [log] [blame]
Jamie Lentin9007d102012-04-18 11:06:40 +01001/*
2 * Copyright 2012 (C), Jamie Lentin <jm@lentin.co.uk>
3 *
4 * arch/arm/mach-kirkwood/board-dnskw.c
5 *
6 * D-link DNS-320 & DNS-325 NAS Init for drivers not converted to
7 * flattened device tree yet.
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
Jamie Lentin9007d102012-04-18 11:06:40 +010017#include <linux/mv643xx_eth.h>
Jamie Lentin9007d102012-04-18 11:06:40 +010018#include <linux/gpio.h>
Jamie Lentin9007d102012-04-18 11:06:40 +010019#include "common.h"
Jamie Lentin9007d102012-04-18 11:06:40 +010020
21static struct mv643xx_eth_platform_data dnskw_ge00_data = {
22 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
23};
24
Jamie Lentin9007d102012-04-18 11:06:40 +010025/* Register any GPIO for output and set the value */
26static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)
27{
28 if (gpio_request(gpio, name) == 0 &&
29 gpio_direction_output(gpio, 0) == 0) {
30 gpio_set_value(gpio, def);
31 if (gpio_export(gpio, 0) != 0)
32 pr_err("dnskw: Failed to export GPIO %s\n", name);
33 } else
34 pr_err("dnskw: Failed to register %s\n", name);
35}
36
37void __init dnskw_init(void)
38{
Jamie Lentin9007d102012-04-18 11:06:40 +010039 kirkwood_ge00_init(&dnskw_ge00_data);
Jamie Lentin9007d102012-04-18 11:06:40 +010040
Jamie Lentin9007d102012-04-18 11:06:40 +010041 /* Set NAS to turn back on after a power failure */
42 dnskw_gpio_register(37, "dnskw:power:recover", 1);
43}