Thomas Gleixner | c942fdd | 2019-05-27 08:55:06 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Daniel Mack | b7d91a6 | 2009-11-19 12:02:06 +0100 | [diff] [blame] | 2 | /* |
| 3 | * LogicPD i.MX31 SOM-LV development board support |
| 4 | * |
| 5 | * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de> |
| 6 | * |
| 7 | * based on code for other MX31 boards, |
| 8 | * |
| 9 | * Copyright 2005-2007 Freescale Semiconductor |
| 10 | * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com> |
| 11 | * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group |
Daniel Mack | b7d91a6 | 2009-11-19 12:02:06 +0100 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/types.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/gpio.h> |
Daniel Mack | 81057f3 | 2009-11-19 12:02:10 +0100 | [diff] [blame] | 18 | #include <linux/leds.h> |
| 19 | #include <linux/platform_device.h> |
Daniel Mack | b7d91a6 | 2009-11-19 12:02:06 +0100 | [diff] [blame] | 20 | |
| 21 | #include <asm/mach-types.h> |
| 22 | #include <asm/mach/arch.h> |
| 23 | #include <asm/mach/map.h> |
| 24 | |
Shawn Guo | 3ed0bcb | 2012-09-13 09:37:49 +0800 | [diff] [blame] | 25 | #include "board-mx31lite.h" |
Shawn Guo | e337247 | 2012-09-13 21:01:00 +0800 | [diff] [blame] | 26 | #include "common.h" |
Uwe Kleine-König | 06606ff | 2010-06-22 10:09:14 +0200 | [diff] [blame] | 27 | #include "devices-imx31.h" |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 28 | #include "hardware.h" |
Shawn Guo | 267dd34 | 2012-09-13 13:26:00 +0800 | [diff] [blame] | 29 | #include "iomux-mx3.h" |
Daniel Mack | b7d91a6 | 2009-11-19 12:02:06 +0100 | [diff] [blame] | 30 | |
| 31 | /* |
| 32 | * This file contains board-specific initialization routines for the |
| 33 | * LogicPD i.MX31 SOM-LV development board, aka 'LiteKit'. |
| 34 | * If you design an own baseboard for the module, use this file as base |
| 35 | * for support code. |
| 36 | */ |
| 37 | |
| 38 | static unsigned int litekit_db_board_pins[] __initdata = { |
Vladimir Zapolskiy | 70c91a3 | 2010-01-26 14:00:40 +0300 | [diff] [blame] | 39 | /* SDHC1 */ |
| 40 | MX31_PIN_SD1_DATA0__SD1_DATA0, |
| 41 | MX31_PIN_SD1_DATA1__SD1_DATA1, |
| 42 | MX31_PIN_SD1_DATA2__SD1_DATA2, |
| 43 | MX31_PIN_SD1_DATA3__SD1_DATA3, |
| 44 | MX31_PIN_SD1_CLK__SD1_CLK, |
| 45 | MX31_PIN_SD1_CMD__SD1_CMD, |
Daniel Mack | b7d91a6 | 2009-11-19 12:02:06 +0100 | [diff] [blame] | 46 | }; |
| 47 | |
Daniel Mack | 364cd54 | 2009-11-19 12:02:07 +0100 | [diff] [blame] | 48 | /* MMC */ |
| 49 | |
| 50 | static int gpio_det, gpio_wp; |
| 51 | |
| 52 | #define MMC_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \ |
Vladimir Zapolskiy | 70c91a3 | 2010-01-26 14:00:40 +0300 | [diff] [blame] | 53 | PAD_CTL_ODE_CMOS) |
Daniel Mack | 364cd54 | 2009-11-19 12:02:07 +0100 | [diff] [blame] | 54 | |
| 55 | static int mxc_mmc1_get_ro(struct device *dev) |
| 56 | { |
Vladimir Zapolskiy | 70c91a3 | 2010-01-26 14:00:40 +0300 | [diff] [blame] | 57 | return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_GPIO1_6)); |
Daniel Mack | 364cd54 | 2009-11-19 12:02:07 +0100 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | static int mxc_mmc1_init(struct device *dev, |
| 61 | irq_handler_t detect_irq, void *data) |
| 62 | { |
| 63 | int ret; |
| 64 | |
| 65 | gpio_det = IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1); |
| 66 | gpio_wp = IOMUX_TO_GPIO(MX31_PIN_GPIO1_6); |
| 67 | |
Vladimir Zapolskiy | 70c91a3 | 2010-01-26 14:00:40 +0300 | [diff] [blame] | 68 | mxc_iomux_set_pad(MX31_PIN_SD1_DATA0, |
| 69 | MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU); |
| 70 | mxc_iomux_set_pad(MX31_PIN_SD1_DATA1, |
| 71 | MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU); |
| 72 | mxc_iomux_set_pad(MX31_PIN_SD1_DATA2, |
| 73 | MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU); |
| 74 | mxc_iomux_set_pad(MX31_PIN_SD1_DATA3, |
| 75 | MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU); |
| 76 | mxc_iomux_set_pad(MX31_PIN_SD1_CMD, |
| 77 | MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU); |
Daniel Mack | 364cd54 | 2009-11-19 12:02:07 +0100 | [diff] [blame] | 78 | mxc_iomux_set_pad(MX31_PIN_SD1_CLK, MMC_PAD_CFG); |
Daniel Mack | 364cd54 | 2009-11-19 12:02:07 +0100 | [diff] [blame] | 79 | |
| 80 | ret = gpio_request(gpio_det, "MMC detect"); |
| 81 | if (ret) |
| 82 | return ret; |
| 83 | |
| 84 | ret = gpio_request(gpio_wp, "MMC w/p"); |
| 85 | if (ret) |
| 86 | goto exit_free_det; |
| 87 | |
| 88 | gpio_direction_input(gpio_det); |
| 89 | gpio_direction_input(gpio_wp); |
| 90 | |
Shawn Guo | ed17534 | 2011-12-02 20:00:33 +0800 | [diff] [blame] | 91 | ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)), |
| 92 | detect_irq, |
Vladimir Zapolskiy | 70c91a3 | 2010-01-26 14:00:40 +0300 | [diff] [blame] | 93 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
Daniel Mack | 364cd54 | 2009-11-19 12:02:07 +0100 | [diff] [blame] | 94 | "MMC detect", data); |
| 95 | if (ret) |
| 96 | goto exit_free_wp; |
| 97 | |
| 98 | return 0; |
| 99 | |
| 100 | exit_free_wp: |
| 101 | gpio_free(gpio_wp); |
| 102 | |
| 103 | exit_free_det: |
| 104 | gpio_free(gpio_det); |
| 105 | |
| 106 | return ret; |
| 107 | } |
| 108 | |
| 109 | static void mxc_mmc1_exit(struct device *dev, void *data) |
| 110 | { |
| 111 | gpio_free(gpio_det); |
| 112 | gpio_free(gpio_wp); |
Shawn Guo | ed17534 | 2011-12-02 20:00:33 +0800 | [diff] [blame] | 113 | free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)), data); |
Daniel Mack | 364cd54 | 2009-11-19 12:02:07 +0100 | [diff] [blame] | 114 | } |
| 115 | |
Uwe Kleine-König | 6a697e3 | 2010-11-12 11:10:55 +0100 | [diff] [blame] | 116 | static const struct imxmmc_platform_data mmc_pdata __initconst = { |
Daniel Mack | 364cd54 | 2009-11-19 12:02:07 +0100 | [diff] [blame] | 117 | .get_ro = mxc_mmc1_get_ro, |
| 118 | .init = mxc_mmc1_init, |
| 119 | .exit = mxc_mmc1_exit, |
| 120 | }; |
| 121 | |
Daniel Mack | 81057f3 | 2009-11-19 12:02:10 +0100 | [diff] [blame] | 122 | /* GPIO LEDs */ |
| 123 | |
Uwe Kleine-König | 47e837b | 2011-05-28 21:05:01 +0200 | [diff] [blame] | 124 | static const struct gpio_led litekit_leds[] __initconst = { |
Daniel Mack | 81057f3 | 2009-11-19 12:02:10 +0100 | [diff] [blame] | 125 | { |
| 126 | .name = "GPIO0", |
| 127 | .gpio = IOMUX_TO_GPIO(MX31_PIN_COMPARE), |
| 128 | .active_low = 1, |
| 129 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
| 130 | }, |
| 131 | { |
| 132 | .name = "GPIO1", |
| 133 | .gpio = IOMUX_TO_GPIO(MX31_PIN_CAPTURE), |
| 134 | .active_low = 1, |
| 135 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
| 136 | } |
| 137 | }; |
| 138 | |
Uwe Kleine-König | 47e837b | 2011-05-28 21:05:01 +0200 | [diff] [blame] | 139 | static const struct gpio_led_platform_data |
| 140 | litekit_led_platform_data __initconst = { |
Daniel Mack | 81057f3 | 2009-11-19 12:02:10 +0100 | [diff] [blame] | 141 | .leds = litekit_leds, |
| 142 | .num_leds = ARRAY_SIZE(litekit_leds), |
| 143 | }; |
| 144 | |
Daniel Mack | b7d91a6 | 2009-11-19 12:02:06 +0100 | [diff] [blame] | 145 | void __init mx31lite_db_init(void) |
| 146 | { |
| 147 | mxc_iomux_setup_multiple_pins(litekit_db_board_pins, |
| 148 | ARRAY_SIZE(litekit_db_board_pins), |
| 149 | "development board pins"); |
Uwe Kleine-König | 6a697e3 | 2010-11-12 11:10:55 +0100 | [diff] [blame] | 150 | imx31_add_mxc_mmc(0, &mmc_pdata); |
Uwe Kleine-König | 47e837b | 2011-05-28 21:05:01 +0200 | [diff] [blame] | 151 | gpio_led_register_device(-1, &litekit_led_platform_data); |
Benoît Thébaudeau | bec31a8 | 2012-07-04 16:35:54 +0200 | [diff] [blame] | 152 | imx31_add_imx2_wdt(); |
| 153 | imx31_add_mxc_rtc(); |
Daniel Mack | b7d91a6 | 2009-11-19 12:02:06 +0100 | [diff] [blame] | 154 | } |