From f3e31d8ebb25f63d5a566f25ec1bd6c80070f9b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Mon, 27 Feb 2012 14:31:27 +0800 Subject: [PATCH] rk30: add basic support for sdmmc --- arch/arm/mach-rk29/include/mach/board.h | 14 ----- arch/arm/mach-rk30/devices.c | 61 +++++++++++++++++++++ arch/arm/mach-rk30/include/mach/board.h | 2 + arch/arm/mach-rk30/include/mach/dma-pl330.h | 1 + arch/arm/plat-rk/include/plat/board.h | 34 +++++++++--- drivers/mmc/host/Kconfig | 4 +- drivers/mmc/host/rk29_sdmmc.c | 4 +- 7 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 arch/arm/mach-rk30/include/mach/dma-pl330.h diff --git a/arch/arm/mach-rk29/include/mach/board.h b/arch/arm/mach-rk29/include/mach/board.h index c63f3f6dfe1b..71a8a9a4fd74 100755 --- a/arch/arm/mach-rk29/include/mach/board.h +++ b/arch/arm/mach-rk29/include/mach/board.h @@ -97,20 +97,6 @@ struct wifi_platform_data { }; #endif -struct rk29_sdmmc_platform_data { - unsigned int host_caps; - unsigned int host_ocr_avail; - unsigned int use_dma:1; - char dma_name[8]; - int (*io_init)(void); - int (*io_deinit)(void); - void (*set_iomux)(int device_id, unsigned int bus_width);//added by xbw at 2011-10-13 - int (*status)(struct device *); - int (*register_status_notify)(void (*callback)(int card_present, void *dev_id), void *dev_id); - int detect_irq; - int enable_sd_wakeup; - int write_prt; -}; struct rk29_i2c_platform_data { int bus_num; unsigned int flags; diff --git a/arch/arm/mach-rk30/devices.c b/arch/arm/mach-rk30/devices.c index 48431859e9b6..980661efa256 100755 --- a/arch/arm/mach-rk30/devices.c +++ b/arch/arm/mach-rk30/devices.c @@ -801,6 +801,66 @@ static struct platform_device device_keys = { }; #endif +#ifdef CONFIG_SDMMC0_RK29 +static struct resource resources_sdmmc0[] = { + { + .start = IRQ_SDMMC, + .end = IRQ_SDMMC, + .flags = IORESOURCE_IRQ, + }, + { + .start = RK30_SDMMC0_PHYS, + .end = RK30_SDMMC0_PHYS + RK30_SDMMC0_SIZE -1, + .flags = IORESOURCE_MEM, + } +}; + +static struct platform_device device_sdmmc0 = { + .name = "rk29_sdmmc", + .id = 0, + .num_resources = ARRAY_SIZE(resources_sdmmc0), + .resource = resources_sdmmc0, + .dev = { + .platform_data = &default_sdmmc0_data, + }, +}; +#endif + +#ifdef CONFIG_SDMMC1_RK29 +static struct resource resources_sdmmc1[] = { + { + .start = IRQ_SDIO, + .end = IRQ_SDIO, + .flags = IORESOURCE_IRQ, + }, + { + .start = RK30_SDIO_PHYS, + .end = RK30_SDIO_PHYS + RK30_SDIO_SIZE - 1, + .flags = IORESOURCE_MEM, + } +}; + +static struct platform_device device_sdmmc1 = { + .name = "rk29_sdmmc", + .id = 1, + .num_resources = ARRAY_SIZE(resources_sdmmc1), + .resource = resources_sdmmc1, + .dev = { + .platform_data = &default_sdmmc1_data, + }, +}; +#endif + +static void __init rk30_init_sdmmc(void) +{ +#ifdef CONFIG_SDMMC0_RK29 + platform_device_register(&device_sdmmc0); +#endif +#ifdef CONFIG_SDMMC1_RK29 + platform_device_register(&device_sdmmc1); +#endif +} + static int __init rk30_init_devices(void) { rk30_init_dma(); @@ -825,6 +885,7 @@ static int __init rk30_init_devices(void) #ifdef CONFIG_TSADC_RK30 platform_device_register(&device_tsadc); #endif + rk30_init_sdmmc(); return 0; } diff --git a/arch/arm/mach-rk30/include/mach/board.h b/arch/arm/mach-rk30/include/mach/board.h index ac4e3026bfbf..07d71ef0ee1c 100755 --- a/arch/arm/mach-rk30/include/mach/board.h +++ b/arch/arm/mach-rk30/include/mach/board.h @@ -34,6 +34,8 @@ struct mma8452_platform_data { void (*exit_platform_hw)(void); }; +extern struct rk29_sdmmc_platform_data default_sdmmc0_data; +extern struct rk29_sdmmc_platform_data default_sdmmc1_data; void __init rk30_map_common_io(void); void __init rk30_init_irq(void); diff --git a/arch/arm/mach-rk30/include/mach/dma-pl330.h b/arch/arm/mach-rk30/include/mach/dma-pl330.h new file mode 100644 index 000000000000..9afde6529658 --- /dev/null +++ b/arch/arm/mach-rk30/include/mach/dma-pl330.h @@ -0,0 +1 @@ +#include diff --git a/arch/arm/plat-rk/include/plat/board.h b/arch/arm/plat-rk/include/plat/board.h index 7a071c58a622..8c70dd5e0445 100644 --- a/arch/arm/plat-rk/include/plat/board.h +++ b/arch/arm/plat-rk/include/plat/board.h @@ -1,7 +1,9 @@ #ifndef __PLAT_BOARD_H #define __PLAT_BOARD_H + #include #include +#include /*spi*/ struct spi_cs_gpio { @@ -31,15 +33,6 @@ struct rk29_bl_info { unsigned int delay_ms; /* in milliseconds */ }; -#define BOOT_MODE_NORMAL 0 -#define BOOT_MODE_FACTORY2 1 -#define BOOT_MODE_RECOVERY 2 -#define BOOT_MODE_CHARGE 3 -#define BOOT_MODE_POWER_TEST 4 -#define BOOT_MODE_OFFMODE_CHARGING 5 -#define BOOT_MODE_REBOOT 6 -#define BOOT_MODE_PANIC 7 - struct rk29lcd_info { u32 lcd_id; u32 txd_pin; @@ -68,6 +61,29 @@ struct rk29fb_info { int (*io_disable)(void); }; +struct rk29_sdmmc_platform_data { + unsigned int host_caps; + unsigned int host_ocr_avail; + unsigned int use_dma:1; + char dma_name[8]; + int (*io_init)(void); + int (*io_deinit)(void); + void (*set_iomux)(int device_id, unsigned int bus_width);//added by xbw at 2011-10-13 + int (*status)(struct device *); + int (*register_status_notify)(void (*callback)(int card_present, void *dev_id), void *dev_id); + int detect_irq; + int enable_sd_wakeup; + int write_prt; +}; + +#define BOOT_MODE_NORMAL 0 +#define BOOT_MODE_FACTORY2 1 +#define BOOT_MODE_RECOVERY 2 +#define BOOT_MODE_CHARGE 3 +#define BOOT_MODE_POWER_TEST 4 +#define BOOT_MODE_OFFMODE_CHARGING 5 +#define BOOT_MODE_REBOOT 6 +#define BOOT_MODE_PANIC 7 int board_boot_mode(void); /* for USB detection */ diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 919144060c9c..bb2c399c89b9 100755 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -6,7 +6,7 @@ comment "MMC/SD/SDIO Host Controller Drivers" config SDMMC_RK29 tristate "RK29 SDMMC controller suppport" - depends on ARCH_RK29 + depends on PLAT_RK help This selects the RK29 SDMMC controller. SDMMC0 used for sd/mmc card, and SDMMC1 used for sdio. @@ -21,7 +21,6 @@ if SDMMC_RK29 config SDMMC0_RK29 tristate "RK29 SDMMC0 controller support(sdmmc)" default y - depends on ARCH_RK29 help This supports the use of the SDMMC0 controller on Rk29 processors. @@ -45,7 +44,6 @@ if SDMMC_RK29 config SDMMC1_RK29 tristate "RK29 SDMMC1 controller support(sdio)" default y - depends on ARCH_RK29 help This supports the use of the SDMMC1 controller on Rk29 processors. config SDMMC1_RK29_WRITE_PROTECT diff --git a/drivers/mmc/host/rk29_sdmmc.c b/drivers/mmc/host/rk29_sdmmc.c index cd26fc9e85ae..708cc8bbb59c 100755 --- a/drivers/mmc/host/rk29_sdmmc.c +++ b/drivers/mmc/host/rk29_sdmmc.c @@ -40,12 +40,12 @@ #include #include -#include +#include #include #include #include -#include +#include #include #include "rk29_sdmmc.h" -- 2.34.1