2 * arch/arm/mach-ep93xx/vision_ep9307.c
3 * Vision Engraving Systems EP9307 SoM support.
5 * Copyright (C) 2008-2011 Vision Engraving Systems
6 * H Hartley Sweeten <hsweeten@visionengravers.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/irq.h>
20 #include <linux/gpio.h>
23 #include <linux/mtd/partitions.h>
24 #include <linux/i2c.h>
25 #include <linux/i2c-gpio.h>
26 #include <linux/i2c/pca953x.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/flash.h>
29 #include <linux/spi/mmc_spi.h>
30 #include <linux/mmc/host.h>
32 #include <mach/hardware.h>
33 #include <linux/platform_data/video-ep93xx.h>
34 #include <linux/platform_data/spi-ep93xx.h>
35 #include <mach/gpio-ep93xx.h>
37 #include <asm/hardware/vic.h>
38 #include <asm/mach-types.h>
39 #include <asm/mach/map.h>
40 #include <asm/mach/arch.h>
44 /*************************************************************************
45 * Static I/O mappings for the FPGA
46 *************************************************************************/
47 #define VISION_PHYS_BASE EP93XX_CS7_PHYS_BASE
48 #define VISION_VIRT_BASE 0xfebff000
50 static struct map_desc vision_io_desc
[] __initdata
= {
52 .virtual = VISION_VIRT_BASE
,
53 .pfn
= __phys_to_pfn(VISION_PHYS_BASE
),
59 static void __init
vision_map_io(void)
63 iotable_init(vision_io_desc
, ARRAY_SIZE(vision_io_desc
));
66 /*************************************************************************
68 *************************************************************************/
69 static struct ep93xx_eth_data vision_eth_data __initdata
= {
73 /*************************************************************************
75 *************************************************************************/
76 #define VISION_LCD_ENABLE EP93XX_GPIO_LINE_EGPIO1
78 static int vision_lcd_setup(struct platform_device
*pdev
)
82 err
= gpio_request_one(VISION_LCD_ENABLE
, GPIOF_INIT_HIGH
,
83 dev_name(&pdev
->dev
));
87 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_RAS
|
88 EP93XX_SYSCON_DEVCFG_RASONP3
|
89 EP93XX_SYSCON_DEVCFG_EXVC
);
94 static void vision_lcd_teardown(struct platform_device
*pdev
)
96 gpio_free(VISION_LCD_ENABLE
);
99 static void vision_lcd_blank(int blank_mode
, struct fb_info
*info
)
102 gpio_set_value(VISION_LCD_ENABLE
, 0);
104 gpio_set_value(VISION_LCD_ENABLE
, 1);
107 static struct ep93xxfb_mach_info ep93xxfb_info __initdata
= {
108 .num_modes
= EP93XXFB_USE_MODEDB
,
110 .flags
= EP93XXFB_USE_SDCSN0
| EP93XXFB_PCLK_FALLING
,
111 .setup
= vision_lcd_setup
,
112 .teardown
= vision_lcd_teardown
,
113 .blank
= vision_lcd_blank
,
117 /*************************************************************************
119 *************************************************************************/
120 #define PCA9539_74_GPIO_BASE (EP93XX_GPIO_LINE_MAX + 1)
121 #define PCA9539_75_GPIO_BASE (PCA9539_74_GPIO_BASE + 16)
122 #define PCA9539_76_GPIO_BASE (PCA9539_75_GPIO_BASE + 16)
123 #define PCA9539_77_GPIO_BASE (PCA9539_76_GPIO_BASE + 16)
125 static struct pca953x_platform_data pca953x_74_gpio_data
= {
126 .gpio_base
= PCA9539_74_GPIO_BASE
,
127 .irq_base
= EP93XX_BOARD_IRQ(0),
130 static struct pca953x_platform_data pca953x_75_gpio_data
= {
131 .gpio_base
= PCA9539_75_GPIO_BASE
,
135 static struct pca953x_platform_data pca953x_76_gpio_data
= {
136 .gpio_base
= PCA9539_76_GPIO_BASE
,
140 static struct pca953x_platform_data pca953x_77_gpio_data
= {
141 .gpio_base
= PCA9539_77_GPIO_BASE
,
145 /*************************************************************************
147 *************************************************************************/
148 static struct i2c_gpio_platform_data vision_i2c_gpio_data __initdata
= {
149 .sda_pin
= EP93XX_GPIO_LINE_EEDAT
,
150 .scl_pin
= EP93XX_GPIO_LINE_EECLK
,
153 static struct i2c_board_info vision_i2c_info
[] __initdata
= {
155 I2C_BOARD_INFO("isl1208", 0x6f),
156 .irq
= IRQ_EP93XX_EXT1
,
158 I2C_BOARD_INFO("pca9539", 0x74),
159 .platform_data
= &pca953x_74_gpio_data
,
161 I2C_BOARD_INFO("pca9539", 0x75),
162 .platform_data
= &pca953x_75_gpio_data
,
164 I2C_BOARD_INFO("pca9539", 0x76),
165 .platform_data
= &pca953x_76_gpio_data
,
167 I2C_BOARD_INFO("pca9539", 0x77),
168 .platform_data
= &pca953x_77_gpio_data
,
172 /*************************************************************************
174 *************************************************************************/
175 #define VISION_SPI_FLASH_CS EP93XX_GPIO_LINE_EGPIO7
177 static struct mtd_partition vision_spi_flash_partitions
[] = {
179 .name
= "SPI bootstrap",
183 .name
= "Bootstrap config",
184 .offset
= MTDPART_OFS_APPEND
,
187 .name
= "System config",
188 .offset
= MTDPART_OFS_APPEND
,
189 .size
= MTDPART_SIZ_FULL
,
193 static struct flash_platform_data vision_spi_flash_data
= {
195 .parts
= vision_spi_flash_partitions
,
196 .nr_parts
= ARRAY_SIZE(vision_spi_flash_partitions
),
199 static int vision_spi_flash_hw_setup(struct spi_device
*spi
)
201 return gpio_request_one(VISION_SPI_FLASH_CS
, GPIOF_INIT_HIGH
,
205 static void vision_spi_flash_hw_cleanup(struct spi_device
*spi
)
207 gpio_free(VISION_SPI_FLASH_CS
);
210 static void vision_spi_flash_hw_cs_control(struct spi_device
*spi
, int value
)
212 gpio_set_value(VISION_SPI_FLASH_CS
, value
);
215 static struct ep93xx_spi_chip_ops vision_spi_flash_hw
= {
216 .setup
= vision_spi_flash_hw_setup
,
217 .cleanup
= vision_spi_flash_hw_cleanup
,
218 .cs_control
= vision_spi_flash_hw_cs_control
,
221 /*************************************************************************
223 *************************************************************************/
224 #define VISION_SPI_MMC_CS EP93XX_GPIO_LINE_G(2)
225 #define VISION_SPI_MMC_WP EP93XX_GPIO_LINE_F(0)
226 #define VISION_SPI_MMC_CD EP93XX_GPIO_LINE_EGPIO15
228 static struct gpio vision_spi_mmc_gpios
[] = {
229 { VISION_SPI_MMC_WP
, GPIOF_DIR_IN
, "mmc_spi:wp" },
230 { VISION_SPI_MMC_CD
, GPIOF_DIR_IN
, "mmc_spi:cd" },
233 static int vision_spi_mmc_init(struct device
*pdev
,
234 irqreturn_t (*func
)(int, void *), void *pdata
)
238 err
= gpio_request_array(vision_spi_mmc_gpios
,
239 ARRAY_SIZE(vision_spi_mmc_gpios
));
243 err
= gpio_set_debounce(VISION_SPI_MMC_CD
, 1);
247 err
= request_irq(gpio_to_irq(VISION_SPI_MMC_CD
), func
,
248 IRQ_TYPE_EDGE_BOTH
, "mmc_spi:cd", pdata
);
255 gpio_free_array(vision_spi_mmc_gpios
, ARRAY_SIZE(vision_spi_mmc_gpios
));
260 static void vision_spi_mmc_exit(struct device
*pdev
, void *pdata
)
262 free_irq(gpio_to_irq(VISION_SPI_MMC_CD
), pdata
);
263 gpio_free_array(vision_spi_mmc_gpios
, ARRAY_SIZE(vision_spi_mmc_gpios
));
266 static int vision_spi_mmc_get_ro(struct device
*pdev
)
268 return !!gpio_get_value(VISION_SPI_MMC_WP
);
271 static int vision_spi_mmc_get_cd(struct device
*pdev
)
273 return !gpio_get_value(VISION_SPI_MMC_CD
);
276 static struct mmc_spi_platform_data vision_spi_mmc_data
= {
277 .init
= vision_spi_mmc_init
,
278 .exit
= vision_spi_mmc_exit
,
279 .get_ro
= vision_spi_mmc_get_ro
,
280 .get_cd
= vision_spi_mmc_get_cd
,
282 .powerup_msecs
= 100,
283 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
286 static int vision_spi_mmc_hw_setup(struct spi_device
*spi
)
288 return gpio_request_one(VISION_SPI_MMC_CS
, GPIOF_INIT_HIGH
,
292 static void vision_spi_mmc_hw_cleanup(struct spi_device
*spi
)
294 gpio_free(VISION_SPI_MMC_CS
);
297 static void vision_spi_mmc_hw_cs_control(struct spi_device
*spi
, int value
)
299 gpio_set_value(VISION_SPI_MMC_CS
, value
);
302 static struct ep93xx_spi_chip_ops vision_spi_mmc_hw
= {
303 .setup
= vision_spi_mmc_hw_setup
,
304 .cleanup
= vision_spi_mmc_hw_cleanup
,
305 .cs_control
= vision_spi_mmc_hw_cs_control
,
308 /*************************************************************************
310 *************************************************************************/
311 static struct spi_board_info vision_spi_board_info
[] __initdata
= {
313 .modalias
= "sst25l",
314 .platform_data
= &vision_spi_flash_data
,
315 .controller_data
= &vision_spi_flash_hw
,
316 .max_speed_hz
= 20000000,
321 .modalias
= "mmc_spi",
322 .platform_data
= &vision_spi_mmc_data
,
323 .controller_data
= &vision_spi_mmc_hw
,
324 .max_speed_hz
= 20000000,
331 static struct ep93xx_spi_info vision_spi_master __initdata
= {
332 .num_chipselect
= ARRAY_SIZE(vision_spi_board_info
),
335 /*************************************************************************
336 * Machine Initialization
337 *************************************************************************/
338 static void __init
vision_init_machine(void)
340 ep93xx_init_devices();
341 ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE
, SZ_64M
);
342 ep93xx_register_eth(&vision_eth_data
, 1);
343 ep93xx_register_fb(&ep93xxfb_info
);
344 ep93xx_register_pwm(1, 0);
347 * Request the gpio expander's interrupt gpio line now to prevent
348 * the kernel from doing a WARN in gpiolib:gpio_ensure_requested().
350 if (gpio_request_one(EP93XX_GPIO_LINE_F(7), GPIOF_DIR_IN
,
352 pr_warn("cannot request interrupt gpio for pca9539:74\n");
354 vision_i2c_info
[1].irq
= gpio_to_irq(EP93XX_GPIO_LINE_F(7));
356 ep93xx_register_i2c(&vision_i2c_gpio_data
, vision_i2c_info
,
357 ARRAY_SIZE(vision_i2c_info
));
358 ep93xx_register_spi(&vision_spi_master
, vision_spi_board_info
,
359 ARRAY_SIZE(vision_spi_board_info
));
362 MACHINE_START(VISION_EP9307
, "Vision Engraving Systems EP9307")
363 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
364 .atag_offset
= 0x100,
365 .map_io
= vision_map_io
,
366 .init_irq
= ep93xx_init_irq
,
367 .handle_irq
= vic_handle_irq
,
368 .timer
= &ep93xx_timer
,
369 .init_machine
= vision_init_machine
,
370 .init_late
= ep93xx_init_late
,
371 .restart
= ep93xx_restart
,