1 From 20369a802d4df104489daeb85388554f79e7e281 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Sun, 13 Apr 2008 07:25:51 +0100
4 Subject: [PATCH] introduce-usb-host-power-control.patch
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
12 # cat /sys/devices/platform/neo1973-pm-host.0/hostmode
14 # echo 1 > /sys/devices/platform/neo1973-pm-host.0/hostmode
16 Signed-off-by: Andy Green <andy@openmoko.com>
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
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",
32 +static struct platform_device gta02_pm_usbhost_dev = {
33 + .name = "neo1973-pm-host",
38 static struct s3c2410_hcd_info gta02_usb_info = {
40 @@ -1287,6 +1292,7 @@ static void __init gta02_machine_init(void)
41 platform_device_register(&s3c_device_spi_acc);
42 platform_device_register(>a01_button_dev);
43 platform_device_register(>a01_pm_gsm_dev);
44 + platform_device_register(>a02_pm_usbhost_dev);
46 mangle_pmu_pdata_by_system_rev();
47 platform_device_register(>a02_pmu_dev);
48 diff --git a/arch/arm/plat-s3c24xx/Makefile b/arch/arm/plat-s3c24xx/Makefile
49 index 7192912..e1686a0 100644
50 --- a/arch/arm/plat-s3c24xx/Makefile
51 +++ b/arch/arm/plat-s3c24xx/Makefile
52 @@ -28,4 +28,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
60 index 0000000..4eae341
62 +++ b/arch/arm/plat-s3c24xx/neo1973_pm_host.c
65 + * Bluetooth PM code for the FIC Neo1973 GSM Phone
67 + * (C) 2007 by OpenMoko Inc.
68 + * Author: Harald Welte <laforge@openmoko.org>
69 + * All rights reserved.
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
77 +#include <linux/module.h>
78 +#include <linux/init.h>
79 +#include <linux/kernel.h>
80 +#include <linux/platform_device.h>
82 +#include <asm/hardware.h>
83 +#include <asm/mach-types.h>
85 +#ifdef CONFIG_MACH_NEO1973_GTA02
86 +#include <asm/arch/gta02.h>
87 +#include <linux/pcf50633.h>
89 +static ssize_t pm_host_read(struct device *dev, struct device_attribute *attr,
92 + return sprintf(buf, "%d\n",
93 + pcf50633_gpio_get(pcf50633_global, PCF50633_GPO));
96 +static ssize_t pm_host_write(struct device *dev, struct device_attribute *attr,
97 + const char *buf, size_t count)
99 + unsigned long on = simple_strtoul(buf, NULL, 10);
101 + pcf50633_gpio_set(pcf50633_global, PCF50633_GPO, on);
106 +static DEVICE_ATTR(hostmode, 0644, pm_host_read, pm_host_write);
108 +static struct attribute *neo1973_pm_host_sysfs_entries[] = {
109 + &dev_attr_hostmode.attr,
113 +static struct attribute_group neo1973_pm_host_attr_group = {
115 + .attrs = neo1973_pm_host_sysfs_entries,
118 +static int __init neo1973_pm_host_probe(struct platform_device *pdev)
120 + dev_info(&pdev->dev, "starting\n");
122 + switch (machine_arch_type) {
123 +#ifdef CONFIG_MACH_NEO1973_GTA01
124 + case MACH_TYPE_NEO1973_GTA01:
126 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
131 + return sysfs_create_group(&pdev->dev.kobj, &neo1973_pm_host_attr_group);
134 +static int neo1973_pm_host_remove(struct platform_device *pdev)
136 + sysfs_remove_group(&pdev->dev.kobj, &neo1973_pm_host_attr_group);
140 +static struct platform_driver neo1973_pm_host_driver = {
141 + .probe = neo1973_pm_host_probe,
142 + .remove = neo1973_pm_host_remove,
144 + .name = "neo1973-pm-host",
148 +static int __devinit neo1973_pm_host_init(void)
150 + return platform_driver_register(&neo1973_pm_host_driver);
153 +static void neo1973_pm_host_exit(void)
155 + platform_driver_unregister(&neo1973_pm_host_driver);
158 +module_init(neo1973_pm_host_init);
159 +module_exit(neo1973_pm_host_exit);
161 +MODULE_LICENSE("GPL");
162 +MODULE_AUTHOR("Andy Green <andy@openmoko.com>");
163 +MODULE_DESCRIPTION("Neo1973 USB Host Power Management");