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
|
/*
* Copyright (C) 2007-2009 Motorola, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA
*/
#include <linux/device.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/spi/cpcap.h>
static int cpcap_usb_chgr_probe(struct platform_device *pdev);
static int cpcap_usb_chgr_remove(struct platform_device *pdev);
static struct platform_driver cpcap_usb_chgr_driver = {
.probe = cpcap_usb_chgr_probe,
.remove = cpcap_usb_chgr_remove,
.driver = {
.name = "cpcap_usb_charger",
.owner = THIS_MODULE,
},
};
static int cpcap_usb_chgr_probe(struct platform_device *pdev)
{
int ret = 0;
struct cpcap_device *cpcap;
if (pdev->dev.platform_data == NULL) {
dev_err(&pdev->dev, "no platform_data\n");
return -EINVAL;
}
cpcap = pdev->dev.platform_data;
platform_set_drvdata(pdev, cpcap);
cpcap_batt_set_usb_prop_curr(cpcap, 500);
cpcap_batt_set_usb_prop_online(cpcap, 1, CPCAP_BATT_USB_MODEL_USB);
return ret;
}
static int cpcap_usb_chgr_remove(struct platform_device *pdev)
{
struct cpcap_device *cpcap = platform_get_drvdata(pdev);
cpcap_batt_set_usb_prop_curr(cpcap, 0);
cpcap_batt_set_usb_prop_online(cpcap, 0, CPCAP_BATT_USB_MODEL_NONE);
return 0;
}
static int __init cpcap_usb_chgr_init(void)
{
return platform_driver_register(&cpcap_usb_chgr_driver);
}
module_init(cpcap_usb_chgr_init);
static void __exit cpcap_usb_chgr_exit(void)
{
platform_driver_unregister(&cpcap_usb_chgr_driver);
}
module_exit(cpcap_usb_chgr_exit);
MODULE_ALIAS("platform:cpcap_usb_chgr");
MODULE_DESCRIPTION("CPCAP USB Charger Device driver");
MODULE_AUTHOR("Motorola");
MODULE_LICENSE("GPL");
|