diff options
Diffstat (limited to 'arch/arm/mach-ep93xx/snappercl15.c')
-rw-r--r-- | arch/arm/mach-ep93xx/snappercl15.c | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/arch/arm/mach-ep93xx/snappercl15.c b/arch/arm/mach-ep93xx/snappercl15.c new file mode 100644 index 000000000000..51134b0382ca --- /dev/null +++ b/arch/arm/mach-ep93xx/snappercl15.c | |||
@@ -0,0 +1,172 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-ep93xx/snappercl15.c | ||
3 | * Bluewater Systems Snapper CL15 system module | ||
4 | * | ||
5 | * Copyright (C) 2009 Bluewater Systems Ltd | ||
6 | * Author: Ryan Mallon <ryan@bluewatersys.com> | ||
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> | ||
23 | #include <linux/gpio.h> | ||
24 | #include <linux/i2c.h> | ||
25 | #include <linux/i2c-gpio.h> | ||
26 | #include <linux/fb.h> | ||
27 | |||
28 | #include <linux/mtd/partitions.h> | ||
29 | #include <linux/mtd/nand.h> | ||
30 | |||
31 | #include <mach/hardware.h> | ||
32 | #include <mach/fb.h> | ||
33 | |||
34 | #include <asm/mach-types.h> | ||
35 | #include <asm/mach/arch.h> | ||
36 | |||
37 | #define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M) | ||
38 | |||
39 | #define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */ | ||
40 | #define SNAPPERCL15_NAND_ALE (1 << 9) /* Address latch */ | ||
41 | #define SNAPPERCL15_NAND_CLE (1 << 10) /* Command latch */ | ||
42 | #define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */ | ||
43 | #define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */ | ||
44 | |||
45 | #define NAND_CTRL_ADDR(chip) (chip->IO_ADDR_W + 0x40) | ||
46 | |||
47 | static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, | ||
48 | unsigned int ctrl) | ||
49 | { | ||
50 | struct nand_chip *chip = mtd->priv; | ||
51 | static u16 nand_state = SNAPPERCL15_NAND_WPN; | ||
52 | u16 set; | ||
53 | |||
54 | if (ctrl & NAND_CTRL_CHANGE) { | ||
55 | set = SNAPPERCL15_NAND_CEN | SNAPPERCL15_NAND_WPN; | ||
56 | |||
57 | if (ctrl & NAND_NCE) | ||
58 | set &= ~SNAPPERCL15_NAND_CEN; | ||
59 | if (ctrl & NAND_CLE) | ||
60 | set |= SNAPPERCL15_NAND_CLE; | ||
61 | if (ctrl & NAND_ALE) | ||
62 | set |= SNAPPERCL15_NAND_ALE; | ||
63 | |||
64 | nand_state &= ~(SNAPPERCL15_NAND_CEN | | ||
65 | SNAPPERCL15_NAND_CLE | | ||
66 | SNAPPERCL15_NAND_ALE); | ||
67 | nand_state |= set; | ||
68 | __raw_writew(nand_state, NAND_CTRL_ADDR(chip)); | ||
69 | } | ||
70 | |||
71 | if (cmd != NAND_CMD_NONE) | ||
72 | __raw_writew((cmd & 0xff) | nand_state, chip->IO_ADDR_W); | ||
73 | } | ||
74 | |||
75 | static int snappercl15_nand_dev_ready(struct mtd_info *mtd) | ||
76 | { | ||
77 | struct nand_chip *chip = mtd->priv; | ||
78 | |||
79 | return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY); | ||
80 | } | ||
81 | |||
82 | static const char *snappercl15_nand_part_probes[] = {"cmdlinepart", NULL}; | ||
83 | |||
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, | ||
100 | .part_probe_types = snappercl15_nand_part_probes, | ||
101 | .partitions = snappercl15_nand_parts, | ||
102 | .nr_partitions = ARRAY_SIZE(snappercl15_nand_parts), | ||
103 | .options = NAND_NO_AUTOINCR, | ||
104 | .chip_delay = 25, | ||
105 | }, | ||
106 | .ctrl = { | ||
107 | .dev_ready = snappercl15_nand_dev_ready, | ||
108 | .cmd_ctrl = snappercl15_nand_cmd_ctrl, | ||
109 | }, | ||
110 | }; | ||
111 | |||
112 | static struct resource snappercl15_nand_resource[] = { | ||
113 | { | ||
114 | .start = SNAPPERCL15_NAND_BASE, | ||
115 | .end = SNAPPERCL15_NAND_BASE + SZ_4K - 1, | ||
116 | .flags = IORESOURCE_MEM, | ||
117 | }, | ||
118 | }; | ||
119 | |||
120 | static struct platform_device snappercl15_nand_device = { | ||
121 | .name = "gen_nand", | ||
122 | .id = -1, | ||
123 | .dev.platform_data = &snappercl15_nand_data, | ||
124 | .resource = snappercl15_nand_resource, | ||
125 | .num_resources = ARRAY_SIZE(snappercl15_nand_resource), | ||
126 | }; | ||
127 | |||
128 | static struct ep93xx_eth_data snappercl15_eth_data = { | ||
129 | .phy_id = 1, | ||
130 | }; | ||
131 | |||
132 | static struct i2c_gpio_platform_data snappercl15_i2c_gpio_data = { | ||
133 | .sda_pin = EP93XX_GPIO_LINE_EEDAT, | ||
134 | .sda_is_open_drain = 0, | ||
135 | .scl_pin = EP93XX_GPIO_LINE_EECLK, | ||
136 | .scl_is_open_drain = 0, | ||
137 | .udelay = 0, | ||
138 | .timeout = 0, | ||
139 | }; | ||
140 | |||
141 | static struct i2c_board_info __initdata snappercl15_i2c_data[] = { | ||
142 | { | ||
143 | /* Audio codec */ | ||
144 | I2C_BOARD_INFO("tlv320aic23", 0x1a), | ||
145 | }, | ||
146 | }; | ||
147 | |||
148 | static struct ep93xxfb_mach_info snappercl15_fb_info = { | ||
149 | .num_modes = EP93XXFB_USE_MODEDB, | ||
150 | .bpp = 16, | ||
151 | }; | ||
152 | |||
153 | static void __init snappercl15_init_machine(void) | ||
154 | { | ||
155 | ep93xx_init_devices(); | ||
156 | ep93xx_register_eth(&snappercl15_eth_data, 1); | ||
157 | ep93xx_register_i2c(&snappercl15_i2c_gpio_data, snappercl15_i2c_data, | ||
158 | ARRAY_SIZE(snappercl15_i2c_data)); | ||
159 | ep93xx_register_fb(&snappercl15_fb_info); | ||
160 | platform_device_register(&snappercl15_nand_device); | ||
161 | } | ||
162 | |||
163 | MACHINE_START(SNAPPER_CL15, "Bluewater Systems Snapper CL15") | ||
164 | /* Maintainer: Ryan Mallon <ryan@bluewatersys.com> */ | ||
165 | .phys_io = EP93XX_APB_PHYS_BASE, | ||
166 | .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc, | ||
167 | .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100, | ||
168 | .map_io = ep93xx_map_io, | ||
169 | .init_irq = ep93xx_init_irq, | ||
170 | .timer = &ep93xx_timer, | ||
171 | .init_machine = snappercl15_init_machine, | ||
172 | MACHINE_END | ||