1 From 97e062a70c0b1ccc5b3f8236966c13b7b79e7c13 Mon Sep 17 00:00:00 2001
2 From: Hugo Villeneuve <hugo@hugovil.com>
3 Date: Fri, 6 Mar 2009 12:31:34 -0500
4 Subject: [PATCH 12/12] Update SFFSDR to support FPGA and lyrvpss drivers
6 Signed-off-by: Hugo Villeneuve <hugo@hugovil.com>
8 arch/arm/configs/davinci_sffsdr_defconfig | 157 +++++++++----
9 arch/arm/mach-davinci/Kconfig | 15 ++
10 arch/arm/mach-davinci/Makefile | 1 +
11 arch/arm/mach-davinci/board-sffsdr-fpga.c | 283 ++++++++++++++++++++++
12 arch/arm/mach-davinci/board-sffsdr.c | 195 ++++++++++++---
13 arch/arm/mach-davinci/include/mach/sffsdr-fpga.h | 54 ++++
14 6 files changed, 628 insertions(+), 77 deletions(-)
15 create mode 100644 arch/arm/mach-davinci/board-sffsdr-fpga.c
16 create mode 100644 arch/arm/mach-davinci/include/mach/sffsdr-fpga.h
18 diff --git a/arch/arm/configs/davinci_sffsdr_defconfig b/arch/arm/configs/davinci_sffsdr_defconfig
19 index 8c17858..91c01f9 100644
20 --- a/arch/arm/configs/davinci_sffsdr_defconfig
21 +++ b/arch/arm/configs/davinci_sffsdr_defconfig
24 # Automatically generated make config: don't edit
25 # Linux kernel version: 2.6.28-davinci1
26 -# Fri Jan 16 12:33:07 2009
27 +# Fri Mar 6 12:29:19 2009
30 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
31 @@ -179,15 +179,11 @@ CONFIG_ARCH_DAVINCI_DM644x=y
33 # CONFIG_MACH_DAVINCI_EVM is not set
37 # CONFIG_DAVINCI_MUX_DEBUG is not set
38 # CONFIG_DAVINCI_MUX_WARNINGS is not set
39 # CONFIG_DAVINCI_RESET_CLOCKS is not set
40 -CONFIG_DAVINCI_BOOT_TAG=y
48 @@ -206,7 +202,7 @@ CONFIG_CPU_CP15_MMU=y
53 +# CONFIG_ARM_THUMB is not set
54 # CONFIG_CPU_ICACHE_DISABLE is not set
55 # CONFIG_CPU_DCACHE_DISABLE is not set
56 # CONFIG_CPU_DCACHE_WRITETHROUGH is not set
57 @@ -378,7 +374,84 @@ CONFIG_EXTRA_FIRMWARE=""
58 # CONFIG_DEBUG_DEVRES is not set
59 # CONFIG_SYS_HYPERVISOR is not set
60 # CONFIG_CONNECTOR is not set
61 -# CONFIG_MTD is not set
63 +# CONFIG_MTD_DEBUG is not set
64 +# CONFIG_MTD_CONCAT is not set
65 +CONFIG_MTD_PARTITIONS=y
66 +# CONFIG_MTD_REDBOOT_PARTS is not set
67 +# CONFIG_MTD_CMDLINE_PARTS is not set
68 +# CONFIG_MTD_AFS_PARTS is not set
69 +# CONFIG_MTD_AR7_PARTS is not set
72 +# User Modules And Translation Layers
75 +# CONFIG_MTD_BLKDEVS is not set
76 +# CONFIG_MTD_BLOCK is not set
77 +# CONFIG_MTD_BLOCK_RO is not set
78 +# CONFIG_FTL is not set
79 +# CONFIG_NFTL is not set
80 +# CONFIG_INFTL is not set
81 +# CONFIG_RFD_FTL is not set
82 +# CONFIG_SSFDC is not set
83 +# CONFIG_MTD_OOPS is not set
86 +# RAM/ROM/Flash chip drivers
88 +# CONFIG_MTD_CFI is not set
89 +# CONFIG_MTD_JEDECPROBE is not set
90 +CONFIG_MTD_MAP_BANK_WIDTH_1=y
91 +CONFIG_MTD_MAP_BANK_WIDTH_2=y
92 +CONFIG_MTD_MAP_BANK_WIDTH_4=y
93 +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
94 +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
95 +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
98 +# CONFIG_MTD_CFI_I4 is not set
99 +# CONFIG_MTD_CFI_I8 is not set
100 +# CONFIG_MTD_RAM is not set
101 +# CONFIG_MTD_ROM is not set
102 +# CONFIG_MTD_ABSENT is not set
105 +# Mapping drivers for chip access
107 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
108 +# CONFIG_MTD_PLATRAM is not set
111 +# Self-contained MTD device drivers
113 +# CONFIG_MTD_SLRAM is not set
114 +# CONFIG_MTD_PHRAM is not set
115 +# CONFIG_MTD_MTDRAM is not set
116 +# CONFIG_MTD_BLOCK2MTD is not set
119 +# Disk-On-Chip Device Drivers
121 +# CONFIG_MTD_DOC2000 is not set
122 +# CONFIG_MTD_DOC2001 is not set
123 +# CONFIG_MTD_DOC2001PLUS is not set
125 +# CONFIG_MTD_NAND_VERIFY_WRITE is not set
126 +# CONFIG_MTD_NAND_ECC_SMC is not set
127 +# CONFIG_MTD_NAND_MUSEUM_IDS is not set
128 +# CONFIG_MTD_NAND_GPIO is not set
129 +CONFIG_MTD_NAND_IDS=y
130 +# CONFIG_MTD_NAND_DISKONCHIP is not set
131 +# CONFIG_MTD_NAND_NANDSIM is not set
132 +# CONFIG_MTD_NAND_PLATFORM is not set
133 +CONFIG_MTD_NAND_DAVINCI=y
134 +# CONFIG_MTD_ONENAND is not set
137 +# UBI - Unsorted block images
139 +# CONFIG_MTD_UBI is not set
140 # CONFIG_PARPORT is not set
142 # CONFIG_BLK_DEV_COW_COMMON is not set
143 @@ -387,7 +460,13 @@ CONFIG_BLK_DEV=y
144 # CONFIG_BLK_DEV_RAM is not set
145 # CONFIG_CDROM_PKTCDVD is not set
146 # CONFIG_ATA_OVER_ETH is not set
147 -# CONFIG_MISC_DEVICES is not set
148 +CONFIG_MISC_DEVICES=y
149 +# CONFIG_EEPROM_93CX6 is not set
150 +# CONFIG_ICS932S401 is not set
151 +# CONFIG_ENCLOSURE_SERVICES is not set
154 +# CONFIG_C2PORT is not set
156 # CONFIG_IDE is not set
158 @@ -499,6 +578,10 @@ CONFIG_UNIX98_PTYS=y
159 # CONFIG_R3964 is not set
160 # CONFIG_RAW_DRIVER is not set
161 # CONFIG_TCG_TPM is not set
162 +CONFIG_LYRTECH_VPSS=y
163 +CONFIG_LYRTECH_VPFE=m
164 +# CONFIG_LYRTECH_VPBE is not set
165 +CONFIG_LYRVPSS_DEBUG=y
167 CONFIG_I2C_BOARDINFO=y
169 @@ -628,11 +711,11 @@ CONFIG_SSB_POSSIBLE=y
170 # Display device support
172 # CONFIG_DISPLAY_SUPPORT is not set
175 # CONFIG_SOUND_OSS_CORE is not set
182 # CONFIG_SND_SEQUENCER is not set
183 # CONFIG_SND_MIXER_OSS is not set
184 # CONFIG_SND_PCM_OSS is not set
185 @@ -643,38 +726,14 @@ CONFIG_SND_DYNAMIC_MINORS=y
186 # CONFIG_SND_DEBUG is not set
187 # CONFIG_SND_DRIVERS is not set
188 # CONFIG_SND_ARM is not set
191 CONFIG_SND_DAVINCI_SOC=m
192 -# CONFIG_SND_DAVINCI_SOC_SFFSDR is not set
193 +CONFIG_SND_DAVINCI_SOC_I2S=m
194 +CONFIG_SND_DAVINCI_SOC_SFFSDR=m
195 # CONFIG_SND_SOC_ALL_CODECS is not set
196 +CONFIG_SND_SOC_PCM3008=m
197 # CONFIG_SOUND_PRIME is not set
198 # CONFIG_USB_SUPPORT is not set
199 -# CONFIG_USB_MUSB_HOST is not set
200 -# CONFIG_USB_MUSB_PERIPHERAL is not set
201 -# CONFIG_USB_MUSB_OTG is not set
202 -# CONFIG_USB_GADGET_MUSB_HDRC is not set
203 -# CONFIG_USB_GADGET_AT91 is not set
204 -# CONFIG_USB_GADGET_ATMEL_USBA is not set
205 -# CONFIG_USB_GADGET_FSL_USB2 is not set
206 -# CONFIG_USB_GADGET_LH7A40X is not set
207 -# CONFIG_USB_GADGET_OMAP is not set
208 -# CONFIG_USB_GADGET_PXA25X is not set
209 -# CONFIG_USB_GADGET_PXA27X is not set
210 -# CONFIG_USB_GADGET_S3C2410 is not set
211 -# CONFIG_USB_GADGET_M66592 is not set
212 -# CONFIG_USB_GADGET_AMD5536UDC is not set
213 -# CONFIG_USB_GADGET_FSL_QE is not set
214 -# CONFIG_USB_GADGET_NET2280 is not set
215 -# CONFIG_USB_GADGET_GOKU is not set
216 -# CONFIG_USB_GADGET_DUMMY_HCD is not set
217 -# CONFIG_USB_ZERO is not set
218 -# CONFIG_USB_ETH is not set
219 -# CONFIG_USB_GADGETFS is not set
220 -# CONFIG_USB_FILE_STORAGE is not set
221 -# CONFIG_USB_G_SERIAL is not set
222 -# CONFIG_USB_MIDI_GADGET is not set
223 -# CONFIG_USB_G_PRINTER is not set
224 -# CONFIG_USB_CDC_COMPOSITE is not set
226 # CONFIG_MMC_DEBUG is not set
227 # CONFIG_MMC_UNSAFE_RESUME is not set
228 @@ -766,6 +825,17 @@ CONFIG_TMPFS=y
229 # CONFIG_BEFS_FS is not set
230 # CONFIG_BFS_FS is not set
231 # CONFIG_EFS_FS is not set
233 +CONFIG_JFFS2_FS_DEBUG=0
234 +CONFIG_JFFS2_FS_WRITEBUFFER=y
235 +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
236 +# CONFIG_JFFS2_SUMMARY is not set
237 +# CONFIG_JFFS2_FS_XATTR is not set
238 +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
240 +# CONFIG_JFFS2_LZO is not set
241 +CONFIG_JFFS2_RTIME=y
242 +# CONFIG_JFFS2_RUBIN is not set
243 # CONFIG_CRAMFS is not set
244 # CONFIG_VXFS_FS is not set
245 # CONFIG_MINIX_FS is not set
246 @@ -1020,13 +1090,16 @@ CONFIG_CRYPTO=y
251 # CONFIG_CRC_CCITT is not set
252 # CONFIG_CRC16 is not set
253 # CONFIG_CRC_T10DIF is not set
254 # CONFIG_CRC_ITU_T is not set
255 -# CONFIG_CRC32 is not set
257 # CONFIG_CRC7 is not set
258 # CONFIG_LIBCRC32C is not set
259 +CONFIG_ZLIB_INFLATE=y
260 +CONFIG_ZLIB_DEFLATE=y
264 diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
265 index 0010f2d..769cd6c 100644
266 --- a/arch/arm/mach-davinci/Kconfig
267 +++ b/arch/arm/mach-davinci/Kconfig
268 @@ -50,6 +50,21 @@ config MACH_SFFSDR
269 Say Y here to select the Lyrtech Small Form Factor
270 Software Defined Radio (SFFSDR) board.
273 + tristate "SFFSDR SX-35 FPGA support"
275 + depends on MACH_SFFSDR
279 + This driver supports the SX-35 FPGA on the Lyrtech SFFSDR board.
280 + The FPGA is mainly used to generate the clocks for the audio
281 + codec and for transferring data to/from the other stacked boards
282 + (using the EMIF or VPSS ports).
284 + To compile this driver as a module, choose M here: the
285 + module will be called sffsdr-fpga.
288 bool "DAVINCI multiplexing support"
289 depends on ARCH_DAVINCI
290 diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
291 index 6783681..8a7b3c2 100644
292 --- a/arch/arm/mach-davinci/Makefile
293 +++ b/arch/arm/mach-davinci/Makefile
294 @@ -19,3 +19,4 @@ obj-$(CONFIG_MACH_DAVINCI_EVM) += board-dm644x-evm.o
295 obj-$(CONFIG_MACH_DAVINCI_DM646X_EVM) += board-dm646x-evm.o
296 obj-$(CONFIG_MACH_DAVINCI_DM355_EVM) += board-dm355-evm.o
297 obj-$(CONFIG_MACH_SFFSDR) += board-sffsdr.o
298 +obj-$(CONFIG_SFFSDR_FPGA) += board-sffsdr-fpga.o
299 diff --git a/arch/arm/mach-davinci/board-sffsdr-fpga.c b/arch/arm/mach-davinci/board-sffsdr-fpga.c
301 index 0000000..b6a64dd
303 +++ b/arch/arm/mach-davinci/board-sffsdr-fpga.c
306 + * SFFSDR-board specific FPGA driver
308 + * Copyright (C) 2008 Lyrtech <www.lyrtech.com>
310 + * This program is free software; you can redistribute it and/or modify
311 + * it under the terms of the GNU General Public License as published by
312 + * the Free Software Foundation; either version 2 of the License, or
313 + * (at your option) any later version.
315 + * This program is distributed in the hope that it will be useful,
316 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
317 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
318 + * GNU General Public License for more details.
320 + * You should have received a copy of the GNU General Public License
321 + * along with this program; if not, write to the Free Software
322 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
325 +#include <linux/kernel.h>
326 +#include <linux/module.h>
327 +#include <linux/init.h>
328 +#include <linux/device.h>
329 +#include <linux/string.h>
330 +#include <linux/platform_device.h>
331 +#include <linux/err.h>
332 +#include <linux/io.h>
333 +#include <linux/cdev.h>
334 +#include <linux/fs.h>
335 +#include <linux/fpgadl.h>
337 +#include <asm/gpio.h>
339 +#include <mach/sffsdr-fpga.h>
341 +#define MODULE_NAME "sffsdr_fpga"
343 +/* Used to determine if the bitstream is loaded. */
344 +#define FPGA_DEVICE_NAME "fpgadl_par0"
346 +/* Define this to have verbose debug messages. */
347 +#define SFFSDR_FPGA_DEBUG 1
349 +#ifdef SFFSDR_FPGA_DEBUG
350 +#define DBGMSG(fmt, args...) \
351 + printk(KERN_INFO "%s: "fmt"\n" , MODULE_NAME, ## args)
352 +#define FAILMSG(fmt, args...) \
353 + printk(KERN_ERR "%s: "fmt"\n" , MODULE_NAME, ## args)
355 +#define DBGMSG(fmt, args...)
356 +#define FAILMSG(fmt, args...)
359 +#define FPGA_FULL_RESET_VAL 3
360 +#define FPGA_PARTIAL_RESET_VAL 2
362 +#define FPGA_DS2_ON (1<<0)
363 +#define FPGA_DS3_ON (1<<1)
364 +#define FPGA_DS4_ON (1<<2)
365 +#define FPGA_DS5_ON (1<<3)
366 +#define FPGA_DS6_ON (1<<4)
368 +/* Sampling frequency divider, bits 5:4 */
369 +#define FPGA_FS_DIV_BY_1 (0<<4)
370 +#define FPGA_FS_DIV_BY_2 (1<<4)
371 +#define FPGA_FS_DIV_BY_4 (2<<4)
372 +#define FPGA_FS_DIV_RSV (3<<4)
374 +/* Sampling rate selection, bit 2 */
375 +#define FPGA_SR_STANDARD (0<<2) /* Standard sampling rate, default */
376 +#define FPGA_SR_DOUBLE (1<<2) /* Double sampling rate */
378 +/* Sampling frequency selection, bits 1:0 */
379 +#define FPGA_FS_48000 (0<<0) /* 48.0 kHz (PLL 12.288 MHz) */
380 +#define FPGA_FS_44100 (1<<0) /* 44.1 kHz (PLL 11.2896 MHz) */
381 +#define FPGA_FS_32000 (2<<0) /* 32.0 kHz (PLL 8.192 MHz) */
382 +#define FPGA_FS_RSV (3<<0) /* Reserved */
384 +struct sffsdr_fpga_dev_t {
385 + int bitstream_mode;
390 + SFFSDR_FPGA_STATE_START,
391 + SFFSDR_FPGA_STATE_DRV_STRUCT_ALLOCATED,
392 + SFFSDR_FPGA_STATE_REGS_MAPPED,
393 +} sffsdr_fpga_state;
395 +struct sffsdr_fpga_dev_t *sffsdr_fpga_dev;
397 +/* The EMIF address lines A0 to A2 are not routed to the
398 + * FPGA. Therefore, the upper 16 bits are never valid. */
399 +u16 sffsdr_fpga_regread(int offset)
401 + return sffsdr_fpga_dev->regs[offset / 2];
403 +EXPORT_SYMBOL(sffsdr_fpga_regread);
405 +void sffsdr_fpga_regwrite(int offset, u16 value)
407 + sffsdr_fpga_dev->regs[offset / 2] = value;
409 +EXPORT_SYMBOL(sffsdr_fpga_regwrite);
411 +/* Reset the inside logic of the FPGA according to the
412 + * bitstream mode. This is done when the bitstream has
413 + * been programmed and is Lyrtech SFF-SDR specific. */
414 +static void sffsdr_fpga_reset(int bitstream_mode)
418 + if (bitstream_mode == BITSTREAM_MODE_FULL)
419 + value = FPGA_FULL_RESET_VAL;
421 + value = FPGA_PARTIAL_RESET_VAL;
423 + sffsdr_fpga_regwrite(SFFSDR_FPGA_GLOBAL_CTRL, value);
424 + sffsdr_fpga_regwrite(SFFSDR_FPGA_GLOBAL_CTRL, 0);
427 +static int sffsdr_fpga_post_load(int bitstream_mode)
429 + DBGMSG("sffsdr_fpga_post_load()");
431 + if (fpgadl_is_bitstream_loaded(FPGA_DEVICE_NAME) < 1) {
432 + FAILMSG(" FPGA is not programmed");
436 + sffsdr_fpga_reset(bitstream_mode);
438 + DBGMSG("FPGA Revision: %d",
439 + sffsdr_fpga_regread(SFFSDR_FPGA_REVISION));
441 + /* Light some LEDs to indicate success. */
442 + sffsdr_fpga_regwrite(SFFSDR_FPGA_LED_CONTROL, FPGA_DS2_ON |
443 + FPGA_DS3_ON | FPGA_DS4_ON | FPGA_DS5_ON |
446 + /* Set default CODEC clock values. */
447 + sffsdr_fpga_regwrite(SFFSDR_FPGA_PLL_CODEC, FPGA_FS_DIV_BY_1 |
448 + FPGA_FS_44100 | FPGA_SR_STANDARD);
453 +int sffsdr_fpga_set_codec_fs(int fs)
457 + if (fpgadl_is_bitstream_loaded(FPGA_DEVICE_NAME) < 1) {
458 + FAILMSG("FPGA is not programmed");
464 + fs_mask = FPGA_FS_32000;
467 + fs_mask = FPGA_FS_44100;
470 + fs_mask = FPGA_FS_48000;
473 + FAILMSG("Unsupported sampling frequency");
478 + sffsdr_fpga_regwrite(SFFSDR_FPGA_PLL_CODEC, FPGA_FS_DIV_BY_1 |
479 + fs_mask | FPGA_SR_STANDARD);
483 +EXPORT_SYMBOL(sffsdr_fpga_set_codec_fs);
485 +static void sffsdr_fpga_cleanup(void)
487 + switch (sffsdr_fpga_state) {
488 + case SFFSDR_FPGA_STATE_REGS_MAPPED:
489 + iounmap(sffsdr_fpga_dev->regs);
490 + case SFFSDR_FPGA_STATE_DRV_STRUCT_ALLOCATED:
491 + kfree(sffsdr_fpga_dev);
492 + case SFFSDR_FPGA_STATE_START:
493 + /* Nothing to do. */
498 +static int __devinit sffsdr_fpga_probe(struct platform_device *pdev)
500 + struct resource *fpgaregs_res;
504 + DBGMSG("sffsdr_fpga_probe()");
506 + sffsdr_fpga_state = SFFSDR_FPGA_STATE_START;
508 + sffsdr_fpga_dev = kzalloc(sizeof(*sffsdr_fpga_dev), GFP_KERNEL);
509 + if (!sffsdr_fpga_dev) {
510 + FAILMSG("Failed to allocate device structure");
514 + sffsdr_fpga_state = SFFSDR_FPGA_STATE_DRV_STRUCT_ALLOCATED;
516 + pdev->dev.driver_data = sffsdr_fpga_dev; /* Private driver data */
518 + /* Assign virtual addresses to FPGAREGS I/O memory regions. */
519 + fpgaregs_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
521 + if (!fpgaregs_res) {
522 + FAILMSG("Error getting fpgaregs ressource");
526 + len = fpgaregs_res->end - fpgaregs_res->start;
527 + sffsdr_fpga_dev->regs = ioremap(fpgaregs_res->start, len);
528 + if (!sffsdr_fpga_dev->regs) {
529 + FAILMSG("Can't remap fpgaregs registers");
533 + sffsdr_fpga_state = SFFSDR_FPGA_STATE_REGS_MAPPED;
536 + sffsdr_fpga_post_load(BITSTREAM_MODE_FULL);
541 + sffsdr_fpga_cleanup();
545 +static int __devexit sffsdr_fpga_remove(struct platform_device *pdev)
547 + DBGMSG("sffsdr_fpga_remove()");
548 + sffsdr_fpga_cleanup();
553 +static struct platform_driver sffsdr_fpga_platform_driver = {
555 + .name = MODULE_NAME,
556 + .owner = THIS_MODULE,
558 + .remove = sffsdr_fpga_remove,
561 +static int __init sffsdr_fpga_init(void)
565 + DBGMSG("sffsdr_fpga_init()");
567 + res = platform_driver_probe(&sffsdr_fpga_platform_driver,
568 + sffsdr_fpga_probe);
570 + DBGMSG("platform_driver_probe() failed");
576 +module_init(sffsdr_fpga_init);
578 +static void __exit sffsdr_fpga_exit(void)
580 + DBGMSG("sffsdr_fpga_exit()");
581 + platform_driver_unregister(&sffsdr_fpga_platform_driver);
583 +module_exit(sffsdr_fpga_exit);
585 +MODULE_AUTHOR("Hugo Villeneuve <hvilleneuve@lyrtech.com>");
586 +MODULE_DESCRIPTION("Lyrtech SFFSDR SX-35 FPGA driver");
587 +MODULE_LICENSE("GPL");
588 diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c
589 index 0d83cb0..aee4472 100644
590 --- a/arch/arm/mach-davinci/board-sffsdr.c
591 +++ b/arch/arm/mach-davinci/board-sffsdr.c
593 * Copyright (C) 2008 Lyrtech <www.lyrtech.com>
595 * Based on DV-EVM platform, original copyright follows:
597 - * Copyright (C) 2007 MontaVista Software, Inc.
598 + * Copyright (C) 2007 MontaVista Software, Inc.
600 * This program is free software; you can redistribute it and/or modify
601 * it under the terms of the GNU General Public License as published by
603 #include <linux/dma-mapping.h>
604 #include <linux/platform_device.h>
605 #include <linux/gpio.h>
607 #include <linux/i2c.h>
608 #include <linux/i2c/at24.h>
609 #include <linux/etherdevice.h>
611 #include <linux/mtd/partitions.h>
612 #include <linux/mtd/physmap.h>
613 #include <linux/io.h>
614 +#include <linux/fpgadl.h>
616 #include <asm/setup.h>
617 #include <asm/mach-types.h>
619 #include <asm/mach/arch.h>
620 #include <asm/mach/map.h>
621 #include <asm/mach/flash.h>
623 #include <mach/emac.h>
624 #include <mach/i2c.h>
625 #include <mach/serial.h>
626 +#include <mach/mmc.h>
627 #include <mach/psc.h>
628 #include <mach/mux.h>
629 +#include <mach/nand.h>
630 +#include <mach/mmc.h>
631 +#include <mach/sffsdr-lyrvpfe.h>
633 +#define XC4VSX35_PAYLOAD_SIZE (1707240)
635 +#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
636 +#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
638 +#define DAVINCI_VPSS_REGS_BASE 0x01C70000
640 +#define FPGA_SELECTMAP_BASE 0x04000000
641 +#define FPGA_SFFSDR_REGS_BASE 0x04008000
643 +/* DDR2 memory is 256 Mbytes */
644 +#define DDR2_BASE 0x80000000
646 -#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
647 -#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
648 +#define SFFSDR_MMC_CD_PIN GPIO(51)
649 +#define SFFSDR_MMC_RO_PIN GPIO(50)
651 struct mtd_partition davinci_sffsdr_nandflash_partition[] = {
652 /* U-Boot Environment: Block 0
653 @@ -78,9 +93,10 @@ struct mtd_partition davinci_sffsdr_nandflash_partition[] = {
657 -static struct flash_platform_data davinci_sffsdr_nandflash_data = {
658 +static struct davinci_nand_pdata davinci_sffsdr_nandflash_data = {
659 .parts = davinci_sffsdr_nandflash_partition,
660 .nr_parts = ARRAY_SIZE(davinci_sffsdr_nandflash_partition),
661 + .ecc_mode = NAND_ECC_HW,
664 static struct resource davinci_sffsdr_nandflash_resource[] = {
665 @@ -105,9 +121,6 @@ static struct platform_device davinci_sffsdr_nandflash_device = {
666 .resource = davinci_sffsdr_nandflash_resource,
669 -/* Get Ethernet address from kernel boot params */
670 -static u8 davinci_sffsdr_mac_addr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
672 static struct at24_platform_data eeprom_info = {
673 .byte_len = (64*1024) / 8,
675 @@ -137,12 +150,126 @@ static void __init sffsdr_init_i2c(void)
676 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
679 +static int sffsdr_mmc_get_cd(int module)
681 + return gpio_get_value(SFFSDR_MMC_CD_PIN);
684 +static int sffsdr_mmc_get_ro(int module)
686 + return gpio_get_value(SFFSDR_MMC_RO_PIN);
689 +static struct davinci_mmc_config sffsdr_mmc_config = {
690 + .get_cd = sffsdr_mmc_get_cd,
691 + .get_ro = sffsdr_mmc_get_ro,
696 + * The FPGA is loaded using the SelectMAP mode through
697 + * the EMIF interface and some dedicated control signals:
700 + * --------------------
704 + * DOUT_BUSY GPIO42 (Not used)
705 + * CS_B EMIF_A13 OR CS3n
707 +static struct fpgadl_pdata_t fpgadl_par_pdata = {
708 + .fpga_family = FPGA_FAMILY_XILINX_XC4V,
709 + .payload_full_size = XC4VSX35_PAYLOAD_SIZE,
710 + .program_b = GPIO(37),
712 + .init_b = GPIO(40),
713 + .bitstream_name = "fpga.bit",
714 + .check_init_low = 0,
717 +/* FPGA physical EMIF register resources. */
718 +static struct resource davinci_fpgadl_par_resources[] = {
720 + .name = "selectmap",
721 + .start = FPGA_SELECTMAP_BASE,
722 + .end = FPGA_SELECTMAP_BASE + 4 - 1,
723 + .flags = IORESOURCE_MEM,
727 +static struct platform_device davinci_fpgadl_par_device = {
728 + .name = "fpgadl_par", /* Name of driver */
731 + .platform_data = &fpgadl_par_pdata,
733 + .num_resources = ARRAY_SIZE(davinci_fpgadl_par_resources),
734 + .resource = davinci_fpgadl_par_resources,
737 +/* SFFSDR specific FPGA registers. */
738 +static struct resource davinci_sffsdr_fpga_resources[] = {
740 + .name = "sffsdr_regs",
741 + .start = FPGA_SFFSDR_REGS_BASE,
742 + .end = FPGA_SFFSDR_REGS_BASE + SZ_1K - 1,
743 + .flags = IORESOURCE_MEM,
747 +static struct platform_device davinci_sffsdr_fpga_device = {
748 + .name = "sffsdr_fpga", /* Name of driver */
749 + .id = -1, /* Only one instance = -1 */
750 + .num_resources = ARRAY_SIZE(davinci_sffsdr_fpga_resources),
751 + .resource = davinci_sffsdr_fpga_resources,
754 +static struct lyrvpfe_platform_data lyrvpfe_pdata = {
756 + * GPIO(1) for DSP to FPGA (VPBE)
757 + * GPIO(0) for FPGA to DSP (VPFE)
759 + .ready_gpio = GPIO(0), /* DSP to FPGA (VPFE) */
762 +static struct resource lyrvpfe_resources[] = {
765 + .start = DAVINCI_VPSS_REGS_BASE,
766 + .end = DAVINCI_VPSS_REGS_BASE + SZ_16K - 1,
767 + .flags = IORESOURCE_MEM,
771 + .start = IRQ_VDINT0,
773 + .flags = IORESOURCE_IRQ,
777 +static struct platform_device lyrvpfe_pdev = {
781 + .platform_data = &lyrvpfe_pdata,
783 + .resource = lyrvpfe_resources,
784 + .num_resources = ARRAY_SIZE(lyrvpfe_resources),
787 static struct platform_device *davinci_sffsdr_devices[] __initdata = {
788 - &davinci_sffsdr_nandflash_device,
789 + &davinci_fpgadl_par_device, /* Bitstream loading - parallel */
790 + &davinci_sffsdr_fpga_device, /* Application functionality */
798 static struct davinci_uart_config uart_config __initdata = {
799 - .enabled_uarts = (1 << 0),
800 + .enabled_uarts = DAVINCI_UART0_ENA | DAVINCI_UART1_ENA,
803 static void __init davinci_sffsdr_map_io(void)
804 @@ -151,39 +278,37 @@ static void __init davinci_sffsdr_map_io(void)
808 -static __init void davinci_sffsdr_init(void)
809 +static void __init davinci_sffsdr_init(void)
811 + gpio_request(SFFSDR_MMC_CD_PIN, "MMC CD");
812 + gpio_direction_input(SFFSDR_MMC_CD_PIN);
813 + gpio_request(SFFSDR_MMC_RO_PIN, "MMC RO");
814 + gpio_direction_input(SFFSDR_MMC_RO_PIN);
816 + /* Turn UART1 MUX ON. */
817 + davinci_cfg_reg(DM644X_UART1);
819 platform_add_devices(davinci_sffsdr_devices,
820 ARRAY_SIZE(davinci_sffsdr_devices));
822 - davinci_serial_init(&uart_config);
823 - davinci_init_emac(davinci_sffsdr_mac_addr);
824 - setup_usb(0, 0); /* We support only peripheral mode. */
826 - /* mux VLYNQ pins */
827 - davinci_cfg_reg(DM644X_VLYNQEN);
828 - davinci_cfg_reg(DM644X_VLYNQWD);
830 + davinci_serial_init(&uart_config);
832 -static int davinci_cpmac_eth_setup(char *str)
835 +#if defined(CONFIG_MTD_NAND_DAVINCI) || \
836 + defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
837 + davinci_cfg_reg(DM644X_HPIEN_DISABLE);
838 + davinci_cfg_reg(DM644X_ATAEN_DISABLE);
839 + platform_device_register(&davinci_sffsdr_nandflash_device);
844 + davinci_setup_mmc(0, &sffsdr_mmc_config);
846 - /* Conversion of a MAC address from a string (AA:BB:CC:DD:EE:FF)
847 - * to a 6 bytes array. */
848 - for (i = 0; i < 6; i++)
849 - davinci_sffsdr_mac_addr[i] = simple_strtol(&str[i*3],
850 - (char **)NULL, 16);
851 + davinci_init_emac(NULL);
854 + setup_usb(0, 0); /* We support only peripheral mode. */
856 -/* Get MAC address from kernel boot parameter eth=AA:BB:CC:DD:EE:FF */
857 -__setup("eth=", davinci_cpmac_eth_setup);
859 -static __init void davinci_sffsdr_irq_init(void)
860 +static void __init davinci_sffsdr_irq_init(void)
864 @@ -195,6 +320,6 @@ MACHINE_START(SFFSDR, "Lyrtech SFFSDR")
865 .boot_params = (DAVINCI_DDR_BASE + 0x100),
866 .map_io = davinci_sffsdr_map_io,
867 .init_irq = davinci_sffsdr_irq_init,
868 - .timer = &davinci_timer,
869 .init_machine = davinci_sffsdr_init,
870 + .timer = &davinci_timer,
872 diff --git a/arch/arm/mach-davinci/include/mach/sffsdr-fpga.h b/arch/arm/mach-davinci/include/mach/sffsdr-fpga.h
874 index 0000000..6607ac0
876 +++ b/arch/arm/mach-davinci/include/mach/sffsdr-fpga.h
881 + * This program is free software; you can redistribute it and/or modify it
882 + * under the terms of the GNU General Public License as published by the
883 + * Free Software Foundation; either version 2 of the License, or (at your
884 + * option) any later version.
886 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
887 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
888 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
889 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
890 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
891 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
892 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
893 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
894 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
895 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
897 + * You should have received a copy of the GNU General Public License along
898 + * with this program; if not, write to the Free Software Foundation, Inc.,
899 + * 675 Mass Ave, Cambridge, MA 02139, USA.
902 +#ifndef __SFFSDR_FPGA_H
903 +#define __SFFSDR_FPGA_H
905 +#define SFFSDR_FPGA_REVISION 0x000
906 +#define SFFSDR_FPGA_GLOBAL_CTRL 0x040
907 +#define SFFSDR_FPGA_LED_CONTROL 0x300
908 +#define SFFSDR_FPGA_PLL_CODEC 0x800
910 +/* VPSS configuration register */
911 +#define SFFSDR_FPGA_VPSS_CONTROL 0xA00
913 +/* VPSS, VPBE packet size configuration register */
914 +#define SFFSDR_FPGA_VPSS_FROM_DSP_FIFO 0xA40
916 +/* VPSS, VPFE packet size configuration register */
917 +#define SFFSDR_FPGA_VPSS_TO_DSP_FIFO 0xA80
919 +/* VPSS, VPFE number of lines configuration register */
920 +#define SFFSDR_FPGA_VPSS_LINES_PER_FRAME 0xAC0
922 +#define SFFSDR_FPGA_CUSTOM_REG0_LSB 0xC00
923 +#define SFFSDR_FPGA_CUSTOM_REG0_MSB 0xC20
925 +u16 sffsdr_fpga_regread(int offset);
927 +void sffsdr_fpga_regwrite(int offset, u16 value);
929 +int sffsdr_fpga_set_codec_fs(int fs);
931 +#endif /* __SFFSDR_FPGA_H */