diff options
author | Alexander Shiyan <shc_work@mail.ru> | 2014-03-03 13:37:44 -0500 |
---|---|---|
committer | Shawn Guo <shawn.guo@freescale.com> | 2014-04-30 01:40:27 -0400 |
commit | 477fbf1db8cb7b33ada578efb6dd8ce2f00de7f8 (patch) | |
tree | 3ab08f0a678ebe9bc757c876e9282d024b5e5f78 | |
parent | d1db0eea852497762cab43b905b879dfcd3b8987 (diff) |
ARM: i.MX: mx21ads: Replace direct handling of peripheral bits with GPIOs
This patch replaces direct handling of peripheral bits with GPIOs by
using basic-mmio-gpio driver. As a result this change eliminate some
low-level code and removes custom io_map() from the board.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
-rw-r--r-- | arch/arm/mach-imx/mach-mx21ads.c | 136 |
1 files changed, 66 insertions, 70 deletions
diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c index a06aa4dc37fc..87425949244a 100644 --- a/arch/arm/mach-imx/mach-mx21ads.c +++ b/arch/arm/mach-imx/mach-mx21ads.c | |||
@@ -17,51 +17,45 @@ | |||
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/physmap.h> | 19 | #include <linux/mtd/physmap.h> |
20 | #include <linux/basic_mmio_gpio.h> | ||
20 | #include <linux/gpio.h> | 21 | #include <linux/gpio.h> |
21 | #include <asm/mach-types.h> | 22 | #include <asm/mach-types.h> |
22 | #include <asm/mach/arch.h> | 23 | #include <asm/mach/arch.h> |
23 | #include <asm/mach/time.h> | 24 | #include <asm/mach/time.h> |
24 | #include <asm/mach/map.h> | ||
25 | 25 | ||
26 | #include "common.h" | 26 | #include "common.h" |
27 | #include "devices-imx21.h" | 27 | #include "devices-imx21.h" |
28 | #include "hardware.h" | 28 | #include "hardware.h" |
29 | #include "iomux-mx21.h" | 29 | #include "iomux-mx21.h" |
30 | 30 | ||
31 | /* | 31 | #define MX21ADS_CS8900A_REG (MX21_CS1_BASE_ADDR + 0x000000) |
32 | * Memory-mapped I/O on MX21ADS base board | 32 | #define MX21ADS_ST16C255_IOBASE_REG (MX21_CS1_BASE_ADDR + 0x200000) |
33 | */ | 33 | #define MX21ADS_VERSION_REG (MX21_CS1_BASE_ADDR + 0x400000) |
34 | #define MX21ADS_MMIO_BASE_ADDR 0xf5000000 | 34 | #define MX21ADS_IO_REG (MX21_CS1_BASE_ADDR + 0x800000) |
35 | #define MX21ADS_MMIO_SIZE 0xc00000 | ||
36 | |||
37 | #define MX21ADS_REG_ADDR(offset) (void __force __iomem *) \ | ||
38 | (MX21ADS_MMIO_BASE_ADDR + (offset)) | ||
39 | 35 | ||
40 | #define MX21ADS_CS8900A_MMIO_SIZE 0x200000 | 36 | #define MX21ADS_MMC_CD IMX_GPIO_NR(4, 25) |
41 | #define MX21ADS_CS8900A_IRQ_GPIO IMX_GPIO_NR(5, 11) | 37 | #define MX21ADS_CS8900A_IRQ_GPIO IMX_GPIO_NR(5, 11) |
42 | #define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000) | 38 | #define MX21ADS_MMGPIO_BASE (6 * 32) |
43 | #define MX21ADS_VERSION_REG MX21ADS_REG_ADDR(0x400000) | ||
44 | #define MX21ADS_IO_REG MX21ADS_REG_ADDR(0x800000) | ||
45 | 39 | ||
46 | /* MX21ADS_IO_REG bit definitions */ | 40 | /* MX21ADS_IO_REG bit definitions */ |
47 | #define MX21ADS_IO_SD_WP 0x0001 /* read */ | 41 | #define MX21ADS_IO_SD_WP (MX21ADS_MMGPIO_BASE + 0) |
48 | #define MX21ADS_IO_TP6 0x0001 /* write */ | 42 | #define MX21ADS_IO_TP6 (MX21ADS_IO_SD_WP) |
49 | #define MX21ADS_IO_SW_SEL 0x0002 /* read */ | 43 | #define MX21ADS_IO_SW_SEL (MX21ADS_MMGPIO_BASE + 1) |
50 | #define MX21ADS_IO_TP7 0x0002 /* write */ | 44 | #define MX21ADS_IO_TP7 (MX21ADS_IO_SW_SEL) |
51 | #define MX21ADS_IO_RESET_E_UART 0x0004 | 45 | #define MX21ADS_IO_RESET_E_UART (MX21ADS_MMGPIO_BASE + 2) |
52 | #define MX21ADS_IO_RESET_BASE 0x0008 | 46 | #define MX21ADS_IO_RESET_BASE (MX21ADS_MMGPIO_BASE + 3) |
53 | #define MX21ADS_IO_CSI_CTL2 0x0010 | 47 | #define MX21ADS_IO_CSI_CTL2 (MX21ADS_MMGPIO_BASE + 4) |
54 | #define MX21ADS_IO_CSI_CTL1 0x0020 | 48 | #define MX21ADS_IO_CSI_CTL1 (MX21ADS_MMGPIO_BASE + 5) |
55 | #define MX21ADS_IO_CSI_CTL0 0x0040 | 49 | #define MX21ADS_IO_CSI_CTL0 (MX21ADS_MMGPIO_BASE + 6) |
56 | #define MX21ADS_IO_UART1_EN 0x0080 | 50 | #define MX21ADS_IO_UART1_EN (MX21ADS_MMGPIO_BASE + 7) |
57 | #define MX21ADS_IO_UART4_EN 0x0100 | 51 | #define MX21ADS_IO_UART4_EN (MX21ADS_MMGPIO_BASE + 8) |
58 | #define MX21ADS_IO_LCDON 0x0200 | 52 | #define MX21ADS_IO_LCDON (MX21ADS_MMGPIO_BASE + 9) |
59 | #define MX21ADS_IO_IRDA_EN 0x0400 | 53 | #define MX21ADS_IO_IRDA_EN (MX21ADS_MMGPIO_BASE + 10) |
60 | #define MX21ADS_IO_IRDA_FIR_SEL 0x0800 | 54 | #define MX21ADS_IO_IRDA_FIR_SEL (MX21ADS_MMGPIO_BASE + 11) |
61 | #define MX21ADS_IO_IRDA_MD0_B 0x1000 | 55 | #define MX21ADS_IO_IRDA_MD0_B (MX21ADS_MMGPIO_BASE + 12) |
62 | #define MX21ADS_IO_IRDA_MD1 0x2000 | 56 | #define MX21ADS_IO_IRDA_MD1 (MX21ADS_MMGPIO_BASE + 13) |
63 | #define MX21ADS_IO_LED4_ON 0x4000 | 57 | #define MX21ADS_IO_LED4_ON (MX21ADS_MMGPIO_BASE + 14) |
64 | #define MX21ADS_IO_LED3_ON 0x8000 | 58 | #define MX21ADS_IO_LED3_ON (MX21ADS_MMGPIO_BASE + 15) |
65 | 59 | ||
66 | static const int mx21ads_pins[] __initconst = { | 60 | static const int mx21ads_pins[] __initconst = { |
67 | 61 | ||
@@ -160,7 +154,7 @@ static struct platform_device mx21ads_nor_mtd_device = { | |||
160 | }; | 154 | }; |
161 | 155 | ||
162 | static struct resource mx21ads_cs8900_resources[] __initdata = { | 156 | static struct resource mx21ads_cs8900_resources[] __initdata = { |
163 | DEFINE_RES_MEM(MX21_CS1_BASE_ADDR, MX21ADS_CS8900A_MMIO_SIZE), | 157 | DEFINE_RES_MEM(MX21_CS1_BASE_ADDR, SZ_1K), |
164 | /* irq number is run-time assigned */ | 158 | /* irq number is run-time assigned */ |
165 | DEFINE_RES_IRQ(-1), | 159 | DEFINE_RES_IRQ(-1), |
166 | }; | 160 | }; |
@@ -179,23 +173,39 @@ static const struct imxuart_platform_data uart_pdata_rts __initconst = { | |||
179 | static const struct imxuart_platform_data uart_pdata_norts __initconst = { | 173 | static const struct imxuart_platform_data uart_pdata_norts __initconst = { |
180 | }; | 174 | }; |
181 | 175 | ||
176 | static struct resource mx21ads_mmgpio_resource = | ||
177 | DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat"); | ||
178 | |||
179 | static struct bgpio_pdata mx21ads_mmgpio_pdata = { | ||
180 | .base = MX21ADS_MMGPIO_BASE, | ||
181 | .ngpio = 16, | ||
182 | }; | ||
183 | |||
184 | static struct platform_device mx21ads_mmgpio = { | ||
185 | .name = "basic-mmio-gpio", | ||
186 | .id = PLATFORM_DEVID_AUTO, | ||
187 | .resource = &mx21ads_mmgpio_resource, | ||
188 | .num_resources = 1, | ||
189 | .dev = { | ||
190 | .platform_data = &mx21ads_mmgpio_pdata, | ||
191 | }, | ||
192 | }; | ||
193 | |||
182 | static int mx21ads_fb_init(struct platform_device *pdev) | 194 | static int mx21ads_fb_init(struct platform_device *pdev) |
183 | { | 195 | { |
184 | u16 tmp; | 196 | int ret; |
185 | 197 | ||
186 | tmp = __raw_readw(MX21ADS_IO_REG); | 198 | ret = gpio_request(MX21ADS_IO_LCDON, "fb-lcdon"); |
187 | tmp |= MX21ADS_IO_LCDON; | 199 | if (ret) |
188 | __raw_writew(tmp, MX21ADS_IO_REG); | 200 | return ret; |
189 | return 0; | 201 | |
202 | return gpio_direction_output(MX21ADS_IO_LCDON, 1); | ||
190 | } | 203 | } |
191 | 204 | ||
192 | static void mx21ads_fb_exit(struct platform_device *pdev) | 205 | static void mx21ads_fb_exit(struct platform_device *pdev) |
193 | { | 206 | { |
194 | u16 tmp; | 207 | gpio_set_value(MX21ADS_IO_LCDON, 0); |
195 | 208 | gpio_free(MX21ADS_IO_LCDON); | |
196 | tmp = __raw_readw(MX21ADS_IO_REG); | ||
197 | tmp &= ~MX21ADS_IO_LCDON; | ||
198 | __raw_writew(tmp, MX21ADS_IO_REG); | ||
199 | } | 209 | } |
200 | 210 | ||
201 | /* | 211 | /* |
@@ -236,19 +246,26 @@ static const struct imx_fb_platform_data mx21ads_fb_data __initconst = { | |||
236 | 246 | ||
237 | static int mx21ads_sdhc_get_ro(struct device *dev) | 247 | static int mx21ads_sdhc_get_ro(struct device *dev) |
238 | { | 248 | { |
239 | return (__raw_readw(MX21ADS_IO_REG) & MX21ADS_IO_SD_WP) ? 1 : 0; | 249 | return gpio_get_value(MX21ADS_IO_SD_WP); |
240 | } | 250 | } |
241 | 251 | ||
242 | static int mx21ads_sdhc_init(struct device *dev, irq_handler_t detect_irq, | 252 | static int mx21ads_sdhc_init(struct device *dev, irq_handler_t detect_irq, |
243 | void *data) | 253 | void *data) |
244 | { | 254 | { |
245 | return request_irq(gpio_to_irq(IMX_GPIO_NR(4, 25)), detect_irq, | 255 | int ret; |
246 | IRQF_TRIGGER_FALLING, "mmc-detect", data); | 256 | |
257 | ret = gpio_request(MX21ADS_IO_SD_WP, "mmc-ro"); | ||
258 | if (ret) | ||
259 | return ret; | ||
260 | |||
261 | return request_irq(gpio_to_irq(MX21ADS_MMC_CD), detect_irq, | ||
262 | IRQF_TRIGGER_FALLING, "mmc-detect", data); | ||
247 | } | 263 | } |
248 | 264 | ||
249 | static void mx21ads_sdhc_exit(struct device *dev, void *data) | 265 | static void mx21ads_sdhc_exit(struct device *dev, void *data) |
250 | { | 266 | { |
251 | free_irq(gpio_to_irq(IMX_GPIO_NR(4, 25)), data); | 267 | free_irq(gpio_to_irq(MX21ADS_MMC_CD), data); |
268 | gpio_free(MX21ADS_IO_SD_WP); | ||
252 | } | 269 | } |
253 | 270 | ||
254 | static const struct imxmmc_platform_data mx21ads_sdhc_pdata __initconst = { | 271 | static const struct imxmmc_platform_data mx21ads_sdhc_pdata __initconst = { |
@@ -264,29 +281,8 @@ mx21ads_nand_board_info __initconst = { | |||
264 | .hw_ecc = 1, | 281 | .hw_ecc = 1, |
265 | }; | 282 | }; |
266 | 283 | ||
267 | static struct map_desc mx21ads_io_desc[] __initdata = { | ||
268 | /* | ||
269 | * Memory-mapped I/O on MX21ADS Base board: | ||
270 | * - CS8900A Ethernet controller | ||
271 | * - ST16C2552CJ UART | ||
272 | * - CPU and Base board version | ||
273 | * - Base board I/O register | ||
274 | */ | ||
275 | { | ||
276 | .virtual = MX21ADS_MMIO_BASE_ADDR, | ||
277 | .pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR), | ||
278 | .length = MX21ADS_MMIO_SIZE, | ||
279 | .type = MT_DEVICE, | ||
280 | }, | ||
281 | }; | ||
282 | |||
283 | static void __init mx21ads_map_io(void) | ||
284 | { | ||
285 | mx21_map_io(); | ||
286 | iotable_init(mx21ads_io_desc, ARRAY_SIZE(mx21ads_io_desc)); | ||
287 | } | ||
288 | |||
289 | static struct platform_device *platform_devices[] __initdata = { | 284 | static struct platform_device *platform_devices[] __initdata = { |
285 | &mx21ads_mmgpio, | ||
290 | &mx21ads_nor_mtd_device, | 286 | &mx21ads_nor_mtd_device, |
291 | }; | 287 | }; |
292 | 288 | ||
@@ -321,7 +317,7 @@ static void __init mx21ads_timer_init(void) | |||
321 | MACHINE_START(MX21ADS, "Freescale i.MX21ADS") | 317 | MACHINE_START(MX21ADS, "Freescale i.MX21ADS") |
322 | /* maintainer: Freescale Semiconductor, Inc. */ | 318 | /* maintainer: Freescale Semiconductor, Inc. */ |
323 | .atag_offset = 0x100, | 319 | .atag_offset = 0x100, |
324 | .map_io = mx21ads_map_io, | 320 | .map_io = mx21_map_io, |
325 | .init_early = imx21_init_early, | 321 | .init_early = imx21_init_early, |
326 | .init_irq = mx21_init_irq, | 322 | .init_irq = mx21_init_irq, |
327 | .handle_irq = imx21_handle_irq, | 323 | .handle_irq = imx21_handle_irq, |