• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Lyrtech SFFSDR board support.
4  *
5  * Copyright (C) 2008 Philip Balister, OpenSDR <philip@opensdr.com>
6  * Copyright (C) 2008 Lyrtech <www.lyrtech.com>
7  *
8  * Based on DV-EVM platform, original copyright follows:
9  *
10  * Copyright (C) 2007 MontaVista Software, Inc.
11  */
12 
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/i2c.h>
16 #include <linux/property.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/rawnand.h>
19 #include <linux/mtd/partitions.h>
20 
21 #include <asm/mach-types.h>
22 #include <asm/mach/arch.h>
23 #include <asm/mach/flash.h>
24 
25 #include <mach/common.h>
26 #include <linux/platform_data/i2c-davinci.h>
27 #include <mach/serial.h>
28 #include <mach/mux.h>
29 #include <linux/platform_data/usb-davinci.h>
30 
31 #include "davinci.h"
32 
33 #define SFFSDR_PHY_ID		"davinci_mdio-0:01"
34 static struct mtd_partition davinci_sffsdr_nandflash_partition[] = {
35 	/* U-Boot Environment: Block 0
36 	 * UBL:                Block 1
37 	 * U-Boot:             Blocks 6-7 (256 kb)
38 	 * Integrity Kernel:   Blocks 8-31 (3 Mb)
39 	 * Integrity Data:     Blocks 100-END
40 	 */
41 	{
42 		.name		= "Linux Kernel",
43 		.offset		= 32 * SZ_128K,
44 		.size		= 16 * SZ_128K, /* 2 Mb */
45 		.mask_flags	= MTD_WRITEABLE, /* Force read-only */
46 	},
47 	{
48 		.name		= "Linux ROOT",
49 		.offset		= MTDPART_OFS_APPEND,
50 		.size		= 256 * SZ_128K, /* 32 Mb */
51 		.mask_flags	= 0, /* R/W */
52 	},
53 };
54 
55 static struct flash_platform_data davinci_sffsdr_nandflash_data = {
56 	.parts		= davinci_sffsdr_nandflash_partition,
57 	.nr_parts	= ARRAY_SIZE(davinci_sffsdr_nandflash_partition),
58 };
59 
60 static struct resource davinci_sffsdr_nandflash_resource[] = {
61 	{
62 		.start		= DM644X_ASYNC_EMIF_DATA_CE0_BASE,
63 		.end		= DM644X_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
64 		.flags		= IORESOURCE_MEM,
65 	}, {
66 		.start		= DM644X_ASYNC_EMIF_CONTROL_BASE,
67 		.end		= DM644X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
68 		.flags		= IORESOURCE_MEM,
69 	},
70 };
71 
72 static struct platform_device davinci_sffsdr_nandflash_device = {
73 	.name		= "davinci_nand", /* Name of driver */
74 	.id		= 0,
75 	.dev		= {
76 		.platform_data	= &davinci_sffsdr_nandflash_data,
77 	},
78 	.num_resources	= ARRAY_SIZE(davinci_sffsdr_nandflash_resource),
79 	.resource	= davinci_sffsdr_nandflash_resource,
80 };
81 
82 static const struct property_entry eeprom_properties[] = {
83 	PROPERTY_ENTRY_U32("pagesize", 32),
84 	{ }
85 };
86 
87 static struct i2c_board_info __initdata i2c_info[] =  {
88 	{
89 		I2C_BOARD_INFO("24c64", 0x50),
90 		.properties = eeprom_properties,
91 	},
92 	/* Other I2C devices:
93 	 * MSP430,  addr 0x23 (not used)
94 	 * PCA9543, addr 0x70 (setup done by U-Boot)
95 	 * ADS7828, addr 0x48 (ADC for voltage monitoring.)
96 	 */
97 };
98 
99 static struct davinci_i2c_platform_data i2c_pdata = {
100 	.bus_freq	= 20 /* kHz */,
101 	.bus_delay	= 100 /* usec */,
102 };
103 
sffsdr_init_i2c(void)104 static void __init sffsdr_init_i2c(void)
105 {
106 	davinci_init_i2c(&i2c_pdata);
107 	i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
108 }
109 
110 static struct platform_device *davinci_sffsdr_devices[] __initdata = {
111 	&davinci_sffsdr_nandflash_device,
112 };
113 
davinci_sffsdr_map_io(void)114 static void __init davinci_sffsdr_map_io(void)
115 {
116 	dm644x_init();
117 }
118 
davinci_sffsdr_init(void)119 static __init void davinci_sffsdr_init(void)
120 {
121 	struct davinci_soc_info *soc_info = &davinci_soc_info;
122 
123 	dm644x_register_clocks();
124 
125 	dm644x_init_devices();
126 
127 	platform_add_devices(davinci_sffsdr_devices,
128 			     ARRAY_SIZE(davinci_sffsdr_devices));
129 	sffsdr_init_i2c();
130 	davinci_serial_init(dm644x_serial_device);
131 	soc_info->emac_pdata->phy_id = SFFSDR_PHY_ID;
132 	davinci_setup_usb(0, 0); /* We support only peripheral mode. */
133 
134 	/* mux VLYNQ pins */
135 	davinci_cfg_reg(DM644X_VLYNQEN);
136 	davinci_cfg_reg(DM644X_VLYNQWD);
137 }
138 
139 MACHINE_START(SFFSDR, "Lyrtech SFFSDR")
140 	.atag_offset  = 0x100,
141 	.map_io	      = davinci_sffsdr_map_io,
142 	.init_irq     = dm644x_init_irq,
143 	.init_time	= dm644x_init_time,
144 	.init_machine = davinci_sffsdr_init,
145 	.init_late	= davinci_init_late,
146 	.dma_zone_size	= SZ_128M,
147 MACHINE_END
148