| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Lyrtech SFFSDR board support. | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 2008 Philip Balister, OpenSDR <philip@opensdr.com> | 
|  | 5 | * Copyright (C) 2008 Lyrtech <www.lyrtech.com> | 
|  | 6 | * | 
|  | 7 | * Based on DV-EVM platform, original copyright follows: | 
|  | 8 | * | 
|  | 9 | * Copyright (C) 2007 MontaVista Software, Inc. | 
|  | 10 | * | 
|  | 11 | * This program is free software; you can redistribute it and/or modify | 
|  | 12 | * it under the terms of the GNU General Public License as published by | 
|  | 13 | * the Free Software Foundation; either version 2 of the License, or | 
|  | 14 | * (at your option) any later version. | 
|  | 15 | * | 
|  | 16 | * This program is distributed in the hope that it will be useful, | 
|  | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 19 | * GNU General Public License for more details. | 
|  | 20 | * | 
|  | 21 | * You should have received a copy of the GNU General Public License | 
|  | 22 | * along with this program; if not, write to the Free Software | 
|  | 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 
|  | 24 | */ | 
|  | 25 |  | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 26 | #include <linux/init.h> | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 27 | #include <linux/platform_device.h> | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 28 | #include <linux/i2c.h> | 
|  | 29 | #include <linux/i2c/at24.h> | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 30 | #include <linux/mtd/mtd.h> | 
|  | 31 | #include <linux/mtd/nand.h> | 
|  | 32 | #include <linux/mtd/partitions.h> | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 33 |  | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 34 | #include <asm/mach-types.h> | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 35 | #include <asm/mach/arch.h> | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 36 | #include <asm/mach/flash.h> | 
|  | 37 |  | 
|  | 38 | #include <mach/dm644x.h> | 
|  | 39 | #include <mach/common.h> | 
|  | 40 | #include <mach/i2c.h> | 
|  | 41 | #include <mach/serial.h> | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 42 | #include <mach/mux.h> | 
| Sergei Shtylyov | 355fb4e | 2009-10-30 23:46:14 +0400 | [diff] [blame] | 43 | #include <mach/usb.h> | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 44 |  | 
| Kevin Hilman | ac7b75b | 2009-05-07 06:19:40 -0700 | [diff] [blame] | 45 | #define SFFSDR_PHY_MASK		(0x2) | 
|  | 46 | #define SFFSDR_MDIO_FREQUENCY	(2200000) /* PHY bus frequency */ | 
|  | 47 |  | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 48 | #define DAVINCI_ASYNC_EMIF_CONTROL_BASE   0x01e00000 | 
|  | 49 | #define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE  0x02000000 | 
|  | 50 |  | 
|  | 51 | struct mtd_partition davinci_sffsdr_nandflash_partition[] = { | 
|  | 52 | /* U-Boot Environment: Block 0 | 
|  | 53 | * UBL:                Block 1 | 
|  | 54 | * U-Boot:             Blocks 6-7 (256 kb) | 
|  | 55 | * Integrity Kernel:   Blocks 8-31 (3 Mb) | 
|  | 56 | * Integrity Data:     Blocks 100-END | 
|  | 57 | */ | 
|  | 58 | { | 
|  | 59 | .name		= "Linux Kernel", | 
|  | 60 | .offset		= 32 * SZ_128K, | 
|  | 61 | .size		= 16 * SZ_128K, /* 2 Mb */ | 
|  | 62 | .mask_flags	= MTD_WRITEABLE, /* Force read-only */ | 
|  | 63 | }, | 
|  | 64 | { | 
|  | 65 | .name		= "Linux ROOT", | 
|  | 66 | .offset		= MTDPART_OFS_APPEND, | 
|  | 67 | .size		= 256 * SZ_128K, /* 32 Mb */ | 
|  | 68 | .mask_flags	= 0, /* R/W */ | 
|  | 69 | }, | 
|  | 70 | }; | 
|  | 71 |  | 
|  | 72 | static struct flash_platform_data davinci_sffsdr_nandflash_data = { | 
|  | 73 | .parts		= davinci_sffsdr_nandflash_partition, | 
|  | 74 | .nr_parts	= ARRAY_SIZE(davinci_sffsdr_nandflash_partition), | 
|  | 75 | }; | 
|  | 76 |  | 
|  | 77 | static struct resource davinci_sffsdr_nandflash_resource[] = { | 
|  | 78 | { | 
|  | 79 | .start		= DAVINCI_ASYNC_EMIF_DATA_CE0_BASE, | 
|  | 80 | .end		= DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1, | 
|  | 81 | .flags		= IORESOURCE_MEM, | 
|  | 82 | }, { | 
|  | 83 | .start		= DAVINCI_ASYNC_EMIF_CONTROL_BASE, | 
|  | 84 | .end		= DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1, | 
|  | 85 | .flags		= IORESOURCE_MEM, | 
|  | 86 | }, | 
|  | 87 | }; | 
|  | 88 |  | 
|  | 89 | static struct platform_device davinci_sffsdr_nandflash_device = { | 
|  | 90 | .name		= "davinci_nand", /* Name of driver */ | 
|  | 91 | .id		= 0, | 
|  | 92 | .dev		= { | 
|  | 93 | .platform_data	= &davinci_sffsdr_nandflash_data, | 
|  | 94 | }, | 
|  | 95 | .num_resources	= ARRAY_SIZE(davinci_sffsdr_nandflash_resource), | 
|  | 96 | .resource	= davinci_sffsdr_nandflash_resource, | 
|  | 97 | }; | 
|  | 98 |  | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 99 | static struct at24_platform_data eeprom_info = { | 
|  | 100 | .byte_len	= (64*1024) / 8, | 
|  | 101 | .page_size	= 32, | 
|  | 102 | .flags		= AT24_FLAG_ADDR16, | 
|  | 103 | }; | 
|  | 104 |  | 
|  | 105 | static struct i2c_board_info __initdata i2c_info[] =  { | 
|  | 106 | { | 
|  | 107 | I2C_BOARD_INFO("24lc64", 0x50), | 
|  | 108 | .platform_data	= &eeprom_info, | 
|  | 109 | }, | 
|  | 110 | /* Other I2C devices: | 
|  | 111 | * MSP430,  addr 0x23 (not used) | 
|  | 112 | * PCA9543, addr 0x70 (setup done by U-Boot) | 
|  | 113 | * ADS7828, addr 0x48 (ADC for voltage monitoring.) | 
|  | 114 | */ | 
|  | 115 | }; | 
|  | 116 |  | 
|  | 117 | static struct davinci_i2c_platform_data i2c_pdata = { | 
|  | 118 | .bus_freq	= 20 /* kHz */, | 
|  | 119 | .bus_delay	= 100 /* usec */, | 
|  | 120 | }; | 
|  | 121 |  | 
|  | 122 | static void __init sffsdr_init_i2c(void) | 
|  | 123 | { | 
|  | 124 | davinci_init_i2c(&i2c_pdata); | 
|  | 125 | i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info)); | 
|  | 126 | } | 
|  | 127 |  | 
|  | 128 | static struct platform_device *davinci_sffsdr_devices[] __initdata = { | 
|  | 129 | &davinci_sffsdr_nandflash_device, | 
|  | 130 | }; | 
|  | 131 |  | 
|  | 132 | static struct davinci_uart_config uart_config __initdata = { | 
|  | 133 | .enabled_uarts = (1 << 0), | 
|  | 134 | }; | 
|  | 135 |  | 
|  | 136 | static void __init davinci_sffsdr_map_io(void) | 
|  | 137 | { | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 138 | dm644x_init(); | 
|  | 139 | } | 
|  | 140 |  | 
|  | 141 | static __init void davinci_sffsdr_init(void) | 
|  | 142 | { | 
| Mark A. Greer | 972412b | 2009-04-15 12:40:56 -0700 | [diff] [blame] | 143 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 
|  | 144 |  | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 145 | platform_add_devices(davinci_sffsdr_devices, | 
|  | 146 | ARRAY_SIZE(davinci_sffsdr_devices)); | 
|  | 147 | sffsdr_init_i2c(); | 
|  | 148 | davinci_serial_init(&uart_config); | 
| Mark A. Greer | 972412b | 2009-04-15 12:40:56 -0700 | [diff] [blame] | 149 | soc_info->emac_pdata->phy_mask = SFFSDR_PHY_MASK; | 
|  | 150 | soc_info->emac_pdata->mdio_max_freq = SFFSDR_MDIO_FREQUENCY; | 
| Sergei Shtylyov | 355fb4e | 2009-10-30 23:46:14 +0400 | [diff] [blame] | 151 | davinci_setup_usb(0, 0); /* We support only peripheral mode. */ | 
| Hugo Villeneuve | f5ce6a6 | 2009-04-29 16:46:57 -0700 | [diff] [blame] | 152 |  | 
|  | 153 | /* mux VLYNQ pins */ | 
|  | 154 | davinci_cfg_reg(DM644X_VLYNQEN); | 
|  | 155 | davinci_cfg_reg(DM644X_VLYNQWD); | 
|  | 156 | } | 
|  | 157 |  | 
|  | 158 | static __init void davinci_sffsdr_irq_init(void) | 
|  | 159 | { | 
|  | 160 | davinci_irq_init(); | 
|  | 161 | } | 
|  | 162 |  | 
|  | 163 | MACHINE_START(SFFSDR, "Lyrtech SFFSDR") | 
|  | 164 | /* Maintainer: Hugo Villeneuve hugo.villeneuve@lyrtech.com */ | 
|  | 165 | .phys_io      = IO_PHYS, | 
|  | 166 | .io_pg_offst  = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc, | 
|  | 167 | .boot_params  = (DAVINCI_DDR_BASE + 0x100), | 
|  | 168 | .map_io	      = davinci_sffsdr_map_io, | 
|  | 169 | .init_irq     = davinci_sffsdr_irq_init, | 
|  | 170 | .timer	      = &davinci_timer, | 
|  | 171 | .init_machine = davinci_sffsdr_init, | 
|  | 172 | MACHINE_END |