Merge tag 'driver-core-5.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / arch / arm / mach-davinci / board-sffsdr.c
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 const struct software_node eeprom_node = {
88         .properties = eeprom_properties,
89 };
90
91 static struct i2c_board_info __initdata i2c_info[] =  {
92         {
93                 I2C_BOARD_INFO("24c64", 0x50),
94                 .swnode = &eeprom_node,
95         },
96         /* Other I2C devices:
97          * MSP430,  addr 0x23 (not used)
98          * PCA9543, addr 0x70 (setup done by U-Boot)
99          * ADS7828, addr 0x48 (ADC for voltage monitoring.)
100          */
101 };
102
103 static struct davinci_i2c_platform_data i2c_pdata = {
104         .bus_freq       = 20 /* kHz */,
105         .bus_delay      = 100 /* usec */,
106 };
107
108 static void __init sffsdr_init_i2c(void)
109 {
110         davinci_init_i2c(&i2c_pdata);
111         i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
112 }
113
114 static struct platform_device *davinci_sffsdr_devices[] __initdata = {
115         &davinci_sffsdr_nandflash_device,
116 };
117
118 static void __init davinci_sffsdr_map_io(void)
119 {
120         dm644x_init();
121 }
122
123 static __init void davinci_sffsdr_init(void)
124 {
125         struct davinci_soc_info *soc_info = &davinci_soc_info;
126
127         dm644x_register_clocks();
128
129         dm644x_init_devices();
130
131         platform_add_devices(davinci_sffsdr_devices,
132                              ARRAY_SIZE(davinci_sffsdr_devices));
133         sffsdr_init_i2c();
134         davinci_serial_init(dm644x_serial_device);
135         soc_info->emac_pdata->phy_id = SFFSDR_PHY_ID;
136         davinci_setup_usb(0, 0); /* We support only peripheral mode. */
137
138         /* mux VLYNQ pins */
139         davinci_cfg_reg(DM644X_VLYNQEN);
140         davinci_cfg_reg(DM644X_VLYNQWD);
141 }
142
143 MACHINE_START(SFFSDR, "Lyrtech SFFSDR")
144         .atag_offset  = 0x100,
145         .map_io       = davinci_sffsdr_map_io,
146         .init_irq     = dm644x_init_irq,
147         .init_time      = dm644x_init_time,
148         .init_machine = davinci_sffsdr_init,
149         .init_late      = davinci_init_late,
150         .dma_zone_size  = SZ_128M,
151 MACHINE_END