1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2000 Deep Blue Solutions Ltd
4 * Copyright (C) 2002 Shane Nay (shane@minirl.com)
5 * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
8 #include <linux/platform_device.h>
9 #include <linux/mtd/mtd.h>
10 #include <linux/mtd/physmap.h>
11 #include <linux/gpio/driver.h>
12 #include <linux/gpio/machine.h>
13 #include <linux/gpio.h>
14 #include <linux/regulator/fixed.h>
15 #include <linux/regulator/machine.h>
16 #include <asm/mach-types.h>
17 #include <asm/mach/arch.h>
20 #include "devices-imx21.h"
22 #include "iomux-mx21.h"
24 #define MX21ADS_CS8900A_REG (MX21_CS1_BASE_ADDR + 0x000000)
25 #define MX21ADS_ST16C255_IOBASE_REG (MX21_CS1_BASE_ADDR + 0x200000)
26 #define MX21ADS_VERSION_REG (MX21_CS1_BASE_ADDR + 0x400000)
27 #define MX21ADS_IO_REG (MX21_CS1_BASE_ADDR + 0x800000)
29 #define MX21ADS_MMC_CD IMX_GPIO_NR(4, 25)
30 #define MX21ADS_CS8900A_IRQ_GPIO IMX_GPIO_NR(5, 11)
31 #define MX21ADS_MMGPIO_BASE (6 * 32)
33 /* MX21ADS_IO_REG bit definitions */
34 #define MX21ADS_IO_SD_WP (MX21ADS_MMGPIO_BASE + 0)
35 #define MX21ADS_IO_TP6 (MX21ADS_IO_SD_WP)
36 #define MX21ADS_IO_SW_SEL (MX21ADS_MMGPIO_BASE + 1)
37 #define MX21ADS_IO_TP7 (MX21ADS_IO_SW_SEL)
38 #define MX21ADS_IO_RESET_E_UART (MX21ADS_MMGPIO_BASE + 2)
39 #define MX21ADS_IO_RESET_BASE (MX21ADS_MMGPIO_BASE + 3)
40 #define MX21ADS_IO_CSI_CTL2 (MX21ADS_MMGPIO_BASE + 4)
41 #define MX21ADS_IO_CSI_CTL1 (MX21ADS_MMGPIO_BASE + 5)
42 #define MX21ADS_IO_CSI_CTL0 (MX21ADS_MMGPIO_BASE + 6)
43 #define MX21ADS_IO_UART1_EN (MX21ADS_MMGPIO_BASE + 7)
44 #define MX21ADS_IO_UART4_EN (MX21ADS_MMGPIO_BASE + 8)
45 #define MX21ADS_IO_LCDON (MX21ADS_MMGPIO_BASE + 9)
46 #define MX21ADS_IO_IRDA_EN (MX21ADS_MMGPIO_BASE + 10)
47 #define MX21ADS_IO_IRDA_FIR_SEL (MX21ADS_MMGPIO_BASE + 11)
48 #define MX21ADS_IO_IRDA_MD0_B (MX21ADS_MMGPIO_BASE + 12)
49 #define MX21ADS_IO_IRDA_MD1 (MX21ADS_MMGPIO_BASE + 13)
50 #define MX21ADS_IO_LED4_ON (MX21ADS_MMGPIO_BASE + 14)
51 #define MX21ADS_IO_LED3_ON (MX21ADS_MMGPIO_BASE + 15)
53 static const int mx21ads_pins
[] __initconst
= {
56 (GPIO_PORTE
| GPIO_GPIO
| GPIO_IN
| 11),
64 /* UART3 (IrDA) - only TXD and RXD */
93 PA24_PF_REV
, /* Sharp panel dedicated signal */
94 PA25_PF_CLS
, /* Sharp panel dedicated signal */
95 PA26_PF_PS
, /* Sharp panel dedicated signal */
96 PA27_PF_SPL_SPR
, /* Sharp panel dedicated signal */
128 /* ADS's NOR flash: 2x AM29BDS128HE9VKI on 32-bit bus */
129 static struct physmap_flash_data mx21ads_flash_data
= {
133 static struct resource mx21ads_flash_resource
=
134 DEFINE_RES_MEM(MX21_CS0_BASE_ADDR
, SZ_32M
);
136 static struct platform_device mx21ads_nor_mtd_device
= {
137 .name
= "physmap-flash",
140 .platform_data
= &mx21ads_flash_data
,
143 .resource
= &mx21ads_flash_resource
,
146 static struct resource mx21ads_cs8900_resources
[] __initdata
= {
147 DEFINE_RES_MEM(MX21ADS_CS8900A_REG
, SZ_1K
),
148 /* irq number is run-time assigned */
152 static const struct platform_device_info mx21ads_cs8900_devinfo __initconst
= {
155 .res
= mx21ads_cs8900_resources
,
156 .num_res
= ARRAY_SIZE(mx21ads_cs8900_resources
),
159 static const struct imxuart_platform_data uart_pdata_rts __initconst
= {
160 .flags
= IMXUART_HAVE_RTSCTS
,
163 static const struct imxuart_platform_data uart_pdata_norts __initconst
= {
166 static struct resource mx21ads_mmgpio_resource
=
167 DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG
, SZ_2
, "dat");
169 static struct bgpio_pdata mx21ads_mmgpio_pdata
= {
170 .label
= "mx21ads-mmgpio",
171 .base
= MX21ADS_MMGPIO_BASE
,
175 static struct platform_device mx21ads_mmgpio
= {
176 .name
= "basic-mmio-gpio",
177 .id
= PLATFORM_DEVID_AUTO
,
178 .resource
= &mx21ads_mmgpio_resource
,
181 .platform_data
= &mx21ads_mmgpio_pdata
,
185 static struct regulator_consumer_supply mx21ads_lcd_regulator_consumer
=
186 REGULATOR_SUPPLY("lcd", "imx-fb.0");
188 static struct regulator_init_data mx21ads_lcd_regulator_init_data
= {
190 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
192 .consumer_supplies
= &mx21ads_lcd_regulator_consumer
,
193 .num_consumer_supplies
= 1,
196 static struct fixed_voltage_config mx21ads_lcd_regulator_pdata
= {
197 .supply_name
= "LCD",
198 .microvolts
= 3300000,
199 .init_data
= &mx21ads_lcd_regulator_init_data
,
202 static struct platform_device mx21ads_lcd_regulator
= {
203 .name
= "reg-fixed-voltage",
204 .id
= PLATFORM_DEVID_AUTO
,
206 .platform_data
= &mx21ads_lcd_regulator_pdata
,
210 static struct gpiod_lookup_table mx21ads_lcd_regulator_gpiod_table
= {
211 .dev_id
= "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */
213 GPIO_LOOKUP("mx21ads-mmgpio", 9, NULL
, GPIO_ACTIVE_HIGH
),
219 * Connected is a portrait Sharp-QVGA display
220 * of type: LQ035Q7DB02
222 static struct imx_fb_videomode mx21ads_modes
[] = {
225 .name
= "Sharp-LQ035Q7",
229 .pixclock
= 188679, /* in ps (5.3MHz) */
242 static const struct imx_fb_platform_data mx21ads_fb_data __initconst
= {
243 .mode
= mx21ads_modes
,
244 .num_modes
= ARRAY_SIZE(mx21ads_modes
),
251 static int mx21ads_sdhc_get_ro(struct device
*dev
)
253 return gpio_get_value(MX21ADS_IO_SD_WP
);
256 static int mx21ads_sdhc_init(struct device
*dev
, irq_handler_t detect_irq
,
261 ret
= gpio_request(MX21ADS_IO_SD_WP
, "mmc-ro");
265 return request_irq(gpio_to_irq(MX21ADS_MMC_CD
), detect_irq
,
266 IRQF_TRIGGER_FALLING
, "mmc-detect", data
);
269 static void mx21ads_sdhc_exit(struct device
*dev
, void *data
)
271 free_irq(gpio_to_irq(MX21ADS_MMC_CD
), data
);
272 gpio_free(MX21ADS_IO_SD_WP
);
275 static const struct imxmmc_platform_data mx21ads_sdhc_pdata __initconst
= {
276 .ocr_avail
= MMC_VDD_29_30
| MMC_VDD_30_31
, /* 3.0V */
277 .get_ro
= mx21ads_sdhc_get_ro
,
278 .init
= mx21ads_sdhc_init
,
279 .exit
= mx21ads_sdhc_exit
,
282 static const struct mxc_nand_platform_data
283 mx21ads_nand_board_info __initconst
= {
288 static struct platform_device
*platform_devices
[] __initdata
= {
290 &mx21ads_lcd_regulator
,
291 &mx21ads_nor_mtd_device
,
294 static void __init
mx21ads_board_init(void)
298 mxc_gpio_setup_multiple_pins(mx21ads_pins
, ARRAY_SIZE(mx21ads_pins
),
301 imx21_add_imx_uart0(&uart_pdata_rts
);
302 imx21_add_imx_uart2(&uart_pdata_norts
);
303 imx21_add_imx_uart3(&uart_pdata_rts
);
304 imx21_add_mxc_nand(&mx21ads_nand_board_info
);
306 imx21_add_imx_fb(&mx21ads_fb_data
);
309 static void __init
mx21ads_late_init(void)
311 imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata
);
313 gpiod_add_lookup_table(&mx21ads_lcd_regulator_gpiod_table
);
314 platform_add_devices(platform_devices
, ARRAY_SIZE(platform_devices
));
316 mx21ads_cs8900_resources
[1].start
=
317 gpio_to_irq(MX21ADS_CS8900A_IRQ_GPIO
);
318 mx21ads_cs8900_resources
[1].end
=
319 gpio_to_irq(MX21ADS_CS8900A_IRQ_GPIO
);
320 platform_device_register_full(&mx21ads_cs8900_devinfo
);
323 static void __init
mx21ads_timer_init(void)
325 mx21_clocks_init(32768, 26000000);
328 MACHINE_START(MX21ADS
, "Freescale i.MX21ADS")
329 /* maintainer: Freescale Semiconductor, Inc. */
330 .atag_offset
= 0x100,
331 .map_io
= mx21_map_io
,
332 .init_early
= imx21_init_early
,
333 .init_irq
= mx21_init_irq
,
334 .init_time
= mx21ads_timer_init
,
335 .init_machine
= mx21ads_board_init
,
336 .init_late
= mx21ads_late_init
,
337 .restart
= mxc_restart
,