fc5720d4ea23a917d0b5557c93907de69e5110f5
[openwrt/svn-archive/archive.git] / target / linux / lantiq / files-3.3 / arch / mips / lantiq / falcon / mach-easy98000.c
1 /*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License version 2 as published
4 * by the Free Software Foundation.
5 *
6 * Copyright (C) 2011 Thomas Langer <thomas.langer@lantiq.com>
7 * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
8 */
9
10 #include <linux/platform_device.h>
11 #include <linux/mtd/partitions.h>
12 #include <linux/spi/spi.h>
13 #include <linux/spi/spi_gpio.h>
14 #include <linux/spi/eeprom.h>
15
16 #include "../machtypes.h"
17
18 #include "devices.h"
19
20 static struct mtd_partition easy98000_nor_partitions[] = {
21 {
22 .name = "uboot",
23 .offset = 0x0,
24 .size = 0x40000,
25 },
26 {
27 .name = "uboot_env",
28 .offset = 0x40000,
29 .size = 0x40000, /* 2 sectors for redundant env. */
30 },
31 {
32 .name = "linux",
33 .offset = 0x80000,
34 .size = 0xF80000, /* map only 16 MiB */
35 },
36 };
37
38 struct physmap_flash_data easy98000_nor_flash_data = {
39 .nr_parts = ARRAY_SIZE(easy98000_nor_partitions),
40 .parts = easy98000_nor_partitions,
41 };
42
43 static struct flash_platform_data easy98000_spi_flash_platform_data = {
44 .name = "sflash",
45 .parts = easy98000_nor_partitions,
46 .nr_parts = ARRAY_SIZE(easy98000_nor_partitions)
47 };
48
49 static struct spi_board_info easy98000_spi_flash_data __initdata = {
50 .modalias = "m25p80",
51 .bus_num = 0,
52 .chip_select = 0,
53 .max_speed_hz = 10 * 1000 * 1000,
54 .mode = SPI_MODE_3,
55 .platform_data = &easy98000_spi_flash_platform_data
56 };
57
58 /* setup gpio based spi bus/device for access to the eeprom on the board */
59 #define SPI_GPIO_MRST 102
60 #define SPI_GPIO_MTSR 103
61 #define SPI_GPIO_CLK 104
62 #define SPI_GPIO_CS0 105
63 #define SPI_GPIO_CS1 106
64 #define SPI_GPIO_BUS_NUM 1
65
66 static struct spi_gpio_platform_data easy98000_spi_gpio_data = {
67 .sck = SPI_GPIO_CLK,
68 .mosi = SPI_GPIO_MTSR,
69 .miso = SPI_GPIO_MRST,
70 .num_chipselect = 2,
71 };
72
73 static struct platform_device easy98000_spi_gpio_device = {
74 .name = "spi_gpio",
75 .id = SPI_GPIO_BUS_NUM,
76 .dev.platform_data = &easy98000_spi_gpio_data,
77 };
78
79 static struct spi_eeprom at25160n = {
80 .byte_len = 16 * 1024 / 8,
81 .name = "at25160n",
82 .page_size = 32,
83 .flags = EE_ADDR2,
84 };
85
86 static struct spi_board_info easy98000_spi_gpio_devices __initdata = {
87 .modalias = "at25",
88 .bus_num = SPI_GPIO_BUS_NUM,
89 .max_speed_hz = 1000 * 1000,
90 .mode = SPI_MODE_3,
91 .chip_select = 1,
92 .controller_data = (void *) SPI_GPIO_CS1,
93 .platform_data = &at25160n,
94 };
95
96 static void __init
97 easy98000_init_common(void)
98 {
99 spi_register_board_info(&easy98000_spi_gpio_devices, 1);
100 platform_device_register(&easy98000_spi_gpio_device);
101 falcon_register_i2c();
102 }
103
104 static void __init
105 easy98000_init(void)
106 {
107 easy98000_init_common();
108 ltq_register_nor(&easy98000_nor_flash_data);
109 }
110
111 static void __init
112 easy98000sf_init(void)
113 {
114 easy98000_init_common();
115 falcon_register_spi_flash(&easy98000_spi_flash_data);
116 }
117
118 static void __init
119 easy98000nand_init(void)
120 {
121 easy98000_init_common();
122 falcon_register_nand();
123 }
124
125 MIPS_MACHINE(LANTIQ_MACH_EASY98000,
126 "EASY98000",
127 "EASY98000 Eval Board",
128 easy98000_init);
129
130 MIPS_MACHINE(LANTIQ_MACH_EASY98000SF,
131 "EASY98000SF",
132 "EASY98000 Eval Board (Serial Flash)",
133 easy98000sf_init);
134
135 MIPS_MACHINE(LANTIQ_MACH_EASY98000NAND,
136 "EASY98000NAND",
137 "EASY98000 Eval Board (NAND Flash)",
138 easy98000nand_init);