Re: [PATCH] Nokia 770 MMC multislot support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ext Arnaud Patard (Rtp) wrote:
> Adds mmc multislot support for Nokia 770 machines. Without this, I can't
> use the MMC slot at all. Also, I had to hardcode some GPIO pin values as
> it's not really easy to use the ones from the OMAP_TAG_MMC ATAG in
> places like the set_power() hook.
>
> Signed-off-by: Arnaud Patard <arnaud.patard@xxxxxxxxxxx>
> ---
>   
> ------------------------------------------------------------------------
>
> ---
>  arch/arm/mach-omap1/Makefile             |    2 	1 +	1 -	0 !
>  arch/arm/mach-omap1/board-nokia770-mmc.c |  105 	105 +	0 -	0 !
>  arch/arm/mach-omap1/board-nokia770.c     |   18 	18 +	0 -	0 !
>  include/asm-arm/arch-omap/board-nokia.h  |    2 	2 +	0 -	0 !
>  4 files changed, 126 insertions(+), 1 deletion(-)
>
> Index: kernel-source-rx-34-2.6.21.0/arch/arm/mach-omap1/board-nokia770.c
> ===================================================================
> --- kernel-source-rx-34-2.6.21.0.orig/arch/arm/mach-omap1/board-nokia770.c	2007-12-02 15:23:38.000000000 +0100
> +++ kernel-source-rx-34-2.6.21.0/arch/arm/mach-omap1/board-nokia770.c	2007-12-02 20:55:04.000000000 +0100
> @@ -40,6 +40,7 @@
>  #include "../plat-omap/dsp/dsp_common.h"
>  
>  #define ADS7846_PENDOWN_GPIO	15
> +#define N770_COVER_GPIO		23
>  
>  static void __init omap_nokia770_init_irq(void)
>  {
> @@ -239,6 +240,19 @@ static struct omap_board_config_kernel n
>  	{ OMAP_TAG_MMC,		&nokia770_mmc_config },
>  };
>  
> +static struct omap_gpio_switch nokia770_gpio_switches[] __initdata = {
> +	{
> +		.name			= "mmc_slot",
> +		.gpio			= N770_COVER_GPIO,
> +		.type			= OMAP_GPIO_SWITCH_TYPE_COVER,
> +		.flags			= OMAP_GPIO_SWITCH_FLAG_INVERTED,
> +		.debounce_rising	= 100,
> +		.debounce_falling	= 0,
> +		.notify			= nokia770_mmc_slot_cover_handler,
> +		.notify_data            = NULL,
> +	},
> +};
> +
>  #if	defined(CONFIG_OMAP_DSP)
>  /*
>   * audio power control
> @@ -362,6 +376,8 @@ static __init int omap_dsp_init(void)
>  }
>  #endif	/* CONFIG_OMAP_DSP */
>  
> +extern void __init nokia770_mmc_init(void);
> +
>  static void __init omap_nokia770_init(void)
>  {
>  	nokia770_config[0].data = &nokia770_usb_config;
> @@ -377,6 +393,8 @@ static void __init omap_nokia770_init(vo
>  	hwa742_dev_init();
>  	ads7846_dev_init();
>  	mipid_dev_init();
> +	nokia770_mmc_init();
> +	omap_register_gpio_switches(nokia770_gpio_switches,ARRAY_SIZE(nokia770_gpio_switches));
>  }
>  
>  static void __init omap_nokia770_map_io(void)
> Index: kernel-source-rx-34-2.6.21.0/arch/arm/mach-omap1/board-nokia770-mmc.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ kernel-source-rx-34-2.6.21.0/arch/arm/mach-omap1/board-nokia770-mmc.c	2007-12-02 21:42:31.000000000 +0100
> @@ -0,0 +1,105 @@
> +/*
> + * arch/arm/mach-omap1/board-nokia770-mmc.c
> + *
> + * Arnaud Patard <arnaud.patard@xxxxxxxxxxx>
> + *
> + * Based on arch/arm/mach-omap1/board-h2-mmc.c
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <asm/arch/mmc.h>
> +#include <asm/arch/gpio.h>
> +
> +/* having to hardcode it while it's in the TAG information is quite bad */
> +#define N770_POWER_PIN	41
> +
> +#ifdef CONFIG_MMC_OMAP
> +static int slot_cover_open;
> +static struct device *mmc_device;
> +
> +static int nokia770_mmc_set_power(struct device *dev, int slot, int power_on,
> +				int vdd)
> +{
> +#ifdef CONFIG_MMC_DEBUG
> +	dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
> +		power_on ? "on" : "off", vdd);
> +#endif
> +	if (slot != 0) {
> +		dev_err(dev, "No such slot %d\n", slot + 1);
> +		return -ENODEV;
> +	}
> +	if (power_on)
> +		omap_set_gpio_dataout(N770_POWER_PIN, 1);
> +	else
> +		omap_set_gpio_dataout(N770_POWER_PIN, 0);
> +
> +	return 0;
> +}
> +
> +static int nokia770_mmc_get_cover_state(struct device *dev, int slot)
> +{
> +	BUG_ON(slot != 0);
> +
> +	return slot_cover_open;
> +}
> +
> +void nokia770_mmc_slot_cover_handler(void *arg, int state)
> +{
> +	if (mmc_device == NULL)
> +		return;
> +
> +	slot_cover_open = state;
> +	omap_mmc_notify_cover_event(mmc_device, 0, state);
> +}
> +
> +static int nokia770_mmc_late_init(struct device *dev)
> +{
> +	int ret = 0;
> +
> +	mmc_device = dev;
> +
> +	return ret;
> +}
> +
> +static void nokia770_mmc_cleanup(struct device *dev)
> +{
> +}
> +
> +static struct omap_mmc_platform_data nokia770_mmc_data = {
> +	.nr_slots                       = 1,
> +	.switch_slot                    = NULL,
> +	.init                           = nokia770_mmc_late_init,
> +	.cleanup                        = nokia770_mmc_cleanup,
> +	.slots[0]       = {
> +		.set_power              = nokia770_mmc_set_power,
> +		.set_bus_mode           = NULL,
> +		.get_ro                 = NULL,
> +		.get_cover_state        = nokia770_mmc_get_cover_state,
> +		.ocr_mask               = MMC_VDD_28_29 | MMC_VDD_30_31 |
> +					  MMC_VDD_32_33 | MMC_VDD_33_34,
> +		.name                   = "external",
> +	},
> +};
> +
> +void __init nokia770_mmc_init(void)
> +{
> +	omap_set_mmc_info(2, &nokia770_mmc_data);
> +	if (omap_request_gpio(N770_POWER_PIN) < 0)
> +		WARN_ON("can't request mmc power pin !");
> +	omap_set_gpio_dataout(N770_POWER_PIN, 0);
> +	omap_set_gpio_direction(N770_POWER_PIN, 0);
> +}
> +
> +#else
> +
> +void __init nokia770_mmc_init(void)
> +{
> +}
> +
> +void nokia770_mmc_slot_cover_handler(void *arg, int state)
> +{
> +}
> +#endif
> Index: kernel-source-rx-34-2.6.21.0/include/asm-arm/arch-omap/board-nokia.h
> ===================================================================
> --- kernel-source-rx-34-2.6.21.0.orig/include/asm-arm/arch-omap/board-nokia.h	2007-12-02 15:23:38.000000000 +0100
> +++ kernel-source-rx-34-2.6.21.0/include/asm-arm/arch-omap/board-nokia.h	2007-12-02 15:48:47.000000000 +0100
> @@ -24,6 +24,8 @@ extern int n800_audio_enable(struct dsp_
>  extern int n800_audio_disable(struct dsp_kfunc_device *kdev, int stage);
>  extern void n800_mmc_slot1_cover_handler(void *arg, int state);
>  
> +extern void nokia770_mmc_slot_cover_handler(void *arg, int state);
> +
>  #define OMAP_TAG_NOKIA_BT	0x4e01
>  #define OMAP_TAG_WLAN_CX3110X	0x4e02
>  #define OMAP_TAG_CBUS		0x4e03
> Index: kernel-source-rx-34-2.6.21.0/arch/arm/mach-omap1/Makefile
> ===================================================================
> --- kernel-source-rx-34-2.6.21.0.orig/arch/arm/mach-omap1/Makefile	2007-11-29 00:03:29.000000000 +0100
> +++ kernel-source-rx-34-2.6.21.0/arch/arm/mach-omap1/Makefile	2007-12-02 20:52:07.000000000 +0100
> @@ -30,7 +30,7 @@ obj-$(CONFIG_MACH_VOICEBLUE)		+= board-v
>  obj-$(CONFIG_MACH_OMAP_PALMTE)		+= board-palmte.o
>  obj-$(CONFIG_MACH_OMAP_PALMZ71)		+= board-palmz71.o
>  obj-$(CONFIG_MACH_OMAP_PALMTT)		+= board-palmtt.o
> -obj-$(CONFIG_MACH_NOKIA770)		+= board-nokia770.o
> +obj-$(CONFIG_MACH_NOKIA770)		+= board-nokia770.o board-nokia770-mmc.o
>  obj-$(CONFIG_MACH_AMS_DELTA)		+= board-ams-delta.o
>  obj-$(CONFIG_MACH_SX1)			+= board-sx1.o
>  
>   
Hi Arnaud,

Some comments below...

Please, at include/asm-arm/arch-omap/board-nokia.h, add the following line:

extern void nokia770_mmc_init(void);


At arch/arm/mach-omap1/board-nokia770.c, remove the line:

extern void __init nokia770_mmc_init(void);


And add the line:

extern struct omap_mmc_platform_data nokia770_mmc_data;


BR,

Carlos.

-- 
Carlos Eduardo Aguiar
Nokia Institute of Technology - INdT
Open Source Mobile Research Center - OSMRC - Manaus
Core Team
Phone: +55 92 2126-1079
Mobile: +55 92 8127-1797
E-mail: carlos.aguiar@xxxxxxxxxxx

-
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux