aboutsummaryrefslogtreecommitdiff
path: root/driver/main.c
blob: a3226164fbfef482b13246aab86e553f76c2fbc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <linux/init.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>

#include "platform.h"

static const struct of_device_id lork_ids[] = {
	{ .compatible = "gpio-extern" },
	{},
};

struct platform_driver lork_driver = {
	.probe = lork_probe,
	.remove = lork_remove,
	.driver = {
		.name = "gpio-extern",
		.owner = THIS_MODULE,
		.of_match_table = of_match_ptr(lork_ids),
	}
};

static int mod_init(void) {
	printk("%s()\n", __PRETTY_FUNCTION__);

	// // configure gpio mux
	// uint32_t* conf_gpmc_a3 = ioremap(TI_AM335X_CM_GPMC_A3_ADDR, sizeof(ti_am335x_word_t));
	// if (conf_gpmc_a3 == NULL)
	// 	return -EINVAL;
	// barrier();
	// uint32_t val = ioread32(conf_gpmc_a3); rmb();
	// val &= ~0x7;
	// val |= 0x7;
	// iowrite32(val, conf_gpmc_a3); wmb();
	// iounmap(conf_gpmc_a3);

	// // configure output pin
	// ti_am335x_word_t* gpio1 = ioremap(TI_AM335X_GPIO1_ADDR, GPIO_REG_SIZE);
	// barrier();
	// ti_am335x_word_t oe_reg = ioread32(gpio1 + GPIO_OE); rmb();
	// oe_reg &= ~(1<<PIN); // 0=output
	// iowrite32(oe_reg, gpio1 + GPIO_OE); wmb();
	// iounmap(gpio1);

	return platform_driver_register(&lork_driver);
}

static void mod_exit(void) {
	printk("%s()\n", __PRETTY_FUNCTION__);
	platform_driver_unregister(&lork_driver);
}

module_init(mod_init);
module_exit(mod_exit);
MODULE_LICENSE("Dual MIT/GPL");