[ar71xx] fix GPIO function select bit definitions (based on a patch by Jonas <jmajau...
[openwrt.git] / target / linux / s3c24xx / patches-2.6.26 / 1087-introduce-usb-host-power-control.patch.patch
1 From a2f39c5197fbea18417722e5c7d362eaa3bc6210 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Fri, 25 Jul 2008 23:06:01 +0100
4 Subject: [PATCH] introduce-usb-host-power-control.patch
5
6 Unless I really really missed the point, there is no support for enabling
7 USB Host power for USB host mode. This patch adds a /sys node for GTA02
8 that allows control of the charge pump for 5V out on the USB mini connector
9 It doesn't change any logical mode in the CPU, just enables (1) and disables
10 (0) USB host power.
11
12 # cat /sys/devices/platform/neo1973-pm-host.0/hostmode
13 0
14 # echo 1 > /sys/devices/platform/neo1973-pm-host.0/hostmode
15
16 Signed-off-by: Andy Green <andy@openmoko.com>
17 ---
18 arch/arm/mach-s3c2440/mach-gta02.c | 6 ++
19 arch/arm/plat-s3c24xx/Makefile | 2 +-
20 arch/arm/plat-s3c24xx/neo1973_pm_host.c | 101 +++++++++++++++++++++++++++++++
21 3 files changed, 108 insertions(+), 1 deletions(-)
22 create mode 100644 arch/arm/plat-s3c24xx/neo1973_pm_host.c
23
24 diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
25 index f18c8fd..5bd68a6 100644
26 --- a/arch/arm/mach-s3c2440/mach-gta02.c
27 +++ b/arch/arm/mach-s3c2440/mach-gta02.c
28 @@ -1030,6 +1030,11 @@ static struct platform_device gta01_pm_gsm_dev = {
29 .name = "neo1973-pm-gsm",
30 };
31
32 +static struct platform_device gta02_pm_usbhost_dev = {
33 + .name = "neo1973-pm-host",
34 +};
35 +
36 +
37 /* USB */
38 static struct s3c2410_hcd_info gta02_usb_info = {
39 .port[0] = {
40 @@ -1287,6 +1292,7 @@ static void __init gta02_machine_init(void)
41 platform_device_register(&s3c_device_spi_acc);
42 platform_device_register(&gta01_button_dev);
43 platform_device_register(&gta01_pm_gsm_dev);
44 + platform_device_register(&gta02_pm_usbhost_dev);
45
46 mangle_pmu_pdata_by_system_rev();
47 platform_device_register(&gta02_pmu_dev);
48 diff --git a/arch/arm/plat-s3c24xx/Makefile b/arch/arm/plat-s3c24xx/Makefile
49 index 6f43aca..d58265f 100644
50 --- a/arch/arm/plat-s3c24xx/Makefile
51 +++ b/arch/arm/plat-s3c24xx/Makefile
52 @@ -29,4 +29,4 @@ obj-$(CONFIG_PM) += pm.o
53 obj-$(CONFIG_PM) += sleep.o
54 obj-$(CONFIG_S3C2410_DMA) += dma.o
55 obj-$(CONFIG_MACH_SMDK) += common-smdk.o
56 -obj-$(CONFIG_MACH_NEO1973) += neo1973_pm_gsm.o neo1973_pm_gps.o neo1973_pm_bt.o
57 +obj-$(CONFIG_MACH_NEO1973) += neo1973_pm_host.o neo1973_pm_gsm.o neo1973_pm_gps.o neo1973_pm_bt.o
58 diff --git a/arch/arm/plat-s3c24xx/neo1973_pm_host.c b/arch/arm/plat-s3c24xx/neo1973_pm_host.c
59 new file mode 100644
60 index 0000000..4eae341
61 --- /dev/null
62 +++ b/arch/arm/plat-s3c24xx/neo1973_pm_host.c
63 @@ -0,0 +1,101 @@
64 +/*
65 + * Bluetooth PM code for the FIC Neo1973 GSM Phone
66 + *
67 + * (C) 2007 by OpenMoko Inc.
68 + * Author: Harald Welte <laforge@openmoko.org>
69 + * All rights reserved.
70 + *
71 + * This program is free software; you can redistribute it and/or modify
72 + * it under the terms of the GNU General Public License version 2 as
73 + * published by the Free Software Foundation
74 + *
75 + */
76 +
77 +#include <linux/module.h>
78 +#include <linux/init.h>
79 +#include <linux/kernel.h>
80 +#include <linux/platform_device.h>
81 +
82 +#include <asm/hardware.h>
83 +#include <asm/mach-types.h>
84 +
85 +#ifdef CONFIG_MACH_NEO1973_GTA02
86 +#include <asm/arch/gta02.h>
87 +#include <linux/pcf50633.h>
88 +
89 +static ssize_t pm_host_read(struct device *dev, struct device_attribute *attr,
90 + char *buf)
91 +{
92 + return sprintf(buf, "%d\n",
93 + pcf50633_gpio_get(pcf50633_global, PCF50633_GPO));
94 +}
95 +
96 +static ssize_t pm_host_write(struct device *dev, struct device_attribute *attr,
97 + const char *buf, size_t count)
98 +{
99 + unsigned long on = simple_strtoul(buf, NULL, 10);
100 +
101 + pcf50633_gpio_set(pcf50633_global, PCF50633_GPO, on);
102 +
103 + return count;
104 +}
105 +
106 +static DEVICE_ATTR(hostmode, 0644, pm_host_read, pm_host_write);
107 +
108 +static struct attribute *neo1973_pm_host_sysfs_entries[] = {
109 + &dev_attr_hostmode.attr,
110 + NULL
111 +};
112 +
113 +static struct attribute_group neo1973_pm_host_attr_group = {
114 + .name = NULL,
115 + .attrs = neo1973_pm_host_sysfs_entries,
116 +};
117 +
118 +static int __init neo1973_pm_host_probe(struct platform_device *pdev)
119 +{
120 + dev_info(&pdev->dev, "starting\n");
121 +
122 + switch (machine_arch_type) {
123 +#ifdef CONFIG_MACH_NEO1973_GTA01
124 + case MACH_TYPE_NEO1973_GTA01:
125 + return -EINVAL;
126 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
127 + default:
128 + break;
129 + }
130 +
131 + return sysfs_create_group(&pdev->dev.kobj, &neo1973_pm_host_attr_group);
132 +}
133 +
134 +static int neo1973_pm_host_remove(struct platform_device *pdev)
135 +{
136 + sysfs_remove_group(&pdev->dev.kobj, &neo1973_pm_host_attr_group);
137 + return 0;
138 +}
139 +
140 +static struct platform_driver neo1973_pm_host_driver = {
141 + .probe = neo1973_pm_host_probe,
142 + .remove = neo1973_pm_host_remove,
143 + .driver = {
144 + .name = "neo1973-pm-host",
145 + },
146 +};
147 +
148 +static int __devinit neo1973_pm_host_init(void)
149 +{
150 + return platform_driver_register(&neo1973_pm_host_driver);
151 +}
152 +
153 +static void neo1973_pm_host_exit(void)
154 +{
155 + platform_driver_unregister(&neo1973_pm_host_driver);
156 +}
157 +
158 +module_init(neo1973_pm_host_init);
159 +module_exit(neo1973_pm_host_exit);
160 +
161 +MODULE_LICENSE("GPL");
162 +MODULE_AUTHOR("Andy Green <andy@openmoko.com>");
163 +MODULE_DESCRIPTION("Neo1973 USB Host Power Management");
164 +#endif
165 --
166 1.5.6.3
167
This page took 0.053411 seconds and 5 git commands to generate.