Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ep93xx/snappercl15.c |
| 3 | * Bluewater Systems Snapper CL15 system module |
| 4 | * |
| 5 | * Copyright (C) 2009 Bluewater Systems Ltd |
Ryan Mallon | 1c5454e | 2011-06-15 14:45:36 +1000 | [diff] [blame] | 6 | * Author: Ryan Mallon |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 7 | * |
| 8 | * NAND code adapted from driver by: |
| 9 | * Andre Renaud <andre@bluewatersys.com> |
| 10 | * James R. McKaskill |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or (at |
| 15 | * your option) any later version. |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/io.h> |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 23 | #include <linux/i2c.h> |
| 24 | #include <linux/i2c-gpio.h> |
| 25 | #include <linux/fb.h> |
| 26 | |
| 27 | #include <linux/mtd/partitions.h> |
| 28 | #include <linux/mtd/nand.h> |
| 29 | |
| 30 | #include <mach/hardware.h> |
Arnd Bergmann | a3b2924 | 2012-08-24 15:12:11 +0200 | [diff] [blame] | 31 | #include <linux/platform_data/video-ep93xx.h> |
Linus Walleij | bd5f12a | 2011-09-22 08:07:00 +0100 | [diff] [blame] | 32 | #include <mach/gpio-ep93xx.h> |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 33 | |
| 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | |
Ryan Mallon | 258249e | 2012-01-11 09:06:08 +1100 | [diff] [blame] | 37 | #include "soc.h" |
| 38 | |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 39 | #define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M) |
| 40 | |
| 41 | #define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */ |
| 42 | #define SNAPPERCL15_NAND_ALE (1 << 9) /* Address latch */ |
| 43 | #define SNAPPERCL15_NAND_CLE (1 << 10) /* Command latch */ |
| 44 | #define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */ |
| 45 | #define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */ |
| 46 | |
| 47 | #define NAND_CTRL_ADDR(chip) (chip->IO_ADDR_W + 0x40) |
| 48 | |
| 49 | static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, |
| 50 | unsigned int ctrl) |
| 51 | { |
| 52 | struct nand_chip *chip = mtd->priv; |
| 53 | static u16 nand_state = SNAPPERCL15_NAND_WPN; |
| 54 | u16 set; |
| 55 | |
| 56 | if (ctrl & NAND_CTRL_CHANGE) { |
| 57 | set = SNAPPERCL15_NAND_CEN | SNAPPERCL15_NAND_WPN; |
| 58 | |
| 59 | if (ctrl & NAND_NCE) |
| 60 | set &= ~SNAPPERCL15_NAND_CEN; |
| 61 | if (ctrl & NAND_CLE) |
| 62 | set |= SNAPPERCL15_NAND_CLE; |
| 63 | if (ctrl & NAND_ALE) |
| 64 | set |= SNAPPERCL15_NAND_ALE; |
| 65 | |
| 66 | nand_state &= ~(SNAPPERCL15_NAND_CEN | |
| 67 | SNAPPERCL15_NAND_CLE | |
| 68 | SNAPPERCL15_NAND_ALE); |
| 69 | nand_state |= set; |
| 70 | __raw_writew(nand_state, NAND_CTRL_ADDR(chip)); |
| 71 | } |
| 72 | |
| 73 | if (cmd != NAND_CMD_NONE) |
| 74 | __raw_writew((cmd & 0xff) | nand_state, chip->IO_ADDR_W); |
| 75 | } |
| 76 | |
| 77 | static int snappercl15_nand_dev_ready(struct mtd_info *mtd) |
| 78 | { |
| 79 | struct nand_chip *chip = mtd->priv; |
| 80 | |
| 81 | return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY); |
| 82 | } |
| 83 | |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 84 | static struct mtd_partition snappercl15_nand_parts[] = { |
| 85 | { |
| 86 | .name = "Kernel", |
| 87 | .offset = 0, |
| 88 | .size = SZ_2M, |
| 89 | }, |
| 90 | { |
| 91 | .name = "Filesystem", |
| 92 | .offset = MTDPART_OFS_APPEND, |
| 93 | .size = MTDPART_SIZ_FULL, |
| 94 | }, |
| 95 | }; |
| 96 | |
| 97 | static struct platform_nand_data snappercl15_nand_data = { |
| 98 | .chip = { |
| 99 | .nr_chips = 1, |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 100 | .partitions = snappercl15_nand_parts, |
| 101 | .nr_partitions = ARRAY_SIZE(snappercl15_nand_parts), |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 102 | .chip_delay = 25, |
| 103 | }, |
| 104 | .ctrl = { |
| 105 | .dev_ready = snappercl15_nand_dev_ready, |
| 106 | .cmd_ctrl = snappercl15_nand_cmd_ctrl, |
| 107 | }, |
| 108 | }; |
| 109 | |
| 110 | static struct resource snappercl15_nand_resource[] = { |
| 111 | { |
| 112 | .start = SNAPPERCL15_NAND_BASE, |
| 113 | .end = SNAPPERCL15_NAND_BASE + SZ_4K - 1, |
| 114 | .flags = IORESOURCE_MEM, |
| 115 | }, |
| 116 | }; |
| 117 | |
| 118 | static struct platform_device snappercl15_nand_device = { |
| 119 | .name = "gen_nand", |
| 120 | .id = -1, |
| 121 | .dev.platform_data = &snappercl15_nand_data, |
| 122 | .resource = snappercl15_nand_resource, |
| 123 | .num_resources = ARRAY_SIZE(snappercl15_nand_resource), |
| 124 | }; |
| 125 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 126 | static struct ep93xx_eth_data __initdata snappercl15_eth_data = { |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 127 | .phy_id = 1, |
| 128 | }; |
| 129 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 130 | static struct i2c_gpio_platform_data __initdata snappercl15_i2c_gpio_data = { |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 131 | .sda_pin = EP93XX_GPIO_LINE_EEDAT, |
| 132 | .sda_is_open_drain = 0, |
| 133 | .scl_pin = EP93XX_GPIO_LINE_EECLK, |
| 134 | .scl_is_open_drain = 0, |
| 135 | .udelay = 0, |
| 136 | .timeout = 0, |
| 137 | }; |
| 138 | |
| 139 | static struct i2c_board_info __initdata snappercl15_i2c_data[] = { |
| 140 | { |
| 141 | /* Audio codec */ |
| 142 | I2C_BOARD_INFO("tlv320aic23", 0x1a), |
| 143 | }, |
| 144 | }; |
| 145 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 146 | static struct ep93xxfb_mach_info __initdata snappercl15_fb_info = { |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 147 | .num_modes = EP93XXFB_USE_MODEDB, |
| 148 | .bpp = 16, |
| 149 | }; |
| 150 | |
Mika Westerberg | 989b790 | 2011-09-11 12:28:55 +0300 | [diff] [blame] | 151 | static struct platform_device snappercl15_audio_device = { |
| 152 | .name = "snappercl15-audio", |
| 153 | .id = -1, |
| 154 | }; |
| 155 | |
| 156 | static void __init snappercl15_register_audio(void) |
| 157 | { |
| 158 | ep93xx_register_i2s(); |
| 159 | platform_device_register(&snappercl15_audio_device); |
| 160 | } |
| 161 | |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 162 | static void __init snappercl15_init_machine(void) |
| 163 | { |
| 164 | ep93xx_init_devices(); |
| 165 | ep93xx_register_eth(&snappercl15_eth_data, 1); |
| 166 | ep93xx_register_i2c(&snappercl15_i2c_gpio_data, snappercl15_i2c_data, |
| 167 | ARRAY_SIZE(snappercl15_i2c_data)); |
| 168 | ep93xx_register_fb(&snappercl15_fb_info); |
Mika Westerberg | 989b790 | 2011-09-11 12:28:55 +0300 | [diff] [blame] | 169 | snappercl15_register_audio(); |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 170 | platform_device_register(&snappercl15_nand_device); |
| 171 | } |
| 172 | |
| 173 | MACHINE_START(SNAPPER_CL15, "Bluewater Systems Snapper CL15") |
Ryan Mallon | 1c5454e | 2011-06-15 14:45:36 +1000 | [diff] [blame] | 174 | /* Maintainer: Ryan Mallon */ |
Nicolas Pitre | e562cf1 | 2011-07-05 22:38:11 -0400 | [diff] [blame] | 175 | .atag_offset = 0x100, |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 176 | .map_io = ep93xx_map_io, |
| 177 | .init_irq = ep93xx_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 178 | .init_time = ep93xx_timer_init, |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 179 | .init_machine = snappercl15_init_machine, |
Shawn Guo | c914283 | 2012-04-26 10:05:15 +0800 | [diff] [blame] | 180 | .init_late = ep93xx_init_late, |
Russell King | 3275166 | 2011-11-05 09:54:14 +0000 | [diff] [blame] | 181 | .restart = ep93xx_restart, |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 182 | MACHINE_END |