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> |
| 31 | #include <mach/fb.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 | |
Jamie Iles | 9a6879b | 2011-09-27 20:07:05 +0100 | [diff] [blame] | 34 | #include <asm/hardware/vic.h> |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 35 | #include <asm/mach-types.h> |
| 36 | #include <asm/mach/arch.h> |
| 37 | |
Ryan Mallon | 258249e | 2012-01-11 09:06:08 +1100 | [diff] [blame] | 38 | #include "soc.h" |
| 39 | |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 40 | #define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M) |
| 41 | |
| 42 | #define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */ |
| 43 | #define SNAPPERCL15_NAND_ALE (1 << 9) /* Address latch */ |
| 44 | #define SNAPPERCL15_NAND_CLE (1 << 10) /* Command latch */ |
| 45 | #define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */ |
| 46 | #define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */ |
| 47 | |
| 48 | #define NAND_CTRL_ADDR(chip) (chip->IO_ADDR_W + 0x40) |
| 49 | |
| 50 | static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, |
| 51 | unsigned int ctrl) |
| 52 | { |
| 53 | struct nand_chip *chip = mtd->priv; |
| 54 | static u16 nand_state = SNAPPERCL15_NAND_WPN; |
| 55 | u16 set; |
| 56 | |
| 57 | if (ctrl & NAND_CTRL_CHANGE) { |
| 58 | set = SNAPPERCL15_NAND_CEN | SNAPPERCL15_NAND_WPN; |
| 59 | |
| 60 | if (ctrl & NAND_NCE) |
| 61 | set &= ~SNAPPERCL15_NAND_CEN; |
| 62 | if (ctrl & NAND_CLE) |
| 63 | set |= SNAPPERCL15_NAND_CLE; |
| 64 | if (ctrl & NAND_ALE) |
| 65 | set |= SNAPPERCL15_NAND_ALE; |
| 66 | |
| 67 | nand_state &= ~(SNAPPERCL15_NAND_CEN | |
| 68 | SNAPPERCL15_NAND_CLE | |
| 69 | SNAPPERCL15_NAND_ALE); |
| 70 | nand_state |= set; |
| 71 | __raw_writew(nand_state, NAND_CTRL_ADDR(chip)); |
| 72 | } |
| 73 | |
| 74 | if (cmd != NAND_CMD_NONE) |
| 75 | __raw_writew((cmd & 0xff) | nand_state, chip->IO_ADDR_W); |
| 76 | } |
| 77 | |
| 78 | static int snappercl15_nand_dev_ready(struct mtd_info *mtd) |
| 79 | { |
| 80 | struct nand_chip *chip = mtd->priv; |
| 81 | |
| 82 | return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY); |
| 83 | } |
| 84 | |
| 85 | static const char *snappercl15_nand_part_probes[] = {"cmdlinepart", NULL}; |
| 86 | |
| 87 | static struct mtd_partition snappercl15_nand_parts[] = { |
| 88 | { |
| 89 | .name = "Kernel", |
| 90 | .offset = 0, |
| 91 | .size = SZ_2M, |
| 92 | }, |
| 93 | { |
| 94 | .name = "Filesystem", |
| 95 | .offset = MTDPART_OFS_APPEND, |
| 96 | .size = MTDPART_SIZ_FULL, |
| 97 | }, |
| 98 | }; |
| 99 | |
| 100 | static struct platform_nand_data snappercl15_nand_data = { |
| 101 | .chip = { |
| 102 | .nr_chips = 1, |
| 103 | .part_probe_types = snappercl15_nand_part_probes, |
| 104 | .partitions = snappercl15_nand_parts, |
| 105 | .nr_partitions = ARRAY_SIZE(snappercl15_nand_parts), |
| 106 | .options = NAND_NO_AUTOINCR, |
| 107 | .chip_delay = 25, |
| 108 | }, |
| 109 | .ctrl = { |
| 110 | .dev_ready = snappercl15_nand_dev_ready, |
| 111 | .cmd_ctrl = snappercl15_nand_cmd_ctrl, |
| 112 | }, |
| 113 | }; |
| 114 | |
| 115 | static struct resource snappercl15_nand_resource[] = { |
| 116 | { |
| 117 | .start = SNAPPERCL15_NAND_BASE, |
| 118 | .end = SNAPPERCL15_NAND_BASE + SZ_4K - 1, |
| 119 | .flags = IORESOURCE_MEM, |
| 120 | }, |
| 121 | }; |
| 122 | |
| 123 | static struct platform_device snappercl15_nand_device = { |
| 124 | .name = "gen_nand", |
| 125 | .id = -1, |
| 126 | .dev.platform_data = &snappercl15_nand_data, |
| 127 | .resource = snappercl15_nand_resource, |
| 128 | .num_resources = ARRAY_SIZE(snappercl15_nand_resource), |
| 129 | }; |
| 130 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 131 | static struct ep93xx_eth_data __initdata snappercl15_eth_data = { |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 132 | .phy_id = 1, |
| 133 | }; |
| 134 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 135 | static struct i2c_gpio_platform_data __initdata snappercl15_i2c_gpio_data = { |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 136 | .sda_pin = EP93XX_GPIO_LINE_EEDAT, |
| 137 | .sda_is_open_drain = 0, |
| 138 | .scl_pin = EP93XX_GPIO_LINE_EECLK, |
| 139 | .scl_is_open_drain = 0, |
| 140 | .udelay = 0, |
| 141 | .timeout = 0, |
| 142 | }; |
| 143 | |
| 144 | static struct i2c_board_info __initdata snappercl15_i2c_data[] = { |
| 145 | { |
| 146 | /* Audio codec */ |
| 147 | I2C_BOARD_INFO("tlv320aic23", 0x1a), |
| 148 | }, |
| 149 | }; |
| 150 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 151 | static struct ep93xxfb_mach_info __initdata snappercl15_fb_info = { |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 152 | .num_modes = EP93XXFB_USE_MODEDB, |
| 153 | .bpp = 16, |
| 154 | }; |
| 155 | |
Mika Westerberg | 989b790 | 2011-09-11 12:28:55 +0300 | [diff] [blame] | 156 | static struct platform_device snappercl15_audio_device = { |
| 157 | .name = "snappercl15-audio", |
| 158 | .id = -1, |
| 159 | }; |
| 160 | |
| 161 | static void __init snappercl15_register_audio(void) |
| 162 | { |
| 163 | ep93xx_register_i2s(); |
| 164 | platform_device_register(&snappercl15_audio_device); |
| 165 | } |
| 166 | |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 167 | static void __init snappercl15_init_machine(void) |
| 168 | { |
| 169 | ep93xx_init_devices(); |
| 170 | ep93xx_register_eth(&snappercl15_eth_data, 1); |
| 171 | ep93xx_register_i2c(&snappercl15_i2c_gpio_data, snappercl15_i2c_data, |
| 172 | ARRAY_SIZE(snappercl15_i2c_data)); |
| 173 | ep93xx_register_fb(&snappercl15_fb_info); |
Mika Westerberg | 989b790 | 2011-09-11 12:28:55 +0300 | [diff] [blame] | 174 | snappercl15_register_audio(); |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 175 | platform_device_register(&snappercl15_nand_device); |
| 176 | } |
| 177 | |
| 178 | MACHINE_START(SNAPPER_CL15, "Bluewater Systems Snapper CL15") |
Ryan Mallon | 1c5454e | 2011-06-15 14:45:36 +1000 | [diff] [blame] | 179 | /* Maintainer: Ryan Mallon */ |
Nicolas Pitre | e562cf1 | 2011-07-05 22:38:11 -0400 | [diff] [blame] | 180 | .atag_offset = 0x100, |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 181 | .map_io = ep93xx_map_io, |
| 182 | .init_irq = ep93xx_init_irq, |
Jamie Iles | 9a6879b | 2011-09-27 20:07:05 +0100 | [diff] [blame] | 183 | .handle_irq = vic_handle_irq, |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 184 | .timer = &ep93xx_timer, |
| 185 | .init_machine = snappercl15_init_machine, |
Russell King | 3275166 | 2011-11-05 09:54:14 +0000 | [diff] [blame] | 186 | .restart = ep93xx_restart, |
Ryan Mallon | dd2ac96 | 2010-02-15 01:16:01 +0100 | [diff] [blame] | 187 | MACHINE_END |