|
21 | 21 | #include <linux/platform_device.h> |
22 | 22 | #include <linux/fb.h> |
23 | 23 | #include <linux/clk.h> |
| 24 | +#include <linux/mfd/core.h> |
| 25 | +#include <linux/mfd/tmio.h> |
24 | 26 | #include <linux/mfd/tc6393xb.h> |
25 | 27 | #include <linux/gpio.h> |
26 | 28 |
|
@@ -108,6 +110,59 @@ struct tc6393xb { |
108 | 110 | int irq_base; |
109 | 111 | }; |
110 | 112 |
|
| 113 | +enum { |
| 114 | + TC6393XB_CELL_NAND, |
| 115 | +}; |
| 116 | + |
| 117 | +/*--------------------------------------------------------------------------*/ |
| 118 | + |
| 119 | +static int tc6393xb_nand_enable(struct platform_device *nand) |
| 120 | +{ |
| 121 | + struct platform_device *dev = to_platform_device(nand->dev.parent); |
| 122 | + struct tc6393xb *tc6393xb = platform_get_drvdata(dev); |
| 123 | + unsigned long flags; |
| 124 | + |
| 125 | + spin_lock_irqsave(&tc6393xb->lock, flags); |
| 126 | + |
| 127 | + /* SMD buffer on */ |
| 128 | + dev_dbg(&dev->dev, "SMD buffer on\n"); |
| 129 | + iowrite8(0xff, tc6393xb->scr + SCR_GPI_BCR(1)); |
| 130 | + |
| 131 | + spin_unlock_irqrestore(&tc6393xb->lock, flags); |
| 132 | + |
| 133 | + return 0; |
| 134 | +} |
| 135 | + |
| 136 | +static struct resource __devinitdata tc6393xb_nand_resources[] = { |
| 137 | + { |
| 138 | + .name = TMIO_NAND_CONFIG, |
| 139 | + .start = 0x0100, |
| 140 | + .end = 0x01ff, |
| 141 | + .flags = IORESOURCE_MEM, |
| 142 | + }, |
| 143 | + { |
| 144 | + .name = TMIO_NAND_CONTROL, |
| 145 | + .start = 0x1000, |
| 146 | + .end = 0x1007, |
| 147 | + .flags = IORESOURCE_MEM, |
| 148 | + }, |
| 149 | + { |
| 150 | + .name = TMIO_NAND_IRQ, |
| 151 | + .start = IRQ_TC6393_NAND, |
| 152 | + .end = IRQ_TC6393_NAND, |
| 153 | + .flags = IORESOURCE_IRQ, |
| 154 | + }, |
| 155 | +}; |
| 156 | + |
| 157 | +static struct mfd_cell __devinitdata tc6393xb_cells[] = { |
| 158 | + [TC6393XB_CELL_NAND] = { |
| 159 | + .name = "tmio-nand", |
| 160 | + .enable = tc6393xb_nand_enable, |
| 161 | + .num_resources = ARRAY_SIZE(tc6393xb_nand_resources), |
| 162 | + .resources = tc6393xb_nand_resources, |
| 163 | + }, |
| 164 | +}; |
| 165 | + |
111 | 166 | /*--------------------------------------------------------------------------*/ |
112 | 167 |
|
113 | 168 | static int tc6393xb_gpio_get(struct gpio_chip *chip, |
@@ -410,6 +465,12 @@ static int __devinit tc6393xb_probe(struct platform_device *dev) |
410 | 465 | if (tc6393xb->irq) |
411 | 466 | tc6393xb_attach_irq(dev); |
412 | 467 |
|
| 468 | + tc6393xb_cells[TC6393XB_CELL_NAND].driver_data = tcpd->nand_data; |
| 469 | + |
| 470 | + retval = mfd_add_devices(dev, |
| 471 | + tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells), |
| 472 | + iomem, tcpd->irq_base); |
| 473 | + |
413 | 474 | return 0; |
414 | 475 |
|
415 | 476 | if (tc6393xb->irq) |
@@ -440,6 +501,8 @@ static int __devexit tc6393xb_remove(struct platform_device *dev) |
440 | 501 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); |
441 | 502 | int ret; |
442 | 503 |
|
| 504 | + mfd_remove_devices(dev); |
| 505 | + |
443 | 506 | if (tc6393xb->irq) |
444 | 507 | tc6393xb_detach_irq(dev); |
445 | 508 |
|
|
0 commit comments