Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.13.7.
  1// SPDX-License-Identifier: GPL-2.0-or-later
  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
 12 */
 13
 14#include <linux/kernel.h>
 15#include <linux/types.h>
 16#include <linux/init.h>
 17#include <linux/gpio.h>
 18#include <linux/leds.h>
 19#include <linux/platform_device.h>
 20
 21#include <asm/mach-types.h>
 22#include <asm/mach/arch.h>
 23#include <asm/mach/map.h>
 24
 25#include "board-mx31lite.h"
 26#include "common.h"
 27#include "devices-imx31.h"
 28#include "hardware.h"
 29#include "iomux-mx3.h"
 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
 38static unsigned int litekit_db_board_pins[] __initdata = {
 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,
 46};
 47
 48/* MMC */
 49
 50static int gpio_det, gpio_wp;
 51
 52#define MMC_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
 53		     PAD_CTL_ODE_CMOS)
 54
 55static int mxc_mmc1_get_ro(struct device *dev)
 56{
 57	return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_GPIO1_6));
 58}
 59
 60static 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
 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);
 78	mxc_iomux_set_pad(MX31_PIN_SD1_CLK, MMC_PAD_CFG);
 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
 91	ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)),
 92			  detect_irq,
 93			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
 94			  "MMC detect", data);
 95	if (ret)
 96		goto exit_free_wp;
 97
 98	return 0;
 99
100exit_free_wp:
101	gpio_free(gpio_wp);
102
103exit_free_det:
104	gpio_free(gpio_det);
105
106	return ret;
107}
108
109static void mxc_mmc1_exit(struct device *dev, void *data)
110{
111	gpio_free(gpio_det);
112	gpio_free(gpio_wp);
113	free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)), data);
114}
115
116static const struct imxmmc_platform_data mmc_pdata __initconst = {
117	.get_ro	 = mxc_mmc1_get_ro,
118	.init	   = mxc_mmc1_init,
119	.exit	   = mxc_mmc1_exit,
120};
121
122/* GPIO LEDs */
123
124static const struct gpio_led litekit_leds[] __initconst = {
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
139static const struct gpio_led_platform_data
140		litekit_led_platform_data __initconst = {
141	.leds           = litekit_leds,
142	.num_leds       = ARRAY_SIZE(litekit_leds),
143};
144
145void __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");
150	imx31_add_mxc_mmc(0, &mmc_pdata);
151	gpio_led_register_device(-1, &litekit_led_platform_data);
152	imx31_add_imx2_wdt();
153	imx31_add_mxc_rtc();
154}