Skip to content

Commit f024ff1

Browse files
lumagRussell King
authored andcommitted
[ARM] 5128/1: tc6393xb: tmio-nand support
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent aa613de commit f024ff1

4 files changed

Lines changed: 83 additions & 0 deletions

File tree

‎drivers/mfd/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ config HTC_PASIC3
4545
config MFD_TC6393XB
4646
bool "Support Toshiba TC6393XB"
4747
depends on HAVE_GPIO_LIB
48+
select MFD_CORE
4849
help
4950
Support for Toshiba Mobile IO Controller TC6393XB
5051

‎drivers/mfd/tc6393xb.c‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <linux/platform_device.h>
2222
#include <linux/fb.h>
2323
#include <linux/clk.h>
24+
#include <linux/mfd/core.h>
25+
#include <linux/mfd/tmio.h>
2426
#include <linux/mfd/tc6393xb.h>
2527
#include <linux/gpio.h>
2628

@@ -108,6 +110,59 @@ struct tc6393xb {
108110
int irq_base;
109111
};
110112

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+
111166
/*--------------------------------------------------------------------------*/
112167

113168
static int tc6393xb_gpio_get(struct gpio_chip *chip,
@@ -410,6 +465,12 @@ static int __devinit tc6393xb_probe(struct platform_device *dev)
410465
if (tc6393xb->irq)
411466
tc6393xb_attach_irq(dev);
412467

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+
413474
return 0;
414475

415476
if (tc6393xb->irq)
@@ -440,6 +501,8 @@ static int __devexit tc6393xb_remove(struct platform_device *dev)
440501
struct tc6393xb *tc6393xb = platform_get_drvdata(dev);
441502
int ret;
442503

504+
mfd_remove_devices(dev);
505+
443506
if (tc6393xb->irq)
444507
tc6393xb_detach_irq(dev);
445508

‎include/linux/mfd/tc6393xb.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ struct tc6393xb_platform_data {
3131

3232
int irq_base; /* a base for cascaded irq */
3333
int gpio_base;
34+
35+
struct tmio_nand_data *nand_data;
3436
};
3537

3638
/*

‎include/linux/mfd/tmio.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef MFD_TMIO_H
2+
#define MFD_TMIO_H
3+
4+
/*
5+
* data for the NAND controller
6+
*/
7+
struct tmio_nand_data {
8+
struct nand_bbt_descr *badblock_pattern;
9+
struct mtd_partition *partition;
10+
unsigned int num_partitions;
11+
};
12+
13+
#define TMIO_NAND_CONFIG "tmio-nand-config"
14+
#define TMIO_NAND_CONTROL "tmio-nand-control"
15+
#define TMIO_NAND_IRQ "tmio-nand"
16+
17+
#endif

0 commit comments

Comments
 (0)