Merge branch 'for-38-rc2' of git://codeaurora.org/quic/kernel/davidb/linux-msm
[pandora-kernel.git] / arch / arm / mach-kirkwood / lacie_v2-common.c
1 /*
2  * arch/arm/mach-kirkwood/lacie_v2-common.c
3  *
4  * This file is licensed under the terms of the GNU General Public
5  * License version 2.  This program is licensed "as is" without any
6  * warranty of any kind, whether express or implied.
7  */
8
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <linux/mtd/physmap.h>
12 #include <linux/spi/flash.h>
13 #include <linux/spi/spi.h>
14 #include <linux/i2c.h>
15 #include <linux/i2c/at24.h>
16 #include <linux/gpio.h>
17 #include <asm/mach/time.h>
18 #include <mach/kirkwood.h>
19 #include <mach/irqs.h>
20 #include <plat/time.h>
21 #include "common.h"
22
23 /*****************************************************************************
24  * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
25  ****************************************************************************/
26
27 static struct mtd_partition lacie_v2_flash_parts[] = {
28         {
29                 .name = "u-boot",
30                 .size = MTDPART_SIZ_FULL,
31                 .offset = 0,
32                 .mask_flags = MTD_WRITEABLE, /* force read-only */
33         },
34 };
35
36 static const struct flash_platform_data lacie_v2_flash = {
37         .type           = "mx25l4005a",
38         .name           = "spi_flash",
39         .parts          = lacie_v2_flash_parts,
40         .nr_parts       = ARRAY_SIZE(lacie_v2_flash_parts),
41 };
42
43 static struct spi_board_info __initdata lacie_v2_spi_slave_info[] = {
44         {
45                 .modalias       = "m25p80",
46                 .platform_data  = &lacie_v2_flash,
47                 .irq            = -1,
48                 .max_speed_hz   = 20000000,
49                 .bus_num        = 0,
50                 .chip_select    = 0,
51         },
52 };
53
54 void __init lacie_v2_register_flash(void)
55 {
56         spi_register_board_info(lacie_v2_spi_slave_info,
57                                 ARRAY_SIZE(lacie_v2_spi_slave_info));
58         kirkwood_spi_init();
59 }
60
61 /*****************************************************************************
62  * I2C devices
63  ****************************************************************************/
64
65 static struct at24_platform_data at24c04 = {
66         .byte_len       = SZ_4K / 8,
67         .page_size      = 16,
68 };
69
70 /*
71  * i2c addr | chip         | description
72  * 0x50     | HT24LC04     | eeprom (512B)
73  */
74
75 static struct i2c_board_info __initdata lacie_v2_i2c_info[] = {
76         {
77                 I2C_BOARD_INFO("24c04", 0x50),
78                 .platform_data  = &at24c04,
79         }
80 };
81
82 void __init lacie_v2_register_i2c_devices(void)
83 {
84         kirkwood_i2c_init();
85         i2c_register_board_info(0, lacie_v2_i2c_info,
86                                 ARRAY_SIZE(lacie_v2_i2c_info));
87 }
88
89 /*****************************************************************************
90  * Hard Disk power
91  ****************************************************************************/
92
93 static int __initdata lacie_v2_gpio_hdd_power[] = { 16, 17, 41, 42, 43 };
94
95 void __init lacie_v2_hdd_power_init(int hdd_num)
96 {
97         int i;
98         int err;
99
100         /* Power up all hard disks. */
101         for (i = 0; i < hdd_num; i++) {
102                 err = gpio_request(lacie_v2_gpio_hdd_power[i], NULL);
103                 if (err == 0) {
104                         err = gpio_direction_output(
105                                         lacie_v2_gpio_hdd_power[i], 1);
106                         /* Free the HDD power GPIOs. This allow user-space to
107                          * configure them via the gpiolib sysfs interface. */
108                         gpio_free(lacie_v2_gpio_hdd_power[i]);
109                 }
110                 if (err)
111                         pr_err("Failed to power up HDD%d\n", i + 1);
112         }
113 }