Path: blob/master/arch/arm/mach-ep93xx/snappercl15.c
10817 views
/*1* arch/arm/mach-ep93xx/snappercl15.c2* Bluewater Systems Snapper CL15 system module3*4* Copyright (C) 2009 Bluewater Systems Ltd5* Author: Ryan Mallon <[email protected]>6*7* NAND code adapted from driver by:8* Andre Renaud <[email protected]>9* James R. McKaskill10*11* This program is free software; you can redistribute it and/or modify12* it under the terms of the GNU General Public License as published by13* the Free Software Foundation; either version 2 of the License, or (at14* your option) any later version.15*16*/1718#include <linux/platform_device.h>19#include <linux/kernel.h>20#include <linux/init.h>21#include <linux/io.h>22#include <linux/gpio.h>23#include <linux/i2c.h>24#include <linux/i2c-gpio.h>25#include <linux/fb.h>2627#include <linux/mtd/partitions.h>28#include <linux/mtd/nand.h>2930#include <mach/hardware.h>31#include <mach/fb.h>3233#include <asm/mach-types.h>34#include <asm/mach/arch.h>3536#define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M)3738#define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */39#define SNAPPERCL15_NAND_ALE (1 << 9) /* Address latch */40#define SNAPPERCL15_NAND_CLE (1 << 10) /* Command latch */41#define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */42#define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */4344#define NAND_CTRL_ADDR(chip) (chip->IO_ADDR_W + 0x40)4546static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,47unsigned int ctrl)48{49struct nand_chip *chip = mtd->priv;50static u16 nand_state = SNAPPERCL15_NAND_WPN;51u16 set;5253if (ctrl & NAND_CTRL_CHANGE) {54set = SNAPPERCL15_NAND_CEN | SNAPPERCL15_NAND_WPN;5556if (ctrl & NAND_NCE)57set &= ~SNAPPERCL15_NAND_CEN;58if (ctrl & NAND_CLE)59set |= SNAPPERCL15_NAND_CLE;60if (ctrl & NAND_ALE)61set |= SNAPPERCL15_NAND_ALE;6263nand_state &= ~(SNAPPERCL15_NAND_CEN |64SNAPPERCL15_NAND_CLE |65SNAPPERCL15_NAND_ALE);66nand_state |= set;67__raw_writew(nand_state, NAND_CTRL_ADDR(chip));68}6970if (cmd != NAND_CMD_NONE)71__raw_writew((cmd & 0xff) | nand_state, chip->IO_ADDR_W);72}7374static int snappercl15_nand_dev_ready(struct mtd_info *mtd)75{76struct nand_chip *chip = mtd->priv;7778return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY);79}8081static const char *snappercl15_nand_part_probes[] = {"cmdlinepart", NULL};8283static struct mtd_partition snappercl15_nand_parts[] = {84{85.name = "Kernel",86.offset = 0,87.size = SZ_2M,88},89{90.name = "Filesystem",91.offset = MTDPART_OFS_APPEND,92.size = MTDPART_SIZ_FULL,93},94};9596static struct platform_nand_data snappercl15_nand_data = {97.chip = {98.nr_chips = 1,99.part_probe_types = snappercl15_nand_part_probes,100.partitions = snappercl15_nand_parts,101.nr_partitions = ARRAY_SIZE(snappercl15_nand_parts),102.options = NAND_NO_AUTOINCR,103.chip_delay = 25,104},105.ctrl = {106.dev_ready = snappercl15_nand_dev_ready,107.cmd_ctrl = snappercl15_nand_cmd_ctrl,108},109};110111static struct resource snappercl15_nand_resource[] = {112{113.start = SNAPPERCL15_NAND_BASE,114.end = SNAPPERCL15_NAND_BASE + SZ_4K - 1,115.flags = IORESOURCE_MEM,116},117};118119static struct platform_device snappercl15_nand_device = {120.name = "gen_nand",121.id = -1,122.dev.platform_data = &snappercl15_nand_data,123.resource = snappercl15_nand_resource,124.num_resources = ARRAY_SIZE(snappercl15_nand_resource),125};126127static struct ep93xx_eth_data __initdata snappercl15_eth_data = {128.phy_id = 1,129};130131static struct i2c_gpio_platform_data __initdata snappercl15_i2c_gpio_data = {132.sda_pin = EP93XX_GPIO_LINE_EEDAT,133.sda_is_open_drain = 0,134.scl_pin = EP93XX_GPIO_LINE_EECLK,135.scl_is_open_drain = 0,136.udelay = 0,137.timeout = 0,138};139140static struct i2c_board_info __initdata snappercl15_i2c_data[] = {141{142/* Audio codec */143I2C_BOARD_INFO("tlv320aic23", 0x1a),144},145};146147static struct ep93xxfb_mach_info __initdata snappercl15_fb_info = {148.num_modes = EP93XXFB_USE_MODEDB,149.bpp = 16,150};151152static void __init snappercl15_init_machine(void)153{154ep93xx_init_devices();155ep93xx_register_eth(&snappercl15_eth_data, 1);156ep93xx_register_i2c(&snappercl15_i2c_gpio_data, snappercl15_i2c_data,157ARRAY_SIZE(snappercl15_i2c_data));158ep93xx_register_fb(&snappercl15_fb_info);159ep93xx_register_i2s();160platform_device_register(&snappercl15_nand_device);161}162163MACHINE_START(SNAPPER_CL15, "Bluewater Systems Snapper CL15")164/* Maintainer: Ryan Mallon <[email protected]> */165.boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,166.map_io = ep93xx_map_io,167.init_irq = ep93xx_init_irq,168.timer = &ep93xx_timer,169.init_machine = snappercl15_init_machine,170MACHINE_END171172173