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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*
* Copyright (C) 2013 Samsung Electronics Co. Ltd.
* Copyright (C) 2013 Linaro Ltd.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/of_gpio.h>
#include <linux/delay.h>
static void board_arndale_setup_hub_gpio(struct platform_device *pdev,
const char *propname, int level)
{
int err;
int gpio;
if (!pdev->dev.of_node)
return;
gpio = of_get_named_gpio(pdev->dev.of_node, propname, 0);
if (!gpio_is_valid(gpio)) {
dev_err(&pdev->dev, "%s gpio not found", propname);
return;
}
err = gpio_request_one(gpio, level, propname);
if (err)
dev_err(&pdev->dev, "can't request %s gpio %d", propname, gpio);
else
gpio_free(gpio);
}
static void board_arndale_hub_reset(struct platform_device *pdev)
{
board_arndale_setup_hub_gpio(pdev, "hub-reset", GPIOF_OUT_INIT_LOW);
msleep(1);
board_arndale_setup_hub_gpio(pdev, "hub-reset", GPIOF_OUT_INIT_HIGH);
board_arndale_setup_hub_gpio(pdev, "hub-connect", GPIOF_OUT_INIT_HIGH);
}
static int board_arndale_probe(struct platform_device *pdev)
{
board_arndale_hub_reset(pdev);
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id board_arndale_match[] = {
{ .compatible = "insignal,arndale-board-setup" },
{},
};
MODULE_DEVICE_TABLE(of, exynos_ehci_match);
#endif
static struct platform_driver board_arndale_driver = {
.probe = board_arndale_probe,
.driver = {
.name = "board-arndale-setup",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(board_arndale_match),
}
};
static int __init board_arndale_init(void)
{
return platform_driver_register(&board_arndale_driver);
}
late_initcall(board_arndale_init);
static void __exit board_arndale_exit(void)
{
platform_driver_unregister(&board_arndale_driver);
}
module_exit(board_arndale_exit);
MODULE_AUTHOR("Tushar Behera");
MODULE_LICENSE("GPL v2");
|