gpio-davinci.c 16.2 KB
Newer Older
1 2 3
/*
 * TI DaVinci GPIO Support
 *
4
 * Copyright (c) 2006-2007 David Brownell
5 6 7 8 9 10 11
 * Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */
12
#include <linux/gpio.h>
13 14 15 16 17
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/io.h>
18
#include <linux/irq.h>
19
#include <linux/irqdomain.h>
K
KV Sujith 已提交
20 21 22
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
23 24
#include <linux/platform_device.h>
#include <linux/platform_data/gpio-davinci.h>
25
#include <linux/irqchip/chained_irq.h>
26

27 28 29 30 31 32 33 34 35 36 37 38 39
struct davinci_gpio_regs {
	u32	dir;
	u32	out_data;
	u32	set_data;
	u32	clr_data;
	u32	in_data;
	u32	set_rising;
	u32	clr_rising;
	u32	set_falling;
	u32	clr_falling;
	u32	intstat;
};

40 41
typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq);

42 43
#define BINTEN	0x8 /* GPIO Interrupt Per-Bank Enable Register */

44
static void __iomem *gpio_base;
45

46
static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio)
47
{
48 49 50
	void __iomem *ptr;

	if (gpio < 32 * 1)
51
		ptr = gpio_base + 0x10;
52
	else if (gpio < 32 * 2)
53
		ptr = gpio_base + 0x38;
54
	else if (gpio < 32 * 3)
55
		ptr = gpio_base + 0x60;
56
	else if (gpio < 32 * 4)
57
		ptr = gpio_base + 0x88;
58
	else if (gpio < 32 * 5)
59
		ptr = gpio_base + 0xb0;
60 61 62
	else
		ptr = NULL;
	return ptr;
63 64
}

65
static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d)
66
{
67
	struct davinci_gpio_regs __iomem *g;
68

69
	g = (__force struct davinci_gpio_regs __iomem *)irq_data_get_irq_chip_data(d);
70 71 72 73

	return g;
}

74
static int davinci_gpio_irq_setup(struct platform_device *pdev);
75 76 77

/*--------------------------------------------------------------------------*/

78
/* board setup code *MUST* setup pinmux and enable the GPIO clock. */
79 80
static inline int __davinci_direction(struct gpio_chip *chip,
			unsigned offset, bool out, int value)
81
{
82
	struct davinci_gpio_controller *d = gpiochip_get_data(chip);
83
	struct davinci_gpio_regs __iomem *g = d->regs;
84
	unsigned long flags;
85
	u32 temp;
86
	u32 mask = 1 << offset;
87

88
	spin_lock_irqsave(&d->lock, flags);
89
	temp = readl_relaxed(&g->dir);
90 91
	if (out) {
		temp &= ~mask;
92
		writel_relaxed(mask, value ? &g->set_data : &g->clr_data);
93 94 95
	} else {
		temp |= mask;
	}
96
	writel_relaxed(temp, &g->dir);
97
	spin_unlock_irqrestore(&d->lock, flags);
98

99 100
	return 0;
}
101

102 103 104 105 106 107 108 109 110 111 112
static int davinci_direction_in(struct gpio_chip *chip, unsigned offset)
{
	return __davinci_direction(chip, offset, false, 0);
}

static int
davinci_direction_out(struct gpio_chip *chip, unsigned offset, int value)
{
	return __davinci_direction(chip, offset, true, value);
}

113 114 115 116 117 118 119
/*
 * Read the pin's value (works even if it's set up as output);
 * returns zero/nonzero.
 *
 * Note that changes are synched to the GPIO clock, so reading values back
 * right after you've set them may give old values.
 */
120
static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset)
121
{
122
	struct davinci_gpio_controller *d = gpiochip_get_data(chip);
123
	struct davinci_gpio_regs __iomem *g = d->regs;
124

125
	return !!((1 << offset) & readl_relaxed(&g->in_data));
126 127
}

128 129 130 131 132
/*
 * Assuming the pin is muxed as a gpio output, set its output value.
 */
static void
davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
133
{
134
	struct davinci_gpio_controller *d = gpiochip_get_data(chip);
135
	struct davinci_gpio_regs __iomem *g = d->regs;
136

137
	writel_relaxed((1 << offset), value ? &g->set_data : &g->clr_data);
138 139
}

K
KV Sujith 已提交
140 141 142 143 144 145 146 147 148
static struct davinci_gpio_platform_data *
davinci_gpio_get_pdata(struct platform_device *pdev)
{
	struct device_node *dn = pdev->dev.of_node;
	struct davinci_gpio_platform_data *pdata;
	int ret;
	u32 val;

	if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
N
Nizam Haider 已提交
149
		return dev_get_platdata(&pdev->dev);
K
KV Sujith 已提交
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173

	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
	if (!pdata)
		return NULL;

	ret = of_property_read_u32(dn, "ti,ngpio", &val);
	if (ret)
		goto of_err;

	pdata->ngpio = val;

	ret = of_property_read_u32(dn, "ti,davinci-gpio-unbanked", &val);
	if (ret)
		goto of_err;

	pdata->gpio_unbanked = val;

	return pdata;

of_err:
	dev_err(&pdev->dev, "Populating pdata from DT failed: err %d\n", ret);
	return NULL;
}

174 175 176 177 178
#ifdef CONFIG_OF_GPIO
static int davinci_gpio_of_xlate(struct gpio_chip *gc,
			     const struct of_phandle_args *gpiospec,
			     u32 *flags)
{
179 180
	struct davinci_gpio_controller *chips = dev_get_drvdata(gc->parent);
	struct davinci_gpio_platform_data *pdata = dev_get_platdata(gc->parent);
181 182 183 184 185 186 187 188 189 190 191 192 193 194

	if (gpiospec->args[0] > pdata->ngpio)
		return -EINVAL;

	if (gc != &chips[gpiospec->args[0] / 32].chip)
		return -EINVAL;

	if (flags)
		*flags = gpiospec->args[1];

	return gpiospec->args[0] % 32;
}
#endif

195
static int davinci_gpio_probe(struct platform_device *pdev)
196 197
{
	int i, base;
198
	unsigned ngpio;
199 200 201 202 203 204
	struct davinci_gpio_controller *chips;
	struct davinci_gpio_platform_data *pdata;
	struct davinci_gpio_regs __iomem *regs;
	struct device *dev = &pdev->dev;
	struct resource *res;

K
KV Sujith 已提交
205
	pdata = davinci_gpio_get_pdata(pdev);
206 207 208 209
	if (!pdata) {
		dev_err(dev, "No platform data found\n");
		return -EINVAL;
	}
210

K
KV Sujith 已提交
211 212
	dev->platform_data = pdata;

213 214
	/*
	 * The gpio banks conceptually expose a segmented bitmap,
D
David Brownell 已提交
215 216 217
	 * and "ngpio" is one more than the largest zero-based
	 * bit index that's valid.
	 */
218
	ngpio = pdata->ngpio;
219
	if (ngpio == 0) {
220
		dev_err(dev, "How many GPIOs?\n");
D
David Brownell 已提交
221 222 223
		return -EINVAL;
	}

224 225
	if (WARN_ON(ARCH_NR_GPIOS < ngpio))
		ngpio = ARCH_NR_GPIOS;
D
David Brownell 已提交
226

227 228 229
	chips = devm_kzalloc(dev,
			     ngpio * sizeof(struct davinci_gpio_controller),
			     GFP_KERNEL);
230
	if (!chips)
231
		return -ENOMEM;
232 233 234 235 236

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	gpio_base = devm_ioremap_resource(dev, res);
	if (IS_ERR(gpio_base))
		return PTR_ERR(gpio_base);
237

D
David Brownell 已提交
238
	for (i = 0, base = 0; base < ngpio; i++, base += 32) {
239 240 241 242 243 244 245 246
		chips[i].chip.label = "DaVinci";

		chips[i].chip.direction_input = davinci_direction_in;
		chips[i].chip.get = davinci_gpio_get;
		chips[i].chip.direction_output = davinci_direction_out;
		chips[i].chip.set = davinci_gpio_set;

		chips[i].chip.base = base;
D
David Brownell 已提交
247
		chips[i].chip.ngpio = ngpio - base;
248 249 250
		if (chips[i].chip.ngpio > 32)
			chips[i].chip.ngpio = 32;

K
KV Sujith 已提交
251
#ifdef CONFIG_OF_GPIO
252 253
		chips[i].chip.of_gpio_n_cells = 2;
		chips[i].chip.of_xlate = davinci_gpio_of_xlate;
254
		chips[i].chip.parent = dev;
K
KV Sujith 已提交
255 256
		chips[i].chip.of_node = dev->of_node;
#endif
257 258
		spin_lock_init(&chips[i].lock);

259 260 261 262 263
		regs = gpio2regs(base);
		chips[i].regs = regs;
		chips[i].set_data = &regs->set_data;
		chips[i].clr_data = &regs->clr_data;
		chips[i].in_data = &regs->in_data;
264

265
		gpiochip_add_data(&chips[i].chip, &chips[i]);
266
	}
267

268 269
	platform_set_drvdata(pdev, chips);
	davinci_gpio_irq_setup(pdev);
270 271 272
	return 0;
}

273
/*--------------------------------------------------------------------------*/
274 275 276 277
/*
 * We expect irqs will normally be set up as input pins, but they can also be
 * used as output pins ... which is convenient for testing.
 *
D
David Brownell 已提交
278
 * NOTE:  The first few GPIOs also have direct INTC hookups in addition
D
David Brownell 已提交
279
 * to their GPIOBNK0 irq, with a bit less overhead.
280
 *
D
David Brownell 已提交
281
 * All those INTC hookups (direct, plus several IRQ banks) can also
282 283 284
 * serve as EDMA event triggers.
 */

285
static void gpio_irq_disable(struct irq_data *d)
286
{
287
	struct davinci_gpio_regs __iomem *g = irq2regs(d);
T
Thomas Gleixner 已提交
288
	u32 mask = (u32) irq_data_get_irq_handler_data(d);
289

290 291
	writel_relaxed(mask, &g->clr_falling);
	writel_relaxed(mask, &g->clr_rising);
292 293
}

294
static void gpio_irq_enable(struct irq_data *d)
295
{
296
	struct davinci_gpio_regs __iomem *g = irq2regs(d);
T
Thomas Gleixner 已提交
297
	u32 mask = (u32) irq_data_get_irq_handler_data(d);
298
	unsigned status = irqd_get_trigger_type(d);
299

D
David Brownell 已提交
300 301 302 303 304
	status &= IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING;
	if (!status)
		status = IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING;

	if (status & IRQ_TYPE_EDGE_FALLING)
305
		writel_relaxed(mask, &g->set_falling);
D
David Brownell 已提交
306
	if (status & IRQ_TYPE_EDGE_RISING)
307
		writel_relaxed(mask, &g->set_rising);
308 309
}

310
static int gpio_irq_type(struct irq_data *d, unsigned trigger)
311 312 313 314 315 316 317 318 319
{
	if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
		return -EINVAL;

	return 0;
}

static struct irq_chip gpio_irqchip = {
	.name		= "GPIO",
320 321 322
	.irq_enable	= gpio_irq_enable,
	.irq_disable	= gpio_irq_disable,
	.irq_set_type	= gpio_irq_type,
323
	.flags		= IRQCHIP_SET_TYPE_MASKED,
324 325
};

326
static void gpio_irq_handler(struct irq_desc *desc)
327
{
328
	unsigned int irq = irq_desc_get_irq(desc);
329
	struct davinci_gpio_regs __iomem *g;
330
	u32 mask = 0xffff;
331
	struct davinci_gpio_controller *d;
332

333 334
	d = (struct davinci_gpio_controller *)irq_desc_get_handler_data(desc);
	g = (struct davinci_gpio_regs __iomem *)d->regs;
335

336 337 338 339 340
	/* we only care about one bank */
	if (irq & 1)
		mask <<= 16;

	/* temporarily mask (level sensitive) parent IRQ */
341
	chained_irq_enter(irq_desc_get_chip(desc), desc);
342 343
	while (1) {
		u32		status;
344
		int		bit;
345 346

		/* ack any irqs */
347
		status = readl_relaxed(&g->intstat) & mask;
348 349
		if (!status)
			break;
350
		writel_relaxed(status, &g->intstat);
351 352

		/* now demux them to the right lowlevel handler */
353

354
		while (status) {
355 356 357 358 359
			bit = __ffs(status);
			status &= ~BIT(bit);
			generic_handle_irq(
				irq_find_mapping(d->irq_domain,
						 d->chip.base + bit));
360 361
		}
	}
362
	chained_irq_exit(irq_desc_get_chip(desc), desc);
363 364 365
	/* now it may re-trigger */
}

D
David Brownell 已提交
366 367
static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset)
{
368
	struct davinci_gpio_controller *d = gpiochip_get_data(chip);
D
David Brownell 已提交
369

370 371 372 373
	if (d->irq_domain)
		return irq_create_mapping(d->irq_domain, d->chip.base + offset);
	else
		return -ENXIO;
D
David Brownell 已提交
374 375 376 377
}

static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
{
378
	struct davinci_gpio_controller *d = gpiochip_get_data(chip);
D
David Brownell 已提交
379

380 381
	/*
	 * NOTE:  we assume for now that only irqs in the first gpio_chip
D
David Brownell 已提交
382 383
	 * can provide direct-mapped IRQs to AINTC (up to 32 GPIOs).
	 */
384
	if (offset < d->gpio_unbanked)
385
		return d->gpio_irq + offset;
D
David Brownell 已提交
386 387 388 389
	else
		return -ENODEV;
}

390
static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger)
D
David Brownell 已提交
391
{
392 393 394 395
	struct davinci_gpio_controller *d;
	struct davinci_gpio_regs __iomem *g;
	u32 mask;

396
	d = (struct davinci_gpio_controller *)irq_data_get_irq_handler_data(data);
397
	g = (struct davinci_gpio_regs __iomem *)d->regs;
398
	mask = __gpio_mask(data->irq - d->gpio_irq);
D
David Brownell 已提交
399 400 401 402

	if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
		return -EINVAL;

403
	writel_relaxed(mask, (trigger & IRQ_TYPE_EDGE_FALLING)
D
David Brownell 已提交
404
		     ? &g->set_falling : &g->clr_falling);
405
	writel_relaxed(mask, (trigger & IRQ_TYPE_EDGE_RISING)
D
David Brownell 已提交
406 407 408 409 410
		     ? &g->set_rising : &g->clr_rising);

	return 0;
}

411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
static int
davinci_gpio_irq_map(struct irq_domain *d, unsigned int irq,
		     irq_hw_number_t hw)
{
	struct davinci_gpio_regs __iomem *g = gpio2regs(hw);

	irq_set_chip_and_handler_name(irq, &gpio_irqchip, handle_simple_irq,
				"davinci_gpio");
	irq_set_irq_type(irq, IRQ_TYPE_NONE);
	irq_set_chip_data(irq, (__force void *)g);
	irq_set_handler_data(irq, (void *)__gpio_mask(hw));

	return 0;
}

static const struct irq_domain_ops davinci_gpio_irq_ops = {
	.map = davinci_gpio_irq_map,
	.xlate = irq_domain_xlate_onetwocell,
};

431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
static struct irq_chip *davinci_gpio_get_irq_chip(unsigned int irq)
{
	static struct irq_chip_type gpio_unbanked;

	gpio_unbanked = *container_of(irq_get_chip(irq),
				      struct irq_chip_type, chip);

	return &gpio_unbanked.chip;
};

static struct irq_chip *keystone_gpio_get_irq_chip(unsigned int irq)
{
	static struct irq_chip gpio_unbanked;

	gpio_unbanked = *irq_get_chip(irq);
	return &gpio_unbanked;
};

static const struct of_device_id davinci_gpio_ids[];

451
/*
D
David Brownell 已提交
452 453
 * NOTE:  for suspend/resume, probably best to make a platform_device with
 * suspend_late/resume_resume calls hooking into results of the set_wake()
454 455
 * calls ... so if no gpios are wakeup events the clock can be disabled,
 * with outputs left at previously set levels, and so that VDD3P3V.IOPWDN0
D
David Brownell 已提交
456
 * (dm6446) can be set appropriately for GPIOV33 pins.
457 458
 */

459
static int davinci_gpio_irq_setup(struct platform_device *pdev)
460
{
461 462
	unsigned	gpio, bank;
	int		irq;
463
	struct clk	*clk;
D
David Brownell 已提交
464
	u32		binten = 0;
465
	unsigned	ngpio, bank_irq;
466 467 468 469 470
	struct device *dev = &pdev->dev;
	struct resource	*res;
	struct davinci_gpio_controller *chips = platform_get_drvdata(pdev);
	struct davinci_gpio_platform_data *pdata = dev->platform_data;
	struct davinci_gpio_regs __iomem *g;
471
	struct irq_domain	*irq_domain = NULL;
472 473 474 475 476 477 478 479 480 481 482 483
	const struct of_device_id *match;
	struct irq_chip *irq_chip;
	gpio_get_irq_chip_cb_t gpio_get_irq_chip;

	/*
	 * Use davinci_gpio_get_irq_chip by default to handle non DT cases
	 */
	gpio_get_irq_chip = davinci_gpio_get_irq_chip;
	match = of_match_device(of_match_ptr(davinci_gpio_ids),
				dev);
	if (match)
		gpio_get_irq_chip = (gpio_get_irq_chip_cb_t)match->data;
484

485 486 487 488 489 490
	ngpio = pdata->ngpio;
	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
	if (!res) {
		dev_err(dev, "Invalid IRQ resource\n");
		return -EBUSY;
	}
D
David Brownell 已提交
491

492 493 494 495 496
	bank_irq = res->start;

	if (!bank_irq) {
		dev_err(dev, "Invalid IRQ resource\n");
		return -ENODEV;
D
David Brownell 已提交
497
	}
498

499
	clk = devm_clk_get(dev, "gpio");
500 501 502
	if (IS_ERR(clk)) {
		printk(KERN_ERR "Error %ld getting gpio clock?\n",
		       PTR_ERR(clk));
D
David Brownell 已提交
503
		return PTR_ERR(clk);
504
	}
505
	clk_prepare_enable(clk);
506

507 508 509 510 511 512
	if (!pdata->gpio_unbanked) {
		irq = irq_alloc_descs(-1, 0, ngpio, 0);
		if (irq < 0) {
			dev_err(dev, "Couldn't allocate IRQ numbers\n");
			return irq;
		}
513

514
		irq_domain = irq_domain_add_legacy(dev->of_node, ngpio, irq, 0,
515 516 517 518 519 520
							&davinci_gpio_irq_ops,
							chips);
		if (!irq_domain) {
			dev_err(dev, "Couldn't register an IRQ domain\n");
			return -ENODEV;
		}
521 522
	}

523 524
	/*
	 * Arrange gpio_to_irq() support, handling either direct IRQs or
D
David Brownell 已提交
525 526 527 528 529 530
	 * banked IRQs.  Having GPIOs in the first GPIO bank use direct
	 * IRQs, while the others use banked IRQs, would need some setup
	 * tweaks to recognize hardware which can do that.
	 */
	for (gpio = 0, bank = 0; gpio < ngpio; bank++, gpio += 32) {
		chips[bank].chip.to_irq = gpio_to_irq_banked;
531
		chips[bank].irq_domain = irq_domain;
D
David Brownell 已提交
532 533 534 535 536 537 538
	}

	/*
	 * AINTC can handle direct/unbanked IRQs for GPIOs, with the GPIO
	 * controller only handling trigger modes.  We currently assume no
	 * IRQ mux conflicts; gpio_irq_type_unbanked() is only for GPIOs.
	 */
539
	if (pdata->gpio_unbanked) {
D
David Brownell 已提交
540 541
		/* pass "bank 0" GPIO IRQs to AINTC */
		chips[0].chip.to_irq = gpio_to_irq_unbanked;
542 543
		chips[0].gpio_irq = bank_irq;
		chips[0].gpio_unbanked = pdata->gpio_unbanked;
544
		binten = GENMASK(pdata->gpio_unbanked / 16, 0);
D
David Brownell 已提交
545 546 547

		/* AINTC handles mask/unmask; GPIO handles triggering */
		irq = bank_irq;
548 549 550
		irq_chip = gpio_get_irq_chip(irq);
		irq_chip->name = "GPIO-AINTC";
		irq_chip->irq_set_type = gpio_irq_type_unbanked;
D
David Brownell 已提交
551 552

		/* default trigger: both edges */
553
		g = gpio2regs(0);
554 555
		writel_relaxed(~0, &g->set_falling);
		writel_relaxed(~0, &g->set_rising);
D
David Brownell 已提交
556 557

		/* set the direct IRQs up to use that irqchip */
558
		for (gpio = 0; gpio < pdata->gpio_unbanked; gpio++, irq++) {
559
			irq_set_chip(irq, irq_chip);
560
			irq_set_handler_data(irq, &chips[gpio / 32]);
561
			irq_set_status_flags(irq, IRQ_TYPE_EDGE_BOTH);
D
David Brownell 已提交
562 563 564 565 566 567 568 569 570
		}

		goto done;
	}

	/*
	 * Or, AINTC can handle IRQs for banks of 16 GPIO IRQs, which we
	 * then chain through our own handler.
	 */
571
	for (gpio = 0, bank = 0; gpio < ngpio; bank++, bank_irq++, gpio += 16) {
D
David Brownell 已提交
572
		/* disabled by default, enabled only as needed */
573
		g = gpio2regs(gpio);
574 575
		writel_relaxed(~0, &g->clr_falling);
		writel_relaxed(~0, &g->clr_rising);
576

577 578 579 580 581
		/*
		 * Each chip handles 32 gpios, and each irq bank consists of 16
		 * gpio irqs. Pass the irq bank's corresponding controller to
		 * the chained irq handler.
		 */
582 583
		irq_set_chained_handler_and_data(bank_irq, gpio_irq_handler,
						 &chips[gpio / 32]);
584

D
David Brownell 已提交
585
		binten |= BIT(bank);
586 587
	}

D
David Brownell 已提交
588
done:
589 590
	/*
	 * BINTEN -- per-bank interrupt enable. genirq would also let these
591 592
	 * bits be set/cleared dynamically.
	 */
593
	writel_relaxed(binten, gpio_base + BINTEN);
594 595 596

	return 0;
}
597

K
KV Sujith 已提交
598 599
#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id davinci_gpio_ids[] = {
600 601
	{ .compatible = "ti,keystone-gpio", keystone_gpio_get_irq_chip},
	{ .compatible = "ti,dm6441-gpio", davinci_gpio_get_irq_chip},
K
KV Sujith 已提交
602 603 604 605 606
	{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, davinci_gpio_ids);
#endif

607 608 609
static struct platform_driver davinci_gpio_driver = {
	.probe		= davinci_gpio_probe,
	.driver		= {
K
KV Sujith 已提交
610 611
		.name		= "davinci_gpio",
		.of_match_table	= of_match_ptr(davinci_gpio_ids),
612 613 614 615 616 617 618 619 620 621 622 623
	},
};

/**
 * GPIO driver registration needs to be done before machine_init functions
 * access GPIO. Hence davinci_gpio_drv_reg() is a postcore_initcall.
 */
static int __init davinci_gpio_drv_reg(void)
{
	return platform_driver_register(&davinci_gpio_driver);
}
postcore_initcall(davinci_gpio_drv_reg);