Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # cat /usr/src/uClinux-dist-2010R1-RC5/linux-2.6.x/arch/blackfin/mach-bf533/boards/ip0x.c
- /*
- * Copyright 2004-2009 Analog Devices Inc.
- * 2007 David Rowe
- * 2006 Intratrade Ltd.
- * Ivan Danov <idanov@gmail.com>
- * 2005 National ICT Australia (NICTA)
- * Aidan Williams <aidan@nicta.com.au>
- *
- * Licensed under the GPL-2 or later.
- */
- #include <linux/device.h>
- #include <linux/platform_device.h>
- #include <linux/mtd/mtd.h>
- #include <linux/mtd/nand.h>
- #include <linux/mtd/partitions.h>
- #include <linux/spi/spi.h>
- #include <linux/spi/flash.h>
- #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
- #include <linux/usb/isp1362.h>
- #endif
- #include <asm/irq.h>
- #include <asm/dma.h>
- #include <asm/bfin5xx_spi.h>
- #include <asm/portmux.h>
- //#include <linux/slab.h>
- //#include <linux/init.h>
- //#include <linux/module.h>
- //#include <asm/blackfin.h>
- //#include <asm/gpio.h>
- #include <asm-generic/io.h>
- /*
- * Name the Board for the /proc/cpuinfo
- */
- const char bfin_board_name[] = "IP04/IP08";
- /*
- * Driver needs to know address, irq and flag pin.
- */
- #if defined(CONFIG_BFIN532_IP0X)
- #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
- #include <linux/dm9000.h>
- static struct resource dm9000_resource1[] = {
- {
- .start = 0x20100000,
- .end = 0x20100000 + 1,
- .flags = IORESOURCE_MEM
- },{
- .start = 0x20100000 + 2,
- .end = 0x20100000 + 3,
- .flags = IORESOURCE_MEM
- },{
- .start = IRQ_PF15,
- .end = IRQ_PF15,
- .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
- }
- };
- static struct resource dm9000_resource2[] = {
- {
- .start = 0x20200000,
- .end = 0x20200000 + 1,
- .flags = IORESOURCE_MEM
- },{
- .start = 0x20200000 + 2,
- .end = 0x20200000 + 3,
- .flags = IORESOURCE_MEM
- },{
- .start = IRQ_PF14,
- .end = IRQ_PF14,
- .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
- }
- };
- /*
- * for the moment we limit ourselves to 16bit IO until some
- * better IO routines can be written and tested
- */
- static struct dm9000_plat_data dm9000_platdata1 = {
- .flags = DM9000_PLATF_16BITONLY,
- };
- static struct platform_device dm9000_device1 = {
- .name = "dm9000",
- .id = 0,
- .num_resources = ARRAY_SIZE(dm9000_resource1),
- .resource = dm9000_resource1,
- .dev = {
- .platform_data = &dm9000_platdata1,
- }
- };
- static struct dm9000_plat_data dm9000_platdata2 = {
- .flags = DM9000_PLATF_16BITONLY,
- };
- static struct platform_device dm9000_device2 = {
- .name = "dm9000",
- .id = 1,
- .num_resources = ARRAY_SIZE(dm9000_resource2),
- .resource = dm9000_resource2,
- .dev = {
- .platform_data = &dm9000_platdata2,
- }
- };
- #endif
- #endif
- #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
- /* all SPI peripherals info goes here */
- #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
- static struct bfin5xx_spi_chip mmc_spi_chip_info = {
- .enable_dma = 0, /* if 1 - block!!! */
- .bits_per_word = 8,
- };
- #endif
- /* Notice: for blackfin, the speed_hz is the value of register
- * SPI_BAUD, not the real baudrate */
- static struct spi_board_info bfin_spi_board_info[] __initdata = {
- #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
- {
- .modalias = "mmc_spi",
- .max_speed_hz = 2,
- .bus_num = 1,
- .chip_select = 5,
- .controller_data = &mmc_spi_chip_info,
- },
- #endif
- };
- /* SPI controller data */
- static struct bfin5xx_spi_master spi_bfin_master_info = {
- .num_chipselect = 8,
- .enable_dma = 1, /* master has the ability to do dma transfer */
- };
- static struct platform_device spi_bfin_master_device = {
- .name = "bfin-spi-master",
- .id = 1, /* Bus number */
- .dev = {
- .platform_data = &spi_bfin_master_info, /* Passed to driver */
- },
- };
- #endif /* spi master and devices */
- #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
- #ifdef CONFIG_SERIAL_BFIN_UART0
- static struct resource bfin_uart0_resources[] = {
- {
- .start = BFIN_UART_THR,
- .end = BFIN_UART_GCTL+2,
- .flags = IORESOURCE_MEM,
- },
- {
- .start = IRQ_UART0_RX,
- .end = IRQ_UART0_RX + 1,
- .flags = IORESOURCE_IRQ,
- },
- {
- .start = IRQ_UART0_ERROR,
- .end = IRQ_UART0_ERROR,
- .flags = IORESOURCE_IRQ,
- },
- {
- .start = CH_UART0_TX,
- .end = CH_UART0_TX,
- .flags = IORESOURCE_DMA,
- },
- {
- .start = CH_UART0_RX,
- .end = CH_UART0_RX,
- .flags = IORESOURCE_DMA,
- },
- };
- unsigned short bfin_uart0_peripherals[] = {
- P_UART0_TX, P_UART0_RX, 0
- };
- static struct platform_device bfin_uart0_device = {
- .name = "bfin-uart",
- .id = 0,
- .num_resources = ARRAY_SIZE(bfin_uart0_resources),
- .resource = bfin_uart0_resources,
- .dev = {
- .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
- },
- };
- #endif
- #endif
- #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
- #ifdef CONFIG_BFIN_SIR0
- static struct resource bfin_sir0_resources[] = {
- {
- .start = 0xFFC00400,
- .end = 0xFFC004FF,
- .flags = IORESOURCE_MEM,
- },
- {
- .start = IRQ_UART0_RX,
- .end = IRQ_UART0_RX+1,
- .flags = IORESOURCE_IRQ,
- },
- {
- .start = CH_UART0_RX,
- .end = CH_UART0_RX+1,
- .flags = IORESOURCE_DMA,
- },
- };
- static struct platform_device bfin_sir0_device = {
- .name = "bfin_sir",
- .id = 0,
- .num_resources = ARRAY_SIZE(bfin_sir0_resources),
- .resource = bfin_sir0_resources,
- };
- #endif
- #endif
- #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
- static struct resource isp1362_hcd_resources[] = {
- {
- .start = 0x20300000,
- .end = 0x20300000 + 1,
- .flags = IORESOURCE_MEM,
- },{
- .start = 0x20300000 + 2,
- .end = 0x20300000 + 3,
- .flags = IORESOURCE_MEM,
- },{
- .start = IRQ_PF11,
- .end = IRQ_PF11,
- .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
- },
- };
- static struct isp1362_platform_data isp1362_priv = {
- .sel15Kres = 1,
- .clknotstop = 0,
- .oc_enable = 0, /* external OC */
- .int_act_high = 0,
- .int_edge_triggered = 0,
- .remote_wakeup_connected = 0,
- .no_power_switching = 1,
- .power_switching_mode = 0,
- };
- static struct platform_device isp1362_hcd_device = {
- .name = "isp1362-hcd",
- .id = 0,
- .dev = {
- .platform_data = &isp1362_priv,
- },
- .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
- .resource = isp1362_hcd_resources,
- };
- #endif
- #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
- #ifdef CONFIG_MTD_PARTITIONS
- const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
- static struct mtd_partition bfin_plat_nand_partitions[] = {
- {
- .name = "linux kernel(nand)",
- .size = 0x800000,
- .offset = 0,
- }, {
- .name = "file system(nand)",
- //.size = MTDPART_SIZ_FULL,
- //Note: in linux-2.6.x/.config: CONFIG_BFIN_NAND_PLAT_SIZE=0x10000000
- .size = (CONFIG_BFIN_NAND_PLAT_SIZE-0x800000),
- //.offset = MTDPART_OFS_APPEND,
- .offset = 0x800000,
- },
- };
- #endif
- //#define BFIN_NAND_BASE CONFIG_BFIN_NAND_BASE */
- #define BFIN_NAND_BASE CONFIG_BFIN_NAND_PLAT_BASE
- //#define BFIN_NAND_CLE (1<<CONFIG_BFIN_NAND_CLE) */ /* Ax -> Command Enable */
- //#define BFIN_NAND_ALE (1<<CONFIG_BFIN_NAND_ALE) /* Ax -> Address Enable */
- #define BFIN_NAND_PLAT_CLE (1<<CONFIG_BFIN_NAND_PLAT_CLE) /* Ax -> Command Enable */
- #define BFIN_NAND_PLAT_ALE (1<<CONFIG_BFIN_NAND_PLAT_ALE) /* Ax -> Address Enable */
- //#define BFIN_NAND_PLAT_CLE 2
- //#define BFIN_NAND_PLAT_ALE 1
- static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
- {
- struct nand_chip *this = mtd->priv;
- if (cmd == NAND_CMD_NONE)
- return;
- if (ctrl & NAND_CLE)
- writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE));
- else
- writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE));
- }
- #define BFIN_NAND_PLAT_READY GPIO_PF3
- static int bfin_plat_nand_dev_ready(struct mtd_info *mtd)
- {
- return gpio_get_value(BFIN_NAND_PLAT_READY);
- }
- static struct platform_nand_data bfin_plat_nand_data = {
- .chip = {
- .nr_chips = 1,
- .chip_delay = 30,
- #ifdef CONFIG_MTD_PARTITIONS
- .part_probe_types = part_probes,
- .partitions = bfin_plat_nand_partitions,
- .nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions),
- #endif
- },
- .ctrl = {
- .cmd_ctrl = bfin_plat_nand_cmd_ctrl,
- .dev_ready = bfin_plat_nand_dev_ready,
- },
- };
- #define MAX(x, y) (x > y ? x : y)
- static struct resource bfin_plat_nand_resources = {
- //.start = 0x20212000,
- .start = 0x20000000,
- //.end = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
- .end = 0x20000000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
- .flags = IORESOURCE_MEM,
- };
- static struct platform_device bfin_async_nand_device = {
- .name = "gen_nand",
- .id = -1,
- .num_resources = 1,
- .resource = &bfin_plat_nand_resources,
- .dev = {
- .platform_data = &bfin_plat_nand_data,
- },
- };
- static void bfin_plat_nand_init(void)
- {
- gpio_request(BFIN_NAND_PLAT_READY, "bfin_nand_plat");
- //Added by me
- printk("CLE is %d and ALE is %d\n",BFIN_NAND_PLAT_CLE,BFIN_NAND_PLAT_ALE);
- }
- #else
- static void bfin_plat_nand_init(void) {}
- #endif
- #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
- static struct mtd_partition stamp_partitions[] = {
- {
- .name = "bootloader(nor)",
- .size = 0x40000,
- .offset = 0,
- }, {
- .name = "linux kernel(nor)",
- .size = 0x180000,
- .offset = MTDPART_OFS_APPEND,
- }, {
- .name = "file system(nor)",
- .size = 0x400000 - 0x40000 - 0x180000 - 0x10000,
- .offset = MTDPART_OFS_APPEND,
- }, {
- .name = "MAC Address(nor)",
- .size = MTDPART_SIZ_FULL,
- .offset = 0x3F0000,
- .mask_flags = MTD_WRITEABLE,
- }
- };
- static struct physmap_flash_data stamp_flash_data = {
- .width = 2,
- .parts = stamp_partitions,
- .nr_parts = ARRAY_SIZE(stamp_partitions),
- #ifdef CONFIG_ROMKERNEL
- .probe_type = "map_rom",
- #endif
- };
- static struct resource stamp_flash_resource = {
- .start = 0x20000000,
- .end = 0x203fffff,
- .flags = IORESOURCE_MEM,
- };
- static struct platform_device stamp_flash_device = {
- .name = "physmap-flash",
- .id = 0,
- .dev = {
- .platform_data = &stamp_flash_data,
- },
- .num_resources = 1,
- .resource = &stamp_flash_resource,
- };
- #endif
- static struct platform_device *ip0x_devices[] __initdata = {
- #if defined(CONFIG_BFIN532_IP0X)
- #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
- &dm9000_device1,
- &dm9000_device2,
- #endif
- #endif
- #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
- &spi_bfin_master_device,
- #endif
- #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
- #ifdef CONFIG_SERIAL_BFIN_UART0
- &bfin_uart0_device,
- #endif
- #endif
- #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
- #ifdef CONFIG_BFIN_SIR0
- &bfin_sir0_device,
- #endif
- #endif
- #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
- &isp1362_hcd_device,
- #endif
- #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
- &bfin_async_nand_device,
- #endif
- };
- static int __init ip0x_init(void)
- {
- int i;
- printk(KERN_INFO "%s(): registering device resources\n", __func__);
- bfin_plat_nand_init();
- platform_add_devices(ip0x_devices, ARRAY_SIZE(ip0x_devices));
- #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
- for (i = 0; i < ARRAY_SIZE(bfin_spi_board_info); ++i) {
- int j = 1 << bfin_spi_board_info[i].chip_select;
- /* set spi cs to 1 */
- bfin_write_FIO_DIR(bfin_read_FIO_DIR() | j);
- bfin_write_FIO_FLAG_S(j);
- }
- spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
- #endif
- return 0;
- }
- arch_initcall(ip0x_init);
- static struct platform_device *ip0x_early_devices[] __initdata = {
- #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
- #ifdef CONFIG_SERIAL_BFIN_UART0
- &bfin_uart0_device,
- #endif
- #endif
- };
- void __init native_machine_early_platform_add_devices(void)
- {
- printk(KERN_INFO "register early platform devices\n");
- early_platform_add_devices(ip0x_early_devices,
- ARRAY_SIZE(ip0x_early_devices));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement