1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * arch/arm/mach-ep93xx/snappercl15.c
4 * Bluewater Systems Snapper CL15 system module
6 * Copyright (C) 2009 Bluewater Systems Ltd
9 * NAND code adapted from driver by:
10 * Andre Renaud <andre@bluewatersys.com>
14 #include <linux/platform_device.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
18 #include <linux/i2c.h>
21 #include <linux/mtd/platnand.h>
24 #include <linux/platform_data/video-ep93xx.h>
25 #include "gpio-ep93xx.h"
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
32 #define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M)
34 #define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */
35 #define SNAPPERCL15_NAND_ALE (1 << 9) /* Address latch */
36 #define SNAPPERCL15_NAND_CLE (1 << 10) /* Command latch */
37 #define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */
38 #define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */
40 #define NAND_CTRL_ADDR(chip) (chip->legacy.IO_ADDR_W + 0x40)
42 static void snappercl15_nand_cmd_ctrl(struct nand_chip
*chip
, int cmd
,
45 static u16 nand_state
= SNAPPERCL15_NAND_WPN
;
48 if (ctrl
& NAND_CTRL_CHANGE
) {
49 set
= SNAPPERCL15_NAND_CEN
| SNAPPERCL15_NAND_WPN
;
52 set
&= ~SNAPPERCL15_NAND_CEN
;
54 set
|= SNAPPERCL15_NAND_CLE
;
56 set
|= SNAPPERCL15_NAND_ALE
;
58 nand_state
&= ~(SNAPPERCL15_NAND_CEN
|
59 SNAPPERCL15_NAND_CLE
|
60 SNAPPERCL15_NAND_ALE
);
62 __raw_writew(nand_state
, NAND_CTRL_ADDR(chip
));
65 if (cmd
!= NAND_CMD_NONE
)
66 __raw_writew((cmd
& 0xff) | nand_state
,
67 chip
->legacy
.IO_ADDR_W
);
70 static int snappercl15_nand_dev_ready(struct nand_chip
*chip
)
72 return !!(__raw_readw(NAND_CTRL_ADDR(chip
)) & SNAPPERCL15_NAND_RDY
);
75 static struct mtd_partition snappercl15_nand_parts
[] = {
83 .offset
= MTDPART_OFS_APPEND
,
84 .size
= MTDPART_SIZ_FULL
,
88 static struct platform_nand_data snappercl15_nand_data
= {
91 .partitions
= snappercl15_nand_parts
,
92 .nr_partitions
= ARRAY_SIZE(snappercl15_nand_parts
),
96 .dev_ready
= snappercl15_nand_dev_ready
,
97 .cmd_ctrl
= snappercl15_nand_cmd_ctrl
,
101 static struct resource snappercl15_nand_resource
[] = {
103 .start
= SNAPPERCL15_NAND_BASE
,
104 .end
= SNAPPERCL15_NAND_BASE
+ SZ_4K
- 1,
105 .flags
= IORESOURCE_MEM
,
109 static struct platform_device snappercl15_nand_device
= {
112 .dev
.platform_data
= &snappercl15_nand_data
,
113 .resource
= snappercl15_nand_resource
,
114 .num_resources
= ARRAY_SIZE(snappercl15_nand_resource
),
117 static struct ep93xx_eth_data __initdata snappercl15_eth_data
= {
121 static struct i2c_board_info __initdata snappercl15_i2c_data
[] = {
124 I2C_BOARD_INFO("tlv320aic23", 0x1a),
128 static struct ep93xxfb_mach_info __initdata snappercl15_fb_info
= {
131 static struct platform_device snappercl15_audio_device
= {
132 .name
= "snappercl15-audio",
136 static void __init
snappercl15_register_audio(void)
138 ep93xx_register_i2s();
139 platform_device_register(&snappercl15_audio_device
);
142 static void __init
snappercl15_init_machine(void)
144 ep93xx_init_devices();
145 ep93xx_register_eth(&snappercl15_eth_data
, 1);
146 ep93xx_register_i2c(snappercl15_i2c_data
,
147 ARRAY_SIZE(snappercl15_i2c_data
));
148 ep93xx_register_fb(&snappercl15_fb_info
);
149 snappercl15_register_audio();
150 platform_device_register(&snappercl15_nand_device
);
153 MACHINE_START(SNAPPER_CL15
, "Bluewater Systems Snapper CL15")
154 /* Maintainer: Ryan Mallon */
155 .atag_offset
= 0x100,
156 .map_io
= ep93xx_map_io
,
157 .init_irq
= ep93xx_init_irq
,
158 .init_time
= ep93xx_timer_init
,
159 .init_machine
= snappercl15_init_machine
,
160 .init_late
= ep93xx_init_late
,
161 .restart
= ep93xx_restart
,