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 12 obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o 13 14 - obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o 15 - obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o 16 - obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o 17 18 obj-$(CONFIG_MFD_WM8400) += wm8400-core.o 19 wm831x-objs := wm831x-core.o wm831x-irq.o wm831x-otp.o
··· 11 12 obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o 13 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 18 obj-$(CONFIG_MFD_WM8400) += wm8400-core.o 19 wm831x-objs := wm831x-core.o wm831x-irq.o wm831x-otp.o
+32 -8
drivers/mfd/asic3.c
··· 80 u16 irq_bothedge[4]; 81 struct gpio_chip gpio; 82 struct device *dev; 83 84 struct asic3_clk clocks[ARRAY_SIZE(asic3_clk_init)]; 85 }; ··· 686 .resources = ds1wm_resources, 687 }; 688 689 static struct tmio_mmc_data asic3_mmc_data = { 690 - .hclk = 24576000, 691 }; 692 693 static struct resource asic3_mmc_resources[] = { 694 { 695 .start = ASIC3_SD_CTRL_BASE, 696 .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 .flags = IORESOURCE_MEM, 703 }, 704 { ··· 754 /* Enable SD card slot 3.3V power supply */ 755 asic3_set_register(asic, ASIC3_OFFSET(SDHWCTRL, SDCONF), 756 ASIC3_SDHWCTRL_SDPWR, 1); 757 758 return 0; 759 } ··· 813 asic3_cell_ds1wm.data_size = sizeof(asic3_cell_ds1wm); 814 815 /* MMC */ 816 asic3_mmc_resources[0].start >>= asic->bus_shift; 817 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 821 asic3_cell_mmc.platform_data = &asic3_cell_mmc; 822 asic3_cell_mmc.data_size = sizeof(asic3_cell_mmc); ··· 841 842 static void asic3_mfd_remove(struct platform_device *pdev) 843 { 844 mfd_remove_devices(&pdev->dev); 845 } 846 847 /* Core */
··· 80 u16 irq_bothedge[4]; 81 struct gpio_chip gpio; 82 struct device *dev; 83 + void __iomem *tmio_cnf; 84 85 struct asic3_clk clocks[ARRAY_SIZE(asic3_clk_init)]; 86 }; ··· 685 .resources = ds1wm_resources, 686 }; 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 + 702 static struct tmio_mmc_data asic3_mmc_data = { 703 + .hclk = 24576000, 704 + .set_pwr = asic3_mmc_pwr, 705 + .set_clk_div = asic3_mmc_clk_div, 706 }; 707 708 static struct resource asic3_mmc_resources[] = { 709 { 710 .start = ASIC3_SD_CTRL_BASE, 711 .end = ASIC3_SD_CTRL_BASE + 0x3ff, 712 .flags = IORESOURCE_MEM, 713 }, 714 { ··· 742 /* Enable SD card slot 3.3V power supply */ 743 asic3_set_register(asic, ASIC3_OFFSET(SDHWCTRL, SDCONF), 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); 749 750 return 0; 751 } ··· 797 asic3_cell_ds1wm.data_size = sizeof(asic3_cell_ds1wm); 798 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 + } 807 asic3_mmc_resources[0].start >>= asic->bus_shift; 808 asic3_mmc_resources[0].end >>= asic->bus_shift; 809 810 asic3_cell_mmc.platform_data = &asic3_cell_mmc; 811 asic3_cell_mmc.data_size = sizeof(asic3_cell_mmc); ··· 820 821 static void asic3_mfd_remove(struct platform_device *pdev) 822 { 823 + struct asic3 *asic = platform_get_drvdata(pdev); 824 + 825 mfd_remove_devices(&pdev->dev); 826 + iounmap(asic->tmio_cnf); 827 } 828 829 /* Core */
+2 -2
drivers/mfd/mc13783-core.c
··· 619 } 620 /* This should go away (END) */ 621 622 if (pdata->flags & MC13783_USE_ADC) 623 mc13783_add_subdevice(mc13783, "mc13783-adc"); 624 ··· 642 643 if (pdata->flags & MC13783_USE_TOUCHSCREEN) 644 mc13783_add_subdevice(mc13783, "mc13783-ts"); 645 - 646 - mc13783_unlock(mc13783); 647 648 return 0; 649 }
··· 619 } 620 /* This should go away (END) */ 621 622 + mc13783_unlock(mc13783); 623 + 624 if (pdata->flags & MC13783_USE_ADC) 625 mc13783_add_subdevice(mc13783, "mc13783-adc"); 626 ··· 640 641 if (pdata->flags & MC13783_USE_TOUCHSCREEN) 642 mc13783_add_subdevice(mc13783, "mc13783-ts"); 643 644 return 0; 645 }
+37 -18
drivers/mfd/t7l66xb.c
··· 38 T7L66XB_CELL_MMC, 39 }; 40 41 #define SCR_REVID 0x08 /* b Revision ID */ 42 #define SCR_IMR 0x42 /* b Interrupt Mask */ 43 #define SCR_DEV_CTL 0xe0 /* b Device control */ ··· 96 97 spin_unlock_irqrestore(&t7l66xb->lock, flags); 98 99 return 0; 100 } 101 ··· 122 return 0; 123 } 124 125 /*--------------------------------------------------------------------------*/ 126 127 static struct tmio_mmc_data t7166xb_mmc_data = { 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 - }, 147 }; 148 149 static const struct resource t7l66xb_nand_resources[] = { ··· 297 clk_enable(t7l66xb->clk48m); 298 if (pdata && pdata->resume) 299 pdata->resume(dev); 300 301 return 0; 302 }
··· 38 T7L66XB_CELL_MMC, 39 }; 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 + 54 #define SCR_REVID 0x08 /* b Revision ID */ 55 #define SCR_IMR 0x42 /* b Interrupt Mask */ 56 #define SCR_DEV_CTL 0xe0 /* b Device control */ ··· 83 84 spin_unlock_irqrestore(&t7l66xb->lock, flags); 85 86 + tmio_core_mmc_enable(t7l66xb->scr + 0x200, 0, 87 + t7l66xb_mmc_resources[0].start & 0xfffe); 88 + 89 return 0; 90 } 91 ··· 106 return 0; 107 } 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 /*--------------------------------------------------------------------------*/ 126 127 static struct tmio_mmc_data t7166xb_mmc_data = { 128 .hclk = 24000000, 129 + .set_pwr = t7l66xb_mmc_pwr, 130 + .set_clk_div = t7l66xb_mmc_clk_div, 131 }; 132 133 static const struct resource t7l66xb_nand_resources[] = { ··· 281 clk_enable(t7l66xb->clk48m); 282 if (pdata && pdata->resume) 283 pdata->resume(dev); 284 + 285 + tmio_core_mmc_enable(t7l66xb->scr + 0x200, 0, 286 + t7l66xb_mmc_resources[0].start & 0xfffe); 287 288 return 0; 289 }
+89 -32
drivers/mfd/tc6387xb.c
··· 22 TC6387XB_CELL_MMC, 23 }; 24 25 #ifdef CONFIG_PM 26 static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) 27 { 28 - struct clk *clk32k = platform_get_drvdata(dev); 29 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 30 31 if (pdata && pdata->suspend) 32 pdata->suspend(dev); 33 - clk_disable(clk32k); 34 35 return 0; 36 } 37 38 static int tc6387xb_resume(struct platform_device *dev) 39 { 40 - struct clk *clk32k = platform_get_drvdata(dev); 41 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 42 43 - clk_enable(clk32k); 44 if (pdata && pdata->resume) 45 pdata->resume(dev); 46 47 return 0; 48 } ··· 77 78 /*--------------------------------------------------------------------------*/ 79 80 static int tc6387xb_mmc_enable(struct platform_device *mmc) 81 { 82 struct platform_device *dev = to_platform_device(mmc->dev.parent); 83 - struct clk *clk32k = platform_get_drvdata(dev); 84 85 - clk_enable(clk32k); 86 87 return 0; 88 } ··· 110 static int tc6387xb_mmc_disable(struct platform_device *mmc) 111 { 112 struct platform_device *dev = to_platform_device(mmc->dev.parent); 113 - struct clk *clk32k = platform_get_drvdata(dev); 114 115 - clk_disable(clk32k); 116 117 return 0; 118 } 119 120 - /*--------------------------------------------------------------------------*/ 121 - 122 static struct tmio_mmc_data tc6387xb_mmc_data = { 123 .hclk = 24000000, 124 }; 125 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 - }; 143 144 static struct mfd_cell tc6387xb_cells[] = { 145 [TC6387XB_CELL_MMC] = { ··· 139 static int tc6387xb_probe(struct platform_device *dev) 140 { 141 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 142 - struct resource *iomem; 143 struct clk *clk32k; 144 int irq, ret; 145 146 iomem = platform_get_resource(dev, IORESOURCE_MEM, 0); ··· 149 return -EINVAL; 150 } 151 152 ret = platform_get_irq(dev, 0); 153 if (ret >= 0) 154 irq = ret; 155 else 156 - goto err_resource; 157 158 clk32k = clk_get(&dev->dev, "CLK_CK32K"); 159 if (IS_ERR(clk32k)) { 160 ret = PTR_ERR(clk32k); 161 - goto err_resource; 162 } 163 - platform_set_drvdata(dev, clk32k); 164 165 if (pdata && pdata->enable) 166 pdata->enable(dev); ··· 200 if (!ret) 201 return 0; 202 203 - clk_put(clk32k); 204 err_resource: 205 return ret; 206 } 207 ··· 251 MODULE_LICENSE("GPL v2"); 252 MODULE_AUTHOR("Ian Molton"); 253 MODULE_ALIAS("platform:tc6387xb");
··· 22 TC6387XB_CELL_MMC, 23 }; 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 + 46 #ifdef CONFIG_PM 47 static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) 48 { 49 + struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 50 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 51 52 if (pdata && pdata->suspend) 53 pdata->suspend(dev); 54 + clk_disable(tc6387xb->clk32k); 55 56 return 0; 57 } 58 59 static int tc6387xb_resume(struct platform_device *dev) 60 { 61 + struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 62 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 63 64 + clk_enable(tc6387xb->clk32k); 65 if (pdata && pdata->resume) 66 pdata->resume(dev); 67 + 68 + tmio_core_mmc_resume(tc6387xb->scr + 0x200, 0, 69 + tc6387xb_mmc_resources[0].start & 0xfffe); 70 71 return 0; 72 } ··· 53 54 /*--------------------------------------------------------------------------*/ 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 + 73 static int tc6387xb_mmc_enable(struct platform_device *mmc) 74 { 75 struct platform_device *dev = to_platform_device(mmc->dev.parent); 76 + struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 77 78 + clk_enable(tc6387xb->clk32k); 79 + 80 + tmio_core_mmc_enable(tc6387xb->scr + 0x200, 0, 81 + tc6387xb_mmc_resources[0].start & 0xfffe); 82 83 return 0; 84 } ··· 66 static int tc6387xb_mmc_disable(struct platform_device *mmc) 67 { 68 struct platform_device *dev = to_platform_device(mmc->dev.parent); 69 + struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 70 71 + clk_disable(tc6387xb->clk32k); 72 73 return 0; 74 } 75 76 static struct tmio_mmc_data tc6387xb_mmc_data = { 77 .hclk = 24000000, 78 + .set_pwr = tc6387xb_mmc_pwr, 79 + .set_clk_div = tc6387xb_mmc_clk_div, 80 }; 81 82 + /*--------------------------------------------------------------------------*/ 83 84 static struct mfd_cell tc6387xb_cells[] = { 85 [TC6387XB_CELL_MMC] = { ··· 111 static int tc6387xb_probe(struct platform_device *dev) 112 { 113 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 114 + struct resource *iomem, *rscr; 115 struct clk *clk32k; 116 + struct tc6387xb *tc6387xb; 117 int irq, ret; 118 119 iomem = platform_get_resource(dev, IORESOURCE_MEM, 0); ··· 120 return -EINVAL; 121 } 122 123 + tc6387xb = kzalloc(sizeof *tc6387xb, GFP_KERNEL); 124 + if (!tc6387xb) 125 + return -ENOMEM; 126 + 127 ret = platform_get_irq(dev, 0); 128 if (ret >= 0) 129 irq = ret; 130 else 131 + goto err_no_irq; 132 133 clk32k = clk_get(&dev->dev, "CLK_CK32K"); 134 if (IS_ERR(clk32k)) { 135 ret = PTR_ERR(clk32k); 136 + goto err_no_clk; 137 } 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); 157 158 if (pdata && pdata->enable) 159 pdata->enable(dev); ··· 149 if (!ret) 150 return 0; 151 152 + err_ioremap: 153 + release_resource(&tc6387xb->rscr); 154 err_resource: 155 + clk_put(clk32k); 156 + err_no_clk: 157 + err_no_irq: 158 + kfree(tc6387xb); 159 return ret; 160 } 161 ··· 195 MODULE_LICENSE("GPL v2"); 196 MODULE_AUTHOR("Ian Molton"); 197 MODULE_ALIAS("platform:tc6387xb"); 198 +
+47 -9
drivers/mfd/tc6393xb.c
··· 136 return 0; 137 } 138 139 - static struct tmio_mmc_data tc6393xb_mmc_data = { 140 - .hclk = 24000000, 141 - }; 142 - 143 static struct resource __devinitdata tc6393xb_nand_resources[] = { 144 { 145 .start = 0x1000, ··· 158 { 159 .start = 0x800, 160 .end = 0x9ff, 161 - .flags = IORESOURCE_MEM, 162 - }, 163 - { 164 - .start = 0x200, 165 - .end = 0x2ff, 166 .flags = IORESOURCE_MEM, 167 }, 168 { ··· 337 } 338 EXPORT_SYMBOL(tc6393xb_lcd_mode); 339 340 static struct mfd_cell __devinitdata tc6393xb_cells[] = { 341 [TC6393XB_CELL_NAND] = { 342 .name = "tmio-nand", ··· 390 }, 391 [TC6393XB_CELL_MMC] = { 392 .name = "tmio-mmc", 393 .driver_data = &tc6393xb_mmc_data, 394 .num_resources = ARRAY_SIZE(tc6393xb_mmc_resources), 395 .resources = tc6393xb_mmc_resources, ··· 873 MODULE_AUTHOR("Ian Molton, Dmitry Baryshkov and Dirk Opfer"); 874 MODULE_DESCRIPTION("tc6393xb Toshiba Mobile IO Controller"); 875 MODULE_ALIAS("platform:tc6393xb");
··· 136 return 0; 137 } 138 139 static struct resource __devinitdata tc6393xb_nand_resources[] = { 140 { 141 .start = 0x1000, ··· 162 { 163 .start = 0x800, 164 .end = 0x9ff, 165 .flags = IORESOURCE_MEM, 166 }, 167 { ··· 346 } 347 EXPORT_SYMBOL(tc6393xb_lcd_mode); 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 + 393 static struct mfd_cell __devinitdata tc6393xb_cells[] = { 394 [TC6393XB_CELL_NAND] = { 395 .name = "tmio-nand", ··· 355 }, 356 [TC6393XB_CELL_MMC] = { 357 .name = "tmio-mmc", 358 + .enable = tc6393xb_mmc_enable, 359 + .resume = tc6393xb_mmc_resume, 360 .driver_data = &tc6393xb_mmc_data, 361 .num_resources = ARRAY_SIZE(tc6393xb_mmc_resources), 362 .resources = tc6393xb_mmc_resources, ··· 836 MODULE_AUTHOR("Ian Molton, Dmitry Baryshkov and Dirk Opfer"); 837 MODULE_DESCRIPTION("tc6393xb Toshiba Mobile IO Controller"); 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 wm8350->reg_cache[WM8350_SECURITY] == WM8350_UNLOCK_KEY) 135 return 0; 136 137 - if ((reg == WM8350_GPIO_CONFIGURATION_I_O) || 138 - (reg >= WM8350_GPIO_FUNCTION_SELECT_1 && 139 reg <= WM8350_GPIO_FUNCTION_SELECT_4) || 140 (reg >= WM8350_BATTERY_CHARGER_CONTROL_1 && 141 reg <= WM8350_BATTERY_CHARGER_CONTROL_3))
··· 134 wm8350->reg_cache[WM8350_SECURITY] == WM8350_UNLOCK_KEY) 135 return 0; 136 137 + if ((reg >= WM8350_GPIO_FUNCTION_SELECT_1 && 138 reg <= WM8350_GPIO_FUNCTION_SELECT_4) || 139 (reg >= WM8350_BATTERY_CHARGER_CONTROL_1 && 140 reg <= WM8350_BATTERY_CHARGER_CONTROL_3))
+2 -2
drivers/mfd/wm8350-irq.c
··· 434 irq_handler_t handler, unsigned long flags, 435 const char *name, void *data) 436 { 437 - if (irq < 0 || irq > WM8350_NUM_IRQ || !handler) 438 return -EINVAL; 439 440 if (wm8350->irq[irq].handler) ··· 453 454 int wm8350_free_irq(struct wm8350 *wm8350, int irq) 455 { 456 - if (irq < 0 || irq > WM8350_NUM_IRQ) 457 return -EINVAL; 458 459 wm8350_mask_irq(wm8350, irq);
··· 434 irq_handler_t handler, unsigned long flags, 435 const char *name, void *data) 436 { 437 + if (irq < 0 || irq >= WM8350_NUM_IRQ || !handler) 438 return -EINVAL; 439 440 if (wm8350->irq[irq].handler) ··· 453 454 int wm8350_free_irq(struct wm8350 *wm8350, int irq) 455 { 456 + if (irq < 0 || irq >= WM8350_NUM_IRQ) 457 return -EINVAL; 458 459 wm8350_mask_irq(wm8350, irq);
+19 -40
drivers/mmc/host/tmio_mmc.c
··· 46 clk |= 0x100; 47 } 48 49 - sd_config_write8(host, CNF_SD_CLK_MODE, clk >> 22); 50 sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk & 0x1ff); 51 } 52 ··· 429 /* Power sequence - OFF -> ON -> UP */ 430 switch (ios->power_mode) { 431 case MMC_POWER_OFF: /* power down SD bus */ 432 - sd_config_write8(host, CNF_PWR_CTL_2, 0x00); 433 tmio_mmc_clk_stop(host); 434 break; 435 case MMC_POWER_ON: /* power up SD bus */ 436 - 437 - sd_config_write8(host, CNF_PWR_CTL_2, 0x02); 438 break; 439 case MMC_POWER_UP: /* start bus clock */ 440 tmio_mmc_clk_start(host); ··· 488 { 489 struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; 490 struct mmc_host *mmc = platform_get_drvdata(dev); 491 - struct tmio_mmc_host *host = mmc_priv(mmc); 492 int ret = 0; 493 494 /* Tell the MFD core we are ready to be enabled */ 495 - if (cell->enable) { 496 - ret = cell->enable(dev); 497 if (ret) 498 goto out; 499 } 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 506 mmc_resume_host(mmc); 507 ··· 511 { 512 struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; 513 struct tmio_mmc_data *pdata; 514 - struct resource *res_ctl, *res_cnf; 515 struct tmio_mmc_host *host; 516 struct mmc_host *mmc; 517 int ret = -EINVAL; 518 519 - if (dev->num_resources != 3) 520 goto out; 521 522 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) 525 goto out; 526 527 pdata = cell->driver_data; ··· 535 536 host = mmc_priv(mmc); 537 host->mmc = mmc; 538 platform_set_drvdata(dev, mmc); 539 540 /* SD control register space size is 0x200, 0x400 for bus_shift=1 */ 541 host->bus_shift = resource_size(res_ctl) >> 10; ··· 547 host->ctl = ioremap(res_ctl->start, resource_size(res_ctl)); 548 if (!host->ctl) 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 555 mmc->ops = &tmio_mmc_ops; 556 mmc->caps = MMC_CAP_4_BIT_DATA; ··· 558 if (cell->enable) { 559 ret = cell->enable(dev); 560 if (ret) 561 - goto unmap_cnf; 562 } 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 578 tmio_mmc_clk_stop(host); 579 reset(host); ··· 568 if (ret >= 0) 569 host->irq = ret; 570 else 571 - goto unmap_cnf; 572 573 disable_mmc_irqs(host, TMIO_MASK_ALL); 574 575 ret = request_irq(host->irq, tmio_mmc_irq, IRQF_DISABLED | 576 IRQF_TRIGGER_FALLING, dev_name(&dev->dev), host); 577 if (ret) 578 - goto unmap_cnf; 579 580 mmc_add_host(mmc); 581 ··· 587 588 return 0; 589 590 - unmap_cnf: 591 - iounmap(host->cnf); 592 unmap_ctl: 593 iounmap(host->ctl); 594 host_free: ··· 606 mmc_remove_host(mmc); 607 free_irq(host->irq, host); 608 iounmap(host->ctl); 609 - iounmap(host->cnf); 610 mmc_free_host(mmc); 611 } 612
··· 46 clk |= 0x100; 47 } 48 49 + if (host->set_clk_div) 50 + host->set_clk_div(host->pdev, (clk>>22) & 1); 51 + 52 sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk & 0x1ff); 53 } 54 ··· 427 /* Power sequence - OFF -> ON -> UP */ 428 switch (ios->power_mode) { 429 case MMC_POWER_OFF: /* power down SD bus */ 430 + if (host->set_pwr) 431 + host->set_pwr(host->pdev, 0); 432 tmio_mmc_clk_stop(host); 433 break; 434 case MMC_POWER_ON: /* power up SD bus */ 435 + if (host->set_pwr) 436 + host->set_pwr(host->pdev, 1); 437 break; 438 case MMC_POWER_UP: /* start bus clock */ 439 tmio_mmc_clk_start(host); ··· 485 { 486 struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; 487 struct mmc_host *mmc = platform_get_drvdata(dev); 488 int ret = 0; 489 490 /* Tell the MFD core we are ready to be enabled */ 491 + if (cell->resume) { 492 + ret = cell->resume(dev); 493 if (ret) 494 goto out; 495 } 496 497 mmc_resume_host(mmc); 498 ··· 514 { 515 struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; 516 struct tmio_mmc_data *pdata; 517 + struct resource *res_ctl; 518 struct tmio_mmc_host *host; 519 struct mmc_host *mmc; 520 int ret = -EINVAL; 521 522 + if (dev->num_resources != 2) 523 goto out; 524 525 res_ctl = platform_get_resource(dev, IORESOURCE_MEM, 0); 526 + if (!res_ctl) 527 goto out; 528 529 pdata = cell->driver_data; ··· 539 540 host = mmc_priv(mmc); 541 host->mmc = mmc; 542 + host->pdev = dev; 543 platform_set_drvdata(dev, mmc); 544 + 545 + host->set_pwr = pdata->set_pwr; 546 + host->set_clk_div = pdata->set_clk_div; 547 548 /* SD control register space size is 0x200, 0x400 for bus_shift=1 */ 549 host->bus_shift = resource_size(res_ctl) >> 10; ··· 547 host->ctl = ioremap(res_ctl->start, resource_size(res_ctl)); 548 if (!host->ctl) 549 goto host_free; 550 551 mmc->ops = &tmio_mmc_ops; 552 mmc->caps = MMC_CAP_4_BIT_DATA; ··· 562 if (cell->enable) { 563 ret = cell->enable(dev); 564 if (ret) 565 + goto unmap_ctl; 566 } 567 568 tmio_mmc_clk_stop(host); 569 reset(host); ··· 586 if (ret >= 0) 587 host->irq = ret; 588 else 589 + goto unmap_ctl; 590 591 disable_mmc_irqs(host, TMIO_MASK_ALL); 592 593 ret = request_irq(host->irq, tmio_mmc_irq, IRQF_DISABLED | 594 IRQF_TRIGGER_FALLING, dev_name(&dev->dev), host); 595 if (ret) 596 + goto unmap_ctl; 597 598 mmc_add_host(mmc); 599 ··· 605 606 return 0; 607 608 unmap_ctl: 609 iounmap(host->ctl); 610 host_free: ··· 626 mmc_remove_host(mmc); 627 free_irq(host->irq, host); 628 iounmap(host->ctl); 629 mmc_free_host(mmc); 630 } 631
+6 -40
drivers/mmc/host/tmio_mmc.h
··· 11 12 #include <linux/highmem.h> 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 #define CTL_SD_CMD 0x00 35 #define CTL_ARG_REG 0x04 36 #define CTL_STOP_INTERNAL_ACTION 0x08 ··· 90 91 92 struct tmio_mmc_host { 93 - void __iomem *cnf; 94 void __iomem *ctl; 95 unsigned long bus_shift; 96 struct mmc_command *cmd; ··· 98 struct mmc_host *mmc; 99 int irq; 100 101 /* pio related stuff */ 102 struct scatterlist *sg_ptr; 103 unsigned int sg_len; 104 unsigned int sg_off; 105 }; 106 107 #include <linux/io.h> ··· 146 { 147 writew(val, host->ctl + (addr << host->bus_shift)); 148 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 } 169 170 #include <linux/scatterlist.h>
··· 11 12 #include <linux/highmem.h> 13 14 #define CTL_SD_CMD 0x00 15 #define CTL_ARG_REG 0x04 16 #define CTL_STOP_INTERNAL_ACTION 0x08 ··· 110 111 112 struct tmio_mmc_host { 113 void __iomem *ctl; 114 unsigned long bus_shift; 115 struct mmc_command *cmd; ··· 119 struct mmc_host *mmc; 120 int irq; 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 + 126 /* pio related stuff */ 127 struct scatterlist *sg_ptr; 128 unsigned int sg_len; 129 unsigned int sg_off; 130 + 131 + struct platform_device *pdev; 132 }; 133 134 #include <linux/io.h> ··· 161 { 162 writew(val, host->ctl + (addr << host->bus_shift)); 163 writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift)); 164 } 165 166 #include <linux/scatterlist.h>
+39
include/linux/mfd/tmio.h
··· 2 #define MFD_TMIO_H 3 4 #include <linux/fb.h> 5 6 #define tmio_ioread8(addr) readb(addr) 7 #define tmio_ioread16(addr) readw(addr) ··· 20 writew((val) >> 16, (addr) + 2); \ 21 } while (0) 22 23 /* 24 * data for the MMC controller 25 */ 26 struct tmio_mmc_data { 27 const unsigned int hclk; 28 }; 29 30 /*
··· 2 #define MFD_TMIO_H 3 4 #include <linux/fb.h> 5 + #include <linux/io.h> 6 + #include <linux/platform_device.h> 7 8 #define tmio_ioread8(addr) readb(addr) 9 #define tmio_ioread16(addr) readw(addr) ··· 18 writew((val) >> 16, (addr) + 2); \ 19 } while (0) 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 + 56 /* 57 * data for the MMC controller 58 */ 59 struct tmio_mmc_data { 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); 63 }; 64 65 /*
+14 -14
include/linux/mfd/wm8350/pmic.h
··· 666 #define WM8350_ISINK_FLASH_DUR_64MS (1 << 8) 667 #define WM8350_ISINK_FLASH_DUR_96MS (2 << 8) 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) 683 684 /* 685 * Regulator Interrupts.
··· 666 #define WM8350_ISINK_FLASH_DUR_64MS (1 << 8) 667 #define WM8350_ISINK_FLASH_DUR_96MS (2 << 8) 668 #define WM8350_ISINK_FLASH_DUR_1024MS (3 << 8) 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 684 /* 685 * Regulator Interrupts.