Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6:
mfd: Unlock mc13783 before subsystems initialisation, at probe time.
mfd: WM835x GPIO direction register is not locked
mfd: tmio_mmc hardware abstraction for CNF area
mfd: WM8350 off by one bug
mfd: Correct WM835x ISINK ramp time defines

+343 -170
+3 -3
drivers/mfd/Makefile
··· 11 11 12 12 obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o 13 13 14 - obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o 15 - obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o 16 - obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o 14 + obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o 15 + obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o tmio_core.o 16 + obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o tmio_core.o 17 17 18 18 obj-$(CONFIG_MFD_WM8400) += wm8400-core.o 19 19 wm831x-objs := wm831x-core.o wm831x-irq.o wm831x-otp.o
+32 -8
drivers/mfd/asic3.c
··· 80 80 u16 irq_bothedge[4]; 81 81 struct gpio_chip gpio; 82 82 struct device *dev; 83 + void __iomem *tmio_cnf; 83 84 84 85 struct asic3_clk clocks[ARRAY_SIZE(asic3_clk_init)]; 85 86 }; ··· 686 685 .resources = ds1wm_resources, 687 686 }; 688 687 688 + static void asic3_mmc_pwr(struct platform_device *pdev, int state) 689 + { 690 + struct asic3 *asic = dev_get_drvdata(pdev->dev.parent); 691 + 692 + tmio_core_mmc_pwr(asic->tmio_cnf, 1 - asic->bus_shift, state); 693 + } 694 + 695 + static void asic3_mmc_clk_div(struct platform_device *pdev, int state) 696 + { 697 + struct asic3 *asic = dev_get_drvdata(pdev->dev.parent); 698 + 699 + tmio_core_mmc_clk_div(asic->tmio_cnf, 1 - asic->bus_shift, state); 700 + } 701 + 689 702 static struct tmio_mmc_data asic3_mmc_data = { 690 - .hclk = 24576000, 703 + .hclk = 24576000, 704 + .set_pwr = asic3_mmc_pwr, 705 + .set_clk_div = asic3_mmc_clk_div, 691 706 }; 692 707 693 708 static struct resource asic3_mmc_resources[] = { 694 709 { 695 710 .start = ASIC3_SD_CTRL_BASE, 696 711 .end = ASIC3_SD_CTRL_BASE + 0x3ff, 697 - .flags = IORESOURCE_MEM, 698 - }, 699 - { 700 - .start = ASIC3_SD_CONFIG_BASE, 701 - .end = ASIC3_SD_CONFIG_BASE + 0x1ff, 702 712 .flags = IORESOURCE_MEM, 703 713 }, 704 714 { ··· 754 742 /* Enable SD card slot 3.3V power supply */ 755 743 asic3_set_register(asic, ASIC3_OFFSET(SDHWCTRL, SDCONF), 756 744 ASIC3_SDHWCTRL_SDPWR, 1); 745 + 746 + /* ASIC3_SD_CTRL_BASE assumes 32-bit addressing, TMIO is 16-bit */ 747 + tmio_core_mmc_enable(asic->tmio_cnf, 1 - asic->bus_shift, 748 + ASIC3_SD_CTRL_BASE >> 1); 757 749 758 750 return 0; 759 751 } ··· 813 797 asic3_cell_ds1wm.data_size = sizeof(asic3_cell_ds1wm); 814 798 815 799 /* MMC */ 800 + asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) + 801 + mem_sdio->start, 0x400 >> asic->bus_shift); 802 + if (!asic->tmio_cnf) { 803 + ret = -ENOMEM; 804 + dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n"); 805 + goto out; 806 + } 816 807 asic3_mmc_resources[0].start >>= asic->bus_shift; 817 808 asic3_mmc_resources[0].end >>= asic->bus_shift; 818 - asic3_mmc_resources[1].start >>= asic->bus_shift; 819 - asic3_mmc_resources[1].end >>= asic->bus_shift; 820 809 821 810 asic3_cell_mmc.platform_data = &asic3_cell_mmc; 822 811 asic3_cell_mmc.data_size = sizeof(asic3_cell_mmc); ··· 841 820 842 821 static void asic3_mfd_remove(struct platform_device *pdev) 843 822 { 823 + struct asic3 *asic = platform_get_drvdata(pdev); 824 + 844 825 mfd_remove_devices(&pdev->dev); 826 + iounmap(asic->tmio_cnf); 845 827 } 846 828 847 829 /* Core */
+2 -2
drivers/mfd/mc13783-core.c
··· 619 619 } 620 620 /* This should go away (END) */ 621 621 622 + mc13783_unlock(mc13783); 623 + 622 624 if (pdata->flags & MC13783_USE_ADC) 623 625 mc13783_add_subdevice(mc13783, "mc13783-adc"); 624 626 ··· 642 640 643 641 if (pdata->flags & MC13783_USE_TOUCHSCREEN) 644 642 mc13783_add_subdevice(mc13783, "mc13783-ts"); 645 - 646 - mc13783_unlock(mc13783); 647 643 648 644 return 0; 649 645 }
+37 -18
drivers/mfd/t7l66xb.c
··· 38 38 T7L66XB_CELL_MMC, 39 39 }; 40 40 41 + static const struct resource t7l66xb_mmc_resources[] = { 42 + { 43 + .start = 0x800, 44 + .end = 0x9ff, 45 + .flags = IORESOURCE_MEM, 46 + }, 47 + { 48 + .start = IRQ_T7L66XB_MMC, 49 + .end = IRQ_T7L66XB_MMC, 50 + .flags = IORESOURCE_IRQ, 51 + }, 52 + }; 53 + 41 54 #define SCR_REVID 0x08 /* b Revision ID */ 42 55 #define SCR_IMR 0x42 /* b Interrupt Mask */ 43 56 #define SCR_DEV_CTL 0xe0 /* b Device control */ ··· 96 83 97 84 spin_unlock_irqrestore(&t7l66xb->lock, flags); 98 85 86 + tmio_core_mmc_enable(t7l66xb->scr + 0x200, 0, 87 + t7l66xb_mmc_resources[0].start & 0xfffe); 88 + 99 89 return 0; 100 90 } 101 91 ··· 122 106 return 0; 123 107 } 124 108 109 + static void t7l66xb_mmc_pwr(struct platform_device *mmc, int state) 110 + { 111 + struct platform_device *dev = to_platform_device(mmc->dev.parent); 112 + struct t7l66xb *t7l66xb = platform_get_drvdata(dev); 113 + 114 + tmio_core_mmc_pwr(t7l66xb->scr + 0x200, 0, state); 115 + } 116 + 117 + static void t7l66xb_mmc_clk_div(struct platform_device *mmc, int state) 118 + { 119 + struct platform_device *dev = to_platform_device(mmc->dev.parent); 120 + struct t7l66xb *t7l66xb = platform_get_drvdata(dev); 121 + 122 + tmio_core_mmc_clk_div(t7l66xb->scr + 0x200, 0, state); 123 + } 124 + 125 125 /*--------------------------------------------------------------------------*/ 126 126 127 127 static struct tmio_mmc_data t7166xb_mmc_data = { 128 128 .hclk = 24000000, 129 - }; 130 - 131 - static const struct resource t7l66xb_mmc_resources[] = { 132 - { 133 - .start = 0x800, 134 - .end = 0x9ff, 135 - .flags = IORESOURCE_MEM, 136 - }, 137 - { 138 - .start = 0x200, 139 - .end = 0x2ff, 140 - .flags = IORESOURCE_MEM, 141 - }, 142 - { 143 - .start = IRQ_T7L66XB_MMC, 144 - .end = IRQ_T7L66XB_MMC, 145 - .flags = IORESOURCE_IRQ, 146 - }, 129 + .set_pwr = t7l66xb_mmc_pwr, 130 + .set_clk_div = t7l66xb_mmc_clk_div, 147 131 }; 148 132 149 133 static const struct resource t7l66xb_nand_resources[] = { ··· 297 281 clk_enable(t7l66xb->clk48m); 298 282 if (pdata && pdata->resume) 299 283 pdata->resume(dev); 284 + 285 + tmio_core_mmc_enable(t7l66xb->scr + 0x200, 0, 286 + t7l66xb_mmc_resources[0].start & 0xfffe); 300 287 301 288 return 0; 302 289 }
+89 -32
drivers/mfd/tc6387xb.c
··· 22 22 TC6387XB_CELL_MMC, 23 23 }; 24 24 25 + struct tc6387xb { 26 + void __iomem *scr; 27 + struct clk *clk32k; 28 + struct resource rscr; 29 + }; 30 + 31 + static struct resource tc6387xb_mmc_resources[] = { 32 + { 33 + .start = 0x800, 34 + .end = 0x9ff, 35 + .flags = IORESOURCE_MEM, 36 + }, 37 + { 38 + .start = 0, 39 + .end = 0, 40 + .flags = IORESOURCE_IRQ, 41 + }, 42 + }; 43 + 44 + /*--------------------------------------------------------------------------*/ 45 + 25 46 #ifdef CONFIG_PM 26 47 static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) 27 48 { 28 - struct clk *clk32k = platform_get_drvdata(dev); 49 + struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 29 50 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 30 51 31 52 if (pdata && pdata->suspend) 32 53 pdata->suspend(dev); 33 - clk_disable(clk32k); 54 + clk_disable(tc6387xb->clk32k); 34 55 35 56 return 0; 36 57 } 37 58 38 59 static int tc6387xb_resume(struct platform_device *dev) 39 60 { 40 - struct clk *clk32k = platform_get_drvdata(dev); 61 + struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 41 62 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 42 63 43 - clk_enable(clk32k); 64 + clk_enable(tc6387xb->clk32k); 44 65 if (pdata && pdata->resume) 45 66 pdata->resume(dev); 67 + 68 + tmio_core_mmc_resume(tc6387xb->scr + 0x200, 0, 69 + tc6387xb_mmc_resources[0].start & 0xfffe); 46 70 47 71 return 0; 48 72 } ··· 77 53 78 54 /*--------------------------------------------------------------------------*/ 79 55 56 + static void tc6387xb_mmc_pwr(struct platform_device *mmc, int state) 57 + { 58 + struct platform_device *dev = to_platform_device(mmc->dev.parent); 59 + struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 60 + 61 + tmio_core_mmc_pwr(tc6387xb->scr + 0x200, 0, state); 62 + } 63 + 64 + static void tc6387xb_mmc_clk_div(struct platform_device *mmc, int state) 65 + { 66 + struct platform_device *dev = to_platform_device(mmc->dev.parent); 67 + struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 68 + 69 + tmio_core_mmc_clk_div(tc6387xb->scr + 0x200, 0, state); 70 + } 71 + 72 + 80 73 static int tc6387xb_mmc_enable(struct platform_device *mmc) 81 74 { 82 75 struct platform_device *dev = to_platform_device(mmc->dev.parent); 83 - struct clk *clk32k = platform_get_drvdata(dev); 76 + struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 84 77 85 - clk_enable(clk32k); 78 + clk_enable(tc6387xb->clk32k); 79 + 80 + tmio_core_mmc_enable(tc6387xb->scr + 0x200, 0, 81 + tc6387xb_mmc_resources[0].start & 0xfffe); 86 82 87 83 return 0; 88 84 } ··· 110 66 static int tc6387xb_mmc_disable(struct platform_device *mmc) 111 67 { 112 68 struct platform_device *dev = to_platform_device(mmc->dev.parent); 113 - struct clk *clk32k = platform_get_drvdata(dev); 69 + struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 114 70 115 - clk_disable(clk32k); 71 + clk_disable(tc6387xb->clk32k); 116 72 117 73 return 0; 118 74 } 119 75 120 - /*--------------------------------------------------------------------------*/ 121 - 122 76 static struct tmio_mmc_data tc6387xb_mmc_data = { 123 77 .hclk = 24000000, 78 + .set_pwr = tc6387xb_mmc_pwr, 79 + .set_clk_div = tc6387xb_mmc_clk_div, 124 80 }; 125 81 126 - static struct resource tc6387xb_mmc_resources[] = { 127 - { 128 - .start = 0x800, 129 - .end = 0x9ff, 130 - .flags = IORESOURCE_MEM, 131 - }, 132 - { 133 - .start = 0x200, 134 - .end = 0x2ff, 135 - .flags = IORESOURCE_MEM, 136 - }, 137 - { 138 - .start = 0, 139 - .end = 0, 140 - .flags = IORESOURCE_IRQ, 141 - }, 142 - }; 82 + /*--------------------------------------------------------------------------*/ 143 83 144 84 static struct mfd_cell tc6387xb_cells[] = { 145 85 [TC6387XB_CELL_MMC] = { ··· 139 111 static int tc6387xb_probe(struct platform_device *dev) 140 112 { 141 113 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 142 - struct resource *iomem; 114 + struct resource *iomem, *rscr; 143 115 struct clk *clk32k; 116 + struct tc6387xb *tc6387xb; 144 117 int irq, ret; 145 118 146 119 iomem = platform_get_resource(dev, IORESOURCE_MEM, 0); ··· 149 120 return -EINVAL; 150 121 } 151 122 123 + tc6387xb = kzalloc(sizeof *tc6387xb, GFP_KERNEL); 124 + if (!tc6387xb) 125 + return -ENOMEM; 126 + 152 127 ret = platform_get_irq(dev, 0); 153 128 if (ret >= 0) 154 129 irq = ret; 155 130 else 156 - goto err_resource; 131 + goto err_no_irq; 157 132 158 133 clk32k = clk_get(&dev->dev, "CLK_CK32K"); 159 134 if (IS_ERR(clk32k)) { 160 135 ret = PTR_ERR(clk32k); 161 - goto err_resource; 136 + goto err_no_clk; 162 137 } 163 - platform_set_drvdata(dev, clk32k); 138 + 139 + rscr = &tc6387xb->rscr; 140 + rscr->name = "tc6387xb-core"; 141 + rscr->start = iomem->start; 142 + rscr->end = iomem->start + 0xff; 143 + rscr->flags = IORESOURCE_MEM; 144 + 145 + ret = request_resource(iomem, rscr); 146 + if (ret) 147 + goto err_resource; 148 + 149 + tc6387xb->scr = ioremap(rscr->start, rscr->end - rscr->start + 1); 150 + if (!tc6387xb->scr) { 151 + ret = -ENOMEM; 152 + goto err_ioremap; 153 + } 154 + 155 + tc6387xb->clk32k = clk32k; 156 + platform_set_drvdata(dev, tc6387xb); 164 157 165 158 if (pdata && pdata->enable) 166 159 pdata->enable(dev); ··· 200 149 if (!ret) 201 150 return 0; 202 151 203 - clk_put(clk32k); 152 + err_ioremap: 153 + release_resource(&tc6387xb->rscr); 204 154 err_resource: 155 + clk_put(clk32k); 156 + err_no_clk: 157 + err_no_irq: 158 + kfree(tc6387xb); 205 159 return ret; 206 160 } 207 161 ··· 251 195 MODULE_LICENSE("GPL v2"); 252 196 MODULE_AUTHOR("Ian Molton"); 253 197 MODULE_ALIAS("platform:tc6387xb"); 198 +
+47 -9
drivers/mfd/tc6393xb.c
··· 136 136 return 0; 137 137 } 138 138 139 - static struct tmio_mmc_data tc6393xb_mmc_data = { 140 - .hclk = 24000000, 141 - }; 142 - 143 139 static struct resource __devinitdata tc6393xb_nand_resources[] = { 144 140 { 145 141 .start = 0x1000, ··· 158 162 { 159 163 .start = 0x800, 160 164 .end = 0x9ff, 161 - .flags = IORESOURCE_MEM, 162 - }, 163 - { 164 - .start = 0x200, 165 - .end = 0x2ff, 166 165 .flags = IORESOURCE_MEM, 167 166 }, 168 167 { ··· 337 346 } 338 347 EXPORT_SYMBOL(tc6393xb_lcd_mode); 339 348 349 + static int tc6393xb_mmc_enable(struct platform_device *mmc) 350 + { 351 + struct platform_device *dev = to_platform_device(mmc->dev.parent); 352 + struct tc6393xb *tc6393xb = platform_get_drvdata(dev); 353 + 354 + tmio_core_mmc_enable(tc6393xb->scr + 0x200, 0, 355 + tc6393xb_mmc_resources[0].start & 0xfffe); 356 + 357 + return 0; 358 + } 359 + 360 + static int tc6393xb_mmc_resume(struct platform_device *mmc) 361 + { 362 + struct platform_device *dev = to_platform_device(mmc->dev.parent); 363 + struct tc6393xb *tc6393xb = platform_get_drvdata(dev); 364 + 365 + tmio_core_mmc_resume(tc6393xb->scr + 0x200, 0, 366 + tc6393xb_mmc_resources[0].start & 0xfffe); 367 + 368 + return 0; 369 + } 370 + 371 + static void tc6393xb_mmc_pwr(struct platform_device *mmc, int state) 372 + { 373 + struct platform_device *dev = to_platform_device(mmc->dev.parent); 374 + struct tc6393xb *tc6393xb = platform_get_drvdata(dev); 375 + 376 + tmio_core_mmc_pwr(tc6393xb->scr + 0x200, 0, state); 377 + } 378 + 379 + static void tc6393xb_mmc_clk_div(struct platform_device *mmc, int state) 380 + { 381 + struct platform_device *dev = to_platform_device(mmc->dev.parent); 382 + struct tc6393xb *tc6393xb = platform_get_drvdata(dev); 383 + 384 + tmio_core_mmc_clk_div(tc6393xb->scr + 0x200, 0, state); 385 + } 386 + 387 + static struct tmio_mmc_data tc6393xb_mmc_data = { 388 + .hclk = 24000000, 389 + .set_pwr = tc6393xb_mmc_pwr, 390 + .set_clk_div = tc6393xb_mmc_clk_div, 391 + }; 392 + 340 393 static struct mfd_cell __devinitdata tc6393xb_cells[] = { 341 394 [TC6393XB_CELL_NAND] = { 342 395 .name = "tmio-nand", ··· 390 355 }, 391 356 [TC6393XB_CELL_MMC] = { 392 357 .name = "tmio-mmc", 358 + .enable = tc6393xb_mmc_enable, 359 + .resume = tc6393xb_mmc_resume, 393 360 .driver_data = &tc6393xb_mmc_data, 394 361 .num_resources = ARRAY_SIZE(tc6393xb_mmc_resources), 395 362 .resources = tc6393xb_mmc_resources, ··· 873 836 MODULE_AUTHOR("Ian Molton, Dmitry Baryshkov and Dirk Opfer"); 874 837 MODULE_DESCRIPTION("tc6393xb Toshiba Mobile IO Controller"); 875 838 MODULE_ALIAS("platform:tc6393xb"); 839 +
+52
drivers/mfd/tmio_core.c
··· 1 + /* 2 + * Copyright(c) 2009 Ian Molton <spyro@f2s.com> 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License version 2 as 6 + * published by the Free Software Foundation. 7 + */ 8 + 9 + #include <linux/mfd/tmio.h> 10 + 11 + int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base) 12 + { 13 + /* Enable the MMC/SD Control registers */ 14 + sd_config_write16(cnf, shift, CNF_CMD, SDCREN); 15 + sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe); 16 + 17 + /* Disable SD power during suspend */ 18 + sd_config_write8(cnf, shift, CNF_PWR_CTL_3, 0x01); 19 + 20 + /* The below is required but why? FIXME */ 21 + sd_config_write8(cnf, shift, CNF_STOP_CLK_CTL, 0x1f); 22 + 23 + /* Power down SD bus */ 24 + sd_config_write8(cnf, shift, CNF_PWR_CTL_2, 0x00); 25 + 26 + return 0; 27 + } 28 + EXPORT_SYMBOL(tmio_core_mmc_enable); 29 + 30 + int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base) 31 + { 32 + 33 + /* Enable the MMC/SD Control registers */ 34 + sd_config_write16(cnf, shift, CNF_CMD, SDCREN); 35 + sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe); 36 + 37 + return 0; 38 + } 39 + EXPORT_SYMBOL(tmio_core_mmc_resume); 40 + 41 + void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state) 42 + { 43 + sd_config_write8(cnf, shift, CNF_PWR_CTL_2, state ? 0x02 : 0x00); 44 + } 45 + EXPORT_SYMBOL(tmio_core_mmc_pwr); 46 + 47 + void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state) 48 + { 49 + sd_config_write8(cnf, shift, CNF_SD_CLK_MODE, state ? 1 : 0); 50 + } 51 + EXPORT_SYMBOL(tmio_core_mmc_clk_div); 52 +
+1 -2
drivers/mfd/wm8350-core.c
··· 134 134 wm8350->reg_cache[WM8350_SECURITY] == WM8350_UNLOCK_KEY) 135 135 return 0; 136 136 137 - if ((reg == WM8350_GPIO_CONFIGURATION_I_O) || 138 - (reg >= WM8350_GPIO_FUNCTION_SELECT_1 && 137 + if ((reg >= WM8350_GPIO_FUNCTION_SELECT_1 && 139 138 reg <= WM8350_GPIO_FUNCTION_SELECT_4) || 140 139 (reg >= WM8350_BATTERY_CHARGER_CONTROL_1 && 141 140 reg <= WM8350_BATTERY_CHARGER_CONTROL_3))
+2 -2
drivers/mfd/wm8350-irq.c
··· 434 434 irq_handler_t handler, unsigned long flags, 435 435 const char *name, void *data) 436 436 { 437 - if (irq < 0 || irq > WM8350_NUM_IRQ || !handler) 437 + if (irq < 0 || irq >= WM8350_NUM_IRQ || !handler) 438 438 return -EINVAL; 439 439 440 440 if (wm8350->irq[irq].handler) ··· 453 453 454 454 int wm8350_free_irq(struct wm8350 *wm8350, int irq) 455 455 { 456 - if (irq < 0 || irq > WM8350_NUM_IRQ) 456 + if (irq < 0 || irq >= WM8350_NUM_IRQ) 457 457 return -EINVAL; 458 458 459 459 wm8350_mask_irq(wm8350, irq);
+19 -40
drivers/mmc/host/tmio_mmc.c
··· 46 46 clk |= 0x100; 47 47 } 48 48 49 - sd_config_write8(host, CNF_SD_CLK_MODE, clk >> 22); 49 + if (host->set_clk_div) 50 + host->set_clk_div(host->pdev, (clk>>22) & 1); 51 + 50 52 sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk & 0x1ff); 51 53 } 52 54 ··· 429 427 /* Power sequence - OFF -> ON -> UP */ 430 428 switch (ios->power_mode) { 431 429 case MMC_POWER_OFF: /* power down SD bus */ 432 - sd_config_write8(host, CNF_PWR_CTL_2, 0x00); 430 + if (host->set_pwr) 431 + host->set_pwr(host->pdev, 0); 433 432 tmio_mmc_clk_stop(host); 434 433 break; 435 434 case MMC_POWER_ON: /* power up SD bus */ 436 - 437 - sd_config_write8(host, CNF_PWR_CTL_2, 0x02); 435 + if (host->set_pwr) 436 + host->set_pwr(host->pdev, 1); 438 437 break; 439 438 case MMC_POWER_UP: /* start bus clock */ 440 439 tmio_mmc_clk_start(host); ··· 488 485 { 489 486 struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; 490 487 struct mmc_host *mmc = platform_get_drvdata(dev); 491 - struct tmio_mmc_host *host = mmc_priv(mmc); 492 488 int ret = 0; 493 489 494 490 /* Tell the MFD core we are ready to be enabled */ 495 - if (cell->enable) { 496 - ret = cell->enable(dev); 491 + if (cell->resume) { 492 + ret = cell->resume(dev); 497 493 if (ret) 498 494 goto out; 499 495 } 500 - 501 - /* Enable the MMC/SD Control registers */ 502 - sd_config_write16(host, CNF_CMD, SDCREN); 503 - sd_config_write32(host, CNF_CTL_BASE, 504 - (dev->resource[0].start >> host->bus_shift) & 0xfffe); 505 496 506 497 mmc_resume_host(mmc); 507 498 ··· 511 514 { 512 515 struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; 513 516 struct tmio_mmc_data *pdata; 514 - struct resource *res_ctl, *res_cnf; 517 + struct resource *res_ctl; 515 518 struct tmio_mmc_host *host; 516 519 struct mmc_host *mmc; 517 520 int ret = -EINVAL; 518 521 519 - if (dev->num_resources != 3) 522 + if (dev->num_resources != 2) 520 523 goto out; 521 524 522 525 res_ctl = platform_get_resource(dev, IORESOURCE_MEM, 0); 523 - res_cnf = platform_get_resource(dev, IORESOURCE_MEM, 1); 524 - if (!res_ctl || !res_cnf) 526 + if (!res_ctl) 525 527 goto out; 526 528 527 529 pdata = cell->driver_data; ··· 535 539 536 540 host = mmc_priv(mmc); 537 541 host->mmc = mmc; 542 + host->pdev = dev; 538 543 platform_set_drvdata(dev, mmc); 544 + 545 + host->set_pwr = pdata->set_pwr; 546 + host->set_clk_div = pdata->set_clk_div; 539 547 540 548 /* SD control register space size is 0x200, 0x400 for bus_shift=1 */ 541 549 host->bus_shift = resource_size(res_ctl) >> 10; ··· 547 547 host->ctl = ioremap(res_ctl->start, resource_size(res_ctl)); 548 548 if (!host->ctl) 549 549 goto host_free; 550 - 551 - host->cnf = ioremap(res_cnf->start, resource_size(res_cnf)); 552 - if (!host->cnf) 553 - goto unmap_ctl; 554 550 555 551 mmc->ops = &tmio_mmc_ops; 556 552 mmc->caps = MMC_CAP_4_BIT_DATA; ··· 558 562 if (cell->enable) { 559 563 ret = cell->enable(dev); 560 564 if (ret) 561 - goto unmap_cnf; 565 + goto unmap_ctl; 562 566 } 563 - 564 - /* Enable the MMC/SD Control registers */ 565 - sd_config_write16(host, CNF_CMD, SDCREN); 566 - sd_config_write32(host, CNF_CTL_BASE, 567 - (dev->resource[0].start >> host->bus_shift) & 0xfffe); 568 - 569 - /* Disable SD power during suspend */ 570 - sd_config_write8(host, CNF_PWR_CTL_3, 0x01); 571 - 572 - /* The below is required but why? FIXME */ 573 - sd_config_write8(host, CNF_STOP_CLK_CTL, 0x1f); 574 - 575 - /* Power down SD bus*/ 576 - sd_config_write8(host, CNF_PWR_CTL_2, 0x00); 577 567 578 568 tmio_mmc_clk_stop(host); 579 569 reset(host); ··· 568 586 if (ret >= 0) 569 587 host->irq = ret; 570 588 else 571 - goto unmap_cnf; 589 + goto unmap_ctl; 572 590 573 591 disable_mmc_irqs(host, TMIO_MASK_ALL); 574 592 575 593 ret = request_irq(host->irq, tmio_mmc_irq, IRQF_DISABLED | 576 594 IRQF_TRIGGER_FALLING, dev_name(&dev->dev), host); 577 595 if (ret) 578 - goto unmap_cnf; 596 + goto unmap_ctl; 579 597 580 598 mmc_add_host(mmc); 581 599 ··· 587 605 588 606 return 0; 589 607 590 - unmap_cnf: 591 - iounmap(host->cnf); 592 608 unmap_ctl: 593 609 iounmap(host->ctl); 594 610 host_free: ··· 606 626 mmc_remove_host(mmc); 607 627 free_irq(host->irq, host); 608 628 iounmap(host->ctl); 609 - iounmap(host->cnf); 610 629 mmc_free_host(mmc); 611 630 } 612 631
+6 -40
drivers/mmc/host/tmio_mmc.h
··· 11 11 12 12 #include <linux/highmem.h> 13 13 14 - #define CNF_CMD 0x04 15 - #define CNF_CTL_BASE 0x10 16 - #define CNF_INT_PIN 0x3d 17 - #define CNF_STOP_CLK_CTL 0x40 18 - #define CNF_GCLK_CTL 0x41 19 - #define CNF_SD_CLK_MODE 0x42 20 - #define CNF_PIN_STATUS 0x44 21 - #define CNF_PWR_CTL_1 0x48 22 - #define CNF_PWR_CTL_2 0x49 23 - #define CNF_PWR_CTL_3 0x4a 24 - #define CNF_CARD_DETECT_MODE 0x4c 25 - #define CNF_SD_SLOT 0x50 26 - #define CNF_EXT_GCLK_CTL_1 0xf0 27 - #define CNF_EXT_GCLK_CTL_2 0xf1 28 - #define CNF_EXT_GCLK_CTL_3 0xf9 29 - #define CNF_SD_LED_EN_1 0xfa 30 - #define CNF_SD_LED_EN_2 0xfe 31 - 32 - #define SDCREN 0x2 /* Enable access to MMC CTL regs. (flag in COMMAND_REG)*/ 33 - 34 14 #define CTL_SD_CMD 0x00 35 15 #define CTL_ARG_REG 0x04 36 16 #define CTL_STOP_INTERNAL_ACTION 0x08 ··· 90 110 91 111 92 112 struct tmio_mmc_host { 93 - void __iomem *cnf; 94 113 void __iomem *ctl; 95 114 unsigned long bus_shift; 96 115 struct mmc_command *cmd; ··· 98 119 struct mmc_host *mmc; 99 120 int irq; 100 121 122 + /* Callbacks for clock / power control */ 123 + void (*set_pwr)(struct platform_device *host, int state); 124 + void (*set_clk_div)(struct platform_device *host, int state); 125 + 101 126 /* pio related stuff */ 102 127 struct scatterlist *sg_ptr; 103 128 unsigned int sg_len; 104 129 unsigned int sg_off; 130 + 131 + struct platform_device *pdev; 105 132 }; 106 133 107 134 #include <linux/io.h> ··· 146 161 { 147 162 writew(val, host->ctl + (addr << host->bus_shift)); 148 163 writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift)); 149 - } 150 - 151 - static inline void sd_config_write8(struct tmio_mmc_host *host, int addr, 152 - u8 val) 153 - { 154 - writeb(val, host->cnf + (addr << host->bus_shift)); 155 - } 156 - 157 - static inline void sd_config_write16(struct tmio_mmc_host *host, int addr, 158 - u16 val) 159 - { 160 - writew(val, host->cnf + (addr << host->bus_shift)); 161 - } 162 - 163 - static inline void sd_config_write32(struct tmio_mmc_host *host, int addr, 164 - u32 val) 165 - { 166 - writew(val, host->cnf + (addr << host->bus_shift)); 167 - writew(val >> 16, host->cnf + ((addr + 2) << host->bus_shift)); 168 164 } 169 165 170 166 #include <linux/scatterlist.h>
+39
include/linux/mfd/tmio.h
··· 2 2 #define MFD_TMIO_H 3 3 4 4 #include <linux/fb.h> 5 + #include <linux/io.h> 6 + #include <linux/platform_device.h> 5 7 6 8 #define tmio_ioread8(addr) readb(addr) 7 9 #define tmio_ioread16(addr) readw(addr) ··· 20 18 writew((val) >> 16, (addr) + 2); \ 21 19 } while (0) 22 20 21 + #define CNF_CMD 0x04 22 + #define CNF_CTL_BASE 0x10 23 + #define CNF_INT_PIN 0x3d 24 + #define CNF_STOP_CLK_CTL 0x40 25 + #define CNF_GCLK_CTL 0x41 26 + #define CNF_SD_CLK_MODE 0x42 27 + #define CNF_PIN_STATUS 0x44 28 + #define CNF_PWR_CTL_1 0x48 29 + #define CNF_PWR_CTL_2 0x49 30 + #define CNF_PWR_CTL_3 0x4a 31 + #define CNF_CARD_DETECT_MODE 0x4c 32 + #define CNF_SD_SLOT 0x50 33 + #define CNF_EXT_GCLK_CTL_1 0xf0 34 + #define CNF_EXT_GCLK_CTL_2 0xf1 35 + #define CNF_EXT_GCLK_CTL_3 0xf9 36 + #define CNF_SD_LED_EN_1 0xfa 37 + #define CNF_SD_LED_EN_2 0xfe 38 + 39 + #define SDCREN 0x2 /* Enable access to MMC CTL regs. (flag in COMMAND_REG)*/ 40 + 41 + #define sd_config_write8(base, shift, reg, val) \ 42 + tmio_iowrite8((val), (base) + ((reg) << (shift))) 43 + #define sd_config_write16(base, shift, reg, val) \ 44 + tmio_iowrite16((val), (base) + ((reg) << (shift))) 45 + #define sd_config_write32(base, shift, reg, val) \ 46 + do { \ 47 + tmio_iowrite16((val), (base) + ((reg) << (shift))); \ 48 + tmio_iowrite16((val) >> 16, (base) + ((reg + 2) << (shift))); \ 49 + } while (0) 50 + 51 + int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base); 52 + int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base); 53 + void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state); 54 + void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state); 55 + 23 56 /* 24 57 * data for the MMC controller 25 58 */ 26 59 struct tmio_mmc_data { 27 60 const unsigned int hclk; 61 + void (*set_pwr)(struct platform_device *host, int state); 62 + void (*set_clk_div)(struct platform_device *host, int state); 28 63 }; 29 64 30 65 /*
+14 -14
include/linux/mfd/wm8350/pmic.h
··· 666 666 #define WM8350_ISINK_FLASH_DUR_64MS (1 << 8) 667 667 #define WM8350_ISINK_FLASH_DUR_96MS (2 << 8) 668 668 #define WM8350_ISINK_FLASH_DUR_1024MS (3 << 8) 669 - #define WM8350_ISINK_FLASH_ON_INSTANT (0 << 4) 670 - #define WM8350_ISINK_FLASH_ON_0_25S (1 << 4) 671 - #define WM8350_ISINK_FLASH_ON_0_50S (2 << 4) 672 - #define WM8350_ISINK_FLASH_ON_1_00S (3 << 4) 673 - #define WM8350_ISINK_FLASH_ON_1_95S (1 << 4) 674 - #define WM8350_ISINK_FLASH_ON_3_91S (2 << 4) 675 - #define WM8350_ISINK_FLASH_ON_7_80S (3 << 4) 676 - #define WM8350_ISINK_FLASH_OFF_INSTANT (0 << 0) 677 - #define WM8350_ISINK_FLASH_OFF_0_25S (1 << 0) 678 - #define WM8350_ISINK_FLASH_OFF_0_50S (2 << 0) 679 - #define WM8350_ISINK_FLASH_OFF_1_00S (3 << 0) 680 - #define WM8350_ISINK_FLASH_OFF_1_95S (1 << 0) 681 - #define WM8350_ISINK_FLASH_OFF_3_91S (2 << 0) 682 - #define WM8350_ISINK_FLASH_OFF_7_80S (3 << 0) 669 + #define WM8350_ISINK_FLASH_ON_INSTANT (0 << 0) 670 + #define WM8350_ISINK_FLASH_ON_0_25S (1 << 0) 671 + #define WM8350_ISINK_FLASH_ON_0_50S (2 << 0) 672 + #define WM8350_ISINK_FLASH_ON_1_00S (3 << 0) 673 + #define WM8350_ISINK_FLASH_ON_1_95S (1 << 0) 674 + #define WM8350_ISINK_FLASH_ON_3_91S (2 << 0) 675 + #define WM8350_ISINK_FLASH_ON_7_80S (3 << 0) 676 + #define WM8350_ISINK_FLASH_OFF_INSTANT (0 << 4) 677 + #define WM8350_ISINK_FLASH_OFF_0_25S (1 << 4) 678 + #define WM8350_ISINK_FLASH_OFF_0_50S (2 << 4) 679 + #define WM8350_ISINK_FLASH_OFF_1_00S (3 << 4) 680 + #define WM8350_ISINK_FLASH_OFF_1_95S (1 << 4) 681 + #define WM8350_ISINK_FLASH_OFF_3_91S (2 << 4) 682 + #define WM8350_ISINK_FLASH_OFF_7_80S (3 << 4) 683 683 684 684 /* 685 685 * Regulator Interrupts.