OMAP: MMC: Move set_power to platform data
Subsystems (5)
PATCH 1/1 OMAP: MMC: Move set_power to platform data
Tony,
Attached patch moves the set_power function to specific board-*.c files. For OMAP24xx-H4 I have to used __raw_* functions instead of OMAP_MMC_WRITE, as it is in local omap.h inside drivers/mmc directory.
Tested on H4, it is able to detect the MMC atleast :) and builds for innovator_1510, h2 and h3. 24xx custom boards needs to be updated if they are not using powerpin gpio.
I am not able to find defconfig for apollon board, so if Kyungmin Park confirms the changes then I can add h4 like setpower function to board-apollon.c in the next patch. Thanx.
---Komal Shah
http://komalshah.blogspot.com/
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Subject: [PATCH] OMAP: MMC: Move set_power to platform data
---
arch/arm/mach-omap1/board-h2.c | 10 +++++++ arch/arm/mach-omap1/board-h3.c | 11 +++++++ arch/arm/mach-omap1/board-innovator.c | 15 ++++++++++ arch/arm/mach-omap2/board-h4.c | 11 +++++++ drivers/mmc/omap.c | 50 ++++----------------------------- include/asm-arm/arch-omap/board.h | 1 + 6 files changed, 54 insertions(+), 44 deletions(-)
ba848bda79bfc460c81aed30280f24aa71e4f042
arch/arm/mach-omap1/board-h2.c +10 -0
@@ -40,6 +40,7 @@#include <asm/arch/irda.h> #include <asm/arch/usb.h> #include <asm/arch/keypad.h> +#include <asm/arch/tps65010.h> #include <asm/arch/common.h> extern int omap_gpio_init (void );
@@ -316,6 +317,14 @@ static struct omap_usb_config h2_usb_con .pins[1] = 3, }; +void h2_mmc_set_power (void __iomem *base,int on) +{ +if (on) +tps65010_set_gpio_out_value (GPIO3 ,HIGH ); +else +tps65010_set_gpio_out_value (GPIO3 ,LOW ); +} +static struct omap_mmc_config h2_mmc_config__initdata = { .mmc [0 ] = { .enabled =1 ,
@@ -323,6 +332,7 @@ static struct omap_mmc_config h2_mmc_con .wp_pin = OMAP_MPUIO(3), .power_pin = -1, /* tps65010 gpio3 */ .switch_pin = OMAP_MPUIO(1), + .set_power = h2_mmc_set_power, }, };
arch/arm/mach-omap1/board-h3.c +11 -0
@@ -43,6 +43,7 @@#include <asm/arch/irda.h> #include <asm/arch/usb.h> #include <asm/arch/keypad.h> +#include <asm/arch/tps65010.h> #include <asm/arch/common.h> extern int omap_gpio_init (void );
@@ -378,11 +379,21 @@ static struct omap_usb_config h3_usb_con .pins[1] = 3, }; +void h3_mmc_set_power (void __iomem *base,int on) +{ +if (on) +/* GPIO 4 of TPS65010 sends SD_EN signal */ +tps65010_set_gpio_out_value (GPIO4 ,HIGH ); +else +tps65010_set_gpio_out_value (GPIO4 ,LOW ); +} +static struct omap_mmc_config h3_mmc_config__initdata = { .mmc[0 ] = { .enabled =1 , .power_pin =-1 ,/* tps65010 GPIO4 */ .switch_pin =OMAP_MPUIO (1 ), + .set_power = h3_mmc_set_power, }, };
arch/arm/mach-omap1/board-innovator.c +15 -0
@@ -36,6 +36,7 @@#include <asm/arch/tc.h> #include <asm/arch/usb.h> #include <asm/arch/keypad.h> +#include <asm/arch/fpga.h> #include <asm/arch/common.h> static int innovator_keymap[] = {
@@ -285,6 +286,19 @@ static struct omap_lcd_config innovator1 };#endif +void innovator_mmc_set_power (void __iomem *base,int on) +{ +#if defined(CONFIG_MACH_OMAP_INNOVATOR ) && defined(CONFIG_ARCH_OMAP15XX ) +if (on) { +fpga_write (fpga_read (OMAP1510_FPGA_POWER ) | (1 <<3 ), +OMAP1510_FPGA_POWER ); + }else { +fpga_write (fpga_read (OMAP1510_FPGA_POWER ) & ~(1 <<3 ), +OMAP1510_FPGA_POWER ); + } +#endif +} +static struct omap_mmc_config innovator_mmc_config__initdata = { .mmc [0 ] = { .enabled =1 ,
@@ -292,6 +306,7 @@ static struct omap_mmc_config innovator_ .wp_pin = OMAP_MPUIO(3), .power_pin = -1, /* FPGA F3 UIO42 */ .switch_pin = -1, /* FPGA F4 UIO43 */ + .set_power = innovator_mmc_set_power, }, };
arch/arm/mach-omap2/board-h4.c +11 -0
@@ -297,6 +297,16 @@ static struct omap_uart_config h4_uart_c .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)), }; +void h4_mmc_set_power (void __iomem *base,int on) +{ +u16 reg =__raw_readw ((base) +0x0c ); + +if (on) +__raw_writew (reg | (1 <<11 ), (base) +0x0c ); +else +__raw_writew (reg & ~(1 <<11 ), (base) +0x0c ); +} +static struct omap_mmc_config h4_mmc_config__initdata = { .mmc [0 ] = { .enabled =1 ,
@@ -304,6 +314,7 @@ static struct omap_mmc_config h4_mmc_con .wp_pin = -1, .power_pin = -1, .switch_pin = -1, + .set_power = h4_mmc_set_power, }, };
drivers/mmc/omap.c +6 -44
80 lines not on this page · raw message
include/asm-arm/arch-omap/board.h +1 -0
@@ -46,6 +46,7 @@ struct omap_mmc_conf {s16 power_pin;s16 switch_pin;s16 wp_pin; +void (*set_power)(void __iomem *base,int on); };struct omap_mmc_config {
Signature · 1 line
1.1.6
Tony Lindgren
maintainerQuoted 6 lines · Komal Shah
Tony,
Attached patch moves the
set_powerfunction to specific board-*.c files. For OMAP24xx-H4 I have to used __raw_* functions instead ofOMAP_MMC_WRITE, as it is in localomap.hinsidedrivers/mmcdirectory.
Quoted 7 lines
Tested on H4, it is able to detect the MMC atleast :) and builds for
innovator_1510, h2 and h3. 24xx custom boards needs to be updated if they are not using powerpin gpio.I am not able to find defconfig for apollon board, so if Kyungmin Park confirms the changes then I can add h4 like setpower function to
board-apollon.cin the next patch. Thanx.
Yeah, let's do some testing before we apply this. One comment below:
Quoted 29 lines
/*
* Turn the socket power on/off. Innovator uses FPGA, most boards
* probably use GPIO.
*/
static voidmmc_omap_power(struct mmc_omap_host *host, int on){drivers/mmc/omap.c +0
-23-if (on) { -if (machine_is_omap_innovator ()) -innovator_fpga_socket_power (1 ); -else if (machine_is_omap_h2 ()) -tps65010_set_gpio_out_value (GPIO3 ,HIGH ); -else if (machine_is_omap_h3 ()) -/* GPIO 4 of TPS65010 sends SD_EN signal */ -tps65010_set_gpio_out_value (GPIO4 ,HIGH ); -else if (cpu_is_omap24xx ()) { -u16 reg =OMAP_MMC_READ (host->base,CON ); -OMAP_MMC_WRITE (host->base,CON , reg | (1 <<11 )); - }else -if (host->power_pin >=0 ) -omap_set_gpio_dataout (host->power_pin,1 ); - }else { -if (machine_is_omap_innovator ()) -innovator_fpga_socket_power (0 ); -else if (machine_is_omap_h2 ()) -tps65010_set_gpio_out_value (GPIO3 ,LOW ); -else if (machine_is_omap_h3 ()) -tps65010_set_gpio_out_value (GPIO4 ,LOW ); -else if (cpu_is_omap24xx ()) { -u16 reg =OMAP_MMC_READ (host->base,CON );
drivers/mmc/omap.c static void mmc_omap_request(struct mmc_ · line 1084
Quoted 10 lines
drivers/mmc/omap.c +4
-5-OMAP_MMC_WRITE (host->base,CON , reg & ~(1 <<11 )); - }else -if (host->power_pin >=0 ) -omap_set_gpio_dataout (host->power_pin,0 ); - } +if (host->set_power) + host->set_power (host->base, on); +else if (host->power_pin >=0 ) +omap_set_gpio_dataout (host->power_pin, on); }
AFAIK nn 24xx the power function is same for all boards as it uses MMC registers. It should be kept in mmc_omap_power().
Tony
drivers/mmc/omap.c struct mmc_omap_host { · line 104
Quoted 7 lines · ext Komal Shah
#include "
omap.h"drivers/mmc/omap.c +1
-0@@ -102,6 +100,7 @@ struct mmc_omap_host {struct work_struct switch_work;struct timer_list switch_timer;int switch_last_state; +void (*set_power)(void __iomem *base,int on); };
Note that just "on" is not enough; some power supplies have support for setting the voltage to several different values.
include/asm-arm/arch-omap/board.h struct omap_mmc_conf { · line 50
Quoted 10 lines
include/asm-arm/arch-omap/board.h +1
-0@@ -46,6 +46,7 @@ struct omap_mmc_conf {s16 power_pin;s16 switch_pin;s16 wp_pin; +void (*set_power)(void __iomem *base,int on); };
You shouldn't use the struct in board.h for this. It is meant for passing data from the bootloader, and passing a kernel function pointer from the bootloader is problematic, to say the least. =)
The proper way to solve this is to introde the concept of a voltage framework, so that we can reference voltages by name instead of a function.
Cheers,
Juha