2 * Copyright (C) 2000 Deep Blue Solutions Ltd
3 * Copyright (C) 2002 Shane Nay (shane@minirl.com)
4 * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 #include <linux/gpio/driver.h>
17 /* Needed for gpio_to_irq() */
18 #include <linux/gpio.h>
19 #include <linux/platform_device.h>
20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/map.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/mtd/physmap.h>
24 #include <linux/i2c.h>
25 #include <linux/irq.h>
27 #include <linux/regulator/fixed.h>
28 #include <linux/regulator/machine.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/time.h>
33 #include <asm/mach/map.h>
36 #include "devices-imx27.h"
38 #include "iomux-mx27.h"
41 * Base address of PBC controller, CS4
43 #define PBC_BASE_ADDRESS 0xf4300000
44 #define PBC_REG_ADDR(offset) (void __force __iomem *) \
45 (PBC_BASE_ADDRESS + (offset))
47 /* When the PBC address connection is fixed in h/w, defined as 1 */
50 /* Offsets for the PBC Controller register */
52 * PBC Board version register offset
54 #define PBC_VERSION_REG PBC_REG_ADDR(0x00000 >> PBC_ADDR_SH)
56 * PBC Board control register 1 set address.
58 #define PBC_BCTRL1_SET_REG PBC_REG_ADDR(0x00008 >> PBC_ADDR_SH)
60 * PBC Board control register 1 clear address.
62 #define PBC_BCTRL1_CLEAR_REG PBC_REG_ADDR(0x0000C >> PBC_ADDR_SH)
64 /* PBC Board Control Register 1 bit definitions */
65 #define PBC_BCTRL1_LCDON 0x0800 /* Enable the LCD */
67 /* to determine the correct external crystal reference */
68 #define CKIH_27MHZ_BIT_SET (1 << 3)
70 static const int mx27ads_pins[] __initconst = {
113 PD11_AOUT_FEC_TX_CLK,
116 PD14_AOUT_FEC_RX_CLK,
169 static const struct mxc_nand_platform_data
170 mx27ads_nand_board_info __initconst = {
175 /* ADS's NOR flash */
176 static struct physmap_flash_data mx27ads_flash_data = {
180 static struct resource mx27ads_flash_resource = {
182 .end = 0xc0000000 + 0x02000000 - 1,
183 .flags = IORESOURCE_MEM,
187 static struct platform_device mx27ads_nor_mtd_device = {
188 .name = "physmap-flash",
191 .platform_data = &mx27ads_flash_data,
194 .resource = &mx27ads_flash_resource,
197 static const struct imxi2c_platform_data mx27ads_i2c1_data __initconst = {
201 static struct i2c_board_info mx27ads_i2c_devices[] = {
204 static void vgpio_set(struct gpio_chip *chip, unsigned offset, int value)
207 imx_writew(PBC_BCTRL1_LCDON, PBC_BCTRL1_SET_REG);
209 imx_writew(PBC_BCTRL1_LCDON, PBC_BCTRL1_CLEAR_REG);
212 static int vgpio_dir_out(struct gpio_chip *chip, unsigned offset, int value)
217 #define MX27ADS_LCD_GPIO (6 * 32)
219 static struct regulator_consumer_supply mx27ads_lcd_regulator_consumer =
220 REGULATOR_SUPPLY("lcd", "imx-fb.0");
222 static struct regulator_init_data mx27ads_lcd_regulator_init_data = {
224 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
226 .consumer_supplies = &mx27ads_lcd_regulator_consumer,
227 .num_consumer_supplies = 1,
230 static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = {
231 .supply_name = "LCD",
232 .microvolts = 3300000,
233 .gpio = MX27ADS_LCD_GPIO,
234 .init_data = &mx27ads_lcd_regulator_init_data,
237 static void __init mx27ads_regulator_init(void)
239 struct gpio_chip *vchip;
241 vchip = kzalloc(sizeof(*vchip), GFP_KERNEL);
242 vchip->owner = THIS_MODULE;
243 vchip->label = "LCD";
244 vchip->base = MX27ADS_LCD_GPIO;
246 vchip->direction_output = vgpio_dir_out;
247 vchip->set = vgpio_set;
248 gpiochip_add_data(vchip, NULL);
250 platform_device_register_data(NULL, "reg-fixed-voltage",
252 &mx27ads_lcd_regulator_pdata,
253 sizeof(mx27ads_lcd_regulator_pdata));
256 static struct imx_fb_videomode mx27ads_modes[] = {
259 .name = "Sharp-LQ035Q7",
263 .pixclock = 188679, /* in ps (5.3MHz) */
276 static const struct imx_fb_platform_data mx27ads_fb_data __initconst = {
277 .mode = mx27ads_modes,
278 .num_modes = ARRAY_SIZE(mx27ads_modes),
281 * - HSYNC active high
282 * - VSYNC active high
283 * - clk notenabled while idle
285 * - data not inverted
286 * - data enable low active
287 * - enable sharp mode
294 static int mx27ads_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
297 return request_irq(gpio_to_irq(IMX_GPIO_NR(5, 21)), detect_irq,
298 IRQF_TRIGGER_RISING, "sdhc1-card-detect", data);
301 static int mx27ads_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
304 return request_irq(gpio_to_irq(IMX_GPIO_NR(2, 7)), detect_irq,
305 IRQF_TRIGGER_RISING, "sdhc2-card-detect", data);
308 static void mx27ads_sdhc1_exit(struct device *dev, void *data)
310 free_irq(gpio_to_irq(IMX_GPIO_NR(5, 21)), data);
313 static void mx27ads_sdhc2_exit(struct device *dev, void *data)
315 free_irq(gpio_to_irq(IMX_GPIO_NR(2, 7)), data);
318 static const struct imxmmc_platform_data sdhc1_pdata __initconst = {
319 .init = mx27ads_sdhc1_init,
320 .exit = mx27ads_sdhc1_exit,
323 static const struct imxmmc_platform_data sdhc2_pdata __initconst = {
324 .init = mx27ads_sdhc2_init,
325 .exit = mx27ads_sdhc2_exit,
328 static struct platform_device *platform_devices[] __initdata = {
329 &mx27ads_nor_mtd_device,
332 static const struct imxuart_platform_data uart_pdata __initconst = {
333 .flags = IMXUART_HAVE_RTSCTS,
336 static void __init mx27ads_board_init(void)
340 mxc_gpio_setup_multiple_pins(mx27ads_pins, ARRAY_SIZE(mx27ads_pins),
343 imx27_add_imx_uart0(&uart_pdata);
344 imx27_add_imx_uart1(&uart_pdata);
345 imx27_add_imx_uart2(&uart_pdata);
346 imx27_add_imx_uart3(&uart_pdata);
347 imx27_add_imx_uart4(&uart_pdata);
348 imx27_add_imx_uart5(&uart_pdata);
349 imx27_add_mxc_nand(&mx27ads_nand_board_info);
351 /* only the i2c master 1 is used on this CPU card */
352 i2c_register_board_info(1, mx27ads_i2c_devices,
353 ARRAY_SIZE(mx27ads_i2c_devices));
354 imx27_add_imx_i2c(1, &mx27ads_i2c1_data);
355 imx27_add_imx_fb(&mx27ads_fb_data);
361 static void __init mx27ads_late_init(void)
363 mx27ads_regulator_init();
365 imx27_add_mxc_mmc(0, &sdhc1_pdata);
366 imx27_add_mxc_mmc(1, &sdhc2_pdata);
368 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
371 static void __init mx27ads_timer_init(void)
373 unsigned long fref = 26000000;
375 if ((imx_readw(PBC_VERSION_REG) & CKIH_27MHZ_BIT_SET) == 0)
378 mx27_clocks_init(fref);
381 static struct map_desc mx27ads_io_desc[] __initdata = {
383 .virtual = PBC_BASE_ADDRESS,
384 .pfn = __phys_to_pfn(MX27_CS4_BASE_ADDR),
390 static void __init mx27ads_map_io(void)
393 iotable_init(mx27ads_io_desc, ARRAY_SIZE(mx27ads_io_desc));
396 MACHINE_START(MX27ADS, "Freescale i.MX27ADS")
397 /* maintainer: Freescale Semiconductor, Inc. */
398 .atag_offset = 0x100,
399 .map_io = mx27ads_map_io,
400 .init_early = imx27_init_early,
401 .init_irq = mx27_init_irq,
402 .init_time = mx27ads_timer_init,
403 .init_machine = mx27ads_board_init,
404 .init_late = mx27ads_late_init,
405 .restart = mxc_restart,