blob: fd846331ddff9119023c2a726adae50a16578f6f [file] [log] [blame]
Ryan Mallondd2ac962010-02-15 01:16:01 +01001/*
2 * arch/arm/mach-ep93xx/snappercl15.c
3 * Bluewater Systems Snapper CL15 system module
4 *
5 * Copyright (C) 2009 Bluewater Systems Ltd
Ryan Mallon1c5454e2011-06-15 14:45:36 +10006 * Author: Ryan Mallon
Ryan Mallondd2ac962010-02-15 01:16:01 +01007 *
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 Mallondd2ac962010-02-15 01:16:01 +010023#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 Walleijbd5f12a2011-09-22 08:07:00 +010032#include <mach/gpio-ep93xx.h>
Ryan Mallondd2ac962010-02-15 01:16:01 +010033
Jamie Iles9a6879b2011-09-27 20:07:05 +010034#include <asm/hardware/vic.h>
Ryan Mallondd2ac962010-02-15 01:16:01 +010035#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37
38#define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M)
39
40#define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */
41#define SNAPPERCL15_NAND_ALE (1 << 9) /* Address latch */
42#define SNAPPERCL15_NAND_CLE (1 << 10) /* Command latch */
43#define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */
44#define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */
45
46#define NAND_CTRL_ADDR(chip) (chip->IO_ADDR_W + 0x40)
47
48static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
49 unsigned int ctrl)
50{
51 struct nand_chip *chip = mtd->priv;
52 static u16 nand_state = SNAPPERCL15_NAND_WPN;
53 u16 set;
54
55 if (ctrl & NAND_CTRL_CHANGE) {
56 set = SNAPPERCL15_NAND_CEN | SNAPPERCL15_NAND_WPN;
57
58 if (ctrl & NAND_NCE)
59 set &= ~SNAPPERCL15_NAND_CEN;
60 if (ctrl & NAND_CLE)
61 set |= SNAPPERCL15_NAND_CLE;
62 if (ctrl & NAND_ALE)
63 set |= SNAPPERCL15_NAND_ALE;
64
65 nand_state &= ~(SNAPPERCL15_NAND_CEN |
66 SNAPPERCL15_NAND_CLE |
67 SNAPPERCL15_NAND_ALE);
68 nand_state |= set;
69 __raw_writew(nand_state, NAND_CTRL_ADDR(chip));
70 }
71
72 if (cmd != NAND_CMD_NONE)
73 __raw_writew((cmd & 0xff) | nand_state, chip->IO_ADDR_W);
74}
75
76static int snappercl15_nand_dev_ready(struct mtd_info *mtd)
77{
78 struct nand_chip *chip = mtd->priv;
79
80 return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY);
81}
82
83static const char *snappercl15_nand_part_probes[] = {"cmdlinepart", NULL};
84
85static struct mtd_partition snappercl15_nand_parts[] = {
86 {
87 .name = "Kernel",
88 .offset = 0,
89 .size = SZ_2M,
90 },
91 {
92 .name = "Filesystem",
93 .offset = MTDPART_OFS_APPEND,
94 .size = MTDPART_SIZ_FULL,
95 },
96};
97
98static struct platform_nand_data snappercl15_nand_data = {
99 .chip = {
100 .nr_chips = 1,
101 .part_probe_types = snappercl15_nand_part_probes,
102 .partitions = snappercl15_nand_parts,
103 .nr_partitions = ARRAY_SIZE(snappercl15_nand_parts),
104 .options = NAND_NO_AUTOINCR,
105 .chip_delay = 25,
106 },
107 .ctrl = {
108 .dev_ready = snappercl15_nand_dev_ready,
109 .cmd_ctrl = snappercl15_nand_cmd_ctrl,
110 },
111};
112
113static struct resource snappercl15_nand_resource[] = {
114 {
115 .start = SNAPPERCL15_NAND_BASE,
116 .end = SNAPPERCL15_NAND_BASE + SZ_4K - 1,
117 .flags = IORESOURCE_MEM,
118 },
119};
120
121static struct platform_device snappercl15_nand_device = {
122 .name = "gen_nand",
123 .id = -1,
124 .dev.platform_data = &snappercl15_nand_data,
125 .resource = snappercl15_nand_resource,
126 .num_resources = ARRAY_SIZE(snappercl15_nand_resource),
127};
128
Hartley Sweetenb370e082010-03-18 18:04:06 +0100129static struct ep93xx_eth_data __initdata snappercl15_eth_data = {
Ryan Mallondd2ac962010-02-15 01:16:01 +0100130 .phy_id = 1,
131};
132
Hartley Sweetenb370e082010-03-18 18:04:06 +0100133static struct i2c_gpio_platform_data __initdata snappercl15_i2c_gpio_data = {
Ryan Mallondd2ac962010-02-15 01:16:01 +0100134 .sda_pin = EP93XX_GPIO_LINE_EEDAT,
135 .sda_is_open_drain = 0,
136 .scl_pin = EP93XX_GPIO_LINE_EECLK,
137 .scl_is_open_drain = 0,
138 .udelay = 0,
139 .timeout = 0,
140};
141
142static struct i2c_board_info __initdata snappercl15_i2c_data[] = {
143 {
144 /* Audio codec */
145 I2C_BOARD_INFO("tlv320aic23", 0x1a),
146 },
147};
148
Hartley Sweetenb370e082010-03-18 18:04:06 +0100149static struct ep93xxfb_mach_info __initdata snappercl15_fb_info = {
Ryan Mallondd2ac962010-02-15 01:16:01 +0100150 .num_modes = EP93XXFB_USE_MODEDB,
151 .bpp = 16,
152};
153
Mika Westerberg989b7902011-09-11 12:28:55 +0300154static struct platform_device snappercl15_audio_device = {
155 .name = "snappercl15-audio",
156 .id = -1,
157};
158
159static void __init snappercl15_register_audio(void)
160{
161 ep93xx_register_i2s();
162 platform_device_register(&snappercl15_audio_device);
163}
164
Ryan Mallondd2ac962010-02-15 01:16:01 +0100165static void __init snappercl15_init_machine(void)
166{
167 ep93xx_init_devices();
168 ep93xx_register_eth(&snappercl15_eth_data, 1);
169 ep93xx_register_i2c(&snappercl15_i2c_gpio_data, snappercl15_i2c_data,
170 ARRAY_SIZE(snappercl15_i2c_data));
171 ep93xx_register_fb(&snappercl15_fb_info);
Mika Westerberg989b7902011-09-11 12:28:55 +0300172 snappercl15_register_audio();
Ryan Mallondd2ac962010-02-15 01:16:01 +0100173 platform_device_register(&snappercl15_nand_device);
174}
175
176MACHINE_START(SNAPPER_CL15, "Bluewater Systems Snapper CL15")
Ryan Mallon1c5454e2011-06-15 14:45:36 +1000177 /* Maintainer: Ryan Mallon */
Nicolas Pitree562cf12011-07-05 22:38:11 -0400178 .atag_offset = 0x100,
Ryan Mallondd2ac962010-02-15 01:16:01 +0100179 .map_io = ep93xx_map_io,
180 .init_irq = ep93xx_init_irq,
Jamie Iles9a6879b2011-09-27 20:07:05 +0100181 .handle_irq = vic_handle_irq,
Ryan Mallondd2ac962010-02-15 01:16:01 +0100182 .timer = &ep93xx_timer,
183 .init_machine = snappercl15_init_machine,
Russell King32751662011-11-05 09:54:14 +0000184 .restart = ep93xx_restart,
Ryan Mallondd2ac962010-02-15 01:16:01 +0100185MACHINE_END