79ab62c2eb4511b9f06862b32f57def14bdfa0ec
[openwrt.git] / target / linux / lantiq / patches-3.2 / 0010-MIPS-lantiq-add-support-for-the-EASY98000-evaluation.patch
1 From 9397aa9584bade07ae667ecd5135653f9c04e236 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Thu, 11 Aug 2011 14:09:35 +0200
4 Subject: [PATCH 10/70] MIPS: lantiq: add support for the EASY98000 evaluation
5  board
6
7 This patch adds the machine code for the EASY9800 evaluation board.
8
9 Signed-off-by: Thomas Langer <thomas.langer@lantiq.com>
10 Signed-off-by: John Crispin <blogic@openwrt.org>
11 ---
12  arch/mips/lantiq/falcon/Kconfig          |   11 +++
13  arch/mips/lantiq/falcon/Makefile         |    1 +
14  arch/mips/lantiq/falcon/mach-easy98000.c |  110 ++++++++++++++++++++++++++++++
15  arch/mips/lantiq/machtypes.h             |    5 ++
16  4 files changed, 127 insertions(+), 0 deletions(-)
17  create mode 100644 arch/mips/lantiq/falcon/Kconfig
18  create mode 100644 arch/mips/lantiq/falcon/mach-easy98000.c
19
20 --- /dev/null
21 +++ b/arch/mips/lantiq/falcon/Kconfig
22 @@ -0,0 +1,11 @@
23 +if SOC_FALCON
24 +
25 +menu "MIPS Machine"
26 +
27 +config LANTIQ_MACH_EASY98000
28 +       bool "Easy98000"
29 +       default y
30 +
31 +endmenu
32 +
33 +endif
34 --- a/arch/mips/lantiq/falcon/Makefile
35 +++ b/arch/mips/lantiq/falcon/Makefile
36 @@ -1 +1,2 @@
37  obj-y := clk.o prom.o reset.o sysctrl.o devices.o gpio.o
38 +obj-$(CONFIG_LANTIQ_MACH_EASY98000) += mach-easy98000.o
39 --- /dev/null
40 +++ b/arch/mips/lantiq/falcon/mach-easy98000.c
41 @@ -0,0 +1,110 @@
42 +/*
43 + *  This program is free software; you can redistribute it and/or modify it
44 + *  under the terms of the GNU General Public License version 2 as published
45 + *  by the Free Software Foundation.
46 + *
47 + *  Copyright (C) 2011 Thomas Langer <thomas.langer@lantiq.com>
48 + *  Copyright (C) 2011 John Crispin <blogic@openwrt.org>
49 + */
50 +
51 +#include <linux/platform_device.h>
52 +#include <linux/mtd/partitions.h>
53 +#include <linux/spi/spi.h>
54 +#include <linux/spi/spi_gpio.h>
55 +#include <linux/spi/eeprom.h>
56 +
57 +#include "../machtypes.h"
58 +
59 +#include "devices.h"
60 +
61 +static struct mtd_partition easy98000_nor_partitions[] = {
62 +       {
63 +               .name   = "uboot",
64 +               .offset = 0x0,
65 +               .size   = 0x40000,
66 +       },
67 +       {
68 +               .name   = "uboot_env",
69 +               .offset = 0x40000,
70 +               .size   = 0x40000,      /* 2 sectors for redundant env. */
71 +       },
72 +       {
73 +               .name   = "linux",
74 +               .offset = 0x80000,
75 +               .size   = 0xF80000,     /* map only 16 MiB */
76 +       },
77 +};
78 +
79 +struct physmap_flash_data easy98000_nor_flash_data = {
80 +       .nr_parts       = ARRAY_SIZE(easy98000_nor_partitions),
81 +       .parts          = easy98000_nor_partitions,
82 +};
83 +
84 +/* setup gpio based spi bus/device for access to the eeprom on the board */
85 +#define SPI_GPIO_MRST          102
86 +#define SPI_GPIO_MTSR          103
87 +#define SPI_GPIO_CLK           104
88 +#define SPI_GPIO_CS0           105
89 +#define SPI_GPIO_CS1           106
90 +#define SPI_GPIO_BUS_NUM       1
91 +
92 +static struct spi_gpio_platform_data easy98000_spi_gpio_data = {
93 +       .sck            = SPI_GPIO_CLK,
94 +       .mosi           = SPI_GPIO_MTSR,
95 +       .miso           = SPI_GPIO_MRST,
96 +       .num_chipselect = 2,
97 +};
98 +
99 +static struct platform_device easy98000_spi_gpio_device = {
100 +       .name                   = "spi_gpio",
101 +       .id                     = SPI_GPIO_BUS_NUM,
102 +       .dev.platform_data      = &easy98000_spi_gpio_data,
103 +};
104 +
105 +static struct spi_eeprom at25160n = {
106 +       .byte_len       = 16 * 1024 / 8,
107 +       .name           = "at25160n",
108 +       .page_size      = 32,
109 +       .flags          = EE_ADDR2,
110 +};
111 +
112 +static struct spi_board_info easy98000_spi_gpio_devices __initdata = {
113 +       .modalias               = "at25",
114 +       .bus_num                = SPI_GPIO_BUS_NUM,
115 +       .max_speed_hz           = 1000 * 1000,
116 +       .mode                   = SPI_MODE_3,
117 +       .chip_select            = 1,
118 +       .controller_data        = (void *) SPI_GPIO_CS1,
119 +       .platform_data          = &at25160n,
120 +};
121 +
122 +static void __init
123 +easy98000_init_common(void)
124 +{
125 +       spi_register_board_info(&easy98000_spi_gpio_devices, 1);
126 +       platform_device_register(&easy98000_spi_gpio_device);
127 +}
128 +
129 +static void __init
130 +easy98000_init(void)
131 +{
132 +       easy98000_init_common();
133 +       ltq_register_nor(&easy98000_nor_flash_data);
134 +}
135 +
136 +static void __init
137 +easy98000nand_init(void)
138 +{
139 +       easy98000_init_common();
140 +       falcon_register_nand();
141 +}
142 +
143 +MIPS_MACHINE(LANTIQ_MACH_EASY98000,
144 +                       "EASY98000",
145 +                       "EASY98000 Eval Board",
146 +                       easy98000_init);
147 +
148 +MIPS_MACHINE(LANTIQ_MACH_EASY98000NAND,
149 +                       "EASY98000NAND",
150 +                       "EASY98000 Eval Board (NAND Flash)",
151 +                       easy98000nand_init);
152 --- a/arch/mips/lantiq/machtypes.h
153 +++ b/arch/mips/lantiq/machtypes.h
154 @@ -15,6 +15,11 @@ enum lantiq_mach_type {
155         LTQ_MACH_GENERIC = 0,
156         LTQ_MACH_EASY50712,     /* Danube evaluation board */
157         LTQ_MACH_EASY50601,     /* Amazon SE evaluation board */
158 +
159 +       /* FALCON */
160 +       LANTIQ_MACH_EASY98000,          /* Falcon Eval Board, NOR Flash */
161 +       LANTIQ_MACH_EASY98000SF,        /* Falcon Eval Board, Serial Flash */
162 +       LANTIQ_MACH_EASY98000NAND,      /* Falcon Eval Board, NAND Flash */
163  };
164  
165  #endif