diff options
| -rw-r--r-- | arch/arm/mach-msm/Makefile | 2 | ||||
| -rw-r--r-- | arch/arm/mach-msm/board-trout-mmc.c | 189 | ||||
| -rw-r--r-- | arch/arm/mach-msm/board-trout.c | 11 |
3 files changed, 201 insertions, 1 deletions
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile index 7ff8020d4d24..704610648a25 100644 --- a/arch/arm/mach-msm/Makefile +++ b/arch/arm/mach-msm/Makefile | |||
| @@ -15,7 +15,7 @@ obj-$(CONFIG_ARCH_QSD8X50) += sirc.o | |||
| 15 | obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o | 15 | obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o |
| 16 | obj-$(CONFIG_MSM_SMD) += last_radio_log.o | 16 | obj-$(CONFIG_MSM_SMD) += last_radio_log.o |
| 17 | 17 | ||
| 18 | obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o devices-msm7x00.o | 18 | obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o devices-msm7x00.o |
| 19 | obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o | 19 | obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o |
| 20 | obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o | 20 | obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o |
| 21 | obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o | 21 | obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o |
diff --git a/arch/arm/mach-msm/board-trout-mmc.c b/arch/arm/mach-msm/board-trout-mmc.c new file mode 100644 index 000000000000..7a773f8c13dc --- /dev/null +++ b/arch/arm/mach-msm/board-trout-mmc.c | |||
| @@ -0,0 +1,189 @@ | |||
| 1 | /* linux/arch/arm/mach-msm/board-trout-mmc.c | ||
| 2 | ** Author: Brian Swetland <swetland@google.com> | ||
| 3 | */ | ||
| 4 | |||
| 5 | #include <linux/kernel.h> | ||
| 6 | #include <linux/init.h> | ||
| 7 | #include <linux/platform_device.h> | ||
| 8 | #include <linux/delay.h> | ||
| 9 | #include <linux/mmc/host.h> | ||
| 10 | #include <linux/mmc/sdio_ids.h> | ||
| 11 | #include <linux/err.h> | ||
| 12 | #include <linux/debugfs.h> | ||
| 13 | |||
| 14 | #include <asm/gpio.h> | ||
| 15 | #include <asm/io.h> | ||
| 16 | |||
| 17 | #include <mach/vreg.h> | ||
| 18 | |||
| 19 | #include <mach/mmc.h> | ||
| 20 | |||
| 21 | #include "devices.h" | ||
| 22 | |||
| 23 | #include "board-trout.h" | ||
| 24 | |||
| 25 | #include "proc_comm.h" | ||
| 26 | |||
| 27 | #define DEBUG_SDSLOT_VDD 1 | ||
| 28 | |||
| 29 | extern int msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat, | ||
| 30 | unsigned int stat_irq, unsigned long stat_irq_flags); | ||
| 31 | |||
| 32 | /* ---- COMMON ---- */ | ||
| 33 | static void config_gpio_table(uint32_t *table, int len) | ||
| 34 | { | ||
| 35 | int n; | ||
| 36 | unsigned id; | ||
| 37 | for(n = 0; n < len; n++) { | ||
| 38 | id = table[n]; | ||
| 39 | msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0); | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | /* ---- SDCARD ---- */ | ||
| 44 | |||
| 45 | static uint32_t sdcard_on_gpio_table[] = { | ||
| 46 | PCOM_GPIO_CFG(62, 2, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA), /* CLK */ | ||
| 47 | PCOM_GPIO_CFG(63, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), /* CMD */ | ||
| 48 | PCOM_GPIO_CFG(64, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), /* DAT3 */ | ||
| 49 | PCOM_GPIO_CFG(65, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), /* DAT2 */ | ||
| 50 | PCOM_GPIO_CFG(66, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_4MA), /* DAT1 */ | ||
| 51 | PCOM_GPIO_CFG(67, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_4MA), /* DAT0 */ | ||
| 52 | }; | ||
| 53 | |||
| 54 | static uint32_t sdcard_off_gpio_table[] = { | ||
| 55 | PCOM_GPIO_CFG(62, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* CLK */ | ||
| 56 | PCOM_GPIO_CFG(63, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* CMD */ | ||
| 57 | PCOM_GPIO_CFG(64, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* DAT3 */ | ||
| 58 | PCOM_GPIO_CFG(65, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* DAT2 */ | ||
| 59 | PCOM_GPIO_CFG(66, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* DAT1 */ | ||
| 60 | PCOM_GPIO_CFG(67, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* DAT0 */ | ||
| 61 | }; | ||
| 62 | |||
| 63 | static uint opt_disable_sdcard; | ||
| 64 | |||
| 65 | static int __init trout_disablesdcard_setup(char *str) | ||
| 66 | { | ||
| 67 | int cal = simple_strtol(str, NULL, 0); | ||
| 68 | |||
| 69 | opt_disable_sdcard = cal; | ||
| 70 | return 1; | ||
| 71 | } | ||
| 72 | |||
| 73 | __setup("board_trout.disable_sdcard=", trout_disablesdcard_setup); | ||
| 74 | |||
| 75 | static struct vreg *vreg_sdslot; /* SD slot power */ | ||
| 76 | |||
| 77 | struct mmc_vdd_xlat { | ||
| 78 | int mask; | ||
| 79 | int level; | ||
| 80 | }; | ||
| 81 | |||
| 82 | static struct mmc_vdd_xlat mmc_vdd_table[] = { | ||
| 83 | { MMC_VDD_165_195, 1800 }, | ||
| 84 | { MMC_VDD_20_21, 2050 }, | ||
| 85 | { MMC_VDD_21_22, 2150 }, | ||
| 86 | { MMC_VDD_22_23, 2250 }, | ||
| 87 | { MMC_VDD_23_24, 2350 }, | ||
| 88 | { MMC_VDD_24_25, 2450 }, | ||
| 89 | { MMC_VDD_25_26, 2550 }, | ||
| 90 | { MMC_VDD_26_27, 2650 }, | ||
| 91 | { MMC_VDD_27_28, 2750 }, | ||
| 92 | { MMC_VDD_28_29, 2850 }, | ||
| 93 | { MMC_VDD_29_30, 2950 }, | ||
| 94 | }; | ||
| 95 | |||
| 96 | static unsigned int sdslot_vdd = 0xffffffff; | ||
| 97 | static unsigned int sdslot_vreg_enabled; | ||
| 98 | |||
| 99 | static uint32_t trout_sdslot_switchvdd(struct device *dev, unsigned int vdd) | ||
| 100 | { | ||
| 101 | int i, rc; | ||
| 102 | |||
| 103 | BUG_ON(!vreg_sdslot); | ||
| 104 | |||
| 105 | if (vdd == sdslot_vdd) | ||
| 106 | return 0; | ||
| 107 | |||
| 108 | sdslot_vdd = vdd; | ||
| 109 | |||
| 110 | if (vdd == 0) { | ||
| 111 | #if DEBUG_SDSLOT_VDD | ||
| 112 | printk("%s: Disabling SD slot power\n", __func__); | ||
| 113 | #endif | ||
| 114 | config_gpio_table(sdcard_off_gpio_table, | ||
| 115 | ARRAY_SIZE(sdcard_off_gpio_table)); | ||
| 116 | vreg_disable(vreg_sdslot); | ||
| 117 | sdslot_vreg_enabled = 0; | ||
| 118 | return 0; | ||
| 119 | } | ||
| 120 | |||
| 121 | if (!sdslot_vreg_enabled) { | ||
| 122 | rc = vreg_enable(vreg_sdslot); | ||
| 123 | if (rc) { | ||
| 124 | printk(KERN_ERR "%s: Error enabling vreg (%d)\n", | ||
| 125 | __func__, rc); | ||
| 126 | } | ||
| 127 | config_gpio_table(sdcard_on_gpio_table, | ||
| 128 | ARRAY_SIZE(sdcard_on_gpio_table)); | ||
| 129 | sdslot_vreg_enabled = 1; | ||
| 130 | } | ||
| 131 | |||
| 132 | for (i = 0; i < ARRAY_SIZE(mmc_vdd_table); i++) { | ||
| 133 | if (mmc_vdd_table[i].mask == (1 << vdd)) { | ||
| 134 | #if DEBUG_SDSLOT_VDD | ||
| 135 | printk("%s: Setting level to %u\n", | ||
| 136 | __func__, mmc_vdd_table[i].level); | ||
| 137 | #endif | ||
| 138 | rc = vreg_set_level(vreg_sdslot, | ||
| 139 | mmc_vdd_table[i].level); | ||
| 140 | if (rc) { | ||
| 141 | printk(KERN_ERR | ||
| 142 | "%s: Error setting vreg level (%d)\n", | ||
| 143 | __func__, rc); | ||
| 144 | } | ||
| 145 | return 0; | ||
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 149 | printk(KERN_ERR "%s: Invalid VDD %d specified\n", __func__, vdd); | ||
| 150 | return 0; | ||
| 151 | } | ||
| 152 | |||
| 153 | static unsigned int trout_sdslot_status(struct device *dev) | ||
| 154 | { | ||
| 155 | unsigned int status; | ||
| 156 | |||
| 157 | status = (unsigned int) gpio_get_value(TROUT_GPIO_SDMC_CD_N); | ||
| 158 | return (!status); | ||
| 159 | } | ||
| 160 | |||
| 161 | #define TROUT_MMC_VDD MMC_VDD_165_195 | MMC_VDD_20_21 | MMC_VDD_21_22 \ | ||
| 162 | | MMC_VDD_22_23 | MMC_VDD_23_24 | MMC_VDD_24_25 \ | ||
| 163 | | MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 \ | ||
| 164 | | MMC_VDD_28_29 | MMC_VDD_29_30 | ||
| 165 | |||
| 166 | static struct mmc_platform_data trout_sdslot_data = { | ||
| 167 | .ocr_mask = TROUT_MMC_VDD, | ||
| 168 | .status = trout_sdslot_status, | ||
| 169 | .translate_vdd = trout_sdslot_switchvdd, | ||
| 170 | }; | ||
| 171 | |||
| 172 | int __init trout_init_mmc(unsigned int sys_rev) | ||
| 173 | { | ||
| 174 | sdslot_vreg_enabled = 0; | ||
| 175 | |||
| 176 | vreg_sdslot = vreg_get(0, "gp6"); | ||
| 177 | if (IS_ERR(vreg_sdslot)) | ||
| 178 | return PTR_ERR(vreg_sdslot); | ||
| 179 | |||
| 180 | set_irq_wake(TROUT_GPIO_TO_INT(TROUT_GPIO_SDMC_CD_N), 1); | ||
| 181 | |||
| 182 | if (!opt_disable_sdcard) | ||
| 183 | msm_add_sdcc(2, &trout_sdslot_data, | ||
| 184 | TROUT_GPIO_TO_INT(TROUT_GPIO_SDMC_CD_N), 0); | ||
| 185 | else | ||
| 186 | printk(KERN_INFO "trout: SD-Card interface disabled\n"); | ||
| 187 | return 0; | ||
| 188 | } | ||
| 189 | |||
diff --git a/arch/arm/mach-msm/board-trout.c b/arch/arm/mach-msm/board-trout.c index dca5a5f062dc..8f1b28f514d2 100644 --- a/arch/arm/mach-msm/board-trout.c +++ b/arch/arm/mach-msm/board-trout.c | |||
| @@ -30,6 +30,8 @@ | |||
| 30 | #include "devices.h" | 30 | #include "devices.h" |
| 31 | #include "board-trout.h" | 31 | #include "board-trout.h" |
| 32 | 32 | ||
| 33 | extern int trout_init_mmc(unsigned int); | ||
| 34 | |||
| 33 | static struct platform_device *devices[] __initdata = { | 35 | static struct platform_device *devices[] __initdata = { |
| 34 | &msm_device_uart3, | 36 | &msm_device_uart3, |
| 35 | &msm_device_smd, | 37 | &msm_device_smd, |
| @@ -56,7 +58,16 @@ static void __init trout_fixup(struct machine_desc *desc, struct tag *tags, | |||
| 56 | 58 | ||
| 57 | static void __init trout_init(void) | 59 | static void __init trout_init(void) |
| 58 | { | 60 | { |
| 61 | int rc; | ||
| 62 | |||
| 59 | platform_add_devices(devices, ARRAY_SIZE(devices)); | 63 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 64 | |||
| 65 | #ifdef CONFIG_MMC | ||
| 66 | rc = trout_init_mmc(system_rev); | ||
| 67 | if (rc) | ||
| 68 | printk(KERN_CRIT "%s: MMC init failure (%d)\n", __func__, rc); | ||
| 69 | #endif | ||
| 70 | |||
| 60 | } | 71 | } |
| 61 | 72 | ||
| 62 | static struct map_desc trout_io_desc[] __initdata = { | 73 | static struct map_desc trout_io_desc[] __initdata = { |
