Project

General

Profile

Adding SPI flash ยป baseboard-sys9000.c

Custom baseboard file - Mary Frantz, 09/11/2014 01:20 PM

 
1
/*
2
 * Critical Link MityOMAP-L138 SoM Baseboard initializtaion file
3
 *
4
 */
5
#include <linux/kernel.h>
6
#include <linux/init.h>
7
#include <linux/gpio.h>
8
#include <linux/platform_device.h>
9
#include <linux/spi/spi.h>
10
#include <linux/spi/flash.h>
11
#include <linux/delay.h>
12
#include <linux/mtd/mtd.h>
13
#include <linux/usb/musb.h>
14
#include <linux/mtd/partitions.h>
15

    
16

    
17
#include <asm/mach-types.h>
18
#include <asm/mach/arch.h>
19
#include <asm/setup.h>
20
#include <mach/mux.h>
21
#include <mach/da8xx.h>
22
#include <linux/can/platform/mcp251x.h>
23

    
24
#define BASEBOARD_NAME "System9000 Baseboard version 0.7"
25

    
26
/*
27
*  12/16/13	Added SPI1_FPGA_CS_N, commented out GPIO(6,2) in sys9000_gpio_pins
28
*           Added arrays for SPI1 bus to 9000FPGA
29
*/
30

    
31
#define SPI1_FLASH_CS_N		GPIO_TO_PIN(2, 15)	// System configuration flash (optional)
32
#define SPI1_FPGA_CS_N		GPIO_TO_PIN(6, 2)	// SOM to FPGA SPI1 cs
33

    
34
/*
35
 * GPIO pins
36
 */
37

    
38
static short sys9000_gpio_pins[] __initdata = {
39
	DA850_GPIO0_1,		// SYNC_PLL_CLK2_LOS
40
	DA850_GPIO0_3,		// SYNC_PLL_LOL
41
	DA850_GPIO0_5,		// SYNC_PLL_CLK1_LOS
42
	DA850_GPIO0_7,		// SYNC_MASTER_EN
43
	DA850_GPIO0_8,		// SOM_GP0_8
44
	DA850_GPIO0_9,		// TEST_LED_0
45
	DA850_GPIO0_10,		// SYS_GOOD_LED_YEL
46
	DA850_GPIO0_11,		// SYS_GOOD_LED_GRN
47
	DA850_GPIO0_12,		// SYNC_LED_YEL
48
	DA850_GPIO0_13,		// SYNC_LED_GRN
49
	DA850_GPIO0_14,		// REC_LED_RED
50
	DA850_GPIO0_15,		// REC_LED_GRN
51

    
52
//	DA850_GPIO1_4,		// TEST_POINT_1 ...I2C0, needed for voltage regulator
53
//	DA850_GPIO1_5,		// TEST_POINT_0 ...I2C0
54
	
55
	DA850_GPIO4_0, 		// VCAL_EN
56
	DA850_GPIO4_1,  	// VCAL_EN_n
57
	DA850_GPIO4_2,		// ECAL_EN_n
58
	DA850_GPIO4_3,		// ECAL_EN_n
59
	DA850_GPIO4_4, 		// VCAL_ZERO
60
	DA850_GPIO4_5,  	// VCAL_OUT_EN
61
	DA850_GPIO4_6,		// VCAL_SPARE
62
	DA850_GPIO4_7,		// SSD_DET_N
63

    
64
	DA850_GPIO5_14,		// TEST_LED_1
65

    
66
	DA850_GPIO6_0,		// SOM_GP6_0
67
	DA850_GPIO6_1,		// SOM_GP6_1
68
	DA850_GPIO6_2,		// SOM_GP6_2, fpga spi cs
69
	DA850_GPIO6_3,		// SOM_GP6_3
70
	DA850_GPIO6_4,		// SOM_GP6_4
71
	DA850_GPIO6_6,		// SOM_GP6_6
72
	DA850_GPIO6_7,		// SOM_GP6_7
73
	DA850_GPIO6_8,		// SOM_GP6_8
74
	DA850_GPIO6_9,		// SOM_GP6_9
75
	DA850_GPIO6_10,		// SOM_GP6_10
76
	DA850_GPIO6_11,		// SOM_GP6_11
77

    
78
	DA850_GPIO7_0,		// LDAC0_n
79
	DA850_GPIO7_1,		// LDAC1_n
80
	DA850_GPIO7_2,		// LDAC2_n
81
	DA850_GPIO7_3,		// LDAC3_n
82
	DA850_GPIO7_4,		// LDAC4_n
83
	DA850_GPIO7_5,		// LDAC5_n
84
	DA850_GPIO7_6,		// LDAC6_n
85

    
86
	DA850_GPIO7_8,		// CARD_DET3
87
	DA850_GPIO7_9,		// CARD_DET2
88
	DA850_GPIO7_10,		// CARD_DET1
89
	DA850_GPIO7_11,		// CARD_DET0
90

    
91
	DA850_GPIO7_12,		// DIO_0_OUT
92
	DA850_GPIO7_13,		// DIO_0_IN
93
	DA850_GPIO7_14,		// DIO_1_OUT
94
	DA850_GPIO7_15,		// DIO_1_IN
95

    
96
	DA850_GPIO8_8,		// SYS_RST_N
97
	DA850_GPIO8_10, 	// Factory Reset In
98
	DA850_GPIO8_12, 	// HW_REV_0
99
	DA850_GPIO8_13, 	// HW_REV_1
100
	DA850_GPIO8_14, 	// HW_REV_2
101
	DA850_GPIO8_15, 	// HW_REV_3
102
	-1,
103
};
104

    
105

    
106
/*
107
 * SPI Devices:
108
 *	SPI1_CS1: Flash M25PE80
109
 */
110
static struct mtd_partition sys9000_spi_flash_partitions[] = {
111
	[0] = {
112
		.name		= "sys9000_fpga",
113
		.offset		= 0,
114
		.size		= SZ_4M,
115
	},
116
	[1] = {
117
		.name		= "sys9000_extra",
118
		.offset		= MTDPART_OFS_APPEND,
119
		.size		= MTDPART_SIZ_FULL,
120
	},
121
};
122

    
123
// Copied from board-mityomapl138.c in this directory
124
static struct flash_platform_data sys9000_spi_flash_data = {
125
	.name		= "m25p80",
126
	.parts		= sys9000_spi_flash_partitions,
127
	.nr_parts	= ARRAY_SIZE(sys9000_spi_flash_partitions),
128
	.type		= "m25p64-nonjedec",
129
};
130

    
131
static struct davinci_spi_config spi_M25PE80_config = {
132
	.io_type	= SPI_IO_TYPE_DMA,
133
	.c2tdelay	= 8,
134
	.t2cdelay	= 8,
135
};
136

    
137
// Added 12/16/13 SPI1 interface to Sys9000 FPGA
138
static struct davinci_spi_config spi_9000FPGA_config = {
139
	.io_type	= SPI_IO_TYPE_DMA,		// restored 04/21/14
140
//	.io_type	= SPI_IO_TYPE_POLL,		// Changed 02/11/14
141
	.c2tdelay	= 0,
142
	.t2cdelay	= 0,
143
};
144

    
145
static struct spi_board_info sys9000_spi1_info[] = {
146
	[0] = {
147
		.modalias		    = "m25p80",
148
		.platform_data		= &sys9000_spi_flash_data,
149
		.controller_data	= &spi_M25PE80_config,
150
		.mode			    = SPI_MODE_0,
151
		.max_speed_hz		= 30000000,
152
		.bus_num		    = 1,
153
		.chip_select		= 1,
154
	},
155

    
156
	// Added 12/16/13 user space spidev for SPI2 Cs2
157
	// Removed 04/21/14
158
//	[1] = {
159
//		.modalias		 = "spidev",
160
//		.controller_data = &spi_9000FPGA_config,
161
//		.max_speed_hz	 = 33000000,
162
//		.bus_num		 = 1,
163
//		.chip_select	 = 2,
164
//	},
165
};
166

    
167
// Added 12/16/13 SPI1_FPGA_CS_N
168
static u8 spi1_cs[] = {
169
	SPI_INTERN_CS,
170
	SPI1_FLASH_CS_N,
171
//	SPI1_FPGA_CS_N			// removed 04/21/14
172
};
173

    
174
static void __init baseboard_setup_spi(void)
175
{
176
	int ret;
177

    
178
	ret = gpio_request(SPI1_FLASH_CS_N, "Sys9000 SPI1 FLASH CS1\n");
179
	if (ret)
180
		pr_warning("%s: can not open Sys9000 Flash SPI CS %d\n", __func__, SPI1_FLASH_CS_N);
181

    
182
// Removed 04/21/14
183
//	ret = gpio_request(SPI1_FPGA_CS_N, "Sys9000 SPI1 Sys9000FPGA CS\n");
184
//	if (ret)
185
//		pr_warning("%s: can not open Sys9000FPGASPI CS %d\n", __func__, SPI1_FPGA_CS_N);
186

    
187
	ret = spi_register_board_info(sys9000_spi1_info,
188
					ARRAY_SIZE(sys9000_spi1_info));
189
	if (ret)
190
		pr_warning("%s: Unable to register SPI1 Info: %d\n", __func__,
191
				ret);
192
}
193

    
194
static int __init baseboard_pre_init(void)
195
{
196
	pr_info("%s: Entered\n", __func__);
197
	da8xx_spi_pdata[1].chip_sel = spi1_cs;
198
	da8xx_spi_pdata[1].num_chipselect = ARRAY_SIZE(spi1_cs);
199
	davinci_soc_info.emac_pdata->phy_id = "0:03";
200
	return 0;
201
}
202
postcore_initcall_sync(baseboard_pre_init);
203

    
204
static int __init baseboard_init(void)
205
{
206
	pr_info("%s [%s]...\n", __func__, BASEBOARD_NAME);
207

    
208
	davinci_cfg_reg_list(sys9000_gpio_pins);
209

    
210
	baseboard_setup_spi();
211

    
212
	return 0;
213
}
214
arch_initcall_sync(baseboard_init);
215

    
    (1-1/1)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)