2 * arch/arm/mach-ep93xx/snappercl15.c
3 * Bluewater Systems Snapper CL15 system module
5 * Copyright (C) 2009 Bluewater Systems Ltd
8 * NAND code adapted from driver by:
9 * Andre Renaud <andre@bluewatersys.com>
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.
19 #include <linux/platform_device.h>
20 #include <linux/kernel.h>
21 #include <linux/init.h>
23 #include <linux/i2c.h>
24 #include <linux/i2c-gpio.h>
27 #include <linux/mtd/partitions.h>
28 #include <linux/mtd/nand.h>
30 #include <mach/hardware.h>
31 #include <linux/platform_data/video-ep93xx.h>
32 #include <mach/gpio-ep93xx.h>
34 #include <asm/hardware/vic.h>
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
40 #define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M)
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 */
48 #define NAND_CTRL_ADDR(chip) (chip->IO_ADDR_W + 0x40)
50 static void snappercl15_nand_cmd_ctrl(struct mtd_info
*mtd
, int cmd
,
53 struct nand_chip
*chip
= mtd
->priv
;
54 static u16 nand_state
= SNAPPERCL15_NAND_WPN
;
57 if (ctrl
& NAND_CTRL_CHANGE
) {
58 set
= SNAPPERCL15_NAND_CEN
| SNAPPERCL15_NAND_WPN
;
61 set
&= ~SNAPPERCL15_NAND_CEN
;
63 set
|= SNAPPERCL15_NAND_CLE
;
65 set
|= SNAPPERCL15_NAND_ALE
;
67 nand_state
&= ~(SNAPPERCL15_NAND_CEN
|
68 SNAPPERCL15_NAND_CLE
|
69 SNAPPERCL15_NAND_ALE
);
71 __raw_writew(nand_state
, NAND_CTRL_ADDR(chip
));
74 if (cmd
!= NAND_CMD_NONE
)
75 __raw_writew((cmd
& 0xff) | nand_state
, chip
->IO_ADDR_W
);
78 static int snappercl15_nand_dev_ready(struct mtd_info
*mtd
)
80 struct nand_chip
*chip
= mtd
->priv
;
82 return !!(__raw_readw(NAND_CTRL_ADDR(chip
)) & SNAPPERCL15_NAND_RDY
);
85 static struct mtd_partition snappercl15_nand_parts
[] = {
93 .offset
= MTDPART_OFS_APPEND
,
94 .size
= MTDPART_SIZ_FULL
,
98 static struct platform_nand_data snappercl15_nand_data
= {
101 .partitions
= snappercl15_nand_parts
,
102 .nr_partitions
= ARRAY_SIZE(snappercl15_nand_parts
),
106 .dev_ready
= snappercl15_nand_dev_ready
,
107 .cmd_ctrl
= snappercl15_nand_cmd_ctrl
,
111 static struct resource snappercl15_nand_resource
[] = {
113 .start
= SNAPPERCL15_NAND_BASE
,
114 .end
= SNAPPERCL15_NAND_BASE
+ SZ_4K
- 1,
115 .flags
= IORESOURCE_MEM
,
119 static struct platform_device snappercl15_nand_device
= {
122 .dev
.platform_data
= &snappercl15_nand_data
,
123 .resource
= snappercl15_nand_resource
,
124 .num_resources
= ARRAY_SIZE(snappercl15_nand_resource
),
127 static struct ep93xx_eth_data __initdata snappercl15_eth_data
= {
131 static 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,
140 static struct i2c_board_info __initdata snappercl15_i2c_data
[] = {
143 I2C_BOARD_INFO("tlv320aic23", 0x1a),
147 static struct ep93xxfb_mach_info __initdata snappercl15_fb_info
= {
148 .num_modes
= EP93XXFB_USE_MODEDB
,
152 static struct platform_device snappercl15_audio_device
= {
153 .name
= "snappercl15-audio",
157 static void __init
snappercl15_register_audio(void)
159 ep93xx_register_i2s();
160 platform_device_register(&snappercl15_audio_device
);
163 static void __init
snappercl15_init_machine(void)
165 ep93xx_init_devices();
166 ep93xx_register_eth(&snappercl15_eth_data
, 1);
167 ep93xx_register_i2c(&snappercl15_i2c_gpio_data
, snappercl15_i2c_data
,
168 ARRAY_SIZE(snappercl15_i2c_data
));
169 ep93xx_register_fb(&snappercl15_fb_info
);
170 snappercl15_register_audio();
171 platform_device_register(&snappercl15_nand_device
);
174 MACHINE_START(SNAPPER_CL15
, "Bluewater Systems Snapper CL15")
175 /* Maintainer: Ryan Mallon */
176 .atag_offset
= 0x100,
177 .map_io
= ep93xx_map_io
,
178 .init_irq
= ep93xx_init_irq
,
179 .handle_irq
= vic_handle_irq
,
180 .timer
= &ep93xx_timer
,
181 .init_machine
= snappercl15_init_machine
,
182 .init_late
= ep93xx_init_late
,
183 .restart
= ep93xx_restart
,